Thursday, August 28, 2014

Convert a bunch of AAC files to MP3 using ffmpeg and bash

Here's a little one-liner to convert a bunch of aac files to mp3 using bash and the non-free version of ffmpeg:

for i in *.aac; do ffmpeg -i $i -aq 2 `basename $i aac`mp3 ; done

A couple of things to note: the filename extension for aac is case-sensitive in bash. And this only works for the non-free version of ffmpeg that has AAC and MP3 enabled.

Thursday, August 21, 2014

Programming interview questions code repo on Google Code

I've started a repo that will include coding samples of interview question answers. The first commit is a simple linked list in C. The repo is called programming-interviews-code.

Friday, April 4, 2014

How to repoen accidentally closed tabs in Google Chrome

Google Chrome is now my browser of choice. Closing tabs accidentally has happened to all of us at some point. To reopen the tabs, simply type Ctrl-Shift-T

Monday, September 16, 2013

Use mplayer to listen to audio only of a video file

Have you ever wanted to listen to the audio of a video file and not waste CPU cycles on the video? Here's how to do it with mplayer:
mplayer -vo null video.mkv
According to commandlinefu.com, this also works.
mplayer -novideo video.mkv

Tuesday, August 6, 2013

Latex spacing commands (double spacing and others)

To specify double spacing in Latex, you first include the package:
\usepackage{setspace}
then use the following
\doublespacing
For one and a half spacing
\onehalfspacing

Sunday, February 3, 2013

How to extract the audio from video files using ffmpeg

Here's how to extract the audio portion of a video using ffmpeg:
    ffmpeg -i yourvideofile.mp4 -vn -ac 2 -ar 44100 -ab 320k -f mp3 audioonly.mp3
If you didn't want to reencode it in mp3, it's even simpler:
    ffmpeg -i yourvideofile.mp4 -vn -acodec copy audioonly.origformat
I do this for a lot of the videos on online education sites like Coursera.

Monday, November 5, 2012

Format json file using Python

Json files being what they are, are usually badly formatted. Here's a neat way to pretty print (and validate) any json file using the json.tool module of Python:
    python -m json.tool example.json
Find json.tool here.