ffmpeg - whatsapp: video format not supported - ffmpeg

I have two videos (.mp4) files. One uploads to whatsapp and another does not.
Using ffmpeg I checked their properties:
a) Properties of video which uploads:
Duration: 00:00:56.45, start: 0.148000, bitrate: 1404 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1080x1080, 1359 kb/s, 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (HE-AACv2) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 47 kb/s (default)
Metadata:
handler_name : SoundHandler
At least one output file must be specified
b) video which does not upload to whatsapp (because its says format not supported)
Duration: 00:00:56.10, start: 0.000000, bitrate: 543 kb/s
Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p, 1080x1080 [SAR 1:1 DAR 1:1], 464 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 47.95 tbc
Stream #0:1: Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 56 kb/s
The difference in video I noticed:
(avc1 / 0x31637661) vs (H264 / 0x34363248)
1359 kb/s vs 464 kb/s
90k tbn vs 23.98 tbn
What can be the reason?
Also the second video is not being played in Android.
The link for the video is https://drive.google.com/open?id=0B4UM6vTHw4pyMExQQ1lxZGp0N2c

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

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"

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

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
Note about faststart
Normally, a MP4 file has all its metadata packets stored at the end of the file, in data units named atoms. The mdat atom is located before the moov atom. If the file is created by adding the -movflags faststart, the moov atom is moved at the beginning of the MP4 file. By using this option, the moov atom is located before the mdat atom. This allows video playback to begin before the file has been completely downloaded.

2023-01-22 I used the most upvoted answer format and it worked for video, but audio was not working on iPhones. Here's what worked for me:
ffmpeg -i broken.mp4 -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -ac 2 working.mp4
I had to add -ac 2 because the audio format I had wasn't seen as stereo by iOS.

Related

ffmpeg can't transcode DVD ac3 audio stream, but VLC can play it

I'm attempting to transcode a DVD to a single MKV file. I've had success in the past with other DVDs, but I'm running into an error I haven't seen before.
First I concatenate the VOB files I want to transcode:
cat VTS_02_1.VOB VTS_02_2.VOB VTS_02_3.VOB > WMAV.VOB
ffprobe output:
$ ffprobe -analyzeduration 100M -probesize 100M WMAV.VOB Input #0, mpeg, from 'WMAV.VOB':
Duration: 01:05:19.42, start: 0.300300, bitrate: 5686 kb/s
Stream #0:0[0x1bf]: Data: dvd_nav_packet
Stream #0:1[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, smpte170m, top first), 720x480 [SAR 32:27 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
Stream #0:2[0x80]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
Unsupported codec with id 100357 for input stream 0
Then I run this command to transcode the file:
ffmpeg -analyzeduration 100M -probesize 100M \
-i WMAV.VOB \
-map 0:1 -map 0:2 \
-c:v libx264 -preset slow -tune film -crf 21 \
-c:a aac -b:a 192k \
wmav.mkv
However, when I include -c:a aac, I get thousands of errors like this:
Error while decoding stream #0:2: Error number -16976906 occurred
[ac3 # 000002bd24d8eec0] expacc 127 is out-of-range
[ac3 # 000002bd24d8eec0] error decoding the audio block
There doesn't seem to be any issue with the audio stream since it plays back fine in VLC. The transcode succeeds if I use -c:a copy.
What is causing this error and how could I fix the problem?

Using ffmpeg to convert MXF fails

I have an MXF video
I googled syntax to convert to mov and ran it in Mobaxterm on Win10.
"/drives/c/Program Files (x86)/ffmpeg/bin/ffmpeg.exe" -i Clip0001.MXF -c:v libx264 -c:a aac -ab 384k -sn -strict -2 output.mov
I view it in VideoLan and it looks great.
I load it into Magix Movie Studio 15 and audio is fine, but video is green!
ffmpeg output.mov....shows me:
Stream #0:0(eng): Video: h264 (High 4:2:2) (avc1 / 0x31637661), yuv422p, 1920x1080 [SAR 1:1 DAR 16:9], 4530 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Even this does not work:
ffmpeg.exe -i Clip0001.MXF output.mov
Any suggestions on converting this?
Edit1:
Here is what it looks like in the editor:
Edit2:
Try this and it works, but quality is terrible.
ffmpeg.exe" -i Clip0001.MXF -c:v mpeg4 -c:a aac -ab 384k -sn -strict -2 output.mov
FFmpeg isn't failing; many video editors usually have limited-capability H264 decoders.
Your input has 4:2:2 chroma subsampling and ffmpeg will preserve that when it can. Here, it can and does. However, your video editor can only deal with 4:2:0 subsampled H264 streams.
So, use
ffmpeg.exe -i Clip0001.MXF -pix_fmt yuv420p -c:v libx264 -c:a aac -b:a 384k -sn output.mov
If this command throws an error for the AAC encoder due to the missing -strict -2, your ffmpeg is very old (> 3 years). You should upgrade.

ffmpeg highest quality mp4 to mpg

I have a mp4 video that I need to convert to mpg (for windows PowerPoint2010)
I have been trying to get best quality. But I keep getting error:
[mpeg # 0x2523620] buffer underflow st=0 bufi=420177 size=445860
[mpeg # 0x2523620] packet too large, ignoring buffer limits to mux it
[mpeg # 0x2523620] buffer underflow st=0 bufi=420177 size=445860
[mpeg # 0x2523620] buffer underflow st=0 bufi=422218 size=445860
Could someone help me with the syntax for best quality ouput to mpg. Here is the output of the mp4 file:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2016-06-10 11:15:06
Duration: 00:04:20.86, start: 0.000000, bitrate: 18677 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 18541 kb/s, 29.97 fps, 29.97 tbr, 29970 tbn, 59.94 tbc (default)
Metadata:
creation_time : 2016-06-10 11:15:06
handler_name : VideoHandler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 132 kb/s (default)
Metadata:
creation_time : 2016-06-10 11:15:06
handler_name : SoundHandler
I have tried the following but keep getting that error:
ffmpeg -i video.mp4 -c:v libx264 -c:a copy -qp 5 video.mpg
ffmpeg -i video.mp4 -c:v libx264 -c:a copy -qscale:v 1 video.mpg
ffmpeg -i video.mp4 -c:v libx264 -crf 0 -c:a copy -bf 2 -flags qprd -flags mv0 video.mpg
ffmpeg -i video.mp4 -c:v libx264 -crf 0 -c:a copy video.mpg
ffmpeg -i video.mp4 -c:v libx264 -preset slow -crf 5 -c:a copy video.mpg
ffmpeg -i video.mp4 -c:v libx264 -preset slow -crf 5 -c:a copy -maxrate 11000k video.mpg
ffmpeg -i video.mp4 -c:v libx264 -preset slow -crf 5 -c:a copy -maxrate 5000 -bufsize 11000 video.mpg
Thanks,
Doesn't look like PP2010 supports H.264. (If it did, you could skip re-encoding altogether).
Try
ffmpeg -i video.mp4 -c:v mpeg2video -q:v 5 -c:a mp2 -f vob video.mpg
This will produce a MPEG-2 Program Stream container with MPEG-2 video and MP2 audio.

FFmpeg - selecting appropriate bitrate for VP9 encoding

I am looking to encode a 4k video shot with iPhone 6s in VP9 in the best quality possible.
For reference, stream data of the video I would like to encode, via ffprobe:
Duration: 00:00:10.48, start: 0.000000, bitrate: 46047 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 3840x2160, 45959 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2017-03-13T21:12:56.000000Z
handler_name : Core Media Data Handler
encoder : H.264
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 79 kb/s (default)
Metadata:
creation_time : 2017-03-13T21:12:56.000000Z
handler_name : Core Media Data Handler
I am using the following FFmpeg commands, based on these instructions (see Best Quality (Slowest) Recommended Settings section).
ffmpeg -i INPUT.mov -c:v libvpx-vp9 -pass 1 -b:v 46000K -threads 4 -speed 4 -g 9999 -an -f webm -y /dev/null
ffmpeg -I INPUT.mov -c:v libvpx-vp9 -pass 2 -b:v 46000K -threads 4 -speed 0 -g 9999 -an -f webm OUTPUT.webm
Is there a best practice to select an optimal -b:v value such that the resulting video is visually indistinguishable from the original? I have tried values ranging from 36000K-46000K, but these result in massive files with an overall bitrate exceeding the target bitrate.
Thanks in advance!
Just have to experiment with different, much lower bit rates, and view the results. I try to watch for artifacts. Does hair still look good? Cloth? Lettering, like on road signs and store windows? No blockiness? No bleeding of dark and light at sharp edges? No echoes? I find motion blur in the original hard to judge, have to compare side by side to tell the difference between that and compression artifacts.
Try 1/10th of 36000k. I find vp9 at a nominal 400k bit rate works great on 1280x720 video. (ffmpeg with libvpx-vp9 overshoots, and I typically end up with a 20% higher actual bit rate, 480k) 4K is 3840x2160, 9x the size of 1280x720, so it would seem a 3600k bit rate should produce good results.
Another guide is that vp9 is reportedly about equal in quality to mp4 at half the bit rate. Video that looks good at a 1000k bit rate in mp4 should look good at 500k in vp9.

Concat mp4 files with a command line tool

I am blocked trying to do something, and I'm ready to make a donation if somebody can help me:
I try to concat http://s.serero.free.fr/rolex.mp4 video and http://s.serero.free.fr/video.mp4 video in one output mp4 file and I tried during a big time without results.
I want to concat http://s.serero.free.fr/rolex.mp4 + http://s.serero.free.fr/video.mp4
or http://s.serero.free.fr/video.mp4 + http://s.serero.free.fr/rolex.mp4.
I tried with ffmpeg command line software and with mp4box command line software, I think that I don't have the good method.
I tried to transform http://s.serero.free.fr/video.mp4 in the same format of http://s.serero.free.fr/rolex.mp4 (and vice versa):
I transformed http://s.serero.free.fr/rolex.mp4 with the same frame rate of http://s.serero.free.fr/video.mp4
I transformed http://s.serero.free.fr/rolex.mp4 with the same video bitrate of http://s.serero.free.fr/video.mp4
I transformed http://s.serero.free.fr/rolex.mp4 with the same video audio bitrate of http://s.serero.free.fr/video.mp4
Can somebody help me?
Explain to me what is wrong in my strategy?
Your input parameters vary, so you have to make them similar before concatenation.
rolex.mp4
Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 835 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc (default)
Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
video.mp4
Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1152x720, 1749 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, s16p, 127 kb/s (default)
This example will make video.mp4 more like rolex.mp4 then concat them:
ffmpeg -i rolex.mp4 -i video.mp4 -filter_complex \
"[1:v]pad=1280:720:(ow-iw)/2:0,fps=25,format=yuv420p[v1]; \
[0:v][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" output.mp4
You don't actually need to declare fps or format because, as the concat filter documentation states:
All corresponding streams must have the same parameters in all
segments; the filtering system will automatically select a common
pixel format for video streams, and a common sample format, sample
rate and channel layout for audio streams, but other settings, such as
resolution, must be converted explicitly by the user.
...but doing so will allow you to manually choose the "common" settings instead of relying on the filter automatically doing so and potentially selecting a setting you don't want.
Thanks for LordNeckbeard for his excellent answer, he just let a little mistake on the command, i just want to a little explanation :
If I want to concat video.mp4(1152X720) with rolex.mp4(1280X720), we must understand that "video.mp4" is the main video so the video(s) to concatene must have exactly the same frame size.
So before to do this operation you need to resize rolex.mp4 video with the same size like video.mp4 with ffmpeg :
ffmpeg -i rolex.mp4 -s 1152x720 -c:a copy newrolexsized.mp4
No video.mp4 and newrolexsized.mp4 has the same frame size, and you can use the command (spcifying pad=1152:720 => size of the main video):
ffmpeg -i video.mp4 -i newrolexsized.mp4 -filter_complex "[1:v]pad=1152:720:(ow-iw)/2:0,fps=25,format=yuv420p[v1];[0:v][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" out.mp4

Resources