[FFmpeg-devel] [PATCH 5/5] fftools/ffmpeg: support applying container level cropping

James Almer jamrial at gmail.com
Thu Jul 20 22:25:02 EEST 2023


On 7/20/2023 4:08 PM, Anton Khirnov wrote:
> Quoting James Almer (2023-07-20 00:20:43)
>> diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
>> index 8b750de4e5..3cf29c8b2c 100644
>> --- a/fftools/ffmpeg_enc.c
>> +++ b/fftools/ffmpeg_enc.c
>> @@ -441,14 +441,16 @@ int enc_open(OutputStream *ost, AVFrame *frame)
>>           int i;
>>           for (i = 0; i < ist->st->nb_side_data; i++) {
>>               AVPacketSideData *sd = &ist->st->side_data[i];
>> -            if (sd->type != AV_PKT_DATA_CPB_PROPERTIES) {
>> +            if (sd->type == AV_PKT_DATA_CPB_PROPERTIES)
>> +                continue;
>> +            if (ist->apply_cropping && sd->type == AV_PKT_DATA_FRAME_CROPPING)
>> +                continue;
> 
> I'm very much not a fan of the encoder doing anything based on decoder
> options.

Right now, all input stream side data (save for CPB) is copied to the 
output stream. Without this chunk, the frame cropping side data will be 
copied regardless of it having been applied or not at the decoding level.
I don't know how else to prevent that. Maybe removing the side data from 
the input stream? Although that's pretty ugly.

I have a separate patchset adding packet side data to codecpar and 
avctx, and deprecating AVStream.side_data in favor of it. With that, i 
could maybe use and therefore remove the cropping side data from 
ist->par (which is internal to the CLI) if applied.

> 
> I know the code below already does the same thing, but I'd like to get
> rid of it rather than add to it.
> 


More information about the ffmpeg-devel mailing list