diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-08-06 12:25:32 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-08-06 12:25:32 +0400 |
commit | 3fa72de82f04802e307085d3fce9eafea1d3dc46 (patch) | |
tree | 075119600cac0d5d61b710c51a1c669306cc291b | |
parent | 84bc317019ba5c35355592df64d152f2cff76339 (diff) | |
parent | 56ee3f9de7b9f6090d599a27d33a392890a2f7b8 (diff) |
Merge commit '56ee3f9de7b9f6090d599a27d33a392890a2f7b8'
* commit '56ee3f9de7b9f6090d599a27d33a392890a2f7b8':
avconv: distinguish between -ss 0 and -ss not being used
Conflicts:
ffmpeg.c
ffmpeg_opt.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg.c | 18 | ||||
-rw-r--r-- | ffmpeg_filter.c | 6 | ||||
-rw-r--r-- | ffmpeg_opt.c | 13 |
3 files changed, 22 insertions, 15 deletions
@@ -751,7 +751,9 @@ static void do_subtitle_out(AVFormatContext *s, nb = 1; /* shift timestamp to honor -ss and make check_recording_time() work with -t */ - pts = sub->pts - output_files[ost->file_index]->start_time; + pts = sub->pts; + if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE) + pts -= output_files[ost->file_index]->start_time; for (i = 0; i < nb; i++) { ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base); if (!check_recording_time(ost)) @@ -1070,10 +1072,11 @@ static int reap_filters(void) } frame_pts = AV_NOPTS_VALUE; if (filtered_frame->pts != AV_NOPTS_VALUE) { + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; filtered_frame->pts = frame_pts = av_rescale_q(filtered_frame->pts, ost->filter->filter->inputs[0]->time_base, ost->st->codec->time_base) - - av_rescale_q(of->start_time, + av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->codec->time_base); } @@ -1377,7 +1380,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) if (ost->source_index != ist_index) return 0; - if (of->start_time && ist->pts < of->start_time) + if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) return 0; return 1; @@ -1386,8 +1389,9 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) { OutputFile *of = output_files[ost->file_index]; - int64_t ost_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ost->st->time_base); - int64_t ist_tb_start_time = av_rescale_q(of->start_time, AV_TIME_BASE_Q, ist->st->time_base); + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; + int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base); + int64_t ist_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ist->st->time_base); AVPicture pict; AVPacket opkt; @@ -1398,7 +1402,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p return; if (pkt->pts == AV_NOPTS_VALUE) { - if (!ost->frame_number && ist->pts < of->start_time && + if (!ost->frame_number && ist->pts < start_time && !ost->copy_prior_start) return; } else { @@ -1408,7 +1412,7 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p } if (of->recording_time != INT64_MAX && - ist->pts >= of->recording_time + of->start_time) { + ist->pts >= of->recording_time + start_time) { close_output_stream(ost); return; } diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 9f9544bc80..1270ffb615 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -286,11 +286,11 @@ static int insert_trim(OutputStream *ost, AVFilterContext **last_filter, int *pa char filter_name[128]; int ret = 0; - if (of->recording_time == INT64_MAX && !of->start_time) + if (of->recording_time == INT64_MAX && of->start_time == AV_NOPTS_VALUE) return 0; // Use with duration and without output starttime is buggy with trim filters - if (!of->start_time) + if (of->start_time == AV_NOPTS_VALUE) return 0; trim = avfilter_get_by_name(name); @@ -310,7 +310,7 @@ static int insert_trim(OutputStream *ost, AVFilterContext **last_filter, int *pa ret = av_opt_set_double(ctx, "duration", (double)of->recording_time / 1e6, AV_OPT_SEARCH_CHILDREN); } - if (ret >= 0 && of->start_time) { + if (ret >= 0 && of->start_time != AV_NOPTS_VALUE) { ret = av_opt_set_double(ctx, "start", (double)of->start_time / 1e6, AV_OPT_SEARCH_CHILDREN); } diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 6e7797f5ab..65f3df92f9 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -147,6 +147,7 @@ static void init_options(OptionsContext *o, int is_input) o->recording_time = INT64_MAX; o->stop_time = INT64_MAX; o->mux_max_delay = 0.7; + o->start_time = AV_NOPTS_VALUE; o->limit_filesize = UINT64_MAX; o->chapters_input_file = INT_MAX; } @@ -824,13 +825,13 @@ static int open_input_file(OptionsContext *o, const char *filename) exit_program(1); } - timestamp = o->start_time; + timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time; /* add the stream start time */ if (ic->start_time != AV_NOPTS_VALUE) timestamp += ic->start_time; /* if seeking requested, we execute it */ - if (o->start_time != 0) { + if (o->start_time != AV_NOPTS_VALUE) { ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, timestamp, 0); if (ret < 0) { av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n", @@ -1451,7 +1452,8 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) for (i = 0; i < is->nb_chapters; i++) { AVChapter *in_ch = is->chapters[i], *out_ch; - int64_t ts_off = av_rescale_q(ofile->start_time - ifile->ts_offset, + int64_t start_time = (ofile->start_time == AV_NOPTS_VALUE) ? 0 : ofile->start_time; + int64_t ts_off = av_rescale_q(start_time - ifile->ts_offset, AV_TIME_BASE_Q, in_ch->time_base); int64_t rt = (ofile->recording_time == INT64_MAX) ? INT64_MAX : av_rescale_q(ofile->recording_time, AV_TIME_BASE_Q, in_ch->time_base); @@ -1586,11 +1588,12 @@ static int open_output_file(OptionsContext *o, const char *filename) } if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) { - if (o->stop_time <= o->start_time) { + int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time; + if (o->stop_time <= start_time) { av_log(NULL, AV_LOG_WARNING, "-to value smaller than -ss; ignoring -to.\n"); o->stop_time = INT64_MAX; } else { - o->recording_time = o->stop_time - o->start_time; + o->recording_time = o->stop_time - start_time; } } |