Here’s a bunch of command line tools I occasionally use over and over again. I can never remember them, so I started noting them down on my Google Drive/Docs. Then Google Drive started annoying me with its sub-par latency, so I figured I’d be doing a favor to video people out there (including myself) by collecting them on this site.

FFmpeg commands

  • Encapsulating yuv video in y4m container
ffmpeg -f rawvideo -pixel_format yuv420p -video_size 352x288 -framerate 30 -i CREW_352x288_30.yuv -f yuv4mpegpipe outputFile.y4m
  • Peeling y4m container header from yuv video
ffmpeg -f yuv4mpegpipe -i input.y4m -f rawvideo -pixel_format yuv420p -video_size 704x576 -framerate 60 output.yuv
  • Encapsulating H.264 NALU byte-stream in mkv container
ffmpeg -i input.264 -c:v copy -f matroska output.mkv
  • Changing the pixel format of raw videos: if you’re feeling lazy to write separate code for different pixel formats, you can use FFmpeg to do that for you. Here are FourCC and Wikipedia pages to learn about YUV color formats.
ffmpeg -f rawvideo -s 1280x720 -pix_fmt uyvy422 -i input.yuv -pix_fmt yuv420p -f yuv4mpegpipe output.y4m

VLC commands

  • Playing yuv files: as usual, we must provide width, height and the color format, as well as the frame rate necessary for correct playback.
vlc --demux rawvideo --rawvid-fps 30 --rawvid-width 352 --rawvid-height 288 --rawvid-chroma=I420 input.yuv
  • Playing the camera feed on Linux (with huge latency): add ‘-I dummy’ to use the simple interface.
vlc v4l2:///dev/video0

x264 commands

  • Encoding in real-time: Here we use a fixed intra-period length and no scene cuts. If you don’t know the encoding parameters you need to set, selecting the profile and tuning according to your needs should be sufficient. Consult the x264 help for more info.
x264 input.yuv --profile main --tune zerolatency -I 32 -i 32 --no-scenecut --demuxer raw --input-res 352x288 --input-csp i420 --fps 30 -o output.mkv

to be continued…