ffmpeg - whatsapp: video format not supported
Copied from https://www.reddit.com/r/ffmpeg/comments/564kyc/ffmpeg_whatsapp_video_format_not_supported/?st=ivjxdi0v&sh=848ce7eb
ffmpeg -i brokenvideo.mp4 -c:v libx264 -c:a aac fixedvideo.mp4
Also had to apply this fix: FFMPEG (libx264) "height not divisible by 2"
There are some options for a better compatibility:
ffmpeg -i broken.mp4 -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p working.mp4
With -profile:v baseline -level 3.0
you make the file more compatible with most older players, including WhatsApp ;). Although, this disables some advanced features.
-pix_fmt yuv420p
is necessary to compile to baseline (YUV planar color space with 4:2:0 chroma subsampling).
Also, you can adjust other options as bitrate, framerate, audio, etc.
Source: H.264 docs
I tried all previous commands and I got some errors. I was able to encode my video using this command and here is the explanation and why I set it up like this for a better compatibility:
ffmpeg -i input.mp4 \
-c:v libx264 -pix_fmt yuv420p \
-profile:v baseline -level 3.0
-vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -vb 1024k \
-acodec aac -ar 44100 -ac 2\
-minrate 1024k -maxrate 1024k -bufsize 1024k \
-movflags +faststart \
output.mp4
- If your input contains AAC audio you can stream copy instead of re-encoding by changing
-acodec aac -ar 44100 -ac 2
to-acodec copy
to preserve the audio quality.
option | explanation |
---|---|
-vcodec libx264 |
Chooses video encoder libx264 |
-pix_fmt yuv420p |
Ensures YUV 4:2:0 chroma subsampling for compatibility |
-profile:v baseline |
Set the encoding profile to baseline. Used primarily for low-cost applications that require additional data loss robustness |
-level 3.0 |
Set the operating point level to 3.0 which is necessary to have compatibility with WhatsApp |
-vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" |
If you get not divisible by 2 error see |
-acodec aac |
Chooses audio encoder aac |
-minrate 1024k |
set min bitrate tolerance to 1024k (in bits/s). It is of little use elsewise |
-maxrate 1024k |
set max bitrate tolerance to 1024k (in bits/s). Requires bufsize to be set |
-bufsize 1024k |
set rate-control buffer size to 1024k (in bits) |
-movflags +faststart |
enables fast start for streaming |
This is worked for me in 2020
ffmpeg -i broken.mp4 -c:v libx264 -profile:v high -level 3.0 -pix_fmt yuv420p -brand mp42 fixed.mp4