Skip to content

Instantly share code, notes, and snippets.

@zhanglianbo35
Last active October 9, 2019 10:30
Show Gist options
  • Save zhanglianbo35/c5da0704fafa8ac925ed52225ca39e8d to your computer and use it in GitHub Desktop.
Save zhanglianbo35/c5da0704fafa8ac925ed52225ca39e8d to your computer and use it in GitHub Desktop.
convert audio format opus (native) to mp3
for file in *.mkv
do
if ! [ -f "${file%.*}.mp4" ] ; then
echo "${file}" && ffmpeg -i "${file}" -acodec mp3 -vcodec copy "${file%.*}.mp4"
fi
if ! [[ -z $(grep '[^[:space:]]' "${file%.*}.mp4") ]] ; then
echo "Convert successful"
rm -f "$file"
else
echo "Convert failed, keep mkv as it is"
rm -f "${file%.*}.mp4"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment