mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avformat/assenc: Add ignore_gaps option
Signed-off-by: Clément Bœsch <u@pkh.me>
This commit is contained in:
parent
ae6118de19
commit
ae437c7ce7
@ -23,6 +23,8 @@
|
|||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
typedef struct DialogueLine {
|
typedef struct DialogueLine {
|
||||||
int readorder;
|
int readorder;
|
||||||
char *line;
|
char *line;
|
||||||
@ -30,12 +32,14 @@ typedef struct DialogueLine {
|
|||||||
} DialogueLine;
|
} DialogueLine;
|
||||||
|
|
||||||
typedef struct ASSContext{
|
typedef struct ASSContext{
|
||||||
|
const AVClass *class;
|
||||||
int write_ts; // 0: ssa (timing in payload), 1: ass (matroska like)
|
int write_ts; // 0: ssa (timing in payload), 1: ass (matroska like)
|
||||||
int expected_readorder;
|
int expected_readorder;
|
||||||
DialogueLine *dialogue_cache;
|
DialogueLine *dialogue_cache;
|
||||||
DialogueLine *last_added_dialogue;
|
DialogueLine *last_added_dialogue;
|
||||||
int cache_size;
|
int cache_size;
|
||||||
int ssa_mode;
|
int ssa_mode;
|
||||||
|
int ignore_readorder;
|
||||||
}ASSContext;
|
}ASSContext;
|
||||||
|
|
||||||
static int write_header(AVFormatContext *s)
|
static int write_header(AVFormatContext *s)
|
||||||
@ -178,7 +182,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
insert_dialogue(ass, dialogue);
|
insert_dialogue(ass, dialogue);
|
||||||
purge_dialogues(s, 0);
|
purge_dialogues(s, ass->ignore_readorder);
|
||||||
} else {
|
} else {
|
||||||
avio_write(s->pb, pkt->data, pkt->size);
|
avio_write(s->pb, pkt->data, pkt->size);
|
||||||
}
|
}
|
||||||
@ -192,6 +196,20 @@ static int write_trailer(AVFormatContext *s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define OFFSET(x) offsetof(ASSContext, x)
|
||||||
|
#define E AV_OPT_FLAG_ENCODING_PARAM
|
||||||
|
static const AVOption options[] = {
|
||||||
|
{ "ignore_readorder", "write events immediately, even if they're out-of-order", OFFSET(ignore_readorder), 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 = {
|
AVOutputFormat ff_ass_muxer = {
|
||||||
.name = "ass",
|
.name = "ass",
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("SSA (SubStation Alpha) subtitle"),
|
.long_name = NULL_IF_CONFIG_SMALL("SSA (SubStation Alpha) subtitle"),
|
||||||
@ -203,4 +221,5 @@ AVOutputFormat ff_ass_muxer = {
|
|||||||
.write_packet = write_packet,
|
.write_packet = write_packet,
|
||||||
.write_trailer = write_trailer,
|
.write_trailer = write_trailer,
|
||||||
.flags = AVFMT_GLOBALHEADER | AVFMT_NOTIMESTAMPS | AVFMT_TS_NONSTRICT,
|
.flags = AVFMT_GLOBALHEADER | AVFMT_NOTIMESTAMPS | AVFMT_TS_NONSTRICT,
|
||||||
|
.priv_class = &ass_class,
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MAJOR 56
|
#define LIBAVFORMAT_VERSION_MAJOR 56
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 11
|
#define LIBAVFORMAT_VERSION_MINOR 11
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 101
|
#define LIBAVFORMAT_VERSION_MICRO 102
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
LIBAVFORMAT_VERSION_MINOR, \
|
LIBAVFORMAT_VERSION_MINOR, \
|
||||||
|
Loading…
Reference in New Issue
Block a user