Skip to content

Instantly share code, notes, and snippets.

@yspreen
Created August 4, 2020 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yspreen/174623b640b1420c50ea3aaa02003d16 to your computer and use it in GitHub Desktop.
Save yspreen/174623b640b1420c50ea3aaa02003d16 to your computer and use it in GitHub Desktop.
#!/bin/sh
vlcconvert() {
######################## Transcode the files using ... ########################
vcodec="mp4v"
acodec="mp4a"
vb="1024"
ab="128"
mux="mp4"
###############################################################################
# Store path to VLC in $vlc
if command -pv vlc >/dev/null 2>&1; then
# Linux should find "vlc" when searching PATH
vlc="vlc"
# Sanity check
if ! command -pv "$vlc" >/dev/null 2>&1; then
printf '%s\n' "Cannot find path to VLC. Abort." >&2
return 1
fi
else
# macOS seems to need an alias
vlc="/Applications/VLC.app/Contents/MacOS/VLC"
# Sanity check
if ! [ -f "$vlc" ]; then
printf '%s\n' "Cannot find path to VLC. Abort." >&2
return 1
fi
fi
for filename in *; do
printf '%s\n' "=> Transcoding '$filename'... "
"$vlc" -I dummy -q "$filename" \
--sout '#transcode{vcodec="'"$vcodec"'",vb="'"$vb"'",acodec="'"$acodec"'",ab="'"$ab"'"}:standard{mux="'"$mux"'",dst="'"$filename"'.'"$mux"'",access=file}' \
vlc://quit
done
}
vlcconvert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment