I have a recording (a simple, unprocessed TS from my satellite receiver, not encrypted) that has uneccessary stuff at the beginning and the ending. I want to cut out the main feature now with ffmpeg.
So I started with ffplay to get the timestamps for the beginning and the ending and crop detection:
ffplay -i "recording_xyz.ts" -vf "cropdetect=24:16:0"
This was the output for the first and the last frame I need:
[Parsed_cropdetect_0 @ 000000000625baa0] x1:0 x2:1279 y1:1 y2:718 w:1280 h:704 x:0 y:8 pts:7888683985 t:81953.624278 crop=1280:704:0:8
...
[Parsed_cropdetect_0 @ 000000000625baa0] x1:0 x2:1279 y1:1 y2:718 w:1280 h:704 x:0 y:8 pts:7888683985 t:87259.194348 crop=1280:704:0:8
The stream itself starts at timestamp 81825.820733
:
Duration: 01:38:00.24, start: 81825.820733, bitrate: 12748 kb/s
With all that information, I tried to cut the desired part out (and also removing streams I don't need) and convert everything into an MKV. It turned out I don't need to crop, so I can simply copy everything:
ffmpeg -i "recording_xyz.ts" -ss 81953.0 -to 87259.0 -c:v copy -c:a copy -c:s copy -map 0:0 -map 0:3 -avoid_negative_ts 1 -reset_timestamps 1 "archive_file.mkv"
The result is an empty MKV file.
What would be the correct way to use ffmpeg to cut a specific scene identified by the timestamps out?
For reference:
ffmpeg version I'm using:
ffmpeg version N-64477-g5864069 Copyright (c) 2000-2014 the FFmpeg developers
built on Jul 6 2014 22:10:36 with gcc 4.8.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 52. 90.101 / 52. 90.101
libavcodec 55. 68.101 / 55. 68.101
libavformat 55. 45.100 / 55. 45.100
libavdevice 55. 13.101 / 55. 13.101
libavfilter 4. 10.100 / 4. 10.100
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
ffmpeg's identification data for the original input stream:
Input #0, mpegts, from 'recording_xyz.ts':
Duration: 01:38:00.24, start: 81825.820733, bitrate: 12748 kb/s
Program 11110
Program 11130
Program 11140
Stream #0:0[0x190a]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, t709), 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x1914](deu): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 253 kb/s
Stream #0:2[0x1915](mis): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz, stereo, s16p, 190 kb/s
Stream #0:3[0x1916](deu): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 448 kb/s
Stream #0:4[0x1917](mul): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 190 kb/s
Stream #0:5[0x191e](deu): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:6[0x181a]: Unknown: none ([5][0][0][0] / 0x0005)
The things that appear on the console while trying to encode:
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] non-existing PPS 0 referenced
Last message repeated 1 times
[h264 @ 0000000002cb9c80] decode_slice_header error
[h264 @ 0000000002cb9c80] no frame!
[h264 @ 0000000002cb9c80] mmco: unref short failure
[mpegts @ 0000000002c784c0] PES packet size mismatch
Last message repeated 3 times
[mpegts @ 0000000002c784c0] Could not find codec parameters for stream 6 (Unknown: none ([5][0][0][0] / 0x0005)): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
... stream identification data goes here (see above) ...
[matroska @ 00000000047c0980] Using AVStream.codec.time_base as a timebase hint to the muxer is deprecated. Set AVStream.time_base instead.
Last message repeated 1 times
Output #0, matroska, to 'archive_file.mkv':
Metadata:
encoder : Lavf55.45.100
Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 50 fps, 1k tbn, 90k tbc
Stream #0:1(deu): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 448 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:3 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 size= 1kB time=00:00:00.00 bitrate=N/A
After some time, ffmpeg finishes:
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown