[FFmpeg-devel] [PATCH 1/3] avcodec: add a parser flag to enable keyframe tagging heuristics

James Almer jamrial at gmail.com
Thu Jul 15 23:55:51 EEST 2021


On 7/15/2021 5:23 PM, Michael Niedermayer wrote:
> On Wed, Jul 14, 2021 at 11:33:59AM -0300, James Almer wrote:
>> It will be used to allow parsers to be more liberal when tagging packets as
>> keyframes.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>>   libavcodec/avcodec.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 8b97895aeb..8e3d888266 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -2809,6 +2809,7 @@ typedef struct AVCodecParserContext {
>>   #define PARSER_FLAG_ONCE                      0x0002
>>   /// Set if the parser has a valid file offset
>>   #define PARSER_FLAG_FETCHED_OFFSET            0x0004
>> +#define PARSER_FLAG_USE_KEYFRAME_HEURISTICS   0x0008
>>   #define PARSER_FLAG_USE_CODEC_TS              0x1000
> 
> This doesnt "feel" like the best solution to me
> 
> dont you think it would be better to export all information ?

The AVParser API is going to be removed at some point for something 
better that works on packets rather than raw buffers, so ideally we 
should not expand it too much, and leave more complex implementations 
for later.

Adding a flag is the simplest way to fix this for now, until a proper 
rework is done.

> 
> the concept of a keyframe is a point at which decoding can begin
> that really are at least 3 points
> 
> the point at which packets begin to be input into the decoder
> 
> the point at which the decoder is able to return some decoded
> data which closely resembles the encoder input
> 
> and the point at which the decoder output matches 1:1 the output
> of a decoder starting from frame 0

All parsers save for h264 are currently only tagging packets containing 
a coded bitstream that, when decoded, it fully resets the decoding state 
and depends on no previously parsed data or state, which is what (most) 
muxers expect. This approach here is making the h264 do the same by 
default (in line with the decoder), to ensure some muxers don't wrongly 
mark certain packets as sync samples, while letting others remain 
liberal about it.

Ideally yes, we'd propagate more detailed information in some way, which 
then the mp4 muxer can use to build sample groups for h264, hevc and 
av1. But the existing AVParser API is not adequate for that.

> 
> 
> 
> Thanks
> 
> [...]
> 
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> 



More information about the ffmpeg-devel mailing list