Small Python script for converting mp4 video to mp3 audio. Requires mplayer and lame to actually do the hard work.

andyp123 andyp123 Last update: Apr 18, 2024

mp4tomp3.py

A small Python script to convert mp4 video files to mp3 audio. Useful for turning video from sites such as www.ted.com into audio files useable on any old mp3 player.
It uses mplayer and lame to do the actual conversion.

Usage: python mp4tomp3.py [input directory [output directory]]
  input directory (optional) - set directory containing mp4 files to convert (defaults to current folder)
  output directory (optional) - set directory to export mp3 files to (defaults to input)
example: python mp4tomp3.py ./video ./audio

Note: you will need python (2 or 3), mplayer and lame for this script to work

sudo apt-get install python2.7   -- for python 2
sudo apt-get install python3.6   -- for python 3
sudo apt-get install mplayer
sudo apt-get install lame

Mac Support: Thanks to jdingus for this tip.
First install Homebrew (https://brew.sh/). Once installed you will be able to install dependencies with the following commands.

brew install mplayer
brew install lame
Tags:

Subscribe to our newsletter