Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert mp4 to maximum mobile supported MP4 using FFMPEG [closed]

Tags:

ffmpeg

h.264

I would like to use ffmpeg to convert an mp4 to 'low size' mp4 ...

I need an mp4 file with h263 video and aac audio (or some other settings supported by low cost mobile.) My main concern is that the video be playable on most devices.

What would be some possible ffmpeg commands to accomplish this?

Thanks in advance.

like image 900
Notepad Avatar asked Nov 26 '12 08:11

Notepad


People also ask

Does FFmpeg convert MP4 video without audio?

After converting videos using FFmpeg, most of the users have observed that the converted MP4 video lacks audio. In addition to this, users have also found that the converted MP4 videos does not have the subtitles that where originally present in MKV source video. Most of the times, the conversion command does not work when using FFmpeg.

How to change the quality of media files using FFmpeg?

With ffmpeg we can choose between two different ways to convert media files. The first and easy one is to copy streams into the desired container, and the second one is to re-encode those streams in order to change their quality or size…

How to convert MP3 to Ogg using FFmpeg?

This command takes an MP3 file called input.mp3 and converts it into an OGG file called output.ogg. From FFmpeg's point of view, this means converting the MP3 audio stream into a Vorbis audio stream and wrapping this stream into an OGG container. You didn't have to specify stream or container types, because FFmpeg figured it out for you.

How to convert a video file to MP4 in Linux?

Compatible with Windows, Mac, and Linux, FFmpeg uses a line command to get the task done. You can use FFmpeg to convert to mp4 in a quick manner. Simple command to convert any videos (mov in below sample command) to MP4 format. ffmpeg -i example.mov example.mp4 -hide_banner.


1 Answers

There are numerous ways to encode mp4 videos, and encoding them for mobile devices is even more complex. I'm not sure what you mean by "low cost mobile" do you mean low cost as in the device, or the bandwidth needed to play said video?

Either way, here a post to get you going: H.264 WEB VIDEO ENCODING TUTORIAL WITH FFMPEG

Examples

Here are some ffmpeg examples from the post ...

“Standard” web video (480p at 500kbit/s):

ffmpeg -i input_file.avi -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k output_file.mp4

360p video for older mobile phones (360p at 250kbit/s in baseline profile):

ffmpeg -i inputfile.avi -vcodec libx264 -vprofile baseline -preset slow -b:v 250k -maxrate 250k -bufsize 500k -vf scale=-1:360 -threads 0 -acodec libvo_aacenc -ab 96k output.mp4

480p video for iPads and tablets (480p at 400kbit/s in main profile):

ffmpeg -i inputfile.avi -vcodec libx264 -vprofile main -preset slow -b:v 400k -maxrate 400k -bufsize 800k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -ab 128k output.mp4

High-quality SD video for archive/storage (PAL at 1Mbit/s in high profile):

ffmpeg -i inputfile.avi -vcodec libx264 -vprofile high -preset slower -b:v 1000k -vf scale=-1:576 -threads 0 -acodec libvo_aacenc -ab 196k output.mp4

Bitrates, scale and profiles ...

From the examples there, some of the key things you might need to pay attention to are ...

-b:v 500k

-b:a 128k

Those are bitrates of the video v and audio a, the lower the number the lower the quality but also the better it might 'play' on a low end device.

scale=-1:480

That will scale the video down to a smaller size, see more info about that in the post)

-vprofile baseline

This seemly odd baseline (or another appropriate profile parameter) can be important when encoding for certain lower-cost (e.g. Android) devices ...

Baseline Profile (BP)

Primarily for low-cost applications that require additional data loss robustness, this profile is used in some videoconferencing and mobile applications. This profile includes all features that are supported in the Constrained Baseline Profile, plus three additional features that can be used for loss robustness (or for other purposes such as low-delay multi-point video stream compositing). The importance of this profile has faded somewhat since the definition of the Constrained Baseline Profile in 2009. All Constrained Baseline Profile bitstreams are also considered to be Baseline Profile bitstreams, as these two profiles share the same profile identifier code value.

like image 137
Justin Jenkins Avatar answered Oct 25 '22 04:10

Justin Jenkins