1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavf/concat: add support for chapters

This commit is contained in:
Nicolas George 2021-08-31 15:57:48 +02:00
parent 1a0aff8ca5
commit 2263ff505c
2 changed files with 15 additions and 1 deletions

View File

@ -184,6 +184,10 @@ Can be present multiple times.
@item @code{stream_codec @var{value}}
Codec for the stream.
@item @code{cahpter @var{id} @var{start} @var{end}}
Add a chapter. @var{id} is an unique identifier, possibly small and
consecutive.
@end table
@subsection Options

View File

@ -408,7 +408,7 @@ static int concat_read_close(AVFormatContext *avf)
return 0;
}
#define MAX_ARGS 2
#define MAX_ARGS 3
#define NEEDS_UNSAFE (1 << 1)
#define NEEDS_FILE (1 << 1)
#define NEEDS_STREAM (1 << 2)
@ -432,6 +432,7 @@ typedef enum ParseDirective {
DIR_EXSID,
DIR_STMETA,
DIR_STCODEC,
DIR_CHAPTER,
} ParseDirective;
static const ParseSyntax syntax[] = {
@ -447,6 +448,7 @@ static const ParseSyntax syntax[] = {
[DIR_EXSID ] = { "exact_stream_id", "i", NEEDS_STREAM },
[DIR_STMETA ] = { "stream_meta", "ks", NEEDS_STREAM },
[DIR_STCODEC ] = { "stream_codec", "k", NEEDS_STREAM },
[DIR_CHAPTER ] = { "chapter", "idd", 0 },
};
static int concat_parse_script(AVFormatContext *avf)
@ -457,6 +459,7 @@ static int concat_parse_script(AVFormatContext *avf)
uint8_t *cursor, *keyword;
ConcatFile *file = NULL;
AVStream *stream = NULL;
AVChapter *chapter = NULL;
unsigned line = 0, arg;
const ParseSyntax *dir;
char *arg_kw[MAX_ARGS];
@ -609,6 +612,13 @@ static int concat_parse_script(AVFormatContext *avf)
break;
}
case DIR_CHAPTER:
chapter = avpriv_new_chapter(avf, arg_int[0], AV_TIME_BASE_Q,
arg_int[1], arg_int[2], NULL);
if (!chapter)
return AVERROR(ENOMEM);
break;
default:
FAIL(AVERROR_BUG);
}