Command line media editing

Command line media editing


This last week I've been trying my hand at a bit of DVD authoring and I thought I'd pass on everything that I've found out! A couple of the most useful tools are command line based, hence the title, but I'm also going to talk about a fantastic GUI that brings these bits and pieces together. To my horror, just as I sat down to write this I discovered Mitch Meyran had just posted a very similar blog entry! This post, however, is a bit more command line based and HOWTO-like in structure.

I think the tool I've found to be most useful so far is ffmpeg. If you install this package through your package manager and then run it with no options in a terminal, you'll see just how flexible it is as your screen fills up with line after line of options! Don't let this overwhelm you though, I've been using it to convert one file format to another and stream recording and have found I needed to know very few options. Imagine you have an MPG file you want converted to an OGG:

ffmpeg -i /path/to/yourinputfile.mpg -sameq /path/to/youroutputfile.ogg

The -i option always has to come before your input file; the output file, however, does not require any options. In this example, I used the -sameq output option, which forces the output to be of the same quality of the input.

Another input option I've found to be very useful is -ss which takes a time argument in the form of hh:mm:ss. It forces the encoding to start from a specific point in the video (or audio) file (it's useful for clipping of the beginning of some files). The other output option I've found very useful is -r which lets you change the frames per second of the encoding – for PAL televisions use 25 and for NTSC use 29 (I believe these numbers are correct).

Sox and soxmix are very similar to ffmpeg: the difference is that they deal specifically with audio files. Sox can be used for converting one audio type to another, or it can also be used for concatenating two audio files together; soxmix can be used for mixing two audio files together to form one. I didn't actually use soxmix in this current project, but I have used it in my podcast for mixing the two sides of the conversations into one file. To achieve this you simply use the following command:

soxmix /path/to/input1 /path/to/input2 /path/to/output

There are a lot of options that can be applied here; for example reduce the volume of one of the files as it is mixed in with the other, but that is the subject of another post... Sox has very similar syntax to Soxmix. However, when you give sox two input files they will not be mixed, but concatenated. To convert one audio type to another with sox you can use a command similar to this:

sox /path/to/input.mp3 /path/to/output.ogg

Next up on the command line is DVD-Slideshow. Used in conjunction with dir2slideshow you can create photo slideshows that will play back on any DVD player. Start of by using dir2slideshow to produce an input file for DVD-Slideshow:

dir2slideshow -n 'name goes here' -t 5 /path/to/photo/folder

The -n option gives the slideshow a name and the -t option sets how many seconds each picture should be displayed for. This produces an output file name.txt; we then use the following command to have DVD-Sideshow format our pictures for a DVD player:

dvd-slideshow -n 'name goes here' -f name.txt -a 'any background music file here'

The -f option lets us specify the file we created with dir2slideshow and the -a option lets you specify some kind of background music to have playing while you watch your photos. If you'd like more information on DVD-slideshow their website is a great wiki and has brilliant documentation. I think that's everything I want to talk about from the command line! My apologies for the simplistic examples, I can only hope they'll prove useful to some people...

Earlier, I mentioned GUI programs. If you're wanting to produce a DVD I haven't managed to find anything better, or more straight-forward, than ManDVD. It doesn't accept all file formats as input and its own editing abilities are limited – which is why all the command line tools are useful – but it is a great program for producing menus, has a good graphical front end for DVD-Slideshow. It will create all the VOB files for you and also an ISO which you can burn to as many discs as you like. It's a KDE app but it's running brilliantly on my Fedora Core 6 Gnome desktop so I don't think that is an issue for anyone. The only problem I can think is that I haven't seen it in any repository, but the dependencies are clearly presented on the site and easy to find. To run it, you simply extract the tarball and either double click the executable or run ./mandvd from the command line. Saying all that, I will soon have to take a look at Mitch's post about video editing that I mentioned, maybe some of those applications will prove useful to me as well.

Category: 

Comments

Anonymous visitor's picture
Submitted by Anonymous visitor (not verified) on

Yes, ffmpeg is a pretty useful tool. Just a note, the -r value for NTSC is 29.97, not 29.

Anonymous visitor's picture
Submitted by Anonymous visitor (not verified) on

I downloaded Sox from sourceforge, configured and made it, but it doesn't seem to include soxmix.
Is there a special configuration flag that needs to be set in order to enable soxmix?
I'm trying to find a command-line tool that can mix two MP3s, and soxmix seems to be a perfect fit.

Author information

Jonathan Roberts's picture

Biography

Currently a gap year student! I have a huge interest in Free Software which seems to keep growing. I run the Questions Please... podcast which can be found at questionsplease.org. On an unrelated note I'm reading theology at Exeter next year.

Most forwarded

Interview with Dave Mohyla, of DTIDATA

Dave Mohyla is the president and founder of dtidata.com, a hard drive recovery facility based in Tampa, Florida.

TM: Where are you based? What does your company do?
DTI Data recovery is based in South Pasadena, Florida which is a suburb of Tampa. We have been here for over 10 years. We operate a bio-metrically secured class 100 clean room where we perform hard drive recovery on all types of hard disks, from laptop hard drives to multi drive RAID systems.

Anybody up to writing good directory software?

Since the very beginning, directories (of any kind) have had a very central role in the internet. (I have recently grown fond of Free Web Directory. Even Slashdot can be considered a directory: a collection of great news and invaluable user-generated comments. As far as software is concerned, doing a quick search on Google about software directories will return the free (as in freedom) software directories like Savannah, SourceForge, Freshmeat and so on, followed by shareware and freeware sites such as FileBuzz, PCWin Download Center and All Freeware (great if you're looking for shareware and freeware, but definitely less comprehensive than their free-as-in-freedom counterparts).

Interview with Mark Shuttleworth

Mark Shuttleworth is the founder of Thawte, the first Certification Authority to sell public SSL certificates. After selling Thawte to Verisign, Mark moved on to training as an astronaut in Russia and visiting space. Once he got back he founded Ubuntu, the leading GNU/Linux distribution. He agreed on releasing a quick interview to Free Software Magazine.

Is better education the key to finding better software?

I read David Jonathon's article Anybody Up To Writing Good Directory Software? the other day, which got me thinking about software directories in general. As David mentioned, many of the software directories one finds when doing a quick google search are free as in beer, not as in freedom. But what interests me is the software directories that already exist, providing a combination of both free as in beer software, and open source software. Sites such as Freeware Downloads and Shareware Download don't advertise themselves as providing free as in liberty software, but each of them have a good selection of open source software available... if you know where to look.

Most emailed

Free Open Document label templates

If you’ve ever spent hours at work doing mailings, cursed your printer for printing outside the lines on your labels, or moaned “There has got to be a better way to do this,” here’s the solution you’ve been looking for. Working smarter, not harder! Worldlabel.com, a manufacture of labels offers Open Office / Libre Office labels templates for downloading in ODF format which will save you time, effort, and (if you want) make really cool-looking labels

Creating a user-centric site in Drupal

A little while ago, while talking in the #drupal mailing list, I showed my latest creation to one of the core developers there. His reaction was "Wow, I am always surprised what people use Drupal for". His surprise is somehow justified: I did create a site for a bunch of entertainers in Perth, a company set to use Drupal to take over the world with Entertainers.Biz.

Update: since writing this article, I have updated the system so that the whole booking process happens online. I will update the article accordingly!

So, why, why do people and companies develop free software?

More and more people are discovering free software. Many people only do so after weeks, or even months, of using it. I wonder, for example, how many Firefox users actually know how free Firefox really is—many of them realise that you can get it for free, but find it hard to believe that anybody can modify it and even redistribute it legally.

When the discovery is made, the first instinct is to ask: why do they do it? Programming is hard work. Even though most (if not all) programmers are driven by their higher-than-normal IQs and their amazing passion for solving problems, it’s still hard to understand why so many of them would donate so much of their time to creating something that they can’t really show off to anybody but their colleagues or geek friends.

Sure, anybody can buy laptops, and just program. No need to get a full-on lab or spend thousands of dollars in equipment. But... is that the full story?

Fun articles

Santa Claus - the most successful open source project

It dawned on me the other day, as I was shopping for the dozens of gifts it seems I have to buy every December, that Santa Claus is the most successful open source project in history. (Bridget @ Illiterarty would agree with that). Santa Claus is essentially a marketing development that is embodied by everyone who stuffs a sock, gives a gift, hosts a dinner or wishes Merry Christmas over the holiday season.

Most emailed

Editorial

When I first started thinking about Free Software Magazine, I was feeling enthusiastic about the dream. I had Dave, Gianluca, and Alan willing to help me, I had established members of the free software community willing to help me out, I had writers volunteering their time and energy for free, and I had a generous offer from OpenHosting for servers, all before I'd proved myself. There was a sense of excitement in the air, and I thought maybe, just maybe, I could make this work.

Free Software Magazine uses Apollo project management software and CRM for its everyday activities!