Skip to content

Instantly share code, notes, and snippets.

/stdin Secret

Created October 15, 2014 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/203026397f53729c9595 to your computer and use it in GitHub Desktop.
Save anonymous/203026397f53729c9595 to your computer and use it in GitHub Desktop.
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 20fc63c..1b10d37 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -95,6 +95,7 @@ int do_benchmark_all = 0;
int do_hex_dump = 0;
int do_pkt_dump = 0;
int copy_ts = 0;
+int shift_copy_ts = 0;
int copy_tb = -1;
int debug_ts = 0;
int exit_on_error = 0;
@@ -926,7 +927,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
f->start_time = o->start_time;
f->recording_time = o->recording_time;
f->input_ts_offset = o->input_ts_offset;
- f->ts_offset = o->input_ts_offset - (copy_ts ? 0 : timestamp);
+ f->ts_offset = o->input_ts_offset - (copy_ts ? (shift_copy_ts ? ((o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time) : 0) : timestamp);
f->nb_streams = ic->nb_streams;
f->rate_emu = o->rate_emu;
f->accurate_seek = o->accurate_seek;
@@ -2906,6 +2907,8 @@ const OptionDef options[] = {
"audio drift threshold", "threshold" },
{ "copyts", OPT_BOOL | OPT_EXPERT, { &copy_ts },
"copy timestamps" },
+ { "shift_copyts", OPT_BOOL | OPT_EXPERT, { &shift_copy_ts },
+ "when using copyts, shift timestamps as if the file started at zero" },
{ "copytb", HAS_ARG | OPT_INT | OPT_EXPERT, { &copy_tb },
"copy input stream time base when stream copying", "mode" },
{ "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment