brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: generate a test media file with ffmpeg instead of hunting for footage

Media
~/tips/tip-media-ffmpeg-testsrc

ffmpeg -f lavfi -i testsrc2=size=1280x720:rate=30 \

Creates a short video with picture and tone for trying out settings.

Testing a player, an upload form or a transcoding setup needs a video you don’t mind sharing. ffmpeg can invent one.

Combine a generated picture with a generated tone:

ffmpeg -f lavfi -i testsrc2=size=1280x720:rate=30 \
  -f lavfi -i sine=frequency=1000:sample_rate=48000 \
  -t 10 -c:v libx264 -pix_fmt yuv420p -c:a aac test.mp4

-f lavfi tells ffmpeg that the input is a filter instead of a file. testsrc2 draws a moving test pattern with a timer, handy for spotting stutter, and sine gives a steady 1 kHz tone. -t 10 stops after ten seconds; without it these sources run forever.

Change the size and rate to match whatever you’re testing, for example size=3840x2160:rate=60 to find out whether a machine can keep up with 4K.

I like having an exact, known file when something fails. If the pattern plays fine and your own video doesn’t, the problem is in your video. It also makes bug reports easy, since anyone can recreate the same input from your command line.

-pix_fmt yuv420p is there for compatibility, because many players struggle with other pixel formats. Remember that a synthetic pattern compresses very differently from camera footage, so don’t draw conclusions about file size or picture quality from it. The command needs a build with libx264.

Further reading: FFmpeg filters documentation, ffmpeg documentation

More Media tips avconvert -s clip.mov -o clip-720.m4v -p Preset1280x720 avmediainfo holiday.mov rpicam-still --timeout 30000 --timelapse 2000 -o timelapse/image%04d.jpg wp media regenerate --only-missing --yes All Media tips (5) All topics

Link