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.
pull/59/head
Nicolas George 13 years ago
parent 7beeea8f17
commit 2fc354f90d
  1. 22
      ffmpeg.c
  2. 1
      tests/ref/fate/bethsoft-vid
  3. 2
      tests/ref/fate/idroq-video-encode
  4. 6
      tests/ref/lavf/dv_fmt
  5. 6
      tests/ref/lavf/gxf
  6. 6
      tests/ref/lavf/ismv
  7. 6
      tests/ref/lavf/mov
  8. 6
      tests/ref/lavf/mpg
  9. 6
      tests/ref/lavf/mxf
  10. 6
      tests/ref/lavf/ogg

@ -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;

@ -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

@ -1 +1 @@
736168b00f6b79f472a57bf47b587c8c
2be5ade557acab688d58f1c5ec0773f4

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save