Lessons Learned from a Circus Clown

As web developers or software developers in general we sometimes take wrong or too complex approaches for solving a problem. Usually, I realize this when discussing requirements with developers or reviewing code, but last weekend I, also/again, fell into this trap when trying to extract the audio from an MP4 video file using this command:

ffmpeg -i video.mp4 -acodec libmp3lame -ab 128k audio.mp3

Although on my local machine this works fine with ffmpeg compiled with MP3 support, I wanted to do it directly on the server, because I don’t want to wait 30-45 minutes for a video download in my home office which «only» has a 16Mbit downstream. The server instead is located in a datacenter with a 200 GBit/s core backbone which is slightly more than your local coworking space, Starbucks or regular office might be able to provide. So downloading a 543M video file just took me 9.1 seconds.

$ wget videos.videopress.com/video_hd.mp4
--2015-12-15 23:25:35-- videos.videopress.com/video_hd.mp4
Resolving videos.videopress.com... 93.184.221.133
Connecting to videos.videopress.com|93.184.221.133|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 568852784 (542M)

Saving to: `video_hd.mp4'

100%[==============================================>] 568,852,784 61.6M/s in 9.1s

2015-12-15 23:25:44 (59.8 MB/s) - `video_hd.mp4' saved [568852784/568852784]
Derek Sivers
Derek Sivers – Picture courtesy of Tim Ferris

Unfortunately, all servers I tried to use for that purpose, did not have ffmpeg compiled with MP3 support, so I tried to compile it from the sources and failed miserably, probably due to lack of regular practice with Ubuntu server admin and maintenance work, which I used to do more often a couple of years ago. After spending probably 2 hours on it I stopped.

Today, after listening to the latest and probably (again) greatest episode of the Tim Ferris podcast with Derek Sivers (originally a professional musician and circus clown) , and thinking about the task again, it all of a sudden dawned on my that there’s a much simpler approach to the problem: I don’t really need MP3 support, there are lots of other audio formats, so why not just convert it to the free, open container format OGG instead, which works out of the box with ffmpeg – no compilation required. This may seem obvious if you read it, but when you’re in the middle of something you often don’t see the trees for the forest. So here’s what I did:

ffmpeg -i video.mp4 -vn -acodec libvorbis audio.ogg

This resulted in a very small 26MB audio file

$ ls -lh
-rw-rw----+ 1 ecom.openstream.ch ecom.openstream.ch 707M Dec 11 01:01 video.mp4
-rw-rw----+ 1 ecom.openstream.ch ecom.openstream.ch 26M Dec 15 22:28 audio.ogg

which I can now upload via soundcloud-cli directly to our SoundCloud in a matter of seconds.

SoundCloud

$ soundcloud-cli upload audio.ogg 
audio.ogg [==================================================] 100%

Now I only have to edit the description and add an image in the SoundCloud web interface and I’m done. Really fast and convenient for producing new audio content for our new SoundCloud podcast.

(Waldfoto: angieconscious  / pixelio.de)

 

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert