[FFmpeg-devel] [PATCH v1] avformat/imfdec: preserve stream information

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Jul 3 21:27:50 EEST 2022


pal at sandflow.com:
> From: Pierre-Anthony Lemieux <pal at palemieux.com>
> 
> As discussed at https://trac.ffmpeg.org/ticket/9818, the IMF demuxer does not
> currently preserve stream information such as language in the case of audio
> streams. This patch is modeled on copy_stream_props() at avformat/concatdec.c.
> 
> ---
>  libavformat/imfdec.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
> index 71dfb26958..7aa66a06bf 100644
> --- a/libavformat/imfdec.c
> +++ b/libavformat/imfdec.c
> @@ -580,11 +580,16 @@ static int set_context_streams_from_tracks(AVFormatContext *s)
>              return AVERROR(ENOMEM);
>          }
>          asset_stream->id = i;
> +        asset_stream->r_frame_rate = first_resource_stream->r_frame_rate;
> +        asset_stream->avg_frame_rate = first_resource_stream->avg_frame_rate;
> +        asset_stream->sample_aspect_ratio = first_resource_stream->sample_aspect_ratio;
>          ret = avcodec_parameters_copy(asset_stream->codecpar, first_resource_stream->codecpar);
>          if (ret < 0) {
>              av_log(s, AV_LOG_ERROR, "Could not copy stream parameters\n");
>              return ret;
>          }
> +        av_dict_copy(&asset_stream->metadata, first_resource_stream->metadata, 0);
> +        ff_stream_side_data_copy(asset_stream, first_resource_stream);
>          avpriv_set_pts_info(asset_stream,
>                              first_resource_stream->pts_wrap_bits,
>                              first_resource_stream->time_base.num,

Seems to me like one should use ff_stream_encode_params_copy here. Of
course, it would have to be renamed and moved if used in a demuxer.

- Andreas


More information about the ffmpeg-devel mailing list