Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I keep the flow (protocol rtsp, codec h264) in file (container mp4)? That is, on input an endless stream (with CCTV camera), and the output files in mp4 format size of 5-10 minutes of recording time.

OS: debian, ubuntu Software: vlc, ffmpeg (avconv)

Currently this scheme is used:

cvlc rtsp://admin:admin@ --sout=file/ts:stream.ts
ffmpeg -i stream.ts -vcodec copy -f mp4 stream.mp4

But it can not record video continuously (between restarts vlc is a loss of about 10 seconds of live video)

share|improve this question
up vote 5 down vote accepted

VLC does not support segmenting the output file. You can try to use directly ffmpeg as it supports output segmentation:

ffmpeg -i rtsp://admin:admin@ -c copy -map 0 -f segment -segment_time 600 -segment_format mp4 "out%03d.mp4"
share|improve this answer
I would advise that you want to use -segment_atclocktime 1 if the application is for "CCTV". As this will try to split based on the wall clock and not time since recording began. – Aron Nov 23 '15 at 14:54

it may be helpful to know how to split audio files into 10 minute segments (i.e. many short files from a huge long file, e.g. for car stereo) since avconv man page has not enough explanatory value. Below is a working shell command line to split up the file "interview.mp3". using less parameters (map) did not work here. some audio files require -map 0:0 , watch output hints.

avconv -i interview.mp3 -codec copy -map 0 -f segment -segment_format mp3 -segment_time 600 "iview%03d.mp3"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.