Simultaneously post process 2 files

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Simultaneously post process 2 files

Post 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.
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: Simultaneously post process 2 files

Post 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
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Re: Simultaneously post process 2 files

Post 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.
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: Simultaneously post process 2 files

Post 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
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Re: Simultaneously post process 2 files

Post 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.
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: Simultaneously post process 2 files

Post 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
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Re: Simultaneously post process 2 files

Post by johnnytk36 »

Very neat idea. I didn't even think of that.

Thank you
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Re: Simultaneously post process 2 files

Post 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.
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: Simultaneously post process 2 files

Post 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)
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Re: Simultaneously post process 2 files

Post 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.
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: Simultaneously post process 2 files

Post 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" &
johnnytk36
Newbie
Newbie
Posts: 30
Joined: February 28th, 2010, 8:37 pm
Contact:

Re: Simultaneously post process 2 files

Post by johnnytk36 »

Thanks a lot. I had already added the quotes. I'll try this out and let you know.
Post Reply