[Libav-user] Parse H.264 without decoding

Alexei Golovko alexej.golovko at gmail.com
Thu Nov 5 19:03:02 EET 2020

how can one change coded_picture_number without fully decoding H.264 frames?

Some context:
we have recordings of RTP streams from IP-cameras (fragmented to 10-minutes
pieces), made with Janus, and use Janus utility (
which calls
to convert them to MP4.

Resulted MP4 does not play in Google Chrome (though plays in Firefox or
VLC); but if "convert" them with:
ffmpeg -i janus.mp4 -c copy out.mp4
— then out.mp4 plays well in Chrome.
Probable cause of the difference is that in janus.mp4 coded_picture_number
starts from non-zero value, and in out.mp4 from zero.

I want to patch this utility to enumerate frames from zero. I've managed to
do this with parsing AVPacket to AVFrames, but such a way involves full
decoding-reencoding and is slow.

How can I change coded_picture_number without fully decoding H.264?

This is definitely possible, as ffmpeg with `-c copy` does this (and does
fast). I've seen ffmpeg source, but don't understand where the key point is.
I also found the function av_parser_parse2, which seems to parse without
decoding, but it's not clear what to do with its output byte array (all
examples use it only for further decoding).

Regards, Alexey Golovko.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20201105/2b981b3b/attachment.html>

More information about the Libav-user mailing list