Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > General > Linux, Mac OS X, & Co

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th March 2006, 07:04   #1  |  Link
PavalloKazzo
Registered User
 
Join Date: Mar 2006
Posts: 12
A little batch NSV converter (to vcd)

I wrote this script these days for help me converting a huge amount of nsv files.
Some limitations:
- It will process nsv files in subdir like dir/subdir/*.nsv (this is because the way streamripper save files);
- it also needs to have a workdir (that you will pass on script startup) so /workdir/dir1/anyname/*.nsv /workdir/dir2/anyname/*.nsv and it will produce /workdir/final_mpg_files/dir1.mpg /workdir/final_mpg_files/dir2.mpg
- It use mplayer, mpgtx (wine and faad for the "demuxer version") tools: need to be installed
- Don't place any other dir except the ones with nsv files cause they will be processed
- Absolutly don't call dir with numbers cause will loop mpgtx creating huge log files

I made two version: one simple (nsv--->mencoder-->mpgtx--->final_mpeg) and other a little ore complex (nsv-->NSVD.exe--->faad--->mencoder-->mpgtx--->final_mpeg) the "demuxer version"
This last because I couldn't get mplayer work with AAC on Debian (now I'm on Fedora 4 and seems ok) so Debian users could try that if their mplayer can't handle AAC

Some known bugs:
- If an nsv file got some corrupted frames this will cause an a/v desync plus the cut of a piece of the stream cause mplayer will do these:
Stream corrupted:
- - - - - - V4 V5 V6 V7 V8
A1A2A3 A4 A5 A6 A7 A8
Resultant mpg files:
V4 V5 V6 V7 V8
A1 A2 A3 A4 A5
if anyone knows how to resolve this is welcome
- Also if someone could please post a good tool to join two+ mpeg files cause mpgtx seems to cause problems (I heard about using I/O redirection aka cat aka <> but could you assure me it will work?); this could be a way to resolve any type of problems derived from bad nsv files, just run the split command to divide nsv files in 512kb or 1 mb chunk each!!!

By now I think it's all

P.S. rename the file from zip to gz
P.P.S Some Spam for google: nvs mplayer vcd svcd xvcd xsvcd dvd nsvd.exe linux
Attached Files
File Type: zip nsv2svcd.sh.tar.zip (1.5 KB, 872 views)
File Type: zip nsv2svcd_with_demuxer.sh.tar.zip (1.8 KB, 758 views)

Last edited by PavalloKazzo; 26th March 2006 at 07:06.
PavalloKazzo is offline   Reply With Quote
Old 26th March 2006, 07:05   #2  |  Link
PavalloKazzo
Registered User
 
Join Date: Mar 2006
Posts: 12
nsv2svcd

#!/bin/sh
ENCODER() {
cd $NSV2SVCD_ROOT/$WORKPATH
WORKPATH_NSV=$(ls)
cd $NSV2SVCD_ROOT/$WORKPATH/$WORKPATH_NSV
I=1
for FILENAME_NSV in *.nsv
do
mencoder ${FILENAME_NSV}.nsv -oac mp3lame -srate 44100 -lameopts cbr:br=128 -af lavcresample=44100 -vf scale=352:288,harddup -ovc lavc -lavcopts vcodec=mpeg1video:keyint=15:vbitrate=2000 -of mpeg -mpegopts format=xvcd -vf scale=352:288,harddup -ofps 25 -o ${I}.mpg >> $NSV2SVCD_ROOT/log/$WORKPATH/${I}_encoder_out 2>&1
echo "Process #$I: mencoder exit status $? " >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
((I++))
done
FILENUMBER_NSV=$(ls *.nsv | wc -l)
FILENUMBER_MPG=$(ls *.mpg | wc -l)
if [ $FILENUMBER_NSV = $FILENUMBER_MPG ]
then
mv $NSV2SVCD_ROOT/$WORKPATH/$WORKPATH_NSV/*.mpg $NSV2SVCD_ROOT/$WORKPATH/
cd $NSV2SVCD_ROOT/$WORKPATH/
rm -r $WORKPATH_NSV
echo -e "All files encoded\nFiles now will be deleted\nProceeding to MERGE status" >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
return 0
else
for (( I=1; I <= FILENUMBER_NSV; I++ ))
do
if [ ! -e ${I}.mpg ]
then
FILENAME_NSV=$( ls *.nsv | sed ${I}'!d' )
echo -e "There has been problems processing files ${FILENAME_NSV}.nsv corresponding to process $I\nCheck $NSV2SVCD_ROOT/log/$WORKPATH/${I}_encoder_out for errors" >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
fi
done
return 1
fi
}

MERGER() {
cd $NSV2SVCD_ROOT/$WORKPATH
mpgfiles2beprocessed=$(ls *.mpg)
mpgtx -j $mpgfiles2beprocessed -o $WORKPATH.mpg >> $NSV2SVCD_ROOT/log/$WORKPATH/merger 2>&1
echo "Merger exit status= $? " >> $NSV2SVCD_ROOT/log/$WORKPATH/merger
if [ -e $WORKPATH.mpg ]
then
mv $WORKPATH.mpg $NSV2SVCD_ROOT/final_mpg_files
cd ..
rm -r $WORKPATH
echo -e "All files merged\nMoving $WORKPATH.mpg to $NSV2SVCD_ROOT/final_mpg_files\nRemoving old files" >> $NSV2SVCD_ROOT/log/$WORKPATH/merger
return 0
else
echo -e "Files couldn't be processed\nCheck $NSV2SVCD_ROOT/log/$WORKPATH/merger for errors" >> $NSV2SVCD_ROOT/log/$WORKPATH/merger
return 1
fi
}

echo -e "This program need these things to work:"
echo -e " - mplayer and mpgtx installed"
echo -e " - NSV files must be placed in dir/subdir respect to program root (it's not important the name of the directories)"
echo -e " So it should be a directory for the program with a subdirectory containing every group of NSV files inside another subdir (/script_root/dir/subdir/*.nsv)"
echo -e " - It's important that no else directories are placed inside the 'work_rooth' and it's important that inside these paths there is no files apart .nsv cause both of these will produce heavy error logs"
echo -e " - DO NOT NAME PATHS WITH NUMBERS: this will cause infinite loop for mpgtx creating huge log file\n"
echo -n "Now please press Ctrl+C to exit or to continue digit the absolut path where the script should work: "
#read $NSV2SVCD_ROOT
NSV2SVCD_ROOT=/home/pava/temp/week_13
ORIGINAL_PATH=$( pwd )
cd $NSV2SVCD_ROOT
WORKPATHS_LIST=$( ls )
mkdir final_mpg_files
mkdir log
for WORKPATH in $WORKPATHS_LIST
do
mkdir $NSV2SVCD_ROOT/log/$WORKPATH/
for NSV2SVCD_FUNCTIONS in "ENCODER" "MERGER"
do
$NSV2SVCD_FUNCTIONS
if [ $? != 0 ]
then
echo "$WORKPATH/$NSV2SVCD_FUNCTIONS: Problems occurred in this process. Check log files">> $NSV2SVCD_ROOT/log/nsv2svcd
else
echo "$WORKPATH/$NSV2SVCD_FUNCTIONS: Everything worked great... maybe!">> $NSV2SVCD_ROOT/log/nsv2svcd
fi
done
done
exit 0
PavalloKazzo is offline   Reply With Quote
Old 26th March 2006, 07:05   #3  |  Link
PavalloKazzo
Registered User
 
Join Date: Mar 2006
Posts: 12
#!/bin/sh
DEMUXER() {
cd $WORKPATH
WORKPATH_NSV=$(ls)
cp $ORIGINAL_PATH/NSVD.exe $WORKPATH_NSV/
cd $WORKPATH_NSV
I=1
for FILENAME_NSV in *.nsv
do
wine NSVD.exe -n $FILENAME_NSV -a $I.avi -w $I.audio >> $NSV2SVCD_ROOT/log/$WORKPATH/${I}_demuxer_out 2>&1
echo "Process #$I $FILENAME_NSV: wine NSVD.exe exit status= $? " >> $NSV2SVCD_ROOT/log/$WORKPATH/demuxer
((I++))
done
FILENUMBER_NSV=$(ls *.nsv | wc -l)
FILENUMBER_AVI=$(ls *.avi | wc -l)
FILENUMBER_AUDIO=$(ls *.audio | wc -l)
if [ $FILENUMBER_AVI = $FILENUMBER_NSV ] && [ $FILENUMBER_AUDIO=$FILENUMBER_NSV ]
then
mv *.avi *.audio $NSV2SVCD_ROOT/$WORKPATH/
cd $NSV2SVCD_ROOT/$WORKPATH
rm -r $WORKPATH_NSV
echo -e "All NSV files demuxed\nNSV files deleted\nProceeding to ENCODE status" >> $NSV2SVCD_ROOT/log/$WORKPATH/demuxer
return 0
else
for (( I=1; I <= FILENUMBER_NSV; I++ ))
do
if [ ! -e ${I}.avi ] && [ ! -e ${I}.audio ]
then
FILENAME_NSV=$( ls *.nsv | sed ${I}'!d' )
echo -e "There has been problems processing file $FILENAME_NSV\nCheck $NSV2SVCD_ROOT/log/$WORKPATH/demuxer_${I}_err for any error" >> $NSV2SVCD_ROOT/log/$WORKPATH/demuxer
fi
done
return 1
fi
}

ENCODER() {
cd $NSV2SVCD_ROOT/$WORKPATH
for (( I=1; I <= FILENUMBER_NSV; I++ ))
do
faad ${I}.audio -o ${I}.wav >> $NSV2SVCD_ROOT/log/$WORKPATH/${I}_encoder_audio_out 2>&1
echo "Process #$I: faad exit status= $? " >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
if [ ! -e ${I}.wav ]
then
mv ${I}.wav ${I}.audio
fi
mencoder ${I}.avi -audiofile ${I}.wav -oac mp3lame -srate 44100 -lameopts cbr:br=128 -af lavcresample=44100 -ovc lavc -lavcopts vcodec=mpeg1video:keyint=15:vrc_buf_size=327:vrc_minrate=1152:vbitrate=1152:vrc_maxrate=1152 -of mpeg -mpegopts format=xvcd -vf scale=352:288,harddup -ofps 25 -o ${I}.mpg >> $NSV2SVCD_ROOT/log/$WORKPATH/${I}_encoder_out 2>&1
echo "Process #$I: mencoder exit status= $? " >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
done
FILENUMBER_MPG=$(ls *.mpg | wc -l)
if [ $FILENUMBER_AVI = $FILENUMBER_MPG ] && [ $FILENUMBER_AUDIO=$FILENUMBER_MPG ]
then
rm $NSV2SVCD_ROOT/$WORKPATH/*.avi $NSV2SVCD_ROOT/$WORKPATH/*.audio
echo -e "All avi and audio files muxed\nFiles now will be deleted\nProceeding to MERGE status" >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
return 0
else
for (( I=1; I <= FILENUMBER_NSV; I++ ))
do
if [ ! -e ${I}.mpg ]
then
echo -e "There has been problems processing files ${1}.avi and ${1}.audio\nCheck $NSV2SVCD_ROOT/log/$WORKPATH/encoder_${I}_err for any error" >> $NSV2SVCD_ROOT/log/$WORKPATH/encoder
fi
done
return 1
fi
}

MERGER() {
cd $NSV2SVCD_ROOT/$WORKPATH
mpgfiles2beprocessed=$(ls *.mpg)
mpgtx -j $mpgfiles2beprocessed -o $WORKPATH.mpg >> $NSV2SVCD_ROOT/log/$WORKPATH/merger 2>&1
echo "Merger exit status= $? " >> $NSV2SVCD_ROOT/log/$WORKPATH/merger
if [ -e $WORKPATH.mpg ]
then
mv $WORKPATH.mpg $NSV2SVCD_ROOT/final_mpg_files
cd ..
rm -r $WORKPATH
echo -e "All files merged\nMoving $WORKPATH.mpg to $NSV2SVCD_ROOT/final_mpg_files\nRemoving old files" >> $NSV2SVCD_ROOT/log/$WORKPATH/merger
return 0
else
echo -e "Files couldn't be processed\nCheck $NSV2SVCD_ROOT/log/$WORKPATH/merger for errors" >> $NSV2SVCD_ROOT/log/$WORKPATH/merger
return 1
fi
}

echo -e "This program need these things to work:"
echo -e " - wine (latest possible version), mplayer, faad and mpgtx installed"
echo -e " - NSV files must be placed in dir/subdir respect to program root (it's not important the name of the directories)"
echo -e " So it should be a directory for the program with a subdirectory containing every group of NSV files inside another subdir (/script_root/dir/subdir/*.nsv)"
echo -e " - It's important that no else directories are placed inside the 'work_rooth' and it's important that inside these paths there is no files apart .nsv cause both of these will produce heavy error logs"
echo -e " - Also there are some files in the package with this script that I will copy soon so please don't touch it, just prepare my work with the things above\n"
#echo -n "Now please press Ctrl+C to exit or to continue digit the absolut path where the script should work: "
#read $NSV2SVCD_ROOT
NSV2SVCD_ROOT=/home/pava/temp/week_13
ORIGINAL_PATH=$( pwd )
cd $NSV2SVCD_ROOT
WORKPATHS_LIST=$( ls )
mkdir final_mpg_files
mkdir log
for WORKPATH in $WORKPATHS_LIST
do
mkdir $NSV2SVCD_ROOT/log/$WORKPATH/
for NSV2SVCD_FUNCTIONS in "DEMUXER" "ENCODER" "MERGER"
do
$NSV2SVCD_FUNCTIONS
if [ $? != 0 ]
then
echo "$WORKPATH/$NSV2SVCD_FUNCTIONS: Problems occurred in this process. Check log files">> $NSV2SVCD_ROOT/log/nsv2svcd
else
echo "$WORKPATH/$NSV2SVCD_FUNCTIONS: Everything worked great... maybe!">> $NSV2SVCD_ROOT/log/nsv2svcd
fi
done
done
exit 0
PavalloKazzo is offline   Reply With Quote
Old 26th March 2006, 20:20   #4  |  Link
PavalloKazzo
Registered User
 
Join Date: Mar 2006
Posts: 12
Ok I need some help with mencoder
Seems like it can't manage to make vcd compliant files...
Any help? What about dvds?
PavalloKazzo is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.