I have a system that records video to disk, and sometimes the system has an error. I'm trying to recreate the recording system in the lab, without the actual camera (it's expensive and there aren't any spares), to attempt to replicate the usage pattern that causes the error.
I'm having trouble taming ffmpeg.
Background:
The video is captured in one thread continuously from an rtsp:// URL provided by the attached camera with this command:
ffmpeg -i rtsp://192.168.0.10/h264 -c copy -map 0 -f segment -segment_time 900 -segment_format mp4 -segment_atclocktime 1 -strftime 1 /tmp/capture-%s.mp4
This works and produces video files of 15 minutes duration as expected.
Problem:
In the lab, I don't have the camera nor the rtsp:// stream. I've instead copied one of the capture MP4s from the real system and am using that as an input to ffmpeg instead. Something like:
ffmpeg -stream_loop -1 -i capture-1469547000.mp4 -c copy -map 0 -f segment **-{NEED PARAM}** -segment_format mp4 -strftime 1 /tmp/captest-%s.mp4
The -stream_loop -1
parameter does what's expected: it reads from the input file (which is 15 minutes in duration) and produces an infinite output stream. This is a reasonable approximation of reading from the rtsp:// stream.
What I can't figure out is what parameters to use to cause this lab system to segment the video into chunks of 15 minute duration just as the real system does. What I expect is a sequence of output files each roughly the same size as the input file.
Attempt #1
Using -segment_time 900
appears to either a) want to use the wall clock value of 15 minutes or b) be ignored. Since copying from an existing MP4 is much much faster than copying from the rtsp:// stream, the resulting capture file is many many copies of the original.
Attempt #2
I used this command
ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 capture-1469547000.mp4
to determine that the input file has 13494 frames.
Using -segment_frames 13494
appears to be ignored, and the output is not segmented at all.
Attempt #3
I've read a bunch of the ffmpeg documentation and am either missing what I need or it doesn't exist.
Using -ss *position* -t *duration*
doesn't do continuous recording & segmentation of output.
Request for help
What parameters should I use to get the segmentation to a) work and b) be 15 minutes of video duration?
Possible complication
The timestamps (DTS?) in the example MP4 are not 'good' in that this error is continuously produced:
[segment @ 0x2abc7c0] Non-monotonous DTS in output stream 0:0; previous: 80990160, current: -74730276972; changing to 80990161. This may result in incorrect timestamps in the output file. DTS 191648787, next:-830336344130 st:0 invalid dropping PTS 191648787, next:-830336344130 invalid dropping st:0
However, I don't need the resulting video files to actually play or be intact, so I am ignoring this, unless it's affecting the segmentation I need to recreate.
Further info
ffmpeg version:
\# /usr/share/local/bin/ffmpeg -version ffmpeg version N-79587-g9f9c833 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8 (Ubuntu/Linaro 4.8.2-16ubuntu4) configuration: --prefix=/home/t/dev/j/third-party/ffmpeg/../build --cross-prefix=/usr/bin/arm-linux-gnueabihf- --cpu=armv7-a --disable-shared --enable-static --enable-gpl --enable-pthreads --enable-nonfree --enable-libx264 --enable-filters --extra-libs=-static --extra-cflags=--static --enable-cross-compile --target-os=linux --disable-inline-asm --arch=armv7 --disable-debug --disable-altivec --disable-sse --disable-armv6 --disable-armv6t2 --disable-mmx --disable-neon --disable-amd3dnow --disable-thumb --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/../build/lib --extra-cflags=-I/home/t/dev/j/third-party/ffmpeg/../build/include --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libavcodec --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libavdevice --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libavfilter --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libavformat --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libavresample --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libavutil --extra-ldflags=-L/home/t/dev/j/third-party/ffmpeg/libswscale --extra-ldflags=-lx264 --extra-ldflags=-lm --extra-ldflags=-ldl --extra-cflags='-fpic -mthumb' libavutil 55. 22.101 / 55. 22.101 libavcodec 57. 38.100 / 57. 38.100 libavformat 57. 34.103 / 57. 34.103 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 44.100 / 6. 44.100 libswscale 4. 1.100 / 4. 1.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100