Linux Stall
  • Home
  • Android
  • How to
  • Perl
  • Tips
  • Tutorials
No Result
View All Result
Linux Stall
No Result
View All Result
Home Tutorials

A complete ffmpeg tutorial

Chankey Pathak by Chankey Pathak
February 24, 2012
in Tutorials
44 2
0
A complete ffmpeg tutorial
15
SHARES
761
VIEWS
Share on FacebookShare on Twitter

Introduction

ffmpeg is a very fast video and audio converter that can also grab from a live audio/video source. It can also convert between arbitrary sample rates and resize video on the fly with a high quality polyphase filter.

Installing ffmpeg

sudo apt-get install ffmpeg

Uses

Below are some tasks which you can perform using ffmpeg.

Getting information of a video

To get information of a video file use -i option as:

ffmpeg -i /path/videofile.avi

Making video from images

You can combine the images to make a video (like movie maker in windows) using ffmpeg as:

ffmpeg -f image2 -i image%d.jpg videofile.mpg

The above command will take all the images from the current directory (image1.jpg, image2.jpg, etc) and will join them to make a video file videofile.mpg.

Making images from video file

This is just opposite of the last step. This will take a video and will generate images from it.

ffmpeg -i videofile.mpg image%d.jpg




Encoding video for iPod/iPhone

  • Source file: s_videofile.avi
  • Audio codec: aac
  • Audio bitrate: 128 kb/s
  • Video codec: mpeg4
  • Video bitrate: 1200 kb/s
  • Video size: 320×180
  • Generated video: f_videofile.mp4
ffpmeg -i s_videofile.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200 kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320*180 -title X f_videofile.mp4

Encoding video for PSP

  • Source : s_videofile.avi
  • Audio codec : aac
  • Audio bitrate : 32 kb/s
  • Video codec : xvid
  • Video bitrate : 1200 kb/s
  • Video size : 320×180
  • Generated video : f_videofile.mp4
ffmpeg -i s_videofile.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac f_videofile.mp4

Video to Audio

You can extract the audio from a video file and save it as mp3 format.

ffmpeg -i s_videofile.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 soundfile.mp3
  • Source video : s_video.avi
  • Audio bitrate : 192kb/s
  • output format : mp3
  • Generated sound : soundfile.mp3

wav to mp3

ffmpeg -i s_audiofile.wav -acodec mp3 -ab 192k f_audiofile.mp3

avi to mpg

ffmpeg -i s_videofile.avi f_videofile.mpg

mpg to avi

ffmpeg -i s_videofile.mpg f_videofile.avi

avi to flv

ffmpeg -i s_videofile.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv f_videofile.flv

avi to dv

ffmpeg -i s_videofile.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 f_videofile.dv

avi to gif

ffmpeg -i s_videofile.avi f_giffile.gif

Mixing video with a sound file

ffmpeg -i s_audiofile.wav -i s_videofile.avi f_videofile.mpg

avi to mpeg (for dvd players)

ffmpeg -i s_videofile.avi -target pal-dvd -ps 2000000000 -aspect 16:9 f_videofile.mpeg

ps 2000000000 is the maximum size for the output file in bits hence it is 2 GB here.

Compress avi to divx

ffmpeg -i s_videofile.avi -s 320x240 -vcodec msmpeg4v2 f_videofile.avi

Compress Ogg Theora to mpeg dvd

ffmpeg -i s_videofile.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 f_videofile.mpg

Compress avi to SVCD mpeg2

NTSC format:

ffmpeg -i s_videofile.avi -target ntsc-svcd f_videofile.mpg

PAL format:

ffmpeg -i s_videofile.avi -target pal-svcd f_videofile.mpg

Compress avi to VCD mpeg2

NTSC format:

ffmpeg -i s_videofile.avi -target ntsc-vcd f_videofile.mpg

PAL format:

ffmpeg -i s_videofile.avi -target pal-vcd f_videofile.mpg

Multipass encoding

ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2
Tags: commandsffmpegTutorials
Previous Post

Ubuntu for Android

Next Post

First beta of gnome 3.4 released

Chankey Pathak

Chankey Pathak

Data Scientist at Morgan Stanley. I've been using Linux since past 12 years. I plan to share what I know about Linux in this blog.

Related Posts

case of computer server workstation technology wireless vector illustration
Tutorials

Port Forwarding in OpenSSH

July 25, 2020
softlinking linux
Tutorials

Softlinks vs. Hardlinks: A Quick Explanation

July 23, 2020
write chroot read stat
Tutorials

Strace in Linux: History, Structure and Usage

July 21, 2020
case of computer server workstation technology wireless vector illustration
Tutorials

Brocade: Health Check Commands

July 12, 2020
A programmer coding
Tutorials

Using Basic Loops In Bash Scripts

July 12, 2020
uname
How to

How to find Linux distribution name and version?

June 22, 2014
Next Post
gnome 3.4

First beta of gnome 3.4 released

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Terms and Conditions
  • Contact Us
  • About Us

© 2012 - 2020 Linux Stall - A place for all your Linux needs.

No Result
View All Result
  • Home
  • Android
  • How to
  • Perl
  • Tips
  • Tutorials

© 2012 - 2020 Linux Stall - A place for all your Linux needs.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In