Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using FFMPEG to losslessly convert YUV to another format for editing in Adobe Premier

Tags:

ffmpeg

yuv

I have a raw YUV video file that I want to do some basic editing to in Adobe CS6 Premiere, but it won't recognize the file. I thought to use ffmpeg to convert it to something Premiere would take in, but I want this to be lossless because afterwards I will need it in YUV format again. I thought of avi, mov, and prores but I can't seem to figure out the proper command line to ffmpeg and how to ensure it is lossless.

Thanks for your help.

like image 941
kilgoretrout Avatar asked Apr 03 '13 04:04

kilgoretrout


1 Answers

Yes, this is possible. It is normal that you can't open that raw video file since it is just raw data in one giant file, without any headers. So Adobe Premiere doesn't know what the size is, what framerate ect.

First make sure you downloaded the FFmpeg command line tool. Then after installing you can start converting by running a command with parameters. There are some parameters you have to fill in yourself before starting to convert:

  1. What type of the YUV pixel format are you using? The most common format is YUV4:2:0 planar 8-bit (YUV420p). You can type ffmpeg -pix_fmts to get a list of all available formats.
  2. What is the framerate? In my example I will use -r 25 fps.
  3. What encoder do you want to use? The libx264 (H.264) encoder is a great one for lossless compression.
  4. What is your framesize? In my example I will use -s 1920x1080

Then we get this command to do your compression.

ffmpeg -f rawvideo -vcodec rawvideo -s 1920x1080 -r 25 -pix_fmt yuv420p -i inputfile.yuv -c:v libx264 -preset ultrafast -qp 0 output.mp4

A little explanation of all other parameters:

  • With -f rawvideo you set the input format to a raw video container
  • With -vcodec rawvideo you set the input file as not compressed
  • With -i inputfile.yuv you set your input file
  • With -c:v libx264 you set the encoder to encode the video to libx264.
  • The -preset ultrafast setting is only speeding up the compression so your file size will be bigger than setting it to veryslow.
  • With -qp 0 you set the maximum quality. 0 is best, 51 is worst quality in our example.
  • Then output.mp4 is your new container to store your data in.

After you are done in Adobe Premiere, you can convert it back to a YUV file by inverting allmost all parameters. FFmpeg recognizes what's inside the mp4 container, so you don't need to provide parameters for the input.

ffmpeg -i input.mp4 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 1920x1080 -r 25 rawvideo.yuv

like image 125
Nick van Tilborg Avatar answered Sep 24 '22 14:09

Nick van Tilborg