Page 6 of 9

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 2:02 pm
by stabu
It hates me

crc@slavebox:~/Files/Movies/Knowing.2009.720p.BluRay.DTS.x264-DON$ bash /home/crc/NZB/Scripts/mkv2m2ts.sh
## Audio language is 'eng'.
## Subtitle language is 'eng'.
## DTS audio found. Transcoding to AC3.
Extracting track 2 with the CodecID 'A_DTS' to the file 'Knowing.2009.720p.BluRay.DTS.x264-DON.dts'. Container format: Digital Theater System (DTS)
Progress: 100%
libdca-0.0.5 - by Gildas Bazin
  based on the a52dec code from Michel Lespinasse and Aaron Holtzman
Stream with high frequencies VQ coding
SIMD usage: MMX SSE SSE2 SSE3
Threads: 2

683059 frames in 268.75 sec (2541.61 fps), 870 last 0.50 sec (1740.00 fps)
683565 frames decoded in 268.95 seconds (2541.61 fps)
## Attempting to mux: Knowing.2009.720p.BluRay.DTS.x264-DON.mkv
@@ Error muxing: Knowing.2009.720p.BluRay.DTS.x264-DON.mkv

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 2:47 pm
by sweetie
Post tsMuxeR log please.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 2:56 pm
by stabu
SmartLabs tsMuxeR.  Version 1.10.6  http://www.smlabs.net
Decoding H264 stream (track 1): Profile: [email protected]  Resolution: 1280:544p  Frame rate: 23.976
Change H264 level from 5.1 to 4
H.264 muxing fps not set. Get fps from stream.
H.264 stream does not contain fps field. Muxing fps=23.976
0.1% complete
H264 bitstream changed: insert nal unit delimiters
H264 bitstream changed: insert pict timing and buffering period SEI units
0.1% complete
M0.2% complete
M0.3% complete
M0.3% complete
M0.4% complete
M0.5% complete
M0.7% complete
M0.8% complete
M0.9% complete
M1.0% complete
M1.1% complete
M1.2% complete
M1.3% complete
M1.5% complete
M1.6% complete
M1.7% complete
M1.8% complete
M1.9% complete
M2.1% complete
M2.2% complete
Pes packet len too large ( >100Mb). Bad stream or invalid codec speciffed.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 2:59 pm
by sweetie
Oh, bad encode I'd say.

Nothing to do with the script at least. tsMuxeR error.

Sorry.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 3:13 pm
by stabu
haha ok. They need to port over mkv2vob or something to linux

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 3:23 pm
by sweetie
It actually runs very well in WINE (need vb6). Though, it does utilise tsMuxeR, so not sure if it would work.

Able to try it?

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 6:18 pm
by stabu
yeah i know it works but i have no idea how to setup though a script.

oh yeah the script still doesnt delete the folder after it converts

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 6:33 pm
by sweetie
I noticed a couple of posts back you had SAVE_MUX_INPUT to 1. Should be 0. The other two as 1.

Definetly working here. Using it myself.

Also, if mkv2vob was to be setup through a script, it would probably have to be an AutoIT (or whatever the 2009 equivalent is.) that automates all functions within the UI. (far less efficient.)

Only improvements that can be made to the script, frankly, is the ability to have multiple audio and subs tracks. Seeing as the PS3 doesn't yet support either, doubt I'll be adding them anytime soon.

Post back your results if mkv2vob does work with the troublesome file. May contact the author, see how he does it.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 7:03 pm
by stabu
SAVE_MUX_INPUT="0" ##set to 1 to retain MKV/AVI input files. Wouldnt that keep the mkv file if its set to 1

Yeah everything worked fine though mkv2vob.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 28th, 2009, 7:14 pm
by sweetie
Well flip. Are the directories removed when you run script manually? Testing it right now and it's working just fine.

Also, may drop the mkv2vob author an email. I don't see any reason it would mux with that and not with this.

Seriously frustrating.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: November 29th, 2009, 1:42 pm
by stabu
Nope, the folder still stays there if i do it manual.

if i do

Code: Select all

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="0" ##remove input dir. after muxing/joining. (MUX_ONE_UP must be "1", SAVE_MUX_INPUT must be "0")
i get >> Mux successful complete.
@@ Cannot remove input directory. SAVE_MUX_INPUT is active.

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: December 1st, 2009, 5:44 pm
by stabu
here is the pastebin for what i have in the script
http://pastebin.com/m23085362

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: December 2nd, 2009, 2:03 am
by sweetie
Seems that somehow I posted an older revision of the script before. try this:

Code: Select all

#!/bin/bash

##mux options
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"; }

##


cd "$1"

allmkv=`find -type f -name "*.mkv" | wc -l`

inputcount="1"
for input in *.mkv; do if [ -f "$input" ]; then

inputfs=`stat -c %s "$input"`

inputbase="${input%.*}"
if [ "$inputfs" -gt "262144000" -a "$allmkv" -le "1" ]; then output="$CWD.m2ts"
elif [ "$inputfs" -lt "262144000" ]; then output="$CWD-Sample-$inputfs.m2ts"
elif [ "$inputfs" -gt "262144000" -a "$allmkv" -ge "2" ]; then output="$CWD-$inputcount.m2ts"; ((inputcount++)); 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
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

if [ "$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`; fi
if [ "$audio_lang" != "" -a "$audio_lang" != "und" ]; then echo_process "Audio language is: '$audio_lang'."; 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
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

if [ "$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`; fi
if [ "$subs_lang" != "" -a "$subs_lang" != "und" ]; then echo_process "Subtitle language is: '$subs_lang'."; 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" | tee "mkvextract.log"
	dcadec -o wavall "$inputbase.dts" | aften -v 0 -readtoeof 1 - "$inputbase.ac3" | tee "dcadec_aften.log"
	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" | tee "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/.." &> /dev/null; 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 [ "$SAVE_MUX_INPUT" = "1" -o "$MUX_ONE_UP" = "0" ]; then
	echo_error "Cannot remove input directory. MUX_ONE_UP must be '1', SAVE_MUX_INPUT must be '0'."; fi; fi

else echo_error "No MKVs found. Unrared?"; fi

done

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: December 2nd, 2009, 6:39 pm
by stabu
Well it works but uhh  it names the file to "bin.m2ts"

Re: [Linux/OSX - Bash] scenesort script. [v3 - AIO post-post-processor.]

Posted: December 4th, 2009, 5:35 am
by sweetie
Where the heck are you runing it from? It's set to rename to "${PWD##*/}" which is current directory name. Only way it could turn out 'bin' is if you're running from there.  ???

You could try changing:

Code: Select all

if [ "$inputfs" -gt "262144000" -a "$allmkv" -le "1" ]; then output="$CWD.m2ts"
elif [ "$inputfs" -lt "262144000" ]; then output="$CWD-Sample-$inputfs.m2ts"
elif [ "$inputfs" -gt "262144000" -a "$allmkv" -ge "2" ]; then output="$CWD-$inputcount.m2ts"; ((inputcount++)); fi
to:

Code: Select all

output="$CWD-$inputcount.m2ts"; ((inputcount++))
You'll have to have sample downloads disabled in SAB.

Let me know.


Is this on Ubuntu still btw? or FreeNAS?