Created
October 22, 2015 22:36
-
-
Save kobapan/79c05a49306c20ed176a to your computer and use it in GitHub Desktop.
ffmpeg wrapper. comvert mp4 to mp3 in a current dir.
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/sh | |
| while getopts dyh OPT | |
| do | |
| case $OPT in | |
| "d" ) | |
| flag_d=1 | |
| ;; | |
| "y" ) | |
| flag_y="-y" | |
| ;; | |
| "h" ) | |
| echo "\n\n $(basename $0)" | |
| echo "\n create mp3 files from mp4 files in the current directory" | |
| echo "\n usage: $(basename $0) [options]\n" | |
| echo " -d delete sorce mp4 files." | |
| echo " -y overwrite existing mp3 files when file name is the same." | |
| echo " -h show this help." | |
| echo "\n" | |
| exit 2 | |
| ;; | |
| esac | |
| done | |
| ls | grep "\.mp4$" | |
| if [ "$?" eq 1 ]; then | |
| echo "no mp4 files" | |
| exit 2 | |
| fi | |
| for f in *.mp4; do ffmpeg `echo $flag_y` -i "$f" "`echo $f | sed -e "s/.mp4/.mp3/"`"; done | |
| if [ "$flag_d" ]; then | |
| echo "\nremoving " | |
| echo `ls | grep "\.mp4$"` | |
| rm *.mp4 | |
| fi | |
| if [ "$?" eq 1 ]; then | |
| echo "something wrong.\n" | |
| else | |
| echo "done.\n" | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment