1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00
FFmpeg/fftools
Shiwang.Xie 694545b6d5 fftools/ffmpeg: fix -t inaccurate recording time
if input start time is not 0 -t is inaccurate doing stream copy,
will record extra duration according to input start time.
it should base on following cases:

input video start time from 60s, duration is 300s,
1. stream copy:
       ffmpeg -ss 40 -t 60 -i in.mp4 -c copy -y out.mp4
   open_input_file() will seek to 100 and set ts_offset to -100,
   process_input() will offset pkt->pts with ts_offset to make it 0,
   so when do_streamcopy() with -t, exits when ist->pts >= recording_time.

2. stream copy with -copyts:
       ffmpeg -ss 40 -t 60 -copyts -i in.mp4 -c copy -y out.mp4
   open_input_file() will seek to 100 and set ts_offset to 0,
   process_input() will keep raw pkt->pts as ts_offset is 0,
   so when do_streamcopy() with -t, exits when
   ist->pts >= (recording_time+f->start_time+f->ctx->start_time).

3. stream copy with -copyts -start_at_zero:
       ffmpeg -ss 40 -t 60 -copyts -start_at_zero -i in.mp4 -c copy -y out.mp4
   open_input_file() will seek to 120 and set ts_offset to -60 as start_to_zero option,
   process_input() will offset pkt->pts with input file start time,
   so when do_streamcopy() with -t, exits when ist->pts >= (recording_time+f->start_time).

0      60     40      60                     360
|_______|_____|_______|_______________________|
      start   -ss     -t

This fixes ticket #9141.

Signed-off-by: Shiwang.Xie <shiwang.xie666@outlook.com>
2021-07-18 09:59:02 +05:30
..
cmdutils.c fftools/cmdutils.c: Add cmd line option to override detection of cpu count. 2021-07-16 10:06:23 +02:00
cmdutils.h fftools/cmdutils.c: Add cmd line option to override detection of cpu count. 2021-07-16 10:06:23 +02:00
ffmpeg_filter.c libavresample: Remove deprecated library 2021-04-27 10:43:13 -03:00
ffmpeg_hw.c ffmpeg: Don't require a known device to pass a frames context to an encoder 2020-05-03 16:04:27 +01:00
ffmpeg_opt.c ffmpeg: add option readrate 2021-07-17 20:34:21 +05:30
ffmpeg_qsv.c ffmpeg: Remove the hw_device_ctx global 2020-04-26 18:38:25 +01:00
ffmpeg_videotoolbox.c ffmpeg_videotoolbox: skip memory copy if hwaccel_output_format match 2021-06-10 19:54:03 +08:00
ffmpeg.c fftools/ffmpeg: fix -t inaccurate recording time 2021-07-18 09:59:02 +05:30
ffmpeg.h ffmpeg: add option readrate 2021-07-17 20:34:21 +05:30
ffplay.c fftools/ffplay: 240M matrix is not the same as BT.601 2021-06-08 21:55:14 +02:00
ffprobe.c ffprobe: use quotation marks in the xml header output 2021-07-15 23:46:40 -03:00
Makefile ffmpeg: remove superfluous custom cuvid hwaccel 2020-03-03 18:11:28 -03:00