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

John Stebbins stebbins at jetheaddev.com
Fri Aug 24 21:42:33 EEST 2018


On 08/24/2018 11:15 AM, 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..fb001f9195 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) == AV_CODEC_ID_NONE)
> +            tag = 0;
> +        else
> +            tag = track->par->codec_tag;
>  
>      return tag;
>  }

On a second look, this really should also validate that the tag is valid for the given track->par->codec_id.  Let me
post a quick update...

-- 
John      GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180824/a03bfb64/attachment.sig>


More information about the ffmpeg-devel mailing list