Video tool Usage Notes
for the 'ffmpeg' command

augmented by usage of the
'mencoder' command

on Linux

Home > RefInfo menu >

Computer topics menu (Linux section) >

Linux Guides/Notes by Blaze menu >

This *ffmpeg* Usage Notes page

! Note !
More notes may be added and updated/corrected
--- if/when I re-visit this page.

< Go to the Table of Contents, below. >

INTRODUCTION :

Initially, this page is meant as a collection place for notes on using ffmpeg --- and for 'mencoder' when 'mencoder' (Mplayer encoder) seems to do a job better than 'ffmpeg'. So initially, this page is 'Notes', NOT a 'Guide'.

It could turn into a 'Guide' IF I ever collect enough notes that they can be organized into a fairly complete reference work for ffmpeg (and mencoder). But ...

Since I will never be a 'master' of 'ffmpeg' usage, I will never call this a Guide. But there are links at the bottom of this page that provide much more information on the usage of 'ffmpeg' --- and 'mencoder'.


Stumbling blocks to wide-spread 'acceptance'
of Linux video editors and 'ffmpeg' :

In the 2001 to 2011 timeframe, there have been many articles and blog postings and forum comments, on the internet, on the sorry state of video editing on Linux --- even 'simple' video editing (cropping, deleting time-sections, adjusting audio volume, converting to a different file format, resizing the image, resizing the file).

The Linux video editors that are usually mentioned or reviewed are (in alphabetical order)

They all have their problems, including frequent crashes for most of them (around 2011).

You can try a WEB SEARCH on keywords such as 'linux video editor crash' (about 468,000 hits, 2011 Jan, using Google) to get an idea of the extent and nature of the problems.

You may find that the video editing situation on Linux has forced (around 2011 and before) many people back to Microsoft windows --- although they usually have to pay at least several hundred dollars per year in software and OS upgrades to keep their video editing systems running on a Microsoft OS.

To name some other issues for each of the interactive Linux video editor candidates (circa 2011) :

  • Avidemux - a confusing interface and no built-in help. There is no hint of how to start on the simple tasks like cropping [bottom, top, or sides], selecting and deleting time-sections, or adjusting audio volume. Avidemux, and most of the other editors, could benefit from a 'Tasks' pop-down menu, to lead the way.

      (The commercial Magix video editor --- available for Microsoft OSes, not Linux --- has a task-oriented interface somewhat like this suggestion.)

  • KDEnlive - really crashy. If you try to learn without reading a guide (this is assuming a good one exists), as you click your way through KDEnlive interface options, you are almost sure to experience a crash within 5 to 10 clicks.

    One has to wonder if they ever turn software 'release candidates' over to a group of volunteer Kdenlive user-testers. It sure does not seem to be the case that they use a good automated 'use-cases' test procedure, nor do they use even a modestly sized user/tester group of people.

  • Kino - creates a huge DV video file as an intermediate work file. You will have to be careful not to consume a lot of disk space with Kino work files left lying around. A positive note: it was fairly simple to figure out how to select and delete a section of video. (Kino became a dead project sometime around 2009.)

  • Pitivi - I have not tried this editor to any notable extent, but it is reported to be crash prone.

  • OpenShot - especially prone to crash during the 'Export Video' phase --- or leave you with an empty output file. And OpenShot often crashes at the end of the export, instead of staying open for possible other editing and/or exporting.

    Postings at OpenShot bug reporting forums indicate that OpenShot export problems are typically a problem in the use of 'ffmpeg' underneath it all. It is often suggested to run 'openshot' in a terminal window so that one can see error messages coming from ffmpeg.

It turns out most of these editors use 'ffmpeg' (or some other command-line oriented utility --- or ffmpeg library routines) underneath it all to perform various operations.

Even if you could see from 'ffmpeg' error messages why an 'Export Video' operation is failing, you would have to wait for the programmers to address the issue and wait for a program release with the fix.


As far as 'stumbling blocks' in the use of 'ffmpeg', the main one cited --- over and over --- is that it is a command line utility, and people are just not going to want to key in about 100 characters of text every time they want to use 'ffmpeg' for a task.

Of course, the experienced Linux/Unix user knows that the best solution to that is to put the command in a script at the earliest possible moment. Then simply edit, run the script ... edit, run the script ... iteratively improving the command a few parameters at a time.


Use of 'ffmpeg' in scripts:
(instead of using 'monolithic' compiled programs)

It became clear to me that I would be better off devising a set of 'ffmpeg' (or 'mencoder') scripts --- in particular, 'Nautilus scripts' --- to do the cropping, audio adjustment, and file conversions that I would typically do --- rather than wait for the developers/maintainers of OpenShot, KDEnlive, Pitivi, etc. to 'get it right' for so many different tasks and so many potential combinations of parameters.

The only task (in my list of common video editing tasks) that I *MAY* find it hard to do via scripts using 'ffmpeg' (or 'mencoder') is selecting and deleting time-sections ('clipping') of a movie file.

Although time-clipping can be done with a script, I will have to use a video player to play the video file and determine the start and end times of the clip.

    (Cropping is also a little clumsy to do via scripts, but if you do the same crop across the entire movie or clip, that is not too hard to handle with a script --- say with 'zenity' GUI prompts for the number of pixels to crop, and a handy image file like this to help determine the number of pixels to crop.)

    ('Clipping' could also be done fairly nicely with a Nautilus script. First, you could play the video to be edited in a player like Mplayer, noting the start-times and durations of the time-sections to be clipped out. Those pairs of values, say in seconds, could be entered at a zenity prompt for start and duration times. The script would use 'ffmpeg' with the '-ss' and '-t' options to do the clips.)


Organization of these notes :

I think you can see that I am motivated to organize these notes according to the tasks I commonly would like to perform on video files.

So there is a Table of Contents, below, that lists those tasks. They are links to sections further down this web page.

If you don't want to use the Table of Contents, you can simply scroll down this page to look for items of interest.

Also, you can use an option of your web browser --- such as 'Find in This Page ...' --- to look for keywords on this page --- such as 'crop', 'select', 'delete', 'audio', 'volume', 'convert', 'codec', 'mpeg', 'mpg', 'flv', 'wmv', 'mov', etc.

The task-sections below currently are brief. They have a sample 'ffmpeg' (or 'mencoder') command to indicate how the task could be done.

Below the 'task-sections', there is an 'external web links' section --- with links to info on 'ffmpeg', 'mencoder', and video formats.

And below that external-links section are links to a couple of 'locally stored' (preserved on this web site) documentation files on 'ffmpeg', near the bottom of this page --- 'man' (manual) help and a list of supported 'codecs' (coders and decoders).


Sample 'VIDEOtools' scripts:

In a RefInfo-Computer-Linux part of this site, I have a 'Handy Scripts' page that provides access to handy Nautilus scripts --- including a set of VIDEO Nautilus scripts. Those scripts were under heavy development in late 2010 and early 2011. Those scripts include 'zenity' GUI prompts for parameter values and Cancel-or-Go options.

    Those 'VIDEOtools' Nautilus scripts have been released at www.freedomenv.com, and the VIDEOtools scripts are described on a VIDEOtools menu page. Code used to develop those scripts is available via that menu page.

As those Nautilus scripts are tested on various video files, the parameters of the 'ffmpeg' (and 'mencoder') commands will hopefully reach a more 'mature' --- and highly useful --- state.

I may update this page occasionally based on experiences in developing those scripts.


'ffmpeg' help on the web:
(often out-of-date --- or sample commands may
lack parameters needed to handle your input file)

There are many web pages, scattered all over the internet, on using 'ffmpeg' parameters to achieve one task or another --- seldom more than a few tasks per web page.

You have to be aware that many of those code examples are out of date, as ffmpeg seems to change fairly rapidly. For example, there are many examples of using '-acodec mp3' to put audio in mp3 format in the video output file. But there was a change in ffmpeg circa 2009 (or before) such that the proper parameter became '-acodec libmp3lame'.

Be aware that there are a lot of out-of-date coding examples of 'ffmpeg' out there --- and many of them exist because people say 'try this', off the top of their heads, without testing the code that they are proposing.

Or, a command works for them on their particular video file --- but that same command needs some other parameters to handle your video file (because the defaults being chosen by ffmpeg do not handle your particular video file).


Enough of this introduction. Here is a table-of-links to sections below on this page.

TABLE OF CONTENTS :

(links to sections of this page, below)

'Passive' operations with 'ffmpeg' :
(no changes to files)

  • Checking Properties of movie files with 'ffmpeg'

  • Seeing Codecs (coders and decoders) that 'ffmpeg' uses

  • Playing of movie files with 'ffmpeg'


'Active' video operations with 'ffmpeg' :
(resulting in a new output video file)
(see separate audio section below)

Audio operations :


Other :

  • some external links to web info on
    'ffmpeg', 'mencoder', and video formats


END OF TABLE OF CONTENTS.   The 'ffmpeg' notes start below.

< Go to TOP of this page, above. >

To Check PROPERTIES of movie files, with 'ffmpeg' :

A sample 'ffmpeg -i' command to do this:

ffmpeg -i "$FILENAME" 2> "$FILEOUT" > "$FILEOUT2"

A link to the code of an FE (Freedom Environment) Nautilus script may be placed here.

< Go to Table of Contents, above. >


To Show CODECS (coders and decoders) that 'ffmpeg' uses :

A sample 'ffmpeg -formats' command to do this:

ffmpeg -formats > "$FILEOUT"

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To PLAY movie files, with 'ffmpeg' :

An 'ffplay' command comes with the 'ffmpeg' package'. A sample 'ffplay' command to do this:

xterm -fg white -bg black -hold -e /usr/bin/ffplay -stats "$FILENAME"

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To CROP tops/bottoms/sides of movie files, with 'ffmpeg' :

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

xterm -hold -fg white -bg black -e \
ffmpeg -i "$FILENAME" -qscale 3 \
-croptop $YPIXELS -padtop $YPIXELS "$FILEOUT"

Similarly for bottom, left, and right cropping.

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To CLIP movie files (using start-times and durations), with 'ffmpeg':

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

xterm -hold -fg white -bg black -e \
ffmpeg -i "$FILENAME" -ss $STARTTIME -t $DURATION \
-vcodec copy -acodec copy "$FILEOUT"

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To CONVERT movie files to other formats, with 'ffmpeg' :

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

xterm -hold -fg white -bg black -e \
ffmpeg -i "$FILENAME" -vcodec mpeg1video "$FILEOUT"

This is a preliminary example for coversion to an mpeg-1 video file. Similar commands can be used for other output formats.

Actually, an h264-aac-mp4 video-audio-container format is more commonly used in the 2010-2018 timeframe. I may replace this example with an example for this type of output.

After some experience in developing the 'VIDEOtools' scripts of the 'feNautilusScripts' system, I found that it was best to have a script for each type of output format (video-audio-container format combination) --- because the 'ffmpeg' command will fail for many input file types if you are not thorough in specifying almost all the major parameters for the output file.

Links to several sample 'convert' FE Nautilus scripts may be placed here --- scripts for several popular types of video file output (formats that have been used on YouTube, for example, in the 2009-2018 decade) --- scripts that have been tested at least once each.

< Go to Table of Contents, above. >


To MERGE movie files, with 'mencoder' :

I had some problems in merging movie files using 'ffmpeg'. I found more success in using 'mencoder'. A sample 'mencoder' command to do this:

mencoder -forceidx -oac copy -ovc copy -o "$FILEOUT" $FILENAMES

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To Put JPEG files into movie files, with 'ffmpeg' :

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

xterm -hold -fg white -bg black -e \
ffmpeg -f image2 $INPUTS "$FILEOUT"

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To Extract JPEG files from movie files, with 'ffmpeg' :

A sample 'ffmpeg' command to do this:

ffmpeg -i "$FILENAME" -f image2 -r $SAMPLETIMING "${FILENAMECROP}_%03d.jpg"

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


Capturing desktop actions into movie files with 'ffmpeg' :

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

    MOVIESIZE="1024x768"
    ...
    xterm -bg black -fg white -hold -geometry 24x18+1000+750 -e \
    ffmpeg -f x11grab -r 25 -s $MOVIESIZE -i ":0.0" \
    -an -vcodec mpeg1video \
    -sameq "$FILEOUT"

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To Adjust Audio Volume of movie files, with 'ffmpeg' :

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

xterm -hold -fg white -bg black -e \
ffmpeg -i "$FILENAME" -vcodec copy -f flv \
-acodec libmp3lame -ar 22050 -ab 56k -ac 1 \
-qscale 6 \
-vol $AUDIOFACTOR "$FILEOUT"

This was used to create a '.flv' (container) output file.

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To Extract Audio from movie files, with 'ffmpeg' :

A sample 'ffmpeg' command to do this (with messages shown in an 'xterm' window):

xterm -hold -fg white -bg black -e \
ffmpeg -i "$FILENAME" -vn \
-f mp3 -acodec copy "$FILEOUT"

This was used to make a '.mp3' audio file. The '-vn' parameter suppresses video output. The '-f mp3' command specifies that an 'mp3' output file is desired.

A link to the code of an FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


To Add Audio to movie files with 'ffmpeg' :

A sample 'ffmpeg' command to do this:

ffmpeg -i "$AUDIOFILE" -i "$VIDEOFILE" "$FILEOUT"

This needs to be tested. Some other parameters might need to be added.

A link to the code of a tested FE Nautilus script may be placed here.

< Go to Table of Contents, above. >


Bottom Line:

In essentially all of the 'tasks' above, it would be nice if 'ffmpeg' would work like the ImageMagick 'convert' command --- that is, choose suitable default parameters to use just by checking on the suffixes on the input and output files.

Unfortunately, many video forums on the internet are full of questions from people who try to use 'ffmpeg' with that simple formulation, only to be advised by those with more experience with 'ffmpeg' that they are going to have to add some parameters to help 'ffmpeg' along.

Some EXTERNAL LINKS on 'ffmpeg' :

Some links on 'mencoder' :

Some links on video (and audio) formats :

A 'local copy' of the 'ffmpeg' 'man' help
(circa 2009-2010, for an Ubuntu 9.10 build)

A 'local copy' of the list of 'ffmpeg' and 'mencoder' codecs
(circa 2009-2010, for an Ubuntu 9.10 build)

Bottom of this
'ffmpeg' video tool Notes - by Blaze page.

To return to a previously visited web page location, click on the Back button of your web browser, a sufficient number of times. OR, use the History-list option of your web browser.
OR ...

< Go to TOP of this page, above. >

< Go to Table of Contents, above. >

Page was created 2011 Jan 06.

Page was changed 2019 Jan 05.
(Added css and javascript to try to handle text-size for smartphones, esp. in portrait orientation. Added some links.)