Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which pixel format for web mp4 video?

I have to create video in mp4 format, and it seems that I can encode it with different pixel formats like yuv420p, yuv422p, yuvj422p. Which one I should use to maximize compatibility with most browsers/players?

like image 653
user606521 Avatar asked Sep 28 '15 18:09

user606521


1 Answers

Use yuv420p

You can use the -vf format=yuv420p (or the alias -pix_fmt yuv420p) output option to make sure your output is YUV 4:2:0.

Example

ffmpeg -i input -c:v libx264 -crf 23 -preset medium -vf format=yuv420p -c:a copy -movflags +faststart output.mp4
  • For web video the -movflags +faststart option is also recommended.
  • The audio is being stream copied (re-muxed) in this example instead of being re-encoded. Useful if the input is already AAC.
  • See FFmpeg Wiki: H.264 & H.265 for more info on the encoder specific settings (-crf and -preset).

Determining the pixel format of a video

You can check the pixel format of a video with ffprobe:

$ ffprobe -loglevel error -show_entries stream=pix_fmt -of csv=p=0 input.mp4
yuv420p
like image 139
llogan Avatar answered Nov 08 '22 23:11

llogan