Search code examples
ubuntuvideoffmpegmp4yuv

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


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.


Solution

  • 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