FFmpeg has three concatenation methods:
Use this method if your inputs do not have the same parameters (width, height, etc), or are not the same formats/codecs, or if you want to perform any filtering.
Note that this method performs a re-encode of all inputs. If you want to avoid the re-encode, you could re-encode just the inputs that don't match so they share the same codec and other parameters, then use the concat demuxer to avoid re-encoding everything.
ffmpeg -i opening.mkv -i episode.mkv -i ending.mkv \
-filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] \
concat=n=3:v=1:a=1 [v] [a]" \
-map "[v]" -map "[a]" output.mkv
Use this method when you want to avoid a re-encode and your format does not support file-level concatenation (most files used by general users do not support file-level concatenation).
$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4
For Windows:
(echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txt
ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
Use this method with formats that support file-level concatenation
(MPEG-1, MPEG-2 PS, DV). Do not use with MP4.
ffmpeg -i "concat:input1|input2" -codec copy output.mkv
This method does not work for many formats, including MP4, due to the nature of these formats and the simplistic concatenation performed by this method.
If in doubt about which method to use, try the concat demuxer.
Also see
Ok, so the solution that I was looking for came in the form of CVLC 2.0.1 [Console-only VLC], but also took advantage of the muxing capabilities of ffmpeg.
This one-liner transcodes the RTSP stream into FLV and pushes it to my localhost server at a specified port.
cvlc rtsp://xxx.xxx.xxx.xxx:554/vga.sdp :sout='#transcode{vcodec=FLV1,vb=2048,fps=25,scale=1,acodec=none,deinterlace}:http{mime=video/x-flv,mux=ffmpeg{mux=flv},dst=127.0.0.1:8090/device_1.flv}' :no-sout-standard-sap :ttl=5 :sout-keep :no-audio --video --no-sout-audio
The advantages of this include not having to edit the ffserver.conf file each time the stream changes resolution, bit rate, frame rate, etc. - Only to restart this one line so that it can re-capture the stream. Also, if the stream has the proper specifications, you don't need the vb=
and fps=
properties; I would only use them if I needed to throttle the stream for the sake of the web page.
--network-caching
was another feature that I was considering, though very useful in certain situations, unnecessary in my case.
The Flowplayer code looks something like:
<div style="width:1280px;height:720px;margin:10px" id="player_1"></div><script language="javascript">
flowplayer("player_1", {src: "/js/flowplayer-3.2.7.swf", wmode:"transparent"},{
clip: {
url: 'http://127.0.0.1:8090/device_1.flv',
autoPlay: true,
autoBuffering: true,
live: true,
bufferLength:0
},
plugins: {
controls: {
all: false,
scrubber: true,
play: true,
fullscreen: true,
time: false,
width: '100%',
opacity: 0.8,
tooltips: {
buttons: true,
fullscreen: 'Enter fullscreen mode'
}
}
}
});
Hope this helps any viewers running into similar issues!
Mason
Best Answer
See this question and answer on Server Fault. In short, switch tools. avconv will do what you want. (ffmpeg has become avconv.)
The feature you are looking for is called segmentation. Your command line would look something like this:
avconv -i rtsp://10.2.2.19/live/ch01_0 -c copy -map 0 -f segment -segment_time 300 -segment_format mp4 "capture-%03d.mp4"