Where to find simple YUV (YUV420P possibly) images to test? (can I extract with ffmpeg?)

Viewed 724

I need to test an OpenGL shader that renders YUV420P (and other YUV formats) into RGB. Decoding a video just for that would be too much.

Are there any image samples with Y, U, and V buffers for me to send to the shader?

On google I only found old websites that no longer host these images.

Maybe there's a way to easily extract a frame from any video using ffmpeg?

2 Answers

Maybe there's a way to easily extract a frame from any video using ffmpeg?

(1) For converting existing image (eg: PNG):

ffmpeg -i test.png -pix_fmt yuv420p test.yuv

(2) For converting video by frame (eg: extract image at video frame xx number):

ffmpeg -i test.mp4 -pix_fmt yuv420p -vf "select=eq(n\,xx)" -frames:v 1 test.yuv

(3) For converting video by timestamp (eg: extract a specific time's frame, ss is in HH:MM:SS format):

ffmpeg -ss 00:23:00 -i test.mp4 -pix_fmt yuv420p -frames:v 1 test.yuv

PS: Whether video or image, if you need a specific resolution use the video filter scale, where either one of those width or height in the W:H setting can be replaced with -1 to keep the aspect ratio (if needed):

ffmpeg -i test.png -pix_fmt yuv420p -vf "scale=1280:720" test.yuv

You can just generate one using ffmpeg.

ffmpeg -f lavfi -i testsrc2=s=1280x720,format=yuv420p -vframes 1 sample.yuv

Note that this is planar layout, so first all Y samples, then U, then V.

Related