Tag Archive for 'Video'

ffmpeg

I recently discovered the wonders of ffmpeg, a command line based utility designed to convert media. Instead of messing around with online converters, or trying to use some “free” program that doesn’t quite do what you want — you just plug in your input and output and ffmpeg does all the work. As I’ve used Ubuntu more and more I have discovered that though people have come up with a number of good interfaces and programs, there is real power in the peculiar, off-putting syntax of the command line. Once an adjustment to accept the command line is made, things can progress smoothly. If you have any problems let me know in the comments and I will answer you and amend this guide. It should be noted that this guide is designed with Ubuntu in mind. Now, on with the brief ffmpeg guide.

Installing

    1. Open a terminal window (when you don’t know where to find a program, hit the Windows button (known as the super button by Ubuntu) and type the name into the box that appears).
    2. Type sudo apt-get install ffmpeg. sudo means do this as root a.k.a. administrator. apt-get is a program, install is a function of the program, and ffmpeg is the parameter to the install function telling it what program we want installed. Terminal will print some text, it might say that you already have it, excellent continue onwards. Else, if it gives you the option to install it, type Y and let it continue on its merry way.
    3. Type sudo apt-get install libavcodec-extra-53. This is an library that has additional codecs that you’ll probably want.
    4. Now you should be all set up to start converting

ffmpeg Commands and Structure

ffmpeg has a lot of commands for manipulating media. The program is controlled through the command line. A basic command that you might enter into terminal looks like this:

ffmpeg -ss 00:00:10 -i gold.mp4 -t 00:03:33 -acodec copy -vcodec copy gold.mp4

Notice that you always start the line with the program you want to use (except when you are treating the running of the program in a certain way, such as with sudo. Next comes a series of option-argument pairs, options for the program followed by the value of that option: -option arguement. One example is the input option followed by the name of the input file -i gold.mp4. At the very end of the command is the output file name. Notice that there is no -option preceding it, it is simply the parameter entered into ffmpeg (like ffmpeg was the parameter for apt-get install). It’s not necessary to specify every option as most have default settings if nothing is specified. In ffmpeg Here’s a list of some of the options for ffmpeg:

  • -ss hh:mm:ss Specify the start location. Note that this should come before -i
  • -i xxxxx.yyy The input file ffmpeg will base this operation on.
  • -t hh:mm:ss Specify the duration of the output file (relative to the start location). Note that this should come after -i.
  • -acodec codec
  • The output audio codec. Most of the time ffmpeg will guess this parameter automatically based on you output file. For example if the output file is gold.mp3, then ffmpeg will automatically use libmp3lame as audio codec, no input required. The only time I've needed this option is to specify something other than what ffmpeg was automatically guessing, or to specify -acodec copy, which makes ffmpeg use the exact same audio codec as the source.

  • -vcodec codec
  • Used for specifying the video codec to use. All the usage rules of the -acodc apply to this one. Don't forget -vcodec copy if you want the output video to be the same as the input.

  • -ar xxx Specifies the audio sample rate. If unspecified it will use the default of the codec or the same as the input file (I'm not quite sure which). You do no good specifying a sample rate higher than that of the input, because it will yield no better quality. On the other hand, a lower sample rate will make for a smaller file (at the cost of quality).
  • -vn Disable video recording.
  • Converting

    ffmpeg -i -ss 00:00:10 gold.mp4 -vn -t 00:03:33 gold.mp3

    The above line takes the input file gold.mp4, starts ten seconds in and records for a total of three minutes and thirty-three seconds, before outputting the file as an mp3.

    I am still pretty new to this. One thing I can't understand is if you enter something such as ffmpeg -i gold.mp4 gold.avi you get a resultant video that is of really low quality. Perhaps this is just due to codec limitations and/or ffmpeg's automatic guessing, I'm really not sure.

    Trimming

    ffmpeg can be really useful if you have a video and just want a section of that video. In that case, type:

    ffmpeg -ss 00:00:10 -i gold.mp4 -t 00:03:33 -acodec copy -vcodec copy gold_trimmed.mp4

    This line will take the input file gold.mp4, start ten secods in and capture a total of three minutes and thirty-three seconds, then output to gold_trimmed.mp4 using the exact same audio and video codec settings as the source. Note that the input file extension is the same as the output, and the -ss parameter comes before the -i and the -t come after the -i (I'm not sure why that order must be obeyed, but if you mix things up the results are off). Make sure that -acodec copy and -vcodec copy are specified, else you get a lower quality result (maybe just because of encoder defaults).

Language, by Stephen Fry

The second in my language related series of found videos. This one is purely about making a point, but I also really like how Matthew Rogers arranged it. Good words and excellence of design.

Stephen Fry Kinetic Typography – Language from Matthew Rogers on Vimeo.

Ninja Say What?!

Today I am in a language related mood. Here’s the first of two videos I find entertaining and, if you’re in the mood, it may produce some discussion.

Domestic Transformer

Maestro Hughes

The History of Hip-Hop

I was shown this by one of my friends.

Breakaway, FRC 2010

Here is the video for this year’s game. FRC is a competition where teams across the nation make a robot and compete against other teams in the “game” for that year (the game changes every year). The beginning half is a teaser, then comes the game animation, and then an FAQ. This is what I get to mentor.

[flowplayer src=http://www.worldwidewilly.immortalkeep.com/video/frckickoff.flv]
Download

Comedian Trailer

Until I get time to edit down the video on the FIRST Robotics Game, here is something to pass the time. This is a trailer for Jerry Seinfeld’s film Comedian.

To set the tone…

I would like this blog to be a breeding ground for good ideas and conversation. Towards that end this video seems like a fitting start, here’s to creatives:


CreaticeJuices.org.uk