Search code examples
ffmpegmp4h.264yuv

Encoding YUV to mP4 With qp to get max quality


I am trying to encode my YUV420 Raw format file into mp4. Here is the ffmpeg command

ffmpeg -f s16le -ar 44100 -ac 1 -i "0.a" -f rawvideo -pix_fmt yuv420p -s 480x480 -r 30 -i "0.v" -vcodec libx264 -profile:v baseline -preset ultrafast -qp 0 -b:v 1024k -g 30 -acodec libfdk_aac -ar 44100 -ac 1 -b:a 64k -f mp4 -movflags faststart "1438947231095.mp4"

If i remove qp = 0; it works however the quality is very low not sure why. If i put qp = 0 it doesn't work, What is wrong?

Getting this error

Error while opening encoder for output stream #0:0 - maybe incorrect parameters

Solution

  • The baseline profile doesn't support lossless H.264. You must use the High 4:4:4 Predictive profile instead:

    -profile:v high444