Skip to content

Stream a still JPEG image

Eric Wheeler edited this page Feb 8, 2022 · 1 revision

This was originally posted in Stack Exchange as Change /dev/video0 to a jpeg using v4l2loopback

ffmpeg -re -loop 1 -i input.jpg -vf format=yuv420p -f v4l2 /dev/video0
  • -re - Process input at real-time, otherwise it will go as fast as possible.
  • -loop 1 - Continuously loop the input.
  • -i input.jpg - The input file. Note that the option is -i, not -I which is invalid (Unrecognized option 'I').
  • -vf format=yuv420p - Use format filter to output a pixel format that is compatible with V4L2.
  • -f v4l2 - Manually set which output format to use. Usually this isn't needed for local, normal file outputs. But it is needed for streaming, and outputting to V4L2 can be considered a type of streaming.
  • /dev/video0 - The output.

FYI for others: If the output is fuzzy, say, because you changed the .jpg being rendered, delete the video0 device and re-create it: ./v4l2loopback-ctl delete /dev/video0; ./v4l2loopback-ctl add /dev/video0

See Is there any way ffmpeg send video to /dev/video0? for more info and examples.

Clone this wiki locally