Search code examples
ffmpegstreamrecordrtspplayback

ffmpeg play RTSP stream while recording


I successfully record to a file a RTSP stream using ffmpeg with the following command:

ffmpeg -i "rtsp://1.1.1.1:554/user=admin&password=admin&channel=1&stream=1" -acodec copy -vcodec copy -movflags frag_keyframe+empty_moov -y http://www.example.com/rec/1.mp4

now I need to play video while ffmpeg is still writing to file. Even changing file format, is it possible?


Solution

  • Pipe a 2nd output to ffplay

    ffmpeg -i "rtsp://1.1.1.1:554/user=admin&password=admin&channel=1&stream=1" -acodec copy -vcodec copy -movflags frag_keyframe+empty_moov -y http://www.example.com/rec/1.mp4 -c copy -f nut - | ffplay