That said, what if you want to store and play live video simultaneously?
Playing live video while storing the incoming video is do-able using these tools and a first-in-first-out (FIFO).
The trick is to recognize that FFMpeg can support converting a single input file into multiple output files. For instance, you can convert a source video file into two output files as follows:
$ ffmpeg -i source.avi /tmp/output.avi /tmp/output.mpg
This command will take the source file source.avi and generate twin output files /tmp/output.avi and /tmp/output.mpg converting them simultaneously.
Similarly, you can use a video device /dev/video rather than an input video file and generate twin output files by using a similar command:
$ ffmpeg -r 15 -s 352x288 -f video4linux -i /dev/video0 /tmp/output.avi /tmp/output.mpg
While cool and closer, attempting to play the file will eventually reach the file end and terminate. Instead, by using a FIFO as an output file and using this FIFO as the input to Mplayer you've accomplished your goal.
$ mkfifo /tmp/vidPipe
$ ffmpeg -y -f video4linux -r 15 -s 352x288 -i /dev/video0 -f avi -vcodec msmpeg4 /tmp/vidPipe /tmp/output.avi
In another terminal window play the fifo with Mplayer using the following command:
$ mplayer /tmp/vidPipe
I love it when a plan comes together.
No comments:
Post a Comment