[FFmpeg-devel] [PATCH] libavformat/assenc: Add ignore_gaps option
wm4
nfxjfg at googlemail.com
Thu Oct 30 13:48:09 CET 2014
On Thu, 30 Oct 2014 04:36:28 -0500
Rodger Combs <rodger.combs at gmail.com> wrote:
> This patch lets the user ignore ReadOrder when writing ASS subtitles, which is useful when e.g. streaming output.
>
> From d3d4cb4da2382a1d762fa1e9bfafbaf3d18cf5c5 Mon Sep 17 00:00:00 2001
> From: Rodger Combs <rodger.combs at gmail.com>
> Date: Thu, 30 Oct 2014 04:33:17 -0500
> Subject: [PATCH] libavformat/assenc: Add ignore_gaps option
>
> ---
> libavformat/assenc.c | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/assenc.c b/libavformat/assenc.c
> index 8225967..c7a1d1e 100644
> --- a/libavformat/assenc.c
> +++ b/libavformat/assenc.c
> @@ -23,6 +23,8 @@
> #include "avformat.h"
> #include "internal.h"
>
> +#include "libavutil/opt.h"
> +
> typedef struct DialogueLine {
> int readorder;
> char *line;
> @@ -30,12 +32,14 @@ typedef struct DialogueLine {
> } DialogueLine;
>
> typedef struct ASSContext{
> + const AVClass *class;
> int write_ts; // 0: ssa (timing in payload), 1: ass (matroska like)
> int expected_readorder;
> DialogueLine *dialogue_cache;
> DialogueLine *last_added_dialogue;
> int cache_size;
> int ssa_mode;
> + int ignore_gaps;
> }ASSContext;
>
> static int write_header(AVFormatContext *s)
> @@ -178,7 +182,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
> return AVERROR(ENOMEM);
> }
> insert_dialogue(ass, dialogue);
> - purge_dialogues(s, 0);
> + purge_dialogues(s, ass->ignore_gaps);
> } else {
> avio_write(s->pb, pkt->data, pkt->size);
> }
> @@ -192,6 +196,20 @@ static int write_trailer(AVFormatContext *s)
> return 0;
> }
>
> +#define OFFSET(x) offsetof(ASSContext, x)
> +#define E AV_OPT_FLAG_ENCODING_PARAM
> +static const AVOption options[] = {
> + { "ignore_gaps", "write events immediately, even if they're out-of-order", OFFSET(ignore_gaps), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E },
> + { NULL },
> +};
> +
> +static const AVClass ass_class = {
> + .class_name = "ass muxer",
> + .item_name = av_default_item_name,
> + .option = options,
> + .version = LIBAVUTIL_VERSION_INT,
> +};
> +
> AVOutputFormat ff_ass_muxer = {
> .name = "ass",
> .long_name = NULL_IF_CONFIG_SMALL("SSA (SubStation Alpha) subtitle"),
> @@ -203,4 +221,5 @@ AVOutputFormat ff_ass_muxer = {
> .write_packet = write_packet,
> .write_trailer = write_trailer,
> .flags = AVFMT_GLOBALHEADER | AVFMT_NOTIMESTAMPS | AVFMT_TS_NONSTRICT,
> + .priv_class = &ass_class,
> };
The option name is a bit unspecific - how about "ignore_readorder"?
More information about the ffmpeg-devel
mailing list