Code: Select all
apt-get install wine
Code: Select all
apt-get install wine
Code: Select all
##mux options
M2TS_AUDIO_LANG="" ##eg. "ger" - leave blank to choose first available. if specified language is not found, will auto-select.
M2TS_SUBS_LANG="" ##as above.
M2TS_SUBS_FONT="/usr/share/fonts/TTF/DejaVuSans.ttf" ##will exit if not found. (only if subs are found.)
SAVE_MUX_INPUT="1" ##set to 1 to retain MKV/AVI input files.
MUX_ONE_UP="1" ##move mux output up one level.
REMOVE_INPUT_DIR="1" ##remove input dir. after muxing/joining. (MUX_ONE_UP must be "1", SAVE_MUX_INPUT must be "0")
Code: Select all
#!/bin/bash
cd "$1"
M2TS_AUDIO_LANG="" ##eg. "eng ger jpn" - prefered priority. if a specified language is not found, will auto-select.
M2TS_SUBS_LANG="" ##as above.
M2TS_SUBS_FONT="/usr/share/fonts/TTF/DejaVuSans.ttf" ##will exit if not found. (only if subs are found.)
SAVE_MUX_INPUT="0" ##set to 1 to retain MKV/AVI input files.
MUX_ONE_UP="1" ##move mux output up one level.
REMOVE_INPUT_DIR="1" ##remove input dir. after muxing/joining. (MUX_ONE_UP must be "1", SAVE_MUX_INPUT must be "0")
CWD="${PWD##*/}"
echo_process () { echo -e "\e[1;33m##\e[0;39;49m" "$1"; }
echo_prompt () { echo -e "\e[1;34m??\e[0;39;49m" "$1"; }
echo_success () { echo -e "\e[1;32m>>\e[0;39;49m" "$1"; }
echo_error () { echo -e "\e[1;31m@@\e[0;39;49m" "$1"; }
echo_success "Processing: "$CWD".."
allmkv=`find -type f -name "*.mkv" | wc -l`
inputcount="0"
for input in *.mkv; do
if [ -f "$input" ]; then
((inputcount++))
inputfs=`stat -c %s "$input"`
inputbase="${input%.*}"
if [ "$inputfs" -gt "104857600" -a "$allmkv" -le "1" ]; then output="$CWD.m2ts"
elif [ "$inputfs" -lt "104857600" ]; then output="$CWD-Sample-$inputfs.m2ts"
elif [ "$inputfs" -gt "104857600" -a "$allmkv" -ge "2" ]; then output="$CWD-$inputcount.m2ts"; fi
mkvinfo "$input" &> "mkvinfo.log"
video_codec=`grep -i "Track type: video" -B2 -C9 "mkvinfo.log" | grep -ie "V_MPEG4/ISO/AVC\|V_MS/VFW/WVC1\|V_MPEG-2" | head -n 1 | cut -d' ' -f6`
video_track=`grep -i "Codec ID: $video_codec" -B10 "mkvinfo.log" | grep -i "Track number:" | head -n 1 | cut -d' ' -f6`
if [ "$M2TS_AUDIO_LANG" = "" ]; then
audio_lang=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -ie "Language: [a-z][a-z][a-z]" | head -n 1 | cut -d' ' -f5`
if [ "$audio_lang" != "" -a "$audio_lang" != "und" ]; then echo_process "Audio language is: '$audio_lang'."; fi
else for all_audio_lang in $M2TS_AUDIO_LANG; do if [ "$audio_lang" = "" ]; then
audio_lang=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -ie "Language: $all_audio_lang" | head -n 1 | cut -d' ' -f5`
if [ "$audio_lang" = "" ]; then echo_process "Audio in '$all_audio_lang' not found."; else
echo_process "Audio language is: '$audio_lang'."; fi; fi; done; fi
audio_codec=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -i "Language: $audio_lang" -B4 | grep -ie "Codec ID: \(A_AC3\|A_AAC\|A_DTS\|A_MP3\|A_LPCM\)" | head -n 1 | cut -d' ' -f6`
audio_track=`grep -i "Codec ID: $audio_codec" -B10 -C3 "mkvinfo.log" | grep -i "Language: $audio_lang" -B13 | grep -i "Track number:" | head -n 1 | cut -d' ' -f6`
if [ "$M2TS_SUBS_LANG" = "" ]; then
subs_lang=`grep -i "Track type: subtitles" -B2 -C12 "mkvinfo.log" | grep -ie "Language: [a-z][a-z][a-z]" | head -n 1 | cut -d' ' -f5`
if [ "$subs_lang" != "" -a "$subs_lang" != "und" ]; then echo_process "Subtitle language is: '$subs_lang'."; fi
else for all_subs_lang in $M2TS_SUBS_LANG; do if [ "$subs_lang" = "" ]; then
subs_lang=`grep -i "Track type: subtitles" -B2 -C12 "mkvinfo.log" | grep -i "Language: $all_subs_lang" | head -n 1 | cut -d' ' -f5`
if [ "$subs_lang" = "" ]; then echo_process "Subtitles in '$all_subs_lang' not found."; else
echo_process "Subtitle language is: '$subs_lang'."; fi; fi; done; fi
subs_format=`grep -i "Track type: subtitles" -B2 -C12 "mkvinfo.log" | grep -i "Language: $subs_lang" -B4 | grep -ie "Codec ID: \(S_HDMV/PGS\|S_TEXT/UTF8\)" | head -n 1 | cut -d' ' -f6`
subs_track=`grep -i "Codec ID: $subs_format" -B10 -C3 "mkvinfo.log" | grep -i "Language: $subs_lang" -B13 | grep -i "Track number:" | head -n 1 | cut -d' ' -f6`
if [ "$video_track" -gt "0" ]; then echo "MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr" >> "$inputbase.meta"
echo "$video_codec, $input, level=4.1, insertSEI, contSPS, track=$video_track, lang=$audio_lang" >> "$inputbase.meta"
else echo "Incompatible video codec found. Exiting."; break; fi
if [ "$audio_codec" = "A_AC3" -o "$audio_codec" = "A_AAC" -o "$audio_codec" = "A_MP3" -o "$audio_codec" = "A_LPCM" ]; then
echo "$audio_codec, $input, track=$audio_track, lang=$audio_lang" >> "$inputbase.meta"
elif [ "$audio_codec" = "A_DTS" ]; then
echo_process "DTS audio found. Extracting track and transcoding to AC3."
mkvextract tracks "$input" "$audio_track":"$inputbase.dts"
dcadec -o wavall "$inputbase.dts" | aften -v 0 -readtoeof 1 - "$inputbase.ac3"
echo "A_AC3, $inputbase.ac3, track=$audio_track, lang=$audio_lang" >> "$inputbase.meta"
else echo_error "Incomptible audio codec found. Exiting."; break; fi
if [ "$subs_format" = "S_HDMV/PGS" -o "$subs_format" = "S_TEXT/UTF8" ]; then
if [ ! -f "$M2TS_SUBS_FONT" ]; then echo_error "Font '$M2TS_SUBS_FONT' not found. Exiting."; break; fi
fps=`grep "Track number: $video_track" -B2 -C15 "mkvinfo.log" | grep -i "Default duration" | cut -d' ' -f7 | tr -d '('`
if [ "$fps" = "" ]; then fps="23.976"; fi ##this isn't ideal, though few files will rely on this fallback.
width=`grep "Pixel width:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
height=`grep "Pixel height:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
echo "$subs_format, "$input", font-name="$M2TS_SUBS_FONT", font-size="65", font-color="0x00ffffff", bottom-offset="24", font-border="2", text-align="center", video-width="$width", video-height="$height", fps="$fps", track="$subs_track", lang="$subs_lang"" >> "$inputbase.meta"
fi
echo_process "Attempting to mux: $input"
tsMuxeR "$inputbase.meta" "$output" &> "tsMuxeR.log"
if grep -q "Mux successful complete." "tsMuxeR.log"; then echo_success "Mux successful complete."; mkv2m2ts="1"
else echo_error "Error muxing: "$input""; fi
for tmp in "$inputbase.meta" "$inputbase.dts" "$inputbase.ac3"; do
[ -f "$tmp" ] || continue
rm -f "$tmp"; done
if [ "$mkv2m2ts" = "1" ]; then if [ "$SAVE_MUX_INPUT" = "0" ]; then rm -f "$input"; fi
if [ "$MUX_ONE_UP" = "1" ]; then for mkv in *.mkv; do if [ ! -f "$mkv" ]; then
for m2ts in *.m2ts; do [ -f "$m2ts" ] || continue; mv -f "$m2ts" "$PWD/.."; done; fi; done; fi
if [ "$REMOVE_INPUT_DIR" = "1" -a "$SAVE_MUX_INPUT" = "0" -a "$MUX_ONE_UP" = "1" ]; then
for mkv in *.mkv; do if [ ! -f "$mkv" ]; then rm -rf "$PWD"; fi; done
elif [ "$REMOVE_INPUT_DIR" = "1" ]; then echo_error "Cannot remove input directory. SAVE_MUX_INPUT is active."; fi; fi
else echo_error "No MKVs found. Unrared?"; fi
done
Code: Select all
#!/bin/bash
M2TS_AUDIO_LANG="" ##eg. "eng ger jpn" - prefered priority. if a specified language is not found, will auto-select.
M2TS_SUBS_LANG="" ##as above.
M2TS_SUBS_FONT="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf" ##will exit if not found. (only if subs are found.)
SAVE_MUX_INPUT="0" ##set to 1 to retain MKV/AVI input files.
MUX_ONE_UP="1" ##move mux output up one level.
REMOVE_INPUT_DIR="1" ##remove input dir. after muxing/joining. (MUX_ONE_UP must be "1", SAVE_MUX_INPUT must be "0")
CWD="${PWD##*/}"
echo_process () { echo -e "\e[1;33m##\e[0;39;49m" "$1"; }
echo_prompt () { echo -e "\e[1;34m??\e[0;39;49m" "$1"; }
echo_success () { echo -e "\e[1;32m>>\e[0;39;49m" "$1"; }
echo_error () { echo -e "\e[1;31m@@\e[0;39;49m" "$1"; }
allmkv=`find -type f -name "*.mkv" | wc -l`
inputcount="0"
for input in *.mkv; do
if [ -f "$input" ]; then
((inputcount++))
inputfs=`stat -c %s "$input"`
inputbase="${input%.*}"
if [ "$inputfs" -gt "104857600" -a "$allmkv" -le "1" ]; then output="$CWD.m2ts"
elif [ "$inputfs" -lt "104857600" ]; then output="$CWD-Sample-$inputfs.m2ts"
elif [ "$inputfs" -gt "104857600" -a "$allmkv" -ge "2" ]; then output="$CWD-$inputcount.m2ts"; fi
mkvinfo "$input" > "mkvinfo.log"
video_codec=`grep -i "Track type: video" -B2 -C9 "mkvinfo.log" | grep -ie "V_MPEG4/ISO/AVC\|V_MS/VFW/WVC1\|V_MPEG-2" | head -n 1 | cut -d' ' -f6`
video_track=`grep -i "Codec ID: $video_codec" -B10 "mkvinfo.log" | grep -i "Track number:" | head -n 1 | cut -d' ' -f6`
if [ "$M2TS_AUDIO_LANG" = "" ]; then
audio_lang=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -ie "Language: [a-z][a-z][a-z]" | head -n 1 | cut -d' ' -f5`
if [ "$audio_lang" != "" -a "$audio_lang" != "und" ]; then echo_process "Audio language is '$audio_lang'."; fi
else for all_audio_lang in $M2TS_AUDIO_LANG; do if [ "$audio_lang" = "" ]; then
audio_lang=`grep -i "Track type: audio" -B2 -C12 "mkvinfo.log" | grep -ie "Language: $all_audio_lang" | head -n 1 | cut -d' ' -f5`
if [ "$audio_lang" = "" ]; then echo_process "Audio in '$all_audio_lang' not found."; else
echo_process "Audio language is '$audio_lang'."; fi; fi; done; fi
audio_codec=`grep -i "Track type: audio" -B2 -C9 "mkvinfo.log" | grep -ie "A_AC3\|A_AAC\|A_DTS\|A_MP3\|A_LPCM" | head -n 1 | cut -d' ' -f6`
audio_track=`grep -i "Codec ID: $audio_codec" -B10 -C3 "mkvinfo.log" | grep -i "Language: $audio_lang" -B13 | grep -i "Track number:" | head -n 1 | cut -d' ' -f6`
if [ "$M2TS_SUBS_LANG" = "" ]; then
subs_lang=`grep -i "Track type: subtitles" -B2 -C12 "mkvinfo.log" | grep -ie "Language: [a-z][a-z][a-z]" | head -n 1 | cut -d' ' -f5`
if [ "$subs_lang" != "" -a "$subs_lang" != "und" ]; then echo_process "Subtitle language is '$subs_lang'."; fi
else for all_subs_lang in $M2TS_SUBS_LANG; do if [ "$subs_lang" = "" ]; then
subs_lang=`grep -i "Track type: subtitles" -B2 -C12 "mkvinfo.log" | grep -ie "Language: $all_subs_lang" | head -n 1 | cut -d' ' -f5`
if [ "$subs_lang" = "" ]; then echo_process "Subtitles in '$all_subs_lang' not found."; else
echo_process "Subtitle language is '$subs_lang'."; fi; fi; done; fi
subs_format=`grep -i "Track type: subtitles" -B2 -C9 "mkvinfo.log" | grep -ie "S_HDMV/PGS\|S_TEXT/UTF8" | head -n 1 | cut -d' ' -f6`
subs_track=`grep -i "Codec ID: $subs_format" -B10 -C3 "mkvinfo.log" | grep -i "Language: $subs_lang" -B13 | grep -i "Track number:" | head -n 1 | cut -d' ' -f6`
if [ "$video_track" -gt "0" ]; then echo "MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr" >> "$inputbase.meta"
echo "$video_codec, $input, level=4.1, insertSEI, contSPS, track=$video_track, lang=$audio_lang" >> "$inputbase.meta"
else echo "Incompatible video codec found. Exiting."; break; fi
#audioext="${audio_codec#*_}"
if [ "$audio_codec" = "A_AC3" -o "$audio_codec" = "A_AAC" -o "$audio_codec" = "A_MP3" -o "$audio_codec" = "A_LPCM" ]; then
echo "$audio_codec, $input, track=$audio_track, lang=$audio_lang" >> "$inputbase.meta"
elif [ "$audio_codec" = "A_DTS" ]; then
echo_process "DTS audio found. Transcoding to AC3."
mkvextract tracks "$input" "$audio_track":"$inputbase.dts"
dcadec -o wavall "$inputbase.dts" | aften -v 0 -readtoeof 1 - "$inputbase.ac3"
echo "A_AC3, $inputbase.ac3, track=$audio_track, lang=$audio_lang" >> "$inputbase.meta"
else echo_error "Incomptible audio codec found. Exiting."; break; fi
if [ "$subs_format" = "S_HDMV/PGS" -o "$subs_format" = "S_TEXT/UTF8" ]; then
if [ ! -f "$M2TS_SUBS_FONT" ]; then echo_error "Font '$M2TS_SUBS_FONT' not found. Exiting."; break; fi
if [ "$video_track" -lt "$audio_track" ]; then
fps=`grep "Frame rate" "mkvinfo.log" | sed -n 1p | cut -d'(' -f2 | cut -d' ' -f1`; else
fps=`grep "Frame rate" "mkvinfo.log" | sed -n 2p | cut -d'(' -f2 | cut -d' ' -f1`; fi
if [ "$fps" = "" ]; then fps="23.976"; fi ##this isn't ideal, though few files will rely on this fallback.
width=`grep "Pixel width:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
height=`grep "Pixel height:" "mkvinfo.log" | cut -d':' -f2 | tr -d ' '`
echo "$subs_format, "$input", font-name="$M2TS_SUBS_FONT", font-size="65", font-color="0x00ffffff", bottom-offset="24", font-border="2", text-align="center", video-width="$width", video-height="$height", fps="$fps", track="$subs_track", lang="$subs_lang"" >> "$inputbase.meta"
fi
echo_process "Attempting to mux: $input"
tsMuxeR "$inputbase.meta" "$output" &> "tsMuxeR.log"
if grep -q "Mux successful complete." "tsMuxeR.log"; then echo_success "Mux successful complete."; mkvmuxok="1"
else echo_error "Error muxing: "$input""; mkvmuxok="0"; fi
for tmp in "$inputbase.meta" "$inputbase.dts" "$inputbase.ac3"; do
[ -f "$tmp" ] || continue
rm -f "$tmp"; done
if [ "$mkvmuxok" = "1" ]; then
if [ "$SAVE_MUX_INPUT" = "0" ]; then rm -f "$input"; fi
if [ "$MUX_ONE_UP" = "1" ]; then for mkv in *.mkv; do if [ ! -f "$mkv" ]; then
for m2ts in *.m2ts; do [ -f "$m2ts" ] || continue; mv -f "$m2ts" "$PWD/.."; done; fi; done; fi
if [ "$REMOVE_INPUT_DIR" = "1" -a "$SAVE_MUX_INPUT" = "0" -a "$MUX_ONE_UP" = "1" ]; then
for mkv in *.mkv; do [ ! -f "$mkv" ] || continue rm -rf "$PWD"; done
else echo_error "Cannot remove input directory. SAVE_MUX_INPUT is active."; fi; fi
else echo_error "No MKVs found. Unrared?"; fi
##mux options
M2TS_AUDIO_LANG="" ##eg. "ger" - leave blank to choose first available. if specified language is not found, will auto-select.
M2TS_SUBS_LANG="" ##as above.
M2TS_SUBS_FONT="/usr/share/fonts/TTF/DejaVuSans.ttf" ##will exit if not found. (only if subs are found.)
SAVE_MUX_INPUT="1" ##set to 1 to retain MKV/AVI input files.
MUX_ONE_UP="1" ##move mux output up one level.
REMOVE_INPUT_DIR="1" ##remove input dir. after muxing/joining. (MUX_ONE_UP must be "1", SAVE_MUX_INPUT must be "0")
done
Code: Select all
wget -c http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2
tar jxvf libdca-0.0.5.tar.bz2
cd libdca-0.0.5/
./configure
make
cd src
make install