[MPlayer-dev-eng] [PATCH] muxer_lavf: fix compilation with newer FFmpeg.

Alexander Strasser eclipse7 at gmx.net
Mon May 3 00:48:18 EEST 2021


Hi all,

I tested this patch a little and it seems to be fine.

I noticed one difference in output files I can't explain; though
somehow the new output seems to be more correct than the old one.

If you check the output of

    mencoder "$FATE_SAMPLES"/msmpeg4v1/mpg4.avi -ovc copy -of lavf -o mpeg4-muxer_lavf.avi

MPlayer says (version without patch vs version with patch)

    VIDEO:  [MPG4]  352x240  24bpp  600.000 fps  1513.3 kbps (184.7 kbyte/s)
    VIDEO:  [MPG4]  352x240  24bpp  29.970 fps  1484.6 kbps (181.2 kbyte/s)

FFmpeg says (version without patch vs version with patch)

  Duration: 00:00:01.64, start: 0.000000, bitrate: 1656 kb/s
    Stream #1:0: Video: msmpeg4v1 (MPG4 / 0x3447504D), yuv420p, 352x240, 1514 kb/s, 600 fps, 29.97 tbr, 600 tbn, 600 tbc
  Duration: 00:00:01.67, start: 0.000000, bitrate: 1517 kb/s
    Stream #2:0: Video: msmpeg4v1 (MPG4 / 0x3447504D), yuv420p, 352x240, 1514 kb/s, 29.97 fps, 29.97 tbr, 29.97 tbn, 29.97 tbc


Otherwise I couldn't find any differences so far.

I'm still working on ve lavc. Hope I can sent a patch tomorrow or the
day after, but no promises...


Best regards,
  Alexander

On 2021-05-01 19:44 +0200, Reimar Döffinger wrote:
> Leaves ve_lavc to fix for mencoder, which is a bit more complicated,
> mostly because it's so many parameters that need to be replaced
> with the matching dictionary setting, which is not easy to find.
> ---
>  libmpdemux/muxer_lavf.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/libmpdemux/muxer_lavf.c b/libmpdemux/muxer_lavf.c
> index 74b6f6e0b..11ca05a1b 100644
> --- a/libmpdemux/muxer_lavf.c
> +++ b/libmpdemux/muxer_lavf.c
> @@ -112,7 +112,7 @@ static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type)
>  	muxer_priv_t *priv = muxer->priv;
>  	muxer_stream_t *stream;
>  	muxer_stream_priv_t *spriv;
> -	AVCodecContext *ctx;
> +	AVCodecParameters *ctx;
>
>  	if(type != MUXER_TYPE_VIDEO && type != MUXER_TYPE_AUDIO)
>  	{
> @@ -154,7 +154,7 @@ static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type)
>  	}
>  	spriv->avstream->id = 1;
>
> -	ctx = spriv->avstream->codec;
> +	ctx = spriv->avstream->codecpar;
>  	ctx->codec_id = AV_CODEC_ID_NONE;
>  	switch(type)
>  	{
> @@ -177,11 +177,9 @@ static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type)
>  static void fix_parameters(muxer_stream_t *stream)
>  {
>  	muxer_stream_priv_t *spriv = stream->priv;
> -	AVCodecContext *ctx = spriv->avstream->codec;
> +	AVCodecParameters *ctx = spriv->avstream->codecpar;
>
>          ctx->bit_rate= stream->avg_rate;
> -        ctx->rc_buffer_size= stream->vbv_size;
> -        ctx->rc_max_rate= stream->max_rate;
>
>  	if(stream->type == MUXER_TYPE_AUDIO)
>  	{
> @@ -221,12 +219,12 @@ static void fix_parameters(muxer_stream_t *stream)
>                      ctx->codec_tag= stream->bih->biCompression;
>  		mp_msg(MSGT_MUXER, MSGL_INFO, "VIDEO CODEC ID: %d\n", ctx->codec_id);
>  		if (stream->imgfmt)
> -		    ctx->pix_fmt = imgfmt2pixfmt(stream->imgfmt);
> +		    ctx->format = imgfmt2pixfmt(stream->imgfmt);
>  		ctx->width = stream->bih->biWidth;
>  		ctx->height = stream->bih->biHeight;
>  		ctx->bit_rate = 800000;
> -		ctx->time_base.den = stream->h.dwRate;
> -		ctx->time_base.num = stream->h.dwScale;
> +		spriv->avstream->time_base.den = stream->h.dwRate;
> +		spriv->avstream->time_base.num = stream->h.dwScale;
>  		if (stream->aspect)
>  			ctx->sample_aspect_ratio =
>  			spriv->avstream->sample_aspect_ratio = av_d2q(stream->aspect * ctx->height / ctx->width, 255);
> @@ -319,9 +317,10 @@ static void write_trailer(muxer_t *muxer)
>  }
>
>  static void list_formats(void) {
> -	AVOutputFormat *fmt;
> +	void *i = NULL;
> +	const AVOutputFormat *fmt;
>  	mp_msg(MSGT_DEMUX, MSGL_INFO, "Available lavf output formats:\n");
> -	for (fmt = av_oformat_next(NULL); fmt; fmt = av_oformat_next(fmt))
> +	while ((fmt = av_muxer_iterate(&i)))
>  		mp_msg(MSGT_DEMUX, MSGL_INFO, "%15s : %s\n", fmt->name, fmt->long_name);
>  }
>
> @@ -368,7 +367,7 @@ int muxer_init_muxer_lavf(muxer_t *muxer)
>              const char *src = out_filename;
>              if (!strncmp(out_filename, "ffmpeg://dummy://", 17)) src += 17;
>              else if (!strncmp(out_filename, "ffmpeg://", 9)) src += 9;
> -            av_strlcpy(priv->oc->filename, src, sizeof(priv->oc->filename));
> +            priv->oc->url = av_strdup(src);
>  	}
>  	priv->oc->oformat = fmt;
>
> --


More information about the MPlayer-dev-eng mailing list