Last active
August 29, 2015 14:02
-
-
Save grzegorzblaszczyk/de59f596d34dfe26d136 to your computer and use it in GitHub Desktop.
MP4 to MP3 converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Quick and dirty MP4 to MP3 converter | |
| # by Grzegorz Błaszczyk <[email protected]> 2014-2015 | |
| # License: MIT http://rem.mit-license.org/ | |
| MPLAYER=`which mplayer` | |
| LAME=`which lame` | |
| RM=`which rm` | |
| EXECS=( "MPLAYER" "LAME" "RM" ); | |
| for exec in "${EXECS[@]}"; do | |
| if [ "x${!exec}" == "x" ]; then | |
| echo "Error: Executable $exec is not installed!" | |
| exit 1; | |
| fi | |
| done | |
| if [ "x$1" == "x" ]; then | |
| echo "Syntax $0 [some MP4 file]" | |
| exit 1 | |
| fi | |
| MP4_FILE=$1 | |
| if [ -e "${MP4_FILE}" ]; then | |
| FILENAME="${MP4_FILE%.*}" | |
| MP3_FILE="${FILENAME}.mp3" | |
| echo "Output file will be: ${MP3_FILE}" | |
| $MPLAYER -vc dummy -vo null -ao pcm:file=${MP4_FILE}.wav ${MP4_FILE} | |
| $LAME -h -b128 ${MP4_FILE}.wav ${MP3_FILE} | |
| $RM -v "${MP4_FILE}.wav" | |
| else | |
| echo "Input file ${MP4_FILE} does not exist :(" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment