[FFmpeg-devel] [PATCH] lavf/movenc: Fail when codec tag is invalid for format

Michael Niedermayer michael at niedermayer.cc
Sat Aug 25 04:13:27 EEST 2018


On Fri, Aug 24, 2018 at 11:44:11AM -0700, John Stebbins wrote:
> Fixes ticket #6897
> ---
>  libavformat/movenc.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 8ad7026741..4507666863 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -1596,23 +1596,21 @@ static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
>      if (is_cover_image(track->st))
>          return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
>  
> -    if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
> -        tag = track->par->codec_tag;
> -    else if (track->mode == MODE_ISM)
> -        tag = track->par->codec_tag;
> -    else if (track->mode == MODE_IPOD) {
> +    if (track->mode == MODE_IPOD)
>          if (!av_match_ext(s->url, "m4a") &&
>              !av_match_ext(s->url, "m4v") &&
>              !av_match_ext(s->url, "m4b"))
>              av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
>                     "Quicktime/Ipod might not play the file\n");
> -        tag = track->par->codec_tag;
> -    } else if (track->mode & MODE_3GP)
> -        tag = track->par->codec_tag;
> -    else if (track->mode == MODE_F4V)
> -        tag = track->par->codec_tag;
> -    else
> +
> +    if (track->mode == MODE_MOV)
>          tag = mov_get_codec_tag(s, track);
> +    else
> +        if (av_codec_get_id(s->oformat->codec_tag,
> +                            track->par->codec_tag) != track->par->codec_id)
> +            tag = 0;
> +        else
> +            tag = track->par->codec_tag;

This breaks mp2, a testcase would be:

./ffmpeg  -i sample.wtv -acodec copy -vn -y file.mp4

sample.wtv should be here:
https://trac.ffmpeg.org/raw-attachment/ticket/1004/sample.wtv

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180825/48aa4e0f/attachment.sig>


More information about the ffmpeg-devel mailing list