Converting a YUV file to .mp4 using ffmpeg for a beginner

16,274

I have recently been doing something similar to you. You may be getting a mess of colours because your input file is 480 but you're telling ffmpeg that it's 1080. Try this:

ffmpeg -s 640x480 -i bbb.yuv -ss 00:00:00 -c:v libx264 -s:v 640x480 -preset slow -t 00:08:20 output.mp4

The -t 00:08:20 is 500 seconds

Hope that helps

Share:
16,274
GreenGodot
Author by

GreenGodot

Updated on June 04, 2022

Comments

  • GreenGodot
    GreenGodot almost 2 years

    I'm a newbie when it comes to linux and ffmpeg but I need to use Evalvid to stream a video file. I want to stream a file for around 500 seconds. My plan is to download one of the videos from here:

    http://media.xiph.org/

    For this example I downloaded a video of Big Buck Bunny (in this case the 480p version). it came in an xz which I used unxz on, getting me a .y4m file which I used ffmpeg to convert to a YUV file.

    ffmpeg -i big_buck_bunny_480p24.y4m bbb.yuv
    

    My problem is right here, I try to use examples from this site but they don't work. What is the exact command to convert it to a .mp4 file using ffmpeg or are their easier alternatives to use?

    I have tried:

     ffmpeg -f rawvideo -s:v 1920x1080 -r 25 -i bbb.yuv -c:v libx264 output.mp4
    

    and this starts the conversion process but after 5 minutes I get an invalid buffer value error and the output is a mess of colours.

  • GreenGodot
    GreenGodot about 10 years
    Thanks, but the output is still a blurred mess of colours and lines. I eventually got around the problem by converting straight from Y4M to MP4, but I am worried that I may be missing something when calculating the MOS for my experiments. Could the problem be how I am converting from Y4M? The YUV file appears similar to the output MP4 when I play it using VLC or a specially designed YUV Player.
  • Joshua F. Rountree
    Joshua F. Rountree almost 9 years
    What about the other way around, converting MP4 to Y4M?