[FFmpeg-devel] [PATCH 1/3] libavcodec: Make disposition forced work with mov_text subtitles.

Michael Niedermayer michael at niedermayer.cc
Mon Jul 18 19:57:43 EEST 2022


On Mon, Jul 18, 2022 at 05:08:31PM +0100, facefunk wrote:
> We are not currently able to force mov_text subtitles by setting -disposition:s:0 +forced or equivalent. By setting the forced flags in movtextenc as specifid in https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html subtitles can be forced as expected in VLC and similar players.
> 
> Copy AVStream disposition to AVCodecContext and use to set DISPLAY_FLAG_ALL_SAMPLES_FORCED in movtextenc.c.
> 
> Signed-off-by: facefunk <facefunk at fcfnk.com>
> ---
>  fftools/ffmpeg_opt.c    |  5 +++++
>  libavcodec/avcodec.h    | 16 ++++++++++++++++
>  libavcodec/movtextenc.c | 41 ++++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index e08455478f..d8ea1d4bc1 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -2244,6 +2244,11 @@ static int set_dispositions(OutputFile *of, AVFormatContext *ctx)
>  
>              if (ret < 0)
>                  return ret;
> +
> +            // For output streams, copy stream disposition to the AVCodecContext
> +            // object.
> +            if(ost->enc_ctx)
> +                ost->enc_ctx->stream_disposition = ost->st->disposition;
>          }
>      } else {
>          // For each media type with more than one stream, find a suitable stream to

> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index cb5c25bf63..eb11de0293 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -37,6 +37,8 @@
>  #include "libavutil/pixfmt.h"
>  #include "libavutil/rational.h"
>  
> +#include "libavformat/avformat.h"

libavcodec should not depend on libavformat


> +
>  #include "codec.h"
>  #include "codec_desc.h"
>  #include "codec_par.h"
> @@ -2054,6 +2056,20 @@ typedef struct AVCodecContext {
>       *             The decoder can then override during decoding as needed.
>       */
>      AVChannelLayout ch_layout;
> +
> +    /**
> +     * Stream disposition - a combination of AV_DISPOSITION_* flags from
> +     * libavformat.
> +     *
> +     * Copied from the relevant AVStream object for codecs that need access to
> +     * the stream disposition parameter, such as movtextenc.c which needs to
> +     * read the AV_DISPOSITION_FORCED flag so it knows when to set forced
> +     * subtitles.
> +     *
> +     * - encoding: Set by set_dispositions in ffmpeg_opt.c.

ffmpeg is one application that uses libavcodec. 
libavcodec API should not really talk about ffmpeg doing this or that, thats
kind of odd

also, your patches dont contain a full name, thats ok if thats what you want
but if you want your full name in git then you may want to correct that

thx


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220718/b1f1df80/attachment.sig>


More information about the ffmpeg-devel mailing list