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

How to handle h264bsdNextOutputPicture returning NULL? #27

Open
alban-rochel opened this issue Jan 17, 2024 · 2 comments
Open

How to handle h264bsdNextOutputPicture returning NULL? #27

alban-rochel opened this issue Jan 17, 2024 · 2 comments

Comments

@alban-rochel
Copy link

Hello,

I am having trouble processing some H.264 streams. After using h264bsdDecode() and getting H264BSD_PIC_RDY, sometimes h264bsdNextOutputPicture() returns a NULL pointer.
In the end, for a 122 images stream (122 times H264BSD_PIC_RDY, and 122 frames produced by ffmpeg when used to convert the .264 file to png), I may end up being able to decode 112 of them.

Those streams are specifically those extracted from MP4 generated by Safari on iPhones using the html MediaRecorder api (mimeType 'video/mp4;codecs="avc1.42001e" for instance). ffprobe shows that they are baseline 3.1 profiles, exactly as similar files produced on Macs (which do work). The only difference I can see is that iPhone files seem to be full color range, but patching this info does not seem to change the result.

Any lead or clue would be greatly appreciated.

Cheers,

Alban

@alban-rochel
Copy link
Author

alban-rochel commented Jan 17, 2024

By the way, I found that if I hard-coded seqParamSet.maxDpbSize value to 2 after h264bsdDecodeSeqParamSet(&strm, &seqParamSet); in h264bsdDecode (default value is 5), I could decode more pictures (but not all of them).
I don't know if my stream is ill-formed or if h264bsd misconfigures the decoder, but that might give clues regarding the nature of this bug.

@alban-rochel
Copy link
Author

More testing shows that in my case (decoding streams from Safari encoded with the MediaRecorder API), forcing
seqParamSet.numRefFrames = 1; seqParamSet.maxDpbSize = 1;
allows decoding every frame but the last one on iOS sources, and all frames on OSX sources.

I hate doing these kinds of hacks, but at least it will do the trick for the moment.

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

No branches or pull requests

1 participant