summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorNicolas George <nicolas.george@normalesup.org>2012-07-03 20:34:27 +0200
committerNicolas George <nicolas.george@normalesup.org>2012-07-04 16:20:47 +0200
commit2fc354f90d61f5f1bb75dbdd808a502dec69cf99 (patch)
tree7a2df588949e2b89a8f066ef0f49b8dd653f5ee1 /ffmpeg.c
parent7beeea8f1755d25d2eaf56cff9a04590244da393 (diff)
downloadffmpeg-2fc354f90d61f5f1bb75dbdd808a502dec69cf99.tar.gz
ffmpeg: rework checks for the -t option.
This commit is based on libav's implementation and makes sure to compare output timestamps together. It also reduces the differences with avconv. The changes to the test reference files are caused by an additional packet at the end, the timestamp of the frame encoded by this packet is always strictly below the limit stated by the -t option.
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index a19f2077ba..1119fdf013 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1570,10 +1570,10 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost,
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
-#if 0
+
if (!check_recording_time(ost))
return;
-#endif
+
if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)
frame->pts = ost->sync_opts;
ost->sync_opts = frame->pts + frame->nb_samples;
@@ -1681,6 +1681,8 @@ static void do_subtitle_out(AVFormatContext *s,
for (i = 0; i < nb; i++) {
ost->sync_opts = av_rescale_q(pts, ist->st->time_base, enc->time_base);
+ if (!check_recording_time(ost))
+ return;
sub->pts = av_rescale_q(pts, ist->st->time_base, AV_TIME_BASE_Q);
// start_display_time is required to be 0
@@ -1787,6 +1789,9 @@ duplicate_frame:
in_picture->pts = ost->sync_opts;
+ if (!check_recording_time(ost))
+ return;
+
if (s->oformat->flags & AVFMT_RAWPICTURE &&
enc->codec->id == CODEC_ID_RAWVIDEO) {
/* raw pictures are written as AVPicture structure to
@@ -2242,13 +2247,6 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost)
if (of->start_time && ist->pts < of->start_time)
return 0;
- if (of->recording_time != INT64_MAX &&
- av_compare_ts(ist->pts, AV_TIME_BASE_Q, of->recording_time + of->start_time,
- (AVRational){ 1, 1000000 }) >= 0) {
- ost->is_past_recording_time = 1;
- return 0;
- }
-
return 1;
}
@@ -2265,6 +2263,12 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
!ost->copy_initial_nonkeyframes)
return;
+ if (of->recording_time != INT64_MAX &&
+ ist->pts >= of->recording_time + of->start_time) {
+ ost->is_past_recording_time = 1;
+ return;
+ }
+
/* force the input stream PTS */
if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
audio_size += pkt->size;