VLC: How to temporarily record an RTSP stream to a file on disk with vlc
VLC: How to temporarily record an RTSP stream to a file on disk with vlcBoth ffmpeg and vlc can be used to record RTSP/RTP streams to local disks. This is how to record a part of an RTSP stream using vlc:
Code:
cvlc "rtsp://192.168.1.70:554/user=admin&password=&channel=2&stream=0.sdp?real_stream--rtp-caching=100" --sout "#transcode{}:duplicate{dst=std{access=file,mux=ts,dst={filename.mp4}}}" --run-time 60 --stop-time=60 vlc://quit
The "sout" part is self explanatory: it duplicates the content of the stream with destination file on disk. Let's analyse the other options from manual:
Code:
vlc://quit Special item to quit VLC
...
--stop-time=<float> Stop time
The stream will stop at this position (in seconds).
--run-time=<float> Run time
The stream will run this duration (in seconds).
According to videolan website, "Transcoding takes quite a while, so it's advisable to use an option like --stop-time=30 to only encode the first 30 seconds - this means you can check the file has transcoded correctly, and that the output is of a suitable quality."
While VLC will record the raw stream to file on the disk, it does not create meta data to the file. This is done with ffmpeg. I'm using specific options here to lower the size of the resulted file:
Code:
ffmpeg -i ~vlc/filename.mp4 -codec:v libx264 -crf 23 -preset medium -codec:a libfdk_aac -movflags faststart -vf scale=-1:720,format=yuv420p filename1.mp4
The resulted filename1.mp4 file can be viewed in vlc or ny other player.