[FFmpeg-cvslog] movenc: Use first H264/HEVC frame as extradata, if it is missing

Martin Storsjö git at videolan.org
Wed May 20 23:05:08 EEST 2020

ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Fri May  8 14:21:32 2020 +0300| [9f891d0b4b584bc061808bfab35ffe9810d3bc77] | committer: Martin Storsjö

movenc: Use first H264/HEVC frame as extradata, if it is missing

Sticking a full frame in the extradata works, as the code for writing
the avcC/hvcC extracts the relevant parameter set NAL units - provided
that they actually exist in the frame.

Some encoders don't provide split out extradata directly on init (or
at all). In particular, the MediaFoundation encoder wrapper doesn't
always (depending on the actual encoder device) - this is the case for
Qualcomm's HEVC encoder on SD835, and also on some QSV H264 encoders).

This only works for cases where the moov hasn't already been written
(e.g. when not writing fragmented mp4 with empty_moov, unless using
the delay_moov option).

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f891d0b4b584bc061808bfab35ffe9810d3bc77

 libavformat/movenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 32e8109268..e6b3ea7ef1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5583,6 +5583,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
     if ((par->codec_id == AV_CODEC_ID_DNXHD ||
+         par->codec_id == AV_CODEC_ID_H264 ||
+         par->codec_id == AV_CODEC_ID_HEVC ||
          par->codec_id == AV_CODEC_ID_TRUEHD ||
          par->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) {
         /* copy frame to create needed atoms */

More information about the ffmpeg-cvslog mailing list