summaryrefslogtreecommitdiff
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
parent7beeea8f1755d25d2eaf56cff9a04590244da393 (diff)
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.
-rw-r--r--ffmpeg.c22
-rw-r--r--tests/ref/fate/bethsoft-vid1
-rw-r--r--tests/ref/fate/idroq-video-encode2
-rw-r--r--tests/ref/lavf/dv_fmt6
-rw-r--r--tests/ref/lavf/gxf6
-rw-r--r--tests/ref/lavf/ismv6
-rw-r--r--tests/ref/lavf/mov6
-rw-r--r--tests/ref/lavf/mpg6
-rw-r--r--tests/ref/lavf/mxf6
-rw-r--r--tests/ref/lavf/ogg6
10 files changed, 35 insertions, 32 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;
diff --git a/tests/ref/fate/bethsoft-vid b/tests/ref/fate/bethsoft-vid
index 19674270a4..f59823cea1 100644
--- a/tests/ref/fate/bethsoft-vid
+++ b/tests/ref/fate/bethsoft-vid
@@ -141,4 +141,3 @@
1, 54760, 54760, 537, 1074, 0x142ce7ba
0, 69, 69, 1, 192000, 0x159313a8
1, 55297, 55297, 925, 1850, 0x7ff682f7
-0, 70, 70, 1, 192000, 0x8e685d68
diff --git a/tests/ref/fate/idroq-video-encode b/tests/ref/fate/idroq-video-encode
index bfffb090c2..24f3f0d823 100644
--- a/tests/ref/fate/idroq-video-encode
+++ b/tests/ref/fate/idroq-video-encode
@@ -1 +1 @@
-736168b00f6b79f472a57bf47b587c8c
+2be5ade557acab688d58f1c5ec0773f4
diff --git a/tests/ref/lavf/dv_fmt b/tests/ref/lavf/dv_fmt
index 2a228b20b9..e8720afc54 100644
--- a/tests/ref/lavf/dv_fmt
+++ b/tests/ref/lavf/dv_fmt
@@ -1,9 +1,9 @@
6f9cfff48f536fa727696f2f9fb3ac08 *./tests/data/lavf/lavf.dv
3600000 ./tests/data/lavf/lavf.dv
./tests/data/lavf/lavf.dv CRC=0x5ce4e5e4
-cc33ae4f9e6828914dea0f09d1241b7e *./tests/data/lavf/lavf.dv
-3480000 ./tests/data/lavf/lavf.dv
-./tests/data/lavf/lavf.dv CRC=0x8d5e9e8f
+2e8989478f05f6d4eaf1921fdfac4799 *./tests/data/lavf/lavf.dv
+3600000 ./tests/data/lavf/lavf.dv
+./tests/data/lavf/lavf.dv CRC=0x747caf33
87d3b20f656235671383a7eaa2f66330 *./tests/data/lavf/lavf.dv
3600000 ./tests/data/lavf/lavf.dv
./tests/data/lavf/lavf.dv CRC=0x0e868a82
diff --git a/tests/ref/lavf/gxf b/tests/ref/lavf/gxf
index 63101b89ed..f70b6d9c05 100644
--- a/tests/ref/lavf/gxf
+++ b/tests/ref/lavf/gxf
@@ -1,9 +1,9 @@
befc1a39c37a4ecd9264942a3e34b3f6 *./tests/data/lavf/lavf.gxf
796392 ./tests/data/lavf/lavf.gxf
./tests/data/lavf/lavf.gxf CRC=0x102918fd
-267d2b2b6e357209d76c366302cf35c3 *./tests/data/lavf/lavf.gxf
-794572 ./tests/data/lavf/lavf.gxf
-./tests/data/lavf/lavf.gxf CRC=0xab47d02d
+474c4dd8b124790b395b435ac95a6d14 *./tests/data/lavf/lavf.gxf
+816772 ./tests/data/lavf/lavf.gxf
+./tests/data/lavf/lavf.gxf CRC=0xc7d66595
0a1a37fa79b62435545271b4e8e882f5 *./tests/data/lavf/lavf.gxf
796392 ./tests/data/lavf/lavf.gxf
./tests/data/lavf/lavf.gxf CRC=0x3b1a8e91
diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv
index cf0a5831ef..08d5552c9e 100644
--- a/tests/ref/lavf/ismv
+++ b/tests/ref/lavf/ismv
@@ -1,9 +1,9 @@
eb116b60befadfd5c9118635d81c5a6e *./tests/data/lavf/lavf.ismv
312271 ./tests/data/lavf/lavf.ismv
./tests/data/lavf/lavf.ismv CRC=0xbcc963fc
-90db70a6f33cf22db9ce242087b5870b *./tests/data/lavf/lavf.ismv
-321545 ./tests/data/lavf/lavf.ismv
-./tests/data/lavf/lavf.ismv CRC=0x3998478f
+456b04d243a2c45f820ee3cd6ed3ae3b *./tests/data/lavf/lavf.ismv
+331249 ./tests/data/lavf/lavf.ismv
+./tests/data/lavf/lavf.ismv CRC=0x5c2fddcd
eb116b60befadfd5c9118635d81c5a6e *./tests/data/lavf/lavf.ismv
312271 ./tests/data/lavf/lavf.ismv
./tests/data/lavf/lavf.ismv CRC=0xbcc963fc
diff --git a/tests/ref/lavf/mov b/tests/ref/lavf/mov
index b23b75dbb6..ca697751ba 100644
--- a/tests/ref/lavf/mov
+++ b/tests/ref/lavf/mov
@@ -4,9 +4,9 @@
21b992f6a677f971dfd685cc055a2b0a *./tests/data/lavf/lavf.mov
358463 ./tests/data/lavf/lavf.mov
./tests/data/lavf/lavf.mov CRC=0x2f6a9b26
-f1e80a52983775ea27dda0590b46e17a *./tests/data/lavf/lavf.mov
-367893 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xab307eb9
+f607c5ac4f2668149c064d75a4ddd0dd *./tests/data/lavf/lavf.mov
+377609 ./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0x4e671506
305a68397e3cdb505704841fedcdc352 *./tests/data/lavf/lavf.mov
357845 ./tests/data/lavf/lavf.mov
./tests/data/lavf/lavf.mov CRC=0x2f6a9b26
diff --git a/tests/ref/lavf/mpg b/tests/ref/lavf/mpg
index 8d2f862afc..8b3ca5ab0e 100644
--- a/tests/ref/lavf/mpg
+++ b/tests/ref/lavf/mpg
@@ -1,9 +1,9 @@
8d47f1d92230442d475477ed4ec0c778 *./tests/data/lavf/lavf.mpg
372736 ./tests/data/lavf/lavf.mpg
./tests/data/lavf/lavf.mpg CRC=0x88f58ba1
-ac56ba7cec2d2be0a1ca17473e5b152c *./tests/data/lavf/lavf.mpg
-387072 ./tests/data/lavf/lavf.mpg
-./tests/data/lavf/lavf.mpg CRC=0xe8637d83
+a0510a6f6ad056882827a2d2a92fd537 *./tests/data/lavf/lavf.mpg
+399360 ./tests/data/lavf/lavf.mpg
+./tests/data/lavf/lavf.mpg CRC=0x93df648f
af32acbc73ee486b05a37d53e516d5e7 *./tests/data/lavf/lavf.mpg
372736 ./tests/data/lavf/lavf.mpg
./tests/data/lavf/lavf.mpg CRC=0x88f58ba1
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 51a488e6c7..7e48d50973 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,9 +1,9 @@
4cc269e1d2066fac03a3d7466f011c8e *./tests/data/lavf/lavf.mxf
525881 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x4ace0849
-87eb6e0e51d31c8ffa414d02672edfa0 *./tests/data/lavf/lavf.mxf
-537657 ./tests/data/lavf/lavf.mxf
-./tests/data/lavf/lavf.mxf CRC=0x9b928d6b
+88ab06201db1953329bfb4aa04a4fe05 *./tests/data/lavf/lavf.mxf
+553529 ./tests/data/lavf/lavf.mxf
+./tests/data/lavf/lavf.mxf CRC=0x86fddf92
52c5b74ecfdc48bd77d79a6bbe62d2de *./tests/data/lavf/lavf.mxf
525881 ./tests/data/lavf/lavf.mxf
./tests/data/lavf/lavf.mxf CRC=0x4ace0849
diff --git a/tests/ref/lavf/ogg b/tests/ref/lavf/ogg
index bfc62de0c8..584e09bfbb 100644
--- a/tests/ref/lavf/ogg
+++ b/tests/ref/lavf/ogg
@@ -1,3 +1,3 @@
-810fbac66c4c65fd155b3c7f27ce69c5 *./tests/data/lavf/lavf.ogg
-12610 ./tests/data/lavf/lavf.ogg
-./tests/data/lavf/lavf.ogg CRC=0xf651632a
+ce1734741fa50c6c85f9cc8f410a720c *./tests/data/lavf/lavf.ogg
+13985 ./tests/data/lavf/lavf.ogg
+./tests/data/lavf/lavf.ogg CRC=0x37a143ea