Ffmpeg Quick Stream Command Line

Again from the stop-trying-to-use every-flag-available department. This makes me think about this Percona engineer who once told me and my team “people keep tuning MySQL with tons of configuration options when really 10 parameters define 90% of the performance”.

For some reason, I was somewhere where I needed to stream my webcam quickly to a remote machine on my home network through a VPN in order to record the current place. Again, I stumbled upon an infinite list of sites where people tried to use every possible ffmpeg flag. Seems like people love Fabrice Bellard so much they want to honor every bit of his creations.

Here’s a quick one liner in order to stream to an UDP address:

$ ffmpeg -f v4l2 -i /dev/video0 -s 640x360 -ar 22050 -f mpegts udp://

I didn’t need huge quality so I reduced the capture size (-s) to 640x360 and audio sample rate (-ar) to 22050. The others options are self-explanatory and mandatory.
To reduce the size of the streamed video, I could have add -r 10 to cap the framerate to 10 images per second, but then the sound would have been choppy.

And on the other end using mplayer for example, because it’s simpler:

$ mplayer -dumpstream udp:// -dumpfile myrecord.mp4

Here. Type less, do more.