Converting Video Formats with FFmpeg
There are a times when you will want to encode a video using a particular codec and file format. FFmpeg lets you choose the codec with which you want to encode by adding -vcodec codec to the command line, where codec is the name of the codec you want to use. So if we want to encode using the MPEG-4 codec at 1,200kbps video bitrate and 128kbps audio bitrate, the command looks like this:
ffmpeg -i InputFile.mpg -ab 128 -b 1200 -vcodec mpeg4 OutputFile.avi
Let's say you have recorded a video that has a lot of background noise and undesired commentary, so you decide to remove the audio component of the video completely. To accomplish this, all you have to do is add the -an option to the command line, and FFmpeg automatically removes all audio from the output. Keep in mind that using this option negates any other option that affects the audio stream.
So, in our example, to remove the audio component, we would run the following command:
ffmpeg -i InputFile.mpg -an -b 1200 OutputFile.avi
Let's say you downloaded a news video from the Net that you want to listen to on your iPod on the way to work, but in order to do that, you have to remove the video component from the output file. FFmpeg allows you to remove the video component of the file completely by adding the -vn option to the command line. Using this option negates any other option that affects the video stream.
So, in our example, to remove the video component and save the audio as a 256kbps MP3 file, we would run the following command:
ffmpeg -i InputFile.mpg -vn -ab 256 OutputFile.mp3
Many DVDs have multiple language tracks available, and you can choose in which language you want to watch the video. Having multiple audio tracks is cool if you speak multiple languages and want to be able to watch videos in multiple languages. However, if you don't speak multiple languages, the extra audio tracks are useless and are taking up disk space.
FFmpeg lets you choose which streams you want to keep and ignore the rest. The command-line parameter that allows you to map streams is called -map. So, if in our test file, stream 0 is the video stream, stream 1 is the Spanish audio stream and stream 2 is the English audio stream, and we want to keep the English audio in the output file, we would issue the following command:
ffmpeg -i InputFile.mpg -map 0:0 -map 2:1 -b 1200 OutputFile.avi
In my experience, stream 0 in most video files is usually the video stream, and the remaining streams are the audio streams available with the video.
FFmpeg provides a wide range of options for manipulating and converting video files between a variety of formats. For more information, or to download the latest version of FFmpeg for yourself, please refer to the project Web site.
Suramya Tomar is a Linux system administrator who also likes to program. Visit www.suramya.com for more information on his background.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Developer Poll
- What's the tweeting protocol?
- Dart: a New Web Programming Experience
- New Products
- Thanks for taking the time to
1 hour 34 min ago - Linux is good
3 hours 32 min ago - Reply to comment | Linux Journal
3 hours 49 min ago - Web Hosting IQ
4 hours 19 min ago - Web Hosting IQ
4 hours 20 min ago - Web Hosting IQ
4 hours 21 min ago - Reply to comment | Linux Journal
7 hours 21 min ago - play with linux? i think you mean work-around linux
15 hours 48 min ago - Where is Epistle?
15 hours 53 min ago - You forgot OwnCloud
16 hours 23 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
GUI
http://transcoder84.sourceforge.net/
video conversion
nice tutorial have a look for more information
http://vipinkrsahu.blogspot.com/2010/01/how-to-make-video-streaming-site...
Hi, I have a questions
Hi,
I have a questions about ffmpeg codification.
I want to encode foreman.avi with this configurations :
- I I I I I ...
-IPPPPPPIPPPPP
- I B P B P B P B I ...
- I B B B B B B B I ...
I know that I have to use the commands -bf and -g...
Can you help me?
Thanks!
H264??
This machine Convert FLV AAC H264???/ TO any other??
mp3
im tryin to convert a video to mp3 using command ffmpeg -i input filename -vn (ive tried -ab -b to 256 128 64 and also -sameq but nothing) output filename
i am using windows xp, dont
i am using windows xp, dont know anything about linux
never too late to learn somethin beter
Windows is for people who cannot think for themselves.
It is never too late to learn linux.
windows is ok for me
i'm glad someone compiled ffmpeg for windows.
convert video to mp3
i normally use like this:
ffmpeg -i dvd_file.vob -ac 2 -ar 44100 -ab 128k out_file.mp3
soz didnt finish it....:P
soz didnt finish it....:P yeah .... i gets me an error:
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 29.97 (30000/1001)
Input #0, flv, from '123.flv':
Duration: 00:02:51.30, start: 0.000000, bitrate: 175 kb/s
Stream #0.0: Video: flv, yuv420p, 320x240, 111 kb/s, 29.97 tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: mp3, 22050 Hz, mono, s16, 64 kb/s
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
Output #0, mp3, to '123.mp3':
Stream #0.0: Audio: 0x0000, 22050 Hz, mono, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Unsupported codec for output stream #0.0
:S?
full command line please
show the command line please
maybe it should be like
maybe it should be like this:
ffmpeg -i infile.flv -ac 2 -ar 44100k -ab 128k outfile.mp3
or depends on some ffmpeg version,
ffmpeg -i infile.flv -ac 2 -ar 44100 -ab 128k outfile.mp3
and/or maybe send me that
and/or maybe send me that .flv file to my email gianmhl @ yahoo . com
command for me to find
command for me to find formats is ffmpeg -formats not --formats
I do not like it
I do not like this software. it can not work for me.
I use iMedia Converter to convert DVD and Videos on Mac.
iMedia Converter for Mac can rip DVD and convert video to sorts of video formats including AVI, FLV, MKV, MP4, 3GP, MTS, M2TS, MOD, WMV, M4V etc. It can also extract audio from video to MP3, WMA, WAV, RA, M4A, AAC, AC3, OGG, MKA, etc.
ffmpeg can do the same thing.
ffmpeg can do the same thing. i used the command line to do it.
i used ffmpeg command line, i
i used ffmpeg command line, i can do the same thing.
mapping right audio languages
I don't have any unix linux knowledge, but from my point of view this shouldn't work
ffmpeg -i InputFile.mpg -map 0:0 -map 2:1 -b 1200 OutputFile.avi
the 0:0 is the leading stream, here the video stream
you want to here in future the english stream from 2
(mpeg calls them #0.1 ... where 0 means the inputfile as far as I understand)
You sync the the second stream to the videostream.
ffmpeg -i InputFile.mpg -map 0:0 -map 0:2 -b 1200 OutputFile.avi
if you want spanish a alternate language than this should work
ffmpeg -i InputFile.mpg -map 0:0 -map 0:2 -map 0:1 -b 1200 OutputFile.avi
but this won't work in mp4 (cause mp4 contains only 1 audio stream).
I hope it will work better, 'cause it took a huge amount of time to find these things out.
File Formats
Exactly which file formats is FFMPEG compatible with?
it can supports lot of
it can supports lot of formats.
ffmpeg bitrate
Hi,
In my version of ffmpeg bitrate requires a following 'k' if it is kilobytes.
ffmpeg -i InputFile.avi -ab 128 -b 1200 OutputFile.mpg
becomes
ffmpeg -i InputFile.avi -ab 128k -b 1200k OutputFile.mpg
Regards,
Chris
Syntax Error
Where you have "--formats" it should be "-formats".
FFMPEG
Thanks a lot for the post. It helped me a lot.
I had 2 scenarios in mind and am wondering if those are possible using FFMPEG:
1) How I can output only part of a video using FFMPEG, example: the output video will start form 10 minutes into the source video and end 15 minutes before the end of the source video.
2) Whether it is possible to output 1 video from 2 source videos in the following manner: output video starts 10 minutes into the first source video and end 15 minutes before the second source video.
I hope you understand what I'm looking for.
I would appreciate any help, or suggestions.
Regards,
Shup
answer to your question 2
if you are using windows, copy the 2 files the use ffmpeg to encode again.
Question about FFMPEG
Hey! Just saw your question about ffmpeg and figured I'd help with what I could. I don't know about part 2, but I know that for duration you do ffmpeg -i InputFile -ss StartTime -t Duration Outputfile. So for example, if the video was 1 hour long, you would do ffmpeg -i InputFile -ss 00:10:00 -t 00:35:00 OutputFile. Hope that was helpful!
--Rob
Cygwin installation?
Hi,
I was trying to install FFmpeg under Cygwin, but the compilation fails with many, many warnings and a fatal error - a missing header file to define the macro "llrint" as I recall. I copied over the standard.h file from somewhere on the Cygwin installation, but the next fatal error was (as I recall) a missing library routine or something - so obviously my environment or PATH variable aren't set up correctly.
Any pointers as to where I can find out what type of libraries are supposed to be found in what locations in order to get a successful compile and link of FFmpeg?
If so I would appreciate a reply to: linuxjournal@spamex.com
[Note: The email address listed above will self destruct at the first sign of Spam. ;-]
Thank you,
Ron
an easier program ?
I was wondering if there's a program with the basic transf. commands that can be used by those who haven't got experience with it.
there are
here are some of them, mencoder, winff, http://www.paehl.com/open_source/?Convert_Tools