DrEaMeR86
22nd February 2007, 10:28
Just trying to simplify some daily actions (converting anime :P).
#!/bin/bash
# Doom9's solutions :P
# DrEaMeR... Just Copy, Paste, and Use it
# DrEaMuX v0.3
SRCFILE="$1"
RESX=`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_WIDTH | cut -f 2 -d "="`
RESY=`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_HEIGHT | cut -f 2 -d "="`
FPS=`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_FPS | cut -f 2 -d "="`
STREAMV=streamvideo$(printf '%05d' ${RANDOM})
STREAMA=streamaudio$(printf '%05d' ${RANDOM})
DSTVFILE="`basename "${SRCFILE}" .avi`.mp4"
DSTAFILE="`basename "${SRCFILE}" .avi`.aac"
LOGFILE=/tmp/"`basename "${SRCFILE}" .avi`.log"
ENCSTATS=/tmp/"`basename "${SRCFILE}" .avi`.stats"
echo -en "Encoding \e[1;31m$1\e[0m from \e[1;32m`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_AUDIO_CODEC | cut -f 2 -d "="`\e[0m to \e[1;32mAAC\e[0m"
echo
mkfifo /tmp/"${STREAMA}"
echo -en "Working with pipe \e[1;34m/tmp/${STREAMA}\e[0m..."
echo
echo -en "Writing to a temporary \e[1;32mAAC\e[0m \e[1;34m/tmp/${DSTAFILE}\e[0m..."
echo
mplayer -ao pcm:file="/tmp/"${STREAMA}"" "${SRCFILE}" -vc dummy -vo null | faac -o lc -c 18000 -b 64 -o /tmp/"${DSTAFILE}" /tmp/"${STREAMA}"
echo -en "Deleting pipe created before \e[1;34m/tmp/${STREAMA}\e[0m..";echo
rm /tmp/"${STREAMA}";
echo "Done."
echo -en "Encoding \e[1;31m$1\e[0m from \e[1;32m`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_FORMAT | cut -f 2 -d "="`\e[0m to \e[1;32mMP4\e[0m. "${RESX}"x"${RESY}" @ "${FPS}""
echo
mkfifo /tmp/"${STREAMV}"
echo -en "Working with pipe \e[1;34m/tmp/${STREAMV}\e[0m..."
echo
echo "First Pass...";
mencoder "${SRCFILE}" -nosound -ovc raw -sws 9 -vf format=i420 -of rawvideo -o /tmp/"${STREAMV}" 2&>1 "${LOGFILE}.v1" & x264 --threads 2 --bitrate 800 --partitions all --direct spatial --direct-8x8 -1 --subme 7 --b-rdo --mixed-refs --8x8dct --trellis 2 --no-dct-decimate --nr 0 --weightb --me hex --merange 16 --scenecut 40 --bframes 3 --b-bias 0 --b-pyramid --ref 9 --no-fast-pskip --deblock 1:1 --qpmin 10 --qpmax 51 --qpstep 4 --keyint 250 --min-keyint 25 --ipratio 1.40 --pbratio 1.60 --pass 1 --stats "${ENCSTATS}" --sar 1:1 --no-psnr --fps "${FPS}" -o "${DSTVFILE}" /tmp/"${STREAMV}" "${RESX}"x"${RESY}" --progress &> "${LOGFILE}.v1b"
echo "First Pass done.";
echo "Second Pass...";
mencoder "${SRCFILE}" -nosound -ovc raw -sws 9 -vf format=i420 -of rawvideo -o /tmp/"${STREAMV}" 2&>1 "${LOGFILE}.v2" & x264 --threads 2 --bitrate 800 --partitions all --direct spatial --direct-8x8 -1 --subme 7 --b-rdo --mixed-refs --8x8dct --trellis 2 --no-dct-decimate --nr 0 --weightb --me hex --merange 16 --scenecut 40 --bframes 3 --b-bias 0 --b-pyramid --ref 9 --no-fast-pskip --deblock 1:1 --qpmin 10 --qpmax 51 --qpstep 4 --keyint 250 --min-keyint 25 --ipratio 1.40 --pbratio 1.60 --pass 2 --stats "${ENCSTATS}" --sar 1:1 --no-psnr --fps "${FPS}" -o "${DSTVFILE}" /tmp/"${STREAMV}" "${RESX}"x"${RESY}" --progress &> "${LOGFILE}.v2b"
echo "Second Pass done";
echo -en "Deleting pipe created before \e[1;34m/tmp/${STREAMV}\e[0m..";echo
rm /tmp/"${STREAMV}";
echo -en "Muxing \e[1;32mAAC\e[0m and \e[1;32mMP4\e[0m."
mp4creator -create=/tmp/"${DSTAFILE}" "${DSTVFILE}"
echo "Done."
echo
echo -en "Deleting temprary \e[1;32mAAC\e[0m"
rm /tmp/"${DSTAFILE}"
echo
echo -en "\e[1;31m$1\e[0m conversion completed."
echo
:stupid:
Audio/Video desync fixed
FPS and RES parameters fixed
Usage: DrEaMuX.sh VIDEO.AVI
TODO:
Add language tag
Silence faac and x264.
for batch encode:
#!/bin/bash
# Doom9's solutions :P
# DrEaMeR... Just Copy, Paste, and Use it
# DrEaMuX-dir v0.1
current_directory="$1"
for i in *.avi; do DrEaMuX.sh "$i"; done
Usage: DrEaMuX-dir.sh /avifiles/
#!/bin/bash
# Doom9's solutions :P
# DrEaMeR... Just Copy, Paste, and Use it
# DrEaMuX v0.3
SRCFILE="$1"
RESX=`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_WIDTH | cut -f 2 -d "="`
RESY=`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_HEIGHT | cut -f 2 -d "="`
FPS=`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_FPS | cut -f 2 -d "="`
STREAMV=streamvideo$(printf '%05d' ${RANDOM})
STREAMA=streamaudio$(printf '%05d' ${RANDOM})
DSTVFILE="`basename "${SRCFILE}" .avi`.mp4"
DSTAFILE="`basename "${SRCFILE}" .avi`.aac"
LOGFILE=/tmp/"`basename "${SRCFILE}" .avi`.log"
ENCSTATS=/tmp/"`basename "${SRCFILE}" .avi`.stats"
echo -en "Encoding \e[1;31m$1\e[0m from \e[1;32m`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_AUDIO_CODEC | cut -f 2 -d "="`\e[0m to \e[1;32mAAC\e[0m"
echo
mkfifo /tmp/"${STREAMA}"
echo -en "Working with pipe \e[1;34m/tmp/${STREAMA}\e[0m..."
echo
echo -en "Writing to a temporary \e[1;32mAAC\e[0m \e[1;34m/tmp/${DSTAFILE}\e[0m..."
echo
mplayer -ao pcm:file="/tmp/"${STREAMA}"" "${SRCFILE}" -vc dummy -vo null | faac -o lc -c 18000 -b 64 -o /tmp/"${DSTAFILE}" /tmp/"${STREAMA}"
echo -en "Deleting pipe created before \e[1;34m/tmp/${STREAMA}\e[0m..";echo
rm /tmp/"${STREAMA}";
echo "Done."
echo -en "Encoding \e[1;31m$1\e[0m from \e[1;32m`mplayer -identify -frames 0 -vo null -ao null "${SRCFILE}" | grep ID_VIDEO_FORMAT | cut -f 2 -d "="`\e[0m to \e[1;32mMP4\e[0m. "${RESX}"x"${RESY}" @ "${FPS}""
echo
mkfifo /tmp/"${STREAMV}"
echo -en "Working with pipe \e[1;34m/tmp/${STREAMV}\e[0m..."
echo
echo "First Pass...";
mencoder "${SRCFILE}" -nosound -ovc raw -sws 9 -vf format=i420 -of rawvideo -o /tmp/"${STREAMV}" 2&>1 "${LOGFILE}.v1" & x264 --threads 2 --bitrate 800 --partitions all --direct spatial --direct-8x8 -1 --subme 7 --b-rdo --mixed-refs --8x8dct --trellis 2 --no-dct-decimate --nr 0 --weightb --me hex --merange 16 --scenecut 40 --bframes 3 --b-bias 0 --b-pyramid --ref 9 --no-fast-pskip --deblock 1:1 --qpmin 10 --qpmax 51 --qpstep 4 --keyint 250 --min-keyint 25 --ipratio 1.40 --pbratio 1.60 --pass 1 --stats "${ENCSTATS}" --sar 1:1 --no-psnr --fps "${FPS}" -o "${DSTVFILE}" /tmp/"${STREAMV}" "${RESX}"x"${RESY}" --progress &> "${LOGFILE}.v1b"
echo "First Pass done.";
echo "Second Pass...";
mencoder "${SRCFILE}" -nosound -ovc raw -sws 9 -vf format=i420 -of rawvideo -o /tmp/"${STREAMV}" 2&>1 "${LOGFILE}.v2" & x264 --threads 2 --bitrate 800 --partitions all --direct spatial --direct-8x8 -1 --subme 7 --b-rdo --mixed-refs --8x8dct --trellis 2 --no-dct-decimate --nr 0 --weightb --me hex --merange 16 --scenecut 40 --bframes 3 --b-bias 0 --b-pyramid --ref 9 --no-fast-pskip --deblock 1:1 --qpmin 10 --qpmax 51 --qpstep 4 --keyint 250 --min-keyint 25 --ipratio 1.40 --pbratio 1.60 --pass 2 --stats "${ENCSTATS}" --sar 1:1 --no-psnr --fps "${FPS}" -o "${DSTVFILE}" /tmp/"${STREAMV}" "${RESX}"x"${RESY}" --progress &> "${LOGFILE}.v2b"
echo "Second Pass done";
echo -en "Deleting pipe created before \e[1;34m/tmp/${STREAMV}\e[0m..";echo
rm /tmp/"${STREAMV}";
echo -en "Muxing \e[1;32mAAC\e[0m and \e[1;32mMP4\e[0m."
mp4creator -create=/tmp/"${DSTAFILE}" "${DSTVFILE}"
echo "Done."
echo
echo -en "Deleting temprary \e[1;32mAAC\e[0m"
rm /tmp/"${DSTAFILE}"
echo
echo -en "\e[1;31m$1\e[0m conversion completed."
echo
:stupid:
Audio/Video desync fixed
FPS and RES parameters fixed
Usage: DrEaMuX.sh VIDEO.AVI
TODO:
Add language tag
Silence faac and x264.
for batch encode:
#!/bin/bash
# Doom9's solutions :P
# DrEaMeR... Just Copy, Paste, and Use it
# DrEaMuX-dir v0.1
current_directory="$1"
for i in *.avi; do DrEaMuX.sh "$i"; done
Usage: DrEaMuX-dir.sh /avifiles/