[FFmpeg-devel] [PATCH v2 4/5] fftools/ffmpeg: flush and recreate encoder instance if resolution changes

Fu, Linjie linjie.fu at intel.com
Tue Jun 16 16:33:50 EEST 2020


> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> Nicolas George
> Sent: Tuesday, June 16, 2020 18:55
> To: FFmpeg development discussions and patches <ffmpeg-
> devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2 4/5] fftools/ffmpeg: flush and
> recreate encoder instance if resolution changes
> 
> Fu, Linjie (12020-06-12):
> > IIRC, the global header in extra data is optional in codec level.
> 
> Where did you take that?

Chapter 2.3 Parameter Sets in < High Efficiency Video Coding (HEVC)
Algorithms and Architectures> [1]:

"Reusing parameter sets is bit rate efficient because it avoids the
necessity to send shared information multiple times. It is also loss
robust because it allows parameter set content to be carried by some
more reliable external communication link or to be repeated frequently
within the bitstream to ensure that it will not get lost."

> The way I understand it, people who design codec will decide if they use
> global extradata or not, but if they decide to, it is necessary to
> decode the data. Otherwise, it would not be there!

Indeed, the definition in spec is just the conformance, and how an encoder is
implemented in Libavcodec (and external library if any) is the thing really matters.

For encoders like libx264[2], libx265[3], libopenh264[4], if AV_CODEC_FLAG_GLOBAL_HEADER
flag is declared, the parameter Sets would be copied to extra data as the global header.
If not, parameter sets would be kept in the original bitstream, since it's fundamentally
supported in the encoder.
(BTW, librav1e seems to be identical, but I didn't check all the encoder and details for now)

And for encoders like libvpx-vp9, they don't implement the global header support, neither does
the libavformat(container) like ivf or webm.

(Please correct me if I missed anything or understood something wrongly, thx)

- Linjie

[1] https://link.springer.com/content/pdf/10.1007%2F978-3-319-06895-4.pdf
[2] https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libx264.c#L924
[3] https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libx265.c#L384
[4] https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libopenh264enc.c#L338



More information about the ffmpeg-devel mailing list