[FFmpeg-cvslog] r25727 - in trunk: doc/ffmpeg-doc.texi ffmpeg.c
elenril
subversion
Fri Nov 12 07:56:19 CET 2010
Author: elenril
Date: Fri Nov 12 07:56:19 2010
New Revision: 25727
Log:
ffmpeg.c: add an option for copying chapters
fixes issue 2068
Modified:
trunk/doc/ffmpeg-doc.texi
trunk/ffmpeg.c
Modified: trunk/doc/ffmpeg-doc.texi
==============================================================================
--- trunk/doc/ffmpeg-doc.texi Fri Nov 12 06:38:57 2010 (r25726)
+++ trunk/doc/ffmpeg-doc.texi Fri Nov 12 07:56:19 2010 (r25727)
@@ -630,6 +630,10 @@ of the output file:
@example
ffmpeg -i in.ogg -map_meta_data 0:0,s0 out.mp3
@end example
+ at item -map_chapters @var{outfile}:@var{infile}
+Copy chapters from @var{infile} to @var{outfile}. If no chapter mapping is specified,
+then chapters are copied from the first input file with at least one chapter to all
+output files. Use a negative file index to disable any chapter copying.
@item -debug
Print specific debug info.
@item -benchmark
Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c Fri Nov 12 06:38:57 2010 (r25726)
+++ trunk/ffmpeg.c Fri Nov 12 07:56:19 2010 (r25727)
@@ -102,6 +102,11 @@ typedef struct AVMetaDataMap {
int index; //< stream/chapter/program number
} AVMetaDataMap;
+typedef struct AVChapterMap {
+ int in_file;
+ int out_file;
+} AVChapterMap;
+
static const OptionDef options[];
#define MAX_FILES 100
@@ -132,6 +137,9 @@ static int nb_meta_data_maps;
static int metadata_streams_autocopy = 1;
static int metadata_chapters_autocopy = 1;
+static AVChapterMap *chapter_maps = NULL;
+static int nb_chapter_maps;
+
/* indexed by output file stream index */
static int *streamid_map = NULL;
static int nb_streamid_map = 0;
@@ -2381,7 +2389,28 @@ static int transcode(AVFormatContext **o
av_metadata_set2(meta[0], mtag->key, mtag->value, AV_METADATA_DONT_OVERWRITE);
}
+ /* copy chapters according to chapter maps */
+ for (i = 0; i < nb_chapter_maps; i++) {
+ int infile = chapter_maps[i].in_file;
+ int outfile = chapter_maps[i].out_file;
+
+ if (infile < 0 || outfile < 0)
+ continue;
+ if (infile >= nb_input_files) {
+ snprintf(error, sizeof(error), "Invalid input file index %d in chapter mapping.\n", infile);
+ ret = AVERROR(EINVAL);
+ goto dump_format;
+ }
+ if (outfile >= nb_output_files) {
+ snprintf(error, sizeof(error), "Invalid output file index %d in chapter mapping.\n",outfile);
+ ret = AVERROR(EINVAL);
+ goto dump_format;
+ }
+ copy_chapters(infile, outfile);
+ }
+
/* copy chapters from the first input file that has them*/
+ if (!nb_chapter_maps)
for (i = 0; i < nb_input_files; i++) {
if (!input_files[i]->nb_chapters)
continue;
@@ -2962,6 +2991,21 @@ static void opt_map_meta_data(const char
metadata_chapters_autocopy = 0;
}
+static void opt_map_chapters(const char *arg)
+{
+ AVChapterMap *c;
+ char *p;
+
+ chapter_maps = grow_array(chapter_maps, sizeof(*chapter_maps), &nb_chapter_maps,
+ nb_chapter_maps + 1);
+ c = &chapter_maps[nb_chapter_maps - 1];
+ c->out_file = strtol(arg, &p, 0);
+ if (*p)
+ p++;
+
+ c->in_file = strtol(p, &p, 0);
+}
+
static void opt_input_ts_scale(const char *arg)
{
unsigned int stream;
@@ -4074,6 +4118,7 @@ static const OptionDef options[] = {
{ "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" },
{ "map", HAS_ARG | OPT_EXPERT, {(void*)opt_map}, "set input stream mapping", "file:stream[:syncfile:syncstream]" },
{ "map_meta_data", HAS_ARG | OPT_EXPERT, {(void*)opt_map_meta_data}, "set meta data information of outfile from infile", "outfile[,metadata]:infile[,metadata]" },
+ { "map_chapters", HAS_ARG | OPT_EXPERT, {(void*)opt_map_chapters}, "set chapters mapping", "outfile:infile" },
{ "t", OPT_FUNC2 | HAS_ARG, {(void*)opt_recording_time}, "record or transcode \"duration\" seconds of audio/video", "duration" },
{ "fs", HAS_ARG | OPT_INT64, {(void*)&limit_filesize}, "set the limit file size in bytes", "limit_size" }, //
{ "ss", OPT_FUNC2 | HAS_ARG, {(void*)opt_start_time}, "set the start time offset", "time_off" },
More information about the ffmpeg-cvslog
mailing list