It’s easy to convert between the two formats as long as you have a fairly recent release of MJPEGTools package installed. Here are the examples on Fedora 21:
- Suppose we have a raw YUV file named BasketballDrill_832x480_50.yuv. This file is one of the HEVC test sequences in 4:2:0 planar format. The display aspect ratio (DAR) should be 16:9. Following is the command line to convert it to Y4M format:
$cat BasketballDrill_832x480_50.yuv | yuv4mpeg -w 832 -h 480 -x 420mpeg2 -a 40:39 -i p -r 50:1 > BasketballDrill.y4m
Note that we specify the pixel aspect ratio (PAR), rather than DAR, in the command line.
- Once the Y4M file is created, we can use the following command line to view the file:
$yuvplay < BasketballDrill.y4m
- In the case that we need to strip a Y4M file down to a raw YUV file so we can feed it to an encoder that does not accept Y4M as input, we can use the following command line:
$y4mtoyuv < BasketballDrill.y4m > BasketballDrill.yuv
For more information, refer to the man pages of the package.