Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | ffmpeg and handbrake GUI |
Time | N/A |
Syntax
The syntax is as follows:
ffmpeg -i "input.avi" "output.mp4" ffmpeg -b bitrate -i "input.avi" "output.mp4" ffmpeg -i input.avi -acodec libfaac -ab 128k -ar 44100 -vcodec mpeg4 -b 1250K output.m4v ffmpeg [other-options] -b bitrate -i "input.avi" "output.mp4" ffmpeg [other-options] -b bitrate -i "New Year Party.avi" "New Year Party.mp4"
Where,
- -i input.avi : Input file name.
- -b bitrate : Set the video bitrate in bit/s (default = 200 kb/s).
- output.mp4 : Output file.
Example
Type the following command to convert japantrip_01.avi to japantrip_01.mp4 format:
$ ffmpeg -b 1250k -i japantrip_01.avi japantrip_01.mp4
Sample outputs:
ffmpeg version 0.7.13, Copyright (c) 2000-2011 the FFmpeg developers built on Jun 13 2012 14:14:09 with gcc 4.4.5 configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libfreetype --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis libavutil 50. 43. 0 / 50. 43. 0 libavcodec 52.123. 0 / 52.123. 0 libavformat 52.111. 0 / 52.111. 0 libavdevice 52. 5. 0 / 52. 5. 0 libavfilter 1. 80. 0 / 1. 80. 0 libswscale 0. 14. 1 / 0. 14. 1 libpostproc 51. 2. 0 / 51. 2. 0 [avi @ 0x19c7800] max_analyze_duration 5000000 reached at 5011200 Seems stream 0 codec frame rate differs from container frame rate: 47.95 (5994/125) -> 23.98 (24000/1001) Input #0, avi, from 'japantrip_01.avi': Metadata: encoder : MEncoder VERSION Duration: 00:23:09.63, start: 0.000000, bitrate: 856 kb/s Stream #0.0: Video: h264 (Main), yuv420p, 848x480 [PAR 427:424 DAR 427:240], PAR 61440:61003 DAR 2048:1151, 23.98 fps, 23.98 tbr, 23.98 tbn, 47.95 tbc Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 320 kb/s [buffer @ 0x19c72a0] w:848 h:480 pixfmt:yuv420p tb:1/1000000 sar:61440/61003 sws_param: [mpeg4 @ 0x19cbde0] Invalid pixel aspect ratio 61440/61003, limit is 255/255 reducing Output #0, mp4, to 'japantrip_01.mp4': Metadata: encoder : Lavf52.111.0 Stream #0.0: Video: mpeg4, yuv420p, 848x480 [PAR 141:140 DAR 2491:1400], q=2-31, 200 kb/s, PAR 61440:61003 DAR 2048:1151, 24k tbn, 23.98 tbc Stream #0.1: Audio: libfaac, 44100 Hz, stereo, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Press [q] to stop, [?] for help frame= 86 fps= 0 q=31.0 size= 260kB time=00:00:03.58 bitrate= 593.1k frame= 172 fps=171 q=31.0 size= 438kB time=00:00:07.17 bitrate= 500.4k frame= 264 fps=175 q=31.0 size= 633kB time=00:00:11.01 bitrate= 470.7k frame= 373 fps=185 q=24.8 size= 827kB time=00:00:15.55 bitrate= 435.2k .... ... .... frame=33132 fps=193 q=31.0 size= 62626kB time=00:23:01.88 bitrate= 371.3k frame=33226 fps=193 q=31.0 size= 62815kB time=00:23:05.80 bitrate= 371.3k frame=33319 fps=193 q=31.0 Lsize= 63702kB time=00:23:07.90 bitrate= 376.0 kbits/s dup=1 drop=0 video:52144kB audio:10819kB global headers:0kB muxing overhead 1.175113%
To list and verify both files, enter:
$ ls -l
$ file japantrip_01.avi
$ file japantrip_01.mp4
Sample outputs:
Fig.01: ffmpeg output
Avi To m4v format
Type the following command
$ ffmpeg -i input.avi -acodec libfaac -ab 128k -ar 44100 -vcodec mpeg4 -b 1250K output.m4v
$ file output.m4v
Sample outputs:
output.m4v: ISO Media, MPEG v4 system, version 2
Avi To MOV format
Type the following command
ffmpeg -i "input.avi" -acodec libmp3lame -ab 192 "output.mov"
Where,
- -acodec libmp3lame : Force audio codec to libmp3lame.
- -ab bitrate : Set the audio bitrate in bit/s i.e. to 192k (default = 64k).
Not a fan of command line tools?
Try handbrake application. It is an open-source, cross-platform (OS X / Linux/Unix / BSD / MS-Windows), multithreaded video transcoder software application.
How do I sync files to my iPod or iPhone?
You need to use native Apple iTunes application. See how to run iTunes under Linux operating system for more information.
🐧 8 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
ipad2:
hptouchpad:
Fullscreen:
Widescreen:
Hi Cr0t,
Any preset you have for old TV captures? 4:3 recordings from VHS?
The HP touchpad’s fullscreen encodes in 4:3 while the widescreen encodes in 16:9.
Brilliant article. Is there a way to do this on Red Hat/Fedora?
Configure RPMforge (now repoforge) and use the yum command to install the same. See RPMForge config howto and this page for more info.
Thank you :) I will try this when I’m home from work
-b bitrate parameter
fix this parameter at a very high value, for example -b 6000k
otherwise the movie will be in a low resolution and a very low quality image.
I find that the HandbrakeCLI is much easier to use and works just as well as ffmpeg for most day to day stuff. Also, you can combine it with the ‘find’ command using the -exec switch to recursively go through directories converting video. I use it on those large AVIs I get on my camera.