-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pi4 MMAL decode of h264 stream makes noise on Headphone playback #4146
Comments
Kernel releases have moved on to 5.10 now - does that also crackle? Also, what config.txt settings are active? Report the output of |
When creating an issue you should have been presented with a template that requested a load of basic system information, ideally the output from https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=195178 There was a change in that area at the end of October. Without knowing versions there is no point in continuing the discussion as we don't know if you are testing before or after that change. |
hi. Other: vcgencmd version Attached file is output of raspinfo Issue still remains after apt update/upgrade to 5.10.
|
Converting the buffer from the internal format / MMAL_ENCODING_OPAQUE to an externally defined pixel format will be the main hit on the VPU, and the likely cause of interaction. Both mmal_example_basic examples convert to the default encoding, which is likely to be MMAL_ENCODING_I420 so will have issues. |
heh.. |
Correct me if I'm wrong, but aren't mmalplay/mmal_example just throwing frames at the decoder as fast as possible? BBB is playing "fast". If you're maxing out the VPU then all bets are off, unless there's a specific regression from firmware version Hexxeh/rpi-firmware@e8ddac7 and onwards. |
Yes, mmalplay plays very fast. Probably as fast as it can. And this is what I need really in my own app - decode as ast as possible. |
Without knowing some more about your use case it is impossible to advise further on how to balance the load. |
The other approach is you add |
Is it possible to render to screen or dispmanx surface only some specific rectangular part of decoded frame? |
Yes, you set the source cropping rectangle. For MMAL you set it on the video render component.
Memory says it is as a 16.16 fixed point representation to allow fractional positioning. DispmanX won't take MMAL_ENCODING_OPAQUE directly, but the same porperty is available for any resources it uses. In vc_dispmanx_element_add you have the prototype
src_rect specifies the cropping of the source image. |
vc_dispmanx_element_add() works only once when element is added. So I cannot use src_rect at this moment. |
DispmanX requires raw pixel buffers - it can not work with MMAL_ENCODING_OPAQUE. That conversion is going to affect your audio. You look a little further down the header file and note https://github.com/raspberrypi/userland/blob/master/interface/vmcs_host/vc_dispmanx.h#L108
You're trying to create a video mosaic type effect? DispmanX and MMAL expect to have all resources available for the render, and then render all the pixels in the output buffer - it's not a simple blit. For offline rendering there's a possibility that you could include the output buffer as a source in the render list at 1:1 resolution, but I couldn't guarantee it will work as it depends on any prefetching working. You want to be using MMAL_PARAMETER_ZERO_COPY set on input[0] and output[0] otherwise each buffer submission involves a copy to/from gpu_mem, but it does mean you need to do a bit of messing with buffer pointers being the vc_handles from a vcsm allocated pool of buffers. |
Is it possible to get description of OPAQUE image format? How to acess it by CPU? I tried all possible implementations with connecting MMAL_COMPONENT_DEFAULT_VIDEO_DECODER to MMAL_COMPONENT_DEFAULT_VIDEO_RENDERER. Yes, when using opaque format between components then no audio crackle issues on headphones. |
If you really think it helps, then the struct is
(I've removed a couple of enums as they don't add anything)
I'd already described one potential route to get the hardware to do your weird composition. |
Closing as the duplicate question has been asked on the forums, and I'm not chasing two identical threads. |
On Pi4 with Raspberry Buster OS with Kernel 5.4 not possible to decode h264 stream with MMAL HW without noise on Headphones during audio playback.
Reproduce is very easy.
Take https://github.com/raspberrypi/userland.git and build with script ./buildme
In output directory there are several MMAL examples, simplest is build/bin/mmalplay
Starting this app with parameter like file test.h264 BigBuckBunny plays fragment of video fullscreen.
Ok, then in separate terminal start
aplay -D hw:2,0 some-audio-8bit-22050hz.wav
Audio plays on Headphone. Then start from other terminal build/bin/mmalplay test.h264 for video playback.
When video starts then audio begins crackling and noising.
Other userland mmal examples do not show playback on screen but simply h264 MMAL decode cause noise on Headphones.
For this test use applications build/bin/mmal_example_basic_1 and build/bin/mmal_example_basic_2
issue is exactly same.
Interesting is that this issue does not happen on older raspberry kernel like 4.19
Other interesting fact is that noise happens only on headphones. Audio on any HDMI port plays good.
There are several similar complains in internet:
https://forum.kodi.tv/showthread.php?tid=349778
https://forum.libreelec.tv/thread/20854-raspberry-pi-4-audio-problems-playing-ts-streams/
But no solution found.
The text was updated successfully, but these errors were encountered: