Created
August 6, 2016 17:00
-
-
Save ilovejs/b8b811021005f50833556e1621612b3f to your computer and use it in GitHub Desktop.
strip audio from video using ffmpeg
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 | |
# usage: | |
# ls *.avi | ./video_to_audio.sh | |
# for f in `ls *.avi`; | |
# do | |
# echo item: $f | |
# done | |
#for src in "$@"; #*.avi; | |
# IFS= read var << EOF | |
# $(foo) | |
# EOF | |
if [ ! -d "job_done" ] | |
then | |
mkdir 'job_done' | |
else | |
echo 'job_done dir exists...' | |
echo | |
fi | |
# It's to hard to quit the loop.... | |
# while read LINE; do | |
# INFILE="$LINE" | |
# STRIP_EXT="${INFILE%.*}" | |
# OUT_NAME="${STRIP_EXT}.mp3" | |
# echo "processing" $OUT_NAME | |
# echo "-----------------------------------" | |
# echo | |
# # ffmpeg -i 02\ -\ Art\ Of\ Prospecting,\ 5\ Keys\ To\ Sales\ Mastery.avi -vn -ar 22050 -ac 2 -ab 32k -threads 3 -f mp3 damn.mp3 | |
# ffmpeg -i "${INFILE}" -vn -ar 22050 -ac 2 -ab 32k -threads 3 -f mp3 "${OUT_NAME}" | |
# touch "${OUT_NAME}" | |
# mv "${OUT_NAME}" 'job_done' | |
# done < /dev/stdin | |
#OUT_NAME="${STRIP_EXT##*/}.mp3" | |
# an alternative solution: | |
IN_NAME="$1" | |
STRIP_EXT="${IN_NAME%.*}" | |
OUT_NAME="${STRIP_EXT}.mp3" | |
echo "processing" $OUT_NAME | |
echo "-----------------------------------" | |
# wrapping in quote prevent file that has space | |
# touch "${OUT_NAME}" | |
## threads = 1.5 x core | |
## sample rate = 22.05 khz | |
## channel = 2 | |
## bit rate = 32k bit/s | |
#### HACK: 2>&1 1>/dev/null | |
## let 'file descriptor 2', stderr pointer, points to what descriptor 1 points to aka stdout. | |
## let 'file descriptor 1', stdout pointer, points to nowhere. | |
## e.g. ls 2>&1 1>/dev/null | grep '.' | |
# >/dev/null 2>&1 | grep | |
# size= 811kB time=00:03:27.46 bitrate= 32.0kbits/s speed=20.6x | |
ffmpeg -i "${IN_NAME}" -vn -ar 22050 -ac 2 -ab 32k -threads 3 -f mp3 "${OUT_NAME}" | |
echo "stripping audio from ${OUTFILE} is done !" | |
echo "Do you want to move file into job_done folder ? [y/n]" | |
read answer | |
if [ "$answer" == "y" ] | |
then | |
mv "${OUT_NAME}" ./job_done | |
echo "move ${OUT_NAME} done" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment