diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2014-11-23 23:31:20 -0600 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-11-24 17:31:26 +0100 |
commit | 39f247121ec6a78d25e87b93a352c91b6f8cbb34 (patch) | |
tree | 938f55dede8ae1e3b113b29b7613a2e44fc4c7f5 | |
parent | 54170a33c2c97b0f50347f57e8f0f2ea681dca1d (diff) | |
download | ffmpeg-39f247121ec6a78d25e87b93a352c91b6f8cbb34.tar.gz |
ffmpeg: fix accurate seeking with -copyts
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.h | 1 | ||||
-rw-r--r-- | ffmpeg_filter.c | 18 |
2 files changed, 17 insertions, 2 deletions
@@ -483,6 +483,7 @@ extern int do_deinterlace; extern int do_hex_dump; extern int do_pkt_dump; extern int copy_ts; +extern int start_at_zero; extern int copy_tb; extern int debug_ts; extern int exit_on_error; diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 0555cf684a..264840b2e9 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -637,6 +637,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, AVBPrint args; char name[255]; int ret, pad_idx = 0; + int64_t tsoffset = 0; if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) { av_log(NULL, AV_LOG_ERROR, "Cannot connect video filter to audio input\n"); @@ -711,8 +712,14 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); + if (copy_ts) { + tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time; + if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE) + tsoffset += f->ctx->start_time; + } ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? - AV_NOPTS_VALUE : 0, f->recording_time, &last_filter, &pad_idx, name); + AV_NOPTS_VALUE : tsoffset, f->recording_time, + &last_filter, &pad_idx, name); if (ret < 0) return ret; @@ -731,6 +738,7 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, AVBPrint args; char name[255]; int ret, pad_idx = 0; + int64_t tsoffset = 0; if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) { av_log(NULL, AV_LOG_ERROR, "Cannot connect audio filter to non audio input\n"); @@ -813,8 +821,14 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter, snprintf(name, sizeof(name), "trim for input stream %d:%d", ist->file_index, ist->st->index); + if (copy_ts) { + tsoffset = f->start_time == AV_NOPTS_VALUE ? 0 : f->start_time; + if (!start_at_zero && f->ctx->start_time != AV_NOPTS_VALUE) + tsoffset += f->ctx->start_time; + } ret = insert_trim(((f->start_time == AV_NOPTS_VALUE) || !f->accurate_seek) ? - AV_NOPTS_VALUE : 0, f->recording_time, &last_filter, &pad_idx, name); + AV_NOPTS_VALUE : tsoffset, f->recording_time, + &last_filter, &pad_idx, name); if (ret < 0) return ret; |