arielCo
arielCo

Reputation: 431

ffmpeg: -copyts makes -t stop at timestamps, not duration

From

-t duration (input/output)

When used as an input option (before -i), limit the duration of data read from the input file.

When used as an output option (before an output url), stop writing the output after its duration reaches duration.

So this should yield a 1-minute file with timestamps starting at 1:49, right?

ffmpeg -y -copyts -ss 1:49 -i ~/Videos/input.mkv -c copy -t 1:00 timing-1m49s.mkv 
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7 (SUSE Linux)
  configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g' --optflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -g' --disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --disable-openssl --enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcelt --enable-libcdio --enable-libdc1394 --enable-libfreetype --enable-libgsm --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-netcdf --enable-vaapi --enable-vdpau --enable-libfdk_aac --enable-nonfree --enable-libmp3lame --enable-libtwolame --enable-libx264 --enable-libx265 --enable-libxvid
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libavresample   3.  5.  0 /  3.  5.  0
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Input #0, matroska,webm, from '/home/ariel/Videos/input.mkv':
  Metadata:
    encoder         : libebml v0.7.7 + libmatroska v0.8.0
    creation_time   : 2006-07-20T03:07:03.000000Z
  Duration: 00:23:57.06, start: 0.000000, bitrate: 1983 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 720x480, SAR 37:30 DAR 37:20, 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s (default)
    Stream #0:2(jpn): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:3(eng): Subtitle: dvd_subtitle, 720x480 (default)
    Metadata:
      title           : English Audio
    Stream #0:4(eng): Subtitle: dvd_subtitle, 720x480
    Metadata:
      title           : Japanese Audio
Output #0, matroska, to 'timing-1m49s.mkv':
  Metadata:
    encoder         : Lavf57.71.100
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p(progressive), 720x480 [SAR 37:30 DAR 37:20], q=2-31, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=-1.0 Lsize=       1kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Wrong. It outputs a file with no frames:

-rwxrwx--- 1 root users 805 Jul 30 01:36 timing-1m49s.mkv

I have to specify -t 1:49 or more, and e.g. -t 1:55 produces a 6-second file that starts at 0:00 and according to the metadata should last 1:55.

I arrived at this point trying to extract a clip and add subtitles in the same command, but this minimal case looks to me contrary to the documentation.

Upvotes: 1

Views: 3216

Answers (1)

Gyan
Gyan

Reputation: 93018

Yes, the -t used as output option looks at the timestamps, which usually start at zero. Except for cases like these when -copyts is used. Use -t as input option:

ffmpeg -y -copyts -ss 1:49 -t 1:00 -i ~/Videos/input.mkv -c copy timing-1m49s.mkv 

Upvotes: 3

Related Questions