Videos which are converted in Linux do not play in mobile browser
I used avconv
and ffmpeg
to convert video files, but these files after this process did not work on a mobile browser. They only work as well on VLC or any other browser of desktop (Linux or Windows).
And I just used all of codes for conversion seen in the StackOverflow! MP4 or WebM using H264 or VP9 codec do not work.
The last code which I used is this:
ffmpeg -i buck.webm -b 1500k -vcodec libx264 -profile:v baseline -g 30 "example.mp4"
Works fine on a PC, but does not work in a mobile browser (Chrome or Firefox).
How should I proceed?
Solution 1:
Have a close look at this document for android developers:
Supported Media Formats
Note that this gives only baseline settings and any given mobile device might provide support for additional formats or file types not listed in the table.
Based on this it looks like your choice of video codec and settings for this codec are acceptable but you would be better to specify aac for the audio codec in your commandline. This would hopefully allow for a wide range of devices with successful playback.
A suggested commandline for FFmpeg would be:
ffmpeg -i input \
-c:v libx264 -preset slow -crf 22 \
-profile:v baseline -level 3.0 \
-movflags +faststart -pix_fmt yuv420p \
-c:a libfdk_aac -b:a 128k \
output.mp4
Some points for this choice of commandline:
- For the greatest compatibility with a wide range of devices it is recommended to use
-profile:v baseline -level 3.0
- It is an idea to add
-movflags +faststart
if your file is going to be displayed online, with this setting it should start playback before fully downloaded - Use
-pix_fmt yuv420p
to allow playback on a wider range of devices -
libfdk_aac
gives better AAC sound than the native FFmpeg AAC encoder (when this encoder was still marked 'experimental')
I have provided a working sample here for testing purposes using this command line; and I note that this file works perfectly with my Google Pixel 3a (Android).