Thanks, the file utility (almost) does what I need.
I read a few select sections of a bash manual and put together the following code: (warning: total shell script amateur)
Code:
#!/bin/zsh
#This script should be run after downloading audio with mpsyt
#(in the folder to which the files were downloaded)
#Plan:
#Find all files that are webm, or mka (ignore m4a which is ALAC)
#Determine stream type
#Extract audio using ffmpeg
#Change Extension
find . -type f -iname "*.webm" -o -iname "*.mka" | while read line; do
FILEBASENAME=${line%.*}
EXTRACT=true
CONVERT=false
if file $line | grep "AAC"; then
EXT=".aac"
elif file $line | grep "Opus audio"; then
EXT=".opus"
elif file $line | grep "Audio file with ID3 version 2.3.0"; then
EXT=".mp3"
elif file $line | grep "Vorbis audio"; then
EXT=".ogg"
elif file $line | grep "WebM"; then
EXT=".ogg"
else
EXTRACT=false
fi
if $EXTRACT; then
ffmpeg -i "${line}" -hide_banner -loglevel fatal -acodec: copy -vn -y $FILEBASENAME$EXT
echo $FILEBASENAME$EXT
rm $line
fi
done
It mostly does what I want it to do, except it won't work on all files at once. I run it, it works on several files. Run it again, it works on some more, but not all at once.
Why won't this script process all files in one go?
Also...
Code:
$ file myfile.webm
myfile.webm: WebM
will only return "WebM" if it's a webm instead of telling me what sort of stream it contains (e.g. opus, vorbis).
BTW, this is to process music downloaded from youtube by using mpsyt.
Bookmarks