olympia Posted May 8, 2010 Share Posted May 8, 2010 I've just started to look into reencode a lot bunch of documentary DVDs I have. @ClunkClunk, thank you for the precompiled packages. My origintal intent was to reencode all the DVDs to mkv with x.264 parameter and whatever quality, but I would like to preserve all the audio tracks in their original format (ie. keep them as they are). It seems that as there is no such parameter, it is not a simple task. I figured that the only way to do this is to do a scan first and then save and parse the output to set the correct number of tracks and formats during the encode. Have somebody experimented something like this yet? Thank you for the feedbacks. Quote Link to comment
ClunkClunk Posted May 9, 2010 Share Posted May 9, 2010 I don't normally use mkv, but I think you can generally always use AC3 passthrough to achieve what you want. How about something like this: HandBrakeCLI -t 1 -f mkv -e x264 -q 20 -a 1 -E ac3 -6 auto -R auto -B auto -m -i SOME_DVD -o Some_DVD.mkv Seems to pass the AC3 through without any re-encodes at all. Quote Link to comment
olympia Posted May 9, 2010 Share Posted May 9, 2010 Thank you for the feedback. Yes, this could potentially work (I think), but the bigger problem is with the number of audio tracks. I want to preserve all, ie. if there is 2 or 3, then all 2 or 3, but of course a general command would needed in a batch process. Unfortunatelly if I set -a 1,2,3 then HB cli is exiting if the input file doesn't exactly has 3 tracks. Means you always have to give the correct number of tracks for this parameter which of course you don't know in a batch process. The scan first, then parse scan results approach was suggested on HB's irc channel, but my scripting knowledge is close to 0, so I am not able to accomplish this... Quote Link to comment
ClunkClunk Posted May 9, 2010 Share Posted May 9, 2010 Ah, yes, I could see how multiple audio tracks could be difficult to deal with. Quote Link to comment
olympia Posted May 18, 2010 Share Posted May 18, 2010 Here it is: for i in /mnt/user/Movies/*.ISO do f=`basename $i .ISO` HandBrakeCLI -i $i -t 1 -o /mnt/disk/hdi1/$f.avi -f avi -p -e ffmpeg -S 700 -a 1 -E lame -B 160 -R 0 -6 dp12 -D 1 -v echo $i done Hi Joe L. Would it be an easy and quick excercise for you to help me out on how to modify your script to be recursive on say a hard coded path and always save the converted file in the same folder as the original iso was? Or that would be more difficult task to just quickly draft it down? Thank you! Quote Link to comment
Joe L. Posted May 18, 2010 Share Posted May 18, 2010 Here it is: for i in /mnt/user/Movies/*.ISO do f=`basename $i .ISO` HandBrakeCLI -i $i -t 1 -o /mnt/disk/hdi1/$f.avi -f avi -p -e ffmpeg -S 700 -a 1 -E lame -B 160 -R 0 -6 dp12 -D 1 -v echo $i done Hi Joe L. Would it be an easy and quick excercise for you to help me out on how to modify your script to be recursive on say a hard coded path and always save the converted file in the same folder as the original iso was? Or that would be more difficult task to just quickly draft it down? Thank you! find /mnt/user -name "*.ISO" -print | while read filename do echo converting $filename f=`basename "$filename" .ISO` d=`dirname "$filename"` HandBrakeCLI -i "$filename" -t 1 -o "$d/$f.avi" -f avi -p -e ffmpeg -S 700 -a 1 -E lame -B 160 -R 0 -6 dp12 -D 1 -v echo $filename completed done This will do it for everything under /mnt/user. If you want a different path, change it where I highlighted it in blue above. It specifically looks for files with a capital .ISO suffix. If yours are lower case, change the .ISO to .iso in both places in the script. The output file is the same name as the input, but with a .avi suffix, and it is stored in the same folder as the .ISO Joe L. Quote Link to comment
olympia Posted May 19, 2010 Share Posted May 19, 2010 Thank you very much Joe L.! As always, you are more than helpful! Cheers, Bence Quote Link to comment
olympia Posted May 20, 2010 Share Posted May 20, 2010 Hi Joe L., I have tried it and seems that at on my end it is only converting the first find of "find /mnt/user -name "*.ISO" -print | while read filename" If I just run the command in itself then it finds all the ISOs recursively in the target dir, but the encode gets done only on the first item with a returned prompt: Rip done! HandBrake has exited. /mnt/user/TargetDir/FirstItem.iso completed root@Tower:/boot/custom/HandBrakeCLI# I haven't modified anything on the script you created. Am I doing something wrong? Quote Link to comment
Joe L. Posted May 20, 2010 Share Posted May 20, 2010 Hi Joe L., I have tried it and seems that at on my end it is only converting the first find of "find /mnt/user -name "*.ISO" -print | while read filename" If I just run the command in itself then it finds all the ISOs recursively in the target dir, but the encode gets done only on the first item with a returned prompt: Rip done! HandBrake has exited. /mnt/user/TargetDir/FirstItem.iso completed root@Tower:/boot/custom/HandBrakeCLI# I haven't modified anything on the script you created. Am I doing something wrong? I can't tell what you typed from here. It will probably type that handbrake has finished after every iso file. Did you use an editor that did NOT put carriage returns at the ends of lines when you edited the set of commands to change iso to lower case? If not, that might be your issue. Use the "fromdos" command as described in the wiki to fix the script if that is the case. If you type find /mnt/user -name "*.ISO" -print it will print what it would convert. If you add an echo in front of the handbrake command, (in blue below) it will print to the screen the commands it would invoke (instead of invoking them) find /mnt/user -name "*.ISO" -print | while read filename do echo converting $filename f=`basename "$filename" .ISO` d=`dirname "$filename"` echo HandBrakeCLI -i "$filename" -t 1 -o "$d/$f.avi" -f avi -p -e ffmpeg -S 700 -a 1 -E lame -B 160 -R 0 -6 dp12 -D 1 -v echo $filename completed done Quote Link to comment
olympia Posted May 21, 2010 Share Posted May 21, 2010 I can't tell what you typed from here. It will probably type that handbrake has finished after every iso file. Did you use an editor that did NOT put carriage returns at the ends of lines when you edited the set of commands to change iso to lower case? If not, that might be your issue. Use the "fromdos" command as described in the wiki to fix the script if that is the case. If you type find /mnt/user -name "*.ISO" -print it will print what it would convert. If you add an echo in front of the handbrake command, (in blue below) it will print to the screen the commands it would invoke (instead of invoking them) find /mnt/user -name "*.ISO" -print | while read filename do echo converting $filename f=`basename "$filename" .ISO` d=`dirname "$filename"` echo HandBrakeCLI -i "$filename" -t 1 -o "$d/$f.avi" -f avi -p -e ffmpeg -S 700 -a 1 -E lame -B 160 -R 0 -6 dp12 -D 1 -v echo $filename completed done Sorry Joe L., obviously I didn't expect you to see exactly what's wrong here. I just use the wrong expression. ...and I wasn't so clear either. I meant, when I run "find /mnt/user -name "*.ISO" -print " command separately, then all the ISOs found recursively in the target folder. Now I've tried the "Echo" debug step to check what the script would invoke and it also looks perfect, it lists the command for all the ISOs, but when I actually run the script, it's still exiting after the first ISO. So the script is perfect, thank you for this again, the problem is on my end, now it's my turn to do my homework and try to figure out what's going on here. Thank you! Quote Link to comment
olympia Posted May 25, 2010 Share Posted May 25, 2010 I am really not able to figure this out. I have tried many combinatation without success. If I copy over a few ISOs to a single dir and using your very original script from the first page, then it works perfectly and convert all the ISOs in the dir. But if I put the same ISOs to a subdir and running the script above, then it always only convert the ISO in the first dir. More weirdly, if I put the echo command before the Handbrake command line, then if I run the script it is correctly listing the Handbrake command for all the ISOs in all the subdirs. I've also noticed, that in the first case (when all the ISOs are in the same dir and I am using the original script), if I hit ctrl-c to cancel the script, it is only canceling the current convert and the script starts the next one in the queue, so I have to hit ctrl-c as many ISOs are in the queue. In case I use the "new" script on a subdirs structure, if I hit ctrl-c, the script exits immediately (it is not starting the next ISO in the queue). Is this something coming for the different behaviour of for and while? Quote Link to comment
Joe L. Posted May 25, 2010 Share Posted May 25, 2010 Ok... Try this Run the command as shown previously with the "echo" preceeding the handbrake command but capture the output in a file like this: [pre] cp /dev/null /tmp/iso_hb find /mnt/user -name "*.ISO" -print | while read filename do echo converting $filename f=`basename "$filename" .ISO` d=`dirname "$filename"` echo HandBrakeCLI -i "$filename" -t 1 -o "$d/$f.avi" -f avi -p -e ffmpeg -S 700 -a 1 -E lame -B 160 -R 0 -6 dp12 -D 1 -v | tee -a /tmp/iso_hb echo $filename completed done [/pre] When the command runs, you will have a file in /tmp named iso_hb containing all the individual handbrake commands to be run to convert your files. You can then just execute that file of commands with chmod +x /tmp/iso_hb /tmp/iso_hb My best guess is you are running out of memory when running in a loop. Quote Link to comment
KermitJr Posted May 26, 2010 Share Posted May 26, 2010 Hi all, Just installed this on 4.5.4 (unmenu installed) and it worked great... or so I thought! The image is blurry around any movement and the sound is static/garbled. Handbrake svn3284 Any thoughts or other options? I have a bunch of iso I want to convert to avi/mp4 I just used the stock HandBrakeCLI -i 01.iso -o 01.mp4 Thanks! KermitJr Quote Link to comment
ClunkClunk Posted May 26, 2010 Share Posted May 26, 2010 Try the Universal preset, just to make sure it's not the default preset that's causing problems: HandBrakeCLI -Z Universal -i 01.iso -o 01.mp4 Quote Link to comment
olympia Posted May 27, 2010 Share Posted May 27, 2010 Ok... Try this ... My best guess is you are running out of memory when running in a loop. Thanks Joe L.! Sorry for the late reponse, but I am abroad for a week with very limited access to Internet. I will try out your suggestion when I am back at home. (Concerning the memory issue, I think 3GB should be enough for my test dir with only 3 ISOs , so I guess there has to be something else). Thank you again! Quote Link to comment
Joe L. Posted May 27, 2010 Share Posted May 27, 2010 Ok... Try this ... My best guess is you are running out of memory when running in a loop. Thanks Joe L.! Sorry for the late reponse, but I am abroad for a week with very limited access to Internet. I will try out your suggestion when I am back at home. (Concerning the memory issue, I think 3GB should be enough for my test dir with only 3 ISOs , so I guess there has to be something else). Thank you again! with only three, you might agree, BUT are any of the three ISO images over 3GB in size? Remember, they are being read into memory as they are being converted, and the disk buffers will use up nearly all the available memory. As handbrake reads in a .ISO, it might leave far less free memory than you might think. Joe L. Quote Link to comment
olympia Posted May 28, 2010 Share Posted May 28, 2010 Hi Joe L., Still from abroad, but I had some time and connection to try it out, and now I am even more confused. It seems that this way, not only the handbrake command for the first ISO gets written to /tmp/iso_hb (as I would expect from the above), but for the last ISO. For me it doesn't make any sense and I feel really like a dumb, but please see the attached screenshot. The script lists all the 3 iso files I have in that test dir, but it only writes the handbrake command for the last to /tmp/hb_iso I hope everyrhing will be visible on the screenshot. Quote Link to comment
Joe L. Posted May 28, 2010 Share Posted May 28, 2010 Hi Joe L., Still from abroad, but I had some time and connection to try it out, and now I am even more confused. It seems that this way, not only the handbrake command for the first ISO gets written to /tmp/iso_hb (as I would expect from the above), but for the last ISO. For me it doesn't make any sense and I feel really like a dumb, but please see the attached screenshot. The script lists all the 3 iso files I have in that test dir, but it only writes the handbrake command for the last to /tmp/hb_iso I hope everyrhing will be visible on the screenshot. my fault. You would need to use tee -a /tmp/iso_hb adding the "-a" option to have it append to the same file each time it is invoked, otherwise, it overwrites the file each time. That is why you only see the last file processed. But then, if you run it again, you'll either need to delete the first file contents or you'll see them too with the subsequent runs of handbrake appended. Quote Link to comment
olympia Posted May 28, 2010 Share Posted May 28, 2010 That was it Joe L.! Thank you very much! It works perfectly this way. Now, just out of curiosity: if this is a memory issue, shouldn't it happen also with your original script when all the ISOs are in the same dir? Quote Link to comment
olympia Posted October 31, 2010 Share Posted October 31, 2010 Hey ClunkClunk, Do you have a recent handbrakecli SVN revision packaged to unRAID by any chance? Quote Link to comment
ClunkClunk Posted November 1, 2010 Share Posted November 1, 2010 olympia, working on that right now. Should be done in a little bit. Just a few notes to myself so next time I don't have to re-research this again: To configure, then compile HandBrake in CLI only (no more GUI errors): ./configure --launch --disable-gtk Quote Link to comment
ClunkClunk Posted November 1, 2010 Share Posted November 1, 2010 Here's SVN 3635: http://www.clunkclunk.com/HandBrakeCLI-svn3635-unraid.tgz I haven't tested it much, but it's built using the same methods as previous ones, so it should be okay. Please let me know if there's any issues. Quote Link to comment
olympia Posted November 2, 2010 Share Posted November 2, 2010 Here's SVN 3635: http://www.clunkclunk.com/HandBrakeCLI-svn3635-unraid.tgz I haven't tested it much, but it's built using the same methods as previous ones, so it should be okay. Please let me know if there's any issues. Thank you very much. Works perfectly! Quote Link to comment
tola5 Posted December 6, 2010 Share Posted December 6, 2010 hi I try to rip my Simpsons to m4v, I like to keep the max size to 200mb but I cant get it to work what do I wrong the size kepp geting to 300mb HandBrakeCLI -i /var/tmp/mnt/SIMPSONS\ SEASON1\ DISC1/ -t 1 -o /mnt/disk5/Ipad-video/SimpsonsS01E01.m4v -e x264 --size 200 -a 1,1 -E faac,ac3 -B 160,auto -R 48,Auto -6 dpl2,auto -f mp4 -X 720 -m -x level=30:cabac=0:ref=3:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1 -s 1 --subtitle-burn 1 Quote Link to comment
ClunkClunk Posted December 6, 2010 Share Posted December 6, 2010 tola, this isn't really the best place for support with HandBrake (you should probably post on the HandBrake forums), but I think what's happening is two things: • the --size parameter is only the video size, not inclusive of audio. Setting it to 200 means the video will take up 200mb, but audio streams are based on their own settings. • you're including ac3 audio and aac audio, which is resulting in probably ~100mb of audio data, pushing your filesize to that 300 mark. I'd try setting the --size parameter to about 175, then getting rid of the ac3 stream, and maybe even dropping the bitrate of the aac stream to 128kbit. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.