Created
July 12, 2019 19:34
-
-
Save stdevPavelmc/6150ffa6267d95720f294fdc0aec6fb9 to your computer and use it in GitHub Desktop.
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 | |
###################################################################### | |
# Convert Youtube AV1 video files, Gnome nautilus script | |
# | |
# You need ffmped, mencoder and aom video encoder/decoder for AV1 video | |
# | |
# Goal here is to convert it as fast as it can with so-so resolution | |
# and playable in any embedded device, specs follows | |
# | |
# * Avi container | |
# * Video codec is xvid | |
# * Video aspect and geometry is preserved | |
# * Bitrate about 750 kbits/s | |
# * Audio codec is mp3 | |
# * Audio Sampling is preserved | |
# | |
# Author is Pavel Milanes (CO7WT) [email protected] | |
# Date is 12 july 2019 | |
# | |
###################################################################### | |
# Get current path | |
mypath="`pwd`" | |
for filename in "$@"; do | |
if [ -n "$*,?" ];then | |
# remove the trailing chars of the extension | |
cutfilename=`echo "$filename" | rev | cut -d "." -f 2- | rev` | |
# check if file exist (fail-safe for overwrite) | |
if [ -f "$mypath/$cutfilename.avi" ] ; then | |
# add "conv" to the filename | |
cutfilename=$cutfilename"_conv" | |
fi | |
TMP=`mktemp` | |
# First extract video | |
aomdec "$mypath/$filename" | mencoder -ovc xvid -xvidencopts pass=2:bitrate=750 -oac copy - -o "$TMP.avi" 2>&1 | awk -vRS="\r" '$1 ~ /Pos/ {gsub(/Pos:/," ");gsub(/%\)/," ");gsub(/ \(/," ");print $3"\n#Posición :\\t"$1"\\nCuadro :\\t"$2"\\nPorcentaje :\\t"$3"%\\nRadio de cuadros :\\t"$4"\\nTiempo restante :\\t"$6; fflush();}' | zenity --progress --auto-kill --auto-close --title="Converting video..." | |
# extracting audio | |
ffmpeg -i "$mypath/$filename" "$TMP.mp3" | |
# packing all togother | |
#ffmpeg -i "$TMP.mp3" -i "$TMP.avi" "$mypath/$cutfilename.avi" | |
mencoder -ovc copy -audiofile "$TMP.mp3" -oac copy "$TMP.avi" -o "$mypath/$cutfilename.avi" 2>&1 | awk -vRS="\r" '$1 ~ /Pos/ {gsub(/Pos:/," ");gsub(/%\)/," ");gsub(/ \(/," ");print $3"\n#Posición :\\t"$1"\\nCuadro :\\t"$2"\\nPorcentaje :\\t"$3"%\\nRadio de cuadros :\\t"$4"\\nTiempo restante :\\t"$6; fflush();}' | zenity --progress --auto-kill --auto-close --title="Packing the final video..." | |
# erase the tmp files | |
rm -rf "$TMP*" | |
fi | |
done | |
zenity --info --text="Video Conversion ended!" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment