Page 1 of 1
Simultaneously post process 2 files
Posted: May 17th, 2010, 11:01 am
by johnnytk36
I know Sabnzbd process files sequentially.
I've searched the wiki and the version .6 trac but i don't see if this option has been added or if there is a way to do it.
I have a post process script that converts some videos using the Handbrake CLI. This can take up to a few hours. What i want to know if there is a Par2 option or a way to make it post process 2 files at once.
What i would really like is the post process script action and the Par2 action to be separate and run side by side.
Re: Simultaneously post process 2 files
Posted: May 17th, 2010, 2:00 pm
by doubledrat
what OS? all you need to do is spawn the process and not wait for it to finish before returning to SAB - sab will then think it's done.
In linux you can do this by putting & on the end of the command that initiates your processing of the video.
in windows you can use the "START" command. Put your video processing in it's own batch file if it's multi line and then in the postproc batch file have
blah
blah
START long_video_processing.bat
blah
blah
that should return to SAB even though the video processing is not finished.
if video proc is single line, just
START handbrake blah blah
Re: Simultaneously post process 2 files
Posted: May 17th, 2010, 2:26 pm
by johnnytk36
I'm using the script found here, modified to work on linux and with my own custom handbrake preset settings.
http://forums.sabnzbd.org/index.php?topic=3562.0
I dont know if just telling it to start would work with this script.
Re: Simultaneously post process 2 files
Posted: May 17th, 2010, 3:59 pm
by doubledrat
if this is called hb.py then create mypostproc.sh with the lines
#!/bin/sh
hb.py &
in it.
this should run hb.py in the background and sab will think the postprocessing is done
Re: Simultaneously post process 2 files
Posted: May 17th, 2010, 4:41 pm
by johnnytk36
I thought about that, but then i run into the problem that if more than one video is being downloaded, i could end up with tons of Handbrake CLI operations running at once.
I was hoping for a Par2 operator, i might have to wait till a later version , i was just hoping to find out if this feature was coming.
Re: Simultaneously post process 2 files
Posted: May 18th, 2010, 8:21 am
by doubledrat
it all depends on how good you are at programming
you could change the handbrake code to read the list of files to process from a file eg myvids.txt.
your postproc job could simply
check the existence of myvids.txt. if it exists, add the filename to this file (echo $filename >> filestoprocess.txt) and exit
if it doesn't exist, add the filename and then run the handbrake script in the background
you'd then need to change your handbrake script to read the filenames from myvids.txt and repeat the process until myvids.txt is empty, then delete it.
either that or you could check for a running handbrake using something like
ps -ef | grep -i handbrake | grep -v grep | wc - l
if that returns 1 then you have handbrake running and you should wait 5 mins and check again
Re: Simultaneously post process 2 files
Posted: May 18th, 2010, 10:47 am
by johnnytk36
Very neat idea. I didn't even think of that.
Thank you
Re: Simultaneously post process 2 files
Posted: May 30th, 2010, 2:48 pm
by johnnytk36
doubledrat wrote:
if this is called hb.py then create mypostproc.sh with the lines
#!/bin/sh
hb.py &
in it.
this should run hb.py in the background and sab will think the postprocessing is done
I just realized if you do this the sab variables wont work in the python script.
example: FINAL_DIRECTORY = len( sys.argv ) >= 2 and sys.argv[1] or "" wont work.
Re: Simultaneously post process 2 files
Posted: May 30th, 2010, 4:43 pm
by doubledrat
if you need the variables, just pass them
hb.py $* &
(I think $* works in linux, if not,
hb.py $1 $2 $3 $4 etc)
Re: Simultaneously post process 2 files
Posted: May 30th, 2010, 11:33 pm
by johnnytk36
Oh you are a life saver, that worked great.
on a side note:
doubledrat wrote:
if this is called hb.py then create mypostproc.sh with the lines
#!/bin/sh
hb.py $1 $2 $3 $4 &
in it.
this should run hb.py in the background and sab will think the postprocessing is done
That isnt running the python script in the background. i still get all the output from the python script.
Re: Simultaneously post process 2 files
Posted: May 31st, 2010, 9:20 am
by doubledrat
that doesn't mean it's not running in the background, if you ended your terminal session the job would continue.
you should redirect standard out and standard error to a file so you can track what's going on. you so this with -
hb.py $1 $2 $3 $4 &> "/tmp/$2.log" &
which will create a unique log file for each job in /tmp
thinking about it, you might need to quote your parameters if they contain spaces-
hb.py "$1" "$2" "$3" "$4" &> "/tmp/$2.log" &
Re: Simultaneously post process 2 files
Posted: May 31st, 2010, 3:17 pm
by johnnytk36
Thanks a lot. I had already added the quotes. I'll try this out and let you know.