Skip to content
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

mmal hw video decoding error detection and reverting to software if error occured #627

Merged
merged 3 commits into from
Jun 6, 2020

Conversation

joyrider3774
Copy link
Contributor

@joyrider3774 joyrider3774 commented Jun 5, 2020

fixes #625 by specifying PLATFORM_RPI4=1 when making and not using mmal for mpeg4 / 2 & vc1 as it's not supported on the pi4 .

I explictly did not use a detection for RPI4 as i don't know how and it might break crosscompiling. If people also omit PLATFORM_RPI4=1 on the make line it will just compile as before but breaks mpeg4 / 2 & vc1 videoplay back as it's not supported on pi4.

Also don't know if you would have had me rather changing the USE_MMAL define instead of creating the PLATFORM_RPI4 one but i guess if there are other specifics to RPI4 it could be reused

sorry did not know how to fix my repo / branch without doing new PR, now it's not showing a merge commit

@joyrider3774 joyrider3774 changed the title Use software decoding for MPEG4/2 and VC1 for RPI4 when mmal is specified Use software decoding for MPEG4/2 and VC1 for RPI4 when mmal is the encoder and PLATFORM_RPI4 is specified Jun 5, 2020
@joyrider3774
Copy link
Contributor Author

should i print a warning when video is reverted to software decoding when playing these vids when mmal decoder is enabled, at least user then knows some of his vids are not supported through mmal on rpi4

@oomek
Copy link
Collaborator

oomek commented Jun 5, 2020

I think yes, it could be useful to see that. Btw, have you thought about implementing a runtime fallback decoder based on the error returned by ffmpeg instead of compile time fixed assignment?

@joyrider3774
Copy link
Contributor Author

a runtime fallback decoder based on the error returned by ffmpeg would be nice, but not sure i'm up to that task. The mmal codecs used are definatly not supported on RPI4 so might as well disable them also when first trying to play the videos through hw decoder and waiting on an error it could induce a delay before actually seeing the videos. Now software is immediatly used as we know the codecs are not supported in rpi4

…g to software

- PLATFORM_RPI4 is not needed anymore will work in general when USE_MMAL is used
- if an mmal decoder fails software decoder is tried first
@joyrider3774
Copy link
Contributor Author

joyrider3774 commented Jun 5, 2020

Added the runtime fallback, it does not need PLATFORM_RPI specified anymore and work for any system where USE_MMAL might be defined. For all decoder types it checks if libavcodec gives error or not if not it uses it. If it does, it retries the original software decoder. Tested on my raspberry pi 4 with mpeg4 videos and this worked fast, there is no delay at all. libavcodec also immediatly returns those errors. No video playback is done to test this.

it should work for the other mmal decoder types as well but i did not have such video's to test with but the code used is the same.

Please verify the code as i'm no c/c++ dev and don't really know all the semantics about memory mangement in c++

@joyrider3774 joyrider3774 changed the title Use software decoding for MPEG4/2 and VC1 for RPI4 when mmal is the encoder and PLATFORM_RPI4 is specified mmal hw video decoding error detection and reverting to software if error occured Jun 5, 2020
@mickelson mickelson merged commit 805b448 into mickelson:master Jun 6, 2020
@mickelson
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There is no HW decoding anymore for MPEG4 and H263 on RPI4 through mmal only for H264 and i think HEVC
3 participants