LinHES Forums http://forum.linhes.org/ |
|
NUV2ISO improved http://forum.linhes.org/viewtopic.php?f=17&t=6839 |
Page 1 of 1 |
Author: | Massif [ Tue Nov 08, 2005 6:19 pm ] |
Post subject: | NUV2ISO improved |
I've done a major overhaul of Dale Gass's nuv2iso. Original : http://www.parker1.co.uk/mythtv/nuv2iso The original version take a list of MPEG4 encoded nuv files, replexes them to DVD compatible mpeg2 and then uses dvdauthor and mkisofs to create the dvd structured iso file. My version of the script: 1. takes in mpeg2 encoded nuv files (which replex didn't seem to like) 2. demuxes the video and audio with tcextract 3. re-encodes the audio with ffmpeg (mp2 -> mp2) 4. calculates whether all the videos and audio that you listed will fit on a 4.7GB disc 5. shrinks the video portions by a calculated factor so that everything will fit nicely 6. fixes any offset problems caused by using commercial_cut to remove commercials (just tested and it works) 7. remultiplexes the video and audio 8. creates the dvd structure 9. removes all the temporary files Most of the programs I used were on my distro by default. Check to make sure you also have them. Once I've got the actual encoding and syncing nailed down, I'm also going to add in automated dvd menu creation. Currently the dvd just plays the videos one after another with no menus. Code: #!/bin/bash
# Run mythlink to create links to recorded programs TVDIR=/video/tv DVDDIR=/video/dvd TMPDIR=$DVDDIR/DVD ISONAME=$(basename $1 | sed 's/\.nuv/.iso/' | sed 's/\.mpg/.iso/') DVDSIZE=4700000000 VIDSIZE=0 AUDSIZE=0 #-------------------------------------------------------------------------- doreplex() { for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') vidfile=$(basename $file | sed 's/\.nuv/.m2v/') audfile=$(basename $file | sed 's/\.nuv/.mp2/') eaudfile=$(basename $file | sed 's/\.nuv/2.mp2/') if [ ! -f $TVDIR/$vidfile ]; then echo "Extracting video from $file" tcextract -i $TVDIR/$file -t vob -x mpeg2 > $vidfile fi if [ ! -f $TVDIR/$audfile ]; then echo "Extracting audio from $file" tcextract -i $TVDIR/$file -a 0 -x mp3 > $audfile fi if [ ! -f $TVDIR/$eaudfile ]; then echo "Re-encoding audio" ffmpeg -vn -ab 256 -ar 48000 -ac 2 -acodec mp2 -i $audfile -vn -ab 256 -ar 48000 -ac 2 -acodec mp2 $eaudfile fi VSIZE=`ls -la | grep $vidfile | awk 'END { print $5 }'` ASIZE=`ls -la | grep $eaudfile | awk 'END { print $5 }'` VIDSIZE=$[VIDSIZE+VSIZE] AUDSIZE=$[AUDSIZE+ASIZE] done echo "Total video size: $VIDSIZE" echo "Total audio size: $AUDSIZE" if [ $[VIDSIZE+AUDSIZE] -ge $DVDSIZE ]; then echo "File size too large, resizing videos..." echo "Calculating resize factor for a $DVDSIZE byte DVD" reqfactor=$(echo "scale=2; $VIDSIZE/($DVDSIZE-$AUDSIZE)*1.04" | bc) echo "Resize factor: $reqfactor" for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') vidfile=$(basename $file | sed 's/\.nuv/.m2v/') svidfile=$(basename $file | sed 's/\.nuv/2.m2v/') audfile=$(basename $file | sed 's/\.nuv/.mp2/') eaudfile=$(basename $file | sed 's/\.nuv/2.mp2/') echo "Resizing $vidfile" tcrequant -i $vidfile -o $svidfile -f $reqfactor echo "Calculating offset between video and audio" PTSb=`tcprobe -i $file | grep PTS | awk '{ print $1 }' | sed 's/PTS=//' | sed 's/,//'` PTSv=`echo $PTSb | awk '{ print $1 }'` PTSa=`echo $PTSb | awk '{ print $2 }'` PTSoff=$(echo "scale=4; $PTSv-$PTSa" | bc)s echo "Offset amount: $PTSoff" echo "Re-multiplexing video and audio" mplex -f 8 -O $PTSoff -o $DVDDIR/$outfile $svidfile $eaudfile echo "Removing temporary files" rm -f $vidfile rm -f $audfile rm -f $eaudfile rm -f $svidfile done else echo "File size is OK. No need to resize." for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') vidfile=$(basename $file | sed 's/\.nuv/.m2v/') eaudfile=$(basename $file | sed 's/\.nuv/2.mp2/') echo "Calculating offset between video and audio" PTSb=`tcprobe -i $file | grep PTS | awk '{ print $1 }' | sed 's/PTS=//' | sed 's/,//'` PTSv=`echo $PTSb | awk '{ print $1 }'` PTSa=`echo $PTSb | awk '{ print $2 }'` PTSoff=$(echo "scale=4; $PTSv-$PTSa" | bc)s echo "Offset amount: $PTSoff" echo "Re-multiplexing video and audio" mplex -f 8 -O $PTSoff -o $DVDDIR/$outfile $vidfile $eaudfile echo "Removing temporary files" rm -f $vidfile rm -f $audfile rm -f $eaudfile done fi } #-------------------------------------------------------------------------- # Get the list of files generated by replex getmpglist() { for file in $*; do echo $DVDDIR/$file | sed 's/\.nuv/.mpg/' done } #-------------------------------------------------------------------------- doreplex $* # Create the temporary directory if [ -d $TMPDIR ]; then rm -r $TMPDIR fi mkdir $TMPDIR MPGLIST=$(getmpglist $*) echo "Creating DVD structure" dvdauthor -o $TMPDIR $MPGLIST echo "Creating DVD table of contents" dvdauthor -T -o $TMPDIR echo "Creating ISO" mkisofs -dvd-video -udf -r -o $DVDDIR/$ISONAME $TMPDIR echo "Removing .mpg files" for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') rm -f $DVDDIR/$outfile done |
Author: | drose12 [ Wed Nov 09, 2005 9:21 pm ] |
Post subject: | |
Great job! Any thoughts about creating DVD menus? ![]() |
Author: | Massif [ Thu Nov 10, 2005 1:14 am ] |
Post subject: | |
Yeah, that will be the next portion. I'm going to try to use the png files from each video as the buttons. I don't know if that's possible...we'll see... Eventually I'd also like to be able to control it all from the mythtv interface, but I don't know exactly what that would entail. I think the menus are done in XML or something. |
Author: | Greg Frost [ Thu Nov 10, 2005 10:08 pm ] |
Post subject: | |
WHy are you bothering with this when there are already 2 dvd burning programs that come pre-installed with KnoppMyth? Surely it would be better if we decided as a community which one looked more promising and concentrated on that one. I already invested a heap of effort into nuv2disc because I thought the decision had been made because at the time, it was the only dvd burning program that came with knoppmyth. Now the mythburn scripts are included too and they have some concrete benefits over nuv2disc (handles MPEG-TS DVB streams). It seems to me it already does most of what you want and is also lacking a mythtv interface. It just seems to me that the scattergun approach is failing to deliver. We should have a good think about where we should be concentrating our efforts. |
Author: | Liv2Cod [ Thu Nov 10, 2005 11:59 pm ] |
Post subject: | |
You know, the one thing that no one has managed (so far as I know) is to record a HIGH DEF show to DVD. I have lots of programs I'd like to convert from 1080i or 720p down to DVD resolution and save on a DVD, but there isn't any solution that does that. So I'm stuck copying over 8GB files to a Windoze computer and using Nero and other tools. And it sucks. So I keep hoping someone who knows a lot more than I do (which is probably most people) comes up with a high-def solution to the DVD problem. |
Author: | Greg Frost [ Fri Nov 11, 2005 3:22 am ] |
Post subject: | |
Liv2Cod wrote: So I keep hoping someone who knows a lot more than I do (which is probably most people) comes up with a high-def solution to the DVD problem.
Have you seen this? I think Avisynth which seems to be the key is a windows app, but you can get source code from sourceforge. http://www.videohelp.com/forum/viewtopic.php?p=1397406 Or perhaps projectx/cinelerra (http://heroinewarrior.com/cinelerra/cinelerra.html#1080%20TO%20480)? Projectx does demux your streams, right? |
Author: | Massif [ Fri Nov 11, 2005 9:52 am ] |
Post subject: | |
Quote: WHy are you bothering with this when there are already 2 dvd burning programs that come pre-installed with KnoppMyth?
Well, I didn't make it specifically for KnoppMyth. It works on any distro as long as they have the other programs required. Since it's just a single bash script, it's pretty portable. I've just downloaded nuv2disc and I'm checking it out. It looks to be pretty robust, but I'm wondering why it uses eboxy as its frontend? Why not just create a new menu in the MythTV interface? |
Author: | jams [ Fri Nov 11, 2005 2:31 pm ] |
Post subject: | |
Quote: Well, I didn't make it specifically for KnoppMyth. It works on any distro as long as they have the other programs required. The same can be said for nuv2disc. Quote: I'm wondering why it uses eboxy as its frontend?
Because the author of nuv2disc didn't want to spend time learning more C++. |
Author: | Massif [ Sat Nov 19, 2005 12:23 pm ] |
Post subject: | |
My other main reason for doing this was that I wanted a single script DVD making solution. I don't intend to make it anywhere near as functional as nuv2disc. I guess this is specifically tailored to my needs, but I figured I would share it with anyone else who's interested. So here is the new version. It now has a menu with up to 6 videos. I picked 6 because it fits nicely onto the menu and also six 30 minute shows fit pretty well onto a 4.7GB DVD. Everything is now integrated into the script so there's no need to download any extra files. This assumes that you have used mythlink to make symbolic links to your nuv files, and that the original nuv files are located in /video directory. I altered mythlink a little so I will also post the slightly altered code for that. I used a lot of actual numbers rather than variables (eg. 720x480 for NTSC, sorry PAL users) but I may fix it a bit later on. Code: #!/bin/bash # Run mythlink to create links to recorded programs TMPDIR=DVD ISONAME=$(basename $1 | sed 's/\.nuv/.iso/' | sed 's/\.mpg/.iso/') DVDSIZE=4700000000 VIDSIZE=0 AUDSIZE=0 #-------------------------------------------------------------------------- doreplex() { for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') vidfile=$(basename $file | sed 's/\.nuv/.m2v/') audfile=$(basename $file | sed 's/\.nuv/.mp2/') eaudfile=$(basename $file | sed 's/\.nuv/2.mp2/') if [ ! -f $vidfile ]; then echo "Extracting video from $file" tcextract -i $file -t vob -x mpeg2 > $vidfile fi if [ ! -f $audfile ]; then echo "Extracting audio from $file" tcextract -i $file -a 0 -x mp3 > $audfile fi if [ ! -f $eaudfile ]; then echo "Re-encoding audio" ffmpeg -vn -ab 256 -ar 48000 -ac 2 -acodec mp2 -i $audfile -vn -ab 256 -ar 48000 -ac 2 -acodec mp2 $eaudfile fi VSIZE=`ls -la | grep $vidfile | awk 'END { print $5 }'` ASIZE=`ls -la | grep $eaudfile | awk 'END { print $5 }'` VIDSIZE=$[VIDSIZE+VSIZE] AUDSIZE=$[AUDSIZE+ASIZE] done echo "Total video size: $VIDSIZE" echo "Total audio size: $AUDSIZE" if [ $[VIDSIZE+AUDSIZE] -ge $DVDSIZE ]; then echo "File size too large, resizing videos..." echo "Calculating resize factor for a $DVDSIZE byte DVD" reqfactor=$(echo "scale=2; $VIDSIZE/($DVDSIZE-$AUDSIZE)*1.04" | bc) echo "Resize factor: $reqfactor" for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') vidfile=$(basename $file | sed 's/\.nuv/.m2v/') svidfile=$(basename $file | sed 's/\.nuv/2.m2v/') audfile=$(basename $file | sed 's/\.nuv/.mp2/') eaudfile=$(basename $file | sed 's/\.nuv/2.mp2/') echo "Resizing $vidfile" tcrequant -i $vidfile -o $svidfile -f $reqfactor echo "Calculating offset between video and audio" PTSb=`tcprobe -i $file | grep PTS | awk '{ print $1 }' | sed 's/PTS=//' | sed 's/,//'` PTSv=`echo $PTSb | awk '{ print $1 }'` PTSa=`echo $PTSb | awk '{ print $2 }'` PTSoff=$(echo "scale=4; $PTSv-$PTSa" | bc)s echo "Offset amount: $PTSoff" echo "Re-multiplexing video and audio" mplex -f 8 -O $PTSoff -o $outfile $svidfile $eaudfile echo "Removing temporary files" rm -f $vidfile rm -f $audfile rm -f $eaudfile rm -f $svidfile done else echo "File size is OK. No need to resize." for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') vidfile=$(basename $file | sed 's/\.nuv/.m2v/') eaudfile=$(basename $file | sed 's/\.nuv/2.mp2/') echo "Calculating offset between video and audio" PTSb=`tcprobe -i $file | grep PTS | awk '{ print $1 }' | sed 's/PTS=//' | sed 's/,//'` PTSv=`echo $PTSb | awk '{ print $1 }'` PTSa=`echo $PTSb | awk '{ print $2 }'` PTSoff=$(echo "scale=4; $PTSv-$PTSa" | bc)s echo "Offset amount: $PTSoff" echo "Re-multiplexing video and audio" mplex -f 8 -O $PTSoff -o $outfile $vidfile $eaudfile echo "Removing temporary files" rm -f $vidfile rm -f $audfile rm -f $eaudfile done fi } #-------------------------------------------------------------------------- # Get the list of files generated by replex getmpglist() { for file in $*; do echo $file | sed 's/\.nuv/.mpg/' done } #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # Create the thumbnail images for dvd menu makemenu() { PICLIST="" WHITELIST="" REDLIST="" for file in $*; do realimg=`ls -la | grep $file | sed 's/.*\/video\//\/video\//' | sed 's/\.nuv/\.nuv\.png/'` echo "text 7,7 \"$(getname $file)\"" > fname convert $realimg -fill "#ffffff" -draw '@fname' $file.png rm -f fname PICLIST="$PICLIST $file.png" WHITELIST="$WHITELIST whitemask.png" REDLIST="$REDLIST redmask.png" done # Creating menu images montage -background transparent -frame 6 -geometry +21+54 $PICLIST menu.png for pic in $PICLIST; do rm -f $pic done convert -size 720x480 xc:transparent png:- | composite -compose Over -gravity Center menu.png - menu2.png convert -size 720x480 -density 81x72 xc:black png:menuBG.png composite -compose Over -gravity Center menu2.png menuBG.png menu3.png mogrify -depth 8 menu3.png # Create empty menu audio dd if=/dev/zero bs=4 count=2000 | lame -b 128 -s 48 /dev/stdin menu.mp3 ffmpeg -vn -ab 128 -ar 48000 -ac 2 -acodec mp2 -i menu.mp3 -vn -ab 128 -ar 48000 -ac 2 -acodec mp3 menu.mp2 # Creating menu mpeg png2yuv -n 50 -I p -f 29.97 -j menu3.png | mpeg2enc -n n -f 8 -o menu.m2v mplex -f 8 -o menu.mpg menu.m2v menu.mp2 # Creating menu masks convert -size 720x480 xc:transparent -density 81x72 png:transparent.png convert -size 214x240 xc:transparent -density 81x72 -units PixelsPerInch -fill white -draw 'line 20,53 20,188 line 21,54 21,187 line 20,53 195,53 line 21,54 194,54 line 21,187 194,187 line 20,188 195,188 line 194,54 194,187 line 195,53 195,188' whitemask.png convert -size 214x240 xc:transparent -density 81x72 -units PixelsPerInch -fill red -draw 'line 20,53 20,188 line 21,54 21,187 line 20,53 195,53 line 21,54 194,54 line 21,187 194,187 line 20,188 195,188 line 194,54 194,187 line 195,53 195,188' redmask.png montage -background transparent -geometry 214x240 $WHITELIST whitemon.png montage -background transparent -geometry 214x240 $REDLIST redmon.png convert -size 720x480 xc:transparent png:- | composite -compose Over -gravity Center whitemon.png - white.png convert -size 720x480 xc:transparent png:- | composite -compose Over -gravity Center redmon.png - red.png echo "<subpictures><stream><spu force=\"yes\" start=\"00:00:00.00\" image=\"transparent.png\" select=\"white.png\" highlight=\"red.png\" autooutline=\"infer\" outlinewidth=\"6\" autoorder=\"rows\"></spu></stream></subpictures>" > menu.xml spumux menu.xml < menu.mpg > menu_final.mpg MPGLIST=$(getmpglist $*) i=0 for file in $MPGLIST; do i=$[$i+1] echo "<button>jump title $i;</button>" >> buttons.xml echo "<titleset><titles><pgc><post>call vmgm menu 1;</post><vob file=\"$file\" /></pgc></titles></titleset>" >> titles.xml done dvdheader="<dvdauthor dest=\"DVD\"><vmgm><menus><pgc>" dvdfooter="</dvdauthor>" dvdmiddle="<vob file=\"menu_final.mpg\" pause=\"inf\" /></pgc></menus></vmgm>" echo $dvdheader >> dvd.xml cat buttons.xml >> dvd.xml echo $dvdmiddle >> dvd.xml cat titles.xml >> dvd.xml echo $dvdfooter >> dvd.xml echo "Removing temporary files" rm -f buttons.xml rm -f titles.xml rm -f menu.xml rm -f menu.png rm -f menuBG.png rm -f menu2.png rm -f menu3.png rm -f menu.m2v rm -f menu.mp3 rm -f menu.mp2 rm -f menu.mpg } #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # Get the proper showname for menu getname() { ls | grep $* | sed 's/[0-9]*_//' | sed 's/\.nuv//' | sed 's/\([^_]*\)\(_\)\([^_]*\)\(_\)\([^_]*\)\(_\)/\1\2\3\4\5\n/g' | sed 's/_/ /g' | sed 's/-/\n/g' } #-------------------------------------------------------------------------- doreplex $* # Create the temporary directory if [ -d $TMPDIR ]; then rm -r $TMPDIR fi mkdir $TMPDIR makemenu $* echo "Creating DVD structure" dvdauthor -o $TMPDIR -x dvd.xml echo "Creating ISO" mkisofs -dvd-video -udf -r -o $ISONAME $TMPDIR echo "Removing temporary files" rm -f menu_final.mpg rm -f dvd.xml for file in $*; do outfile=$(basename $file | sed 's/\.nuv/.mpg/') rm -f $outfile done And here's the altered mythlink code: Code: #!/bin/sh
# mythlink.sh - Symlinks mythtv files to more readable versions # by Dale Gass if [ ! -d /video/tv ]; then mkdir /video/tv; fi rm -f /video/dvd/*.nuv echo "Done RM" mysql -uroot -p mythconverg -B --exec "select chanid,starttime,endtime,title,subtitle from recorded;" >/tmp/mythlink.$$ perl -w -e ' my $mythpath= "/video"; my $altpath= "/video/dvd"; if (!-d $altpath) { mkdir $altpath or die "Failed to make directory: $altpath\n"; } <>; while (<>) { chomp; my ($chanid,$start,$end,$title,$subtitle) = split /\t/; $start =~ s/[^0-9]//g; $end =~ s/[^0-9]//g; $subtitle = "" if(!defined $subtitle); my $ofn = "${chanid}_${start}_${end}.nuv"; do { print "Skipping $mythpath/$ofn\n"; next } unless -e "$mythpath/$ofn"; $start =~ /^....(........)/; #my $nfn = "$1_${title}_${subtitle}"; my $nfn = "$1_${title}"; if ($subtitle) {$nfn="${nfn}-${subtitle}"} $nfn =~ s/ /_/g; $nfn =~ s/&/+/g; $nfn =~ s/[^+0-9a-zA-Z_-]+/_/g; $nfn = "${nfn}.nuv"; print "Creating $nfn\n"; unlink "$altpath/$nfn" if(-e "$altpath/$nfn"); symlink "$mythpath/$ofn", "$altpath/$nfn" or die "Failed to create symlink $altpath/$nfn: $!"; } ' /tmp/mythlink.$$ rm /tmp/mythlink.$$ |
Author: | spit2k1 [ Wed Nov 23, 2005 9:15 am ] |
Post subject: | |
Hi. Dont forget that theres also MythBurn software thats included in all newer Knoppmyth installations! Do your scripts above cope with PAL DVD's - these screen resolutions dont look correct to me?!? Regards |
Author: | Massif [ Wed Nov 23, 2005 10:35 am ] |
Post subject: | |
Currently it's only for NTSC. I have to parameterize the resolution to allow for easier changing. As for MythBurn, I'm not trying to compete with it. I'm running Fedora so I don't have MythBurn by default. I'd rather use a script than install a whole package anyway. |
Author: | spit2k1 [ Fri Nov 25, 2005 7:18 am ] |
Post subject: | |
Massif wrote: As for MythBurn, I'm not trying to compete with it. I'm running Fedora so I don't have MythBurn by default. I'd rather use a script than install a whole package anyway.
I'm only teasing you! ![]() Mythburn is completely script based - theres no huge install and the latest versions are just as simple as running install.sh ! |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |