Project

General

Profile

Post-processing finish alert

Added by Edward Crosby over 7 years ago

Whenever I record I have Handbrake-CLI complete a post-processing conversion for me. Is there a way within TVHeadend I can be notified when that post-processing is done?
If not, I may have to find a way to write script or something to be notified when the CPU jumps to max and when it resumes to normal for the Handbrake-CLI process.


Replies (10)

RE: Post-processing finish alert - Added by Joe User over 7 years ago

Why not just invoke a script for the post-processing which notifies you after it runs Handbrake? Although I am not sure just how you want to be notified??? Email?

Or something more along the lines of and icon in the upcoming/current recordings which shows that post-processing is still taking place?

Or maybe something under status showing post-processing commands/scripts currently running?

Maybe a feature request is in order...

RE: Post-processing finish alert - Added by Edward Crosby over 7 years ago

I've used mutt many times before to send out emails in shell scripts I figure I could probably use that. I'm just not that familiar with Handbrake-CLI to know how to get the information of when the process is done.

RE: Post-processing finish alert - Added by Joe User over 7 years ago

In the Post-processing option, give it the path to a script. In the script, the first line would run handbrake and the second line (which would not run until after handbrake finishes) will send the email. If you want to get fancy, you can check the exit code of handbrake to let you know if it completed successfully or not...

You can look here for an example of a script: [[https://tvheadend.org/issues/4298]]

RE: Post-processing finish alert - Added by Edward Crosby over 7 years ago

Gotcha. I'll play around and see what I can figure out.

RE: Post-processing finish alert - Added by Edward Crosby over 7 years ago

Something doesn't seem to be working right. Here is what I have in the Post-Process of the DVR Profile section:

Here is the script referenced in the image above:


#!/bin/bash
/usr/bin/HandBrakeCLI --input "%f" --output "/home/hts/converted/%b" --preset "High Profile" 2>&1 | tee -a pvrconvert.log
sleep 4
echo "PVR Converted" | mutt -e 'my_hdr From:[email protected]' -s "PVR log" [email protected] -a pvrconvert.log

I have tested that script to run by itself and it works. I'm not sure why the Post-Process isn't launching it.

RE: Post-processing finish alert - Added by Robert Cameron over 7 years ago

It doesn't look like any arguments are being passed to your script. Also, those %f type variables are internal to Tvheadend I believe, and cannot be accessed from within your script; to use them you must pass them explicitly as arguments.

RE: Post-processing finish alert - Added by Joe User over 7 years ago

Yes, Robert is correct. You need to change your Post-processor command to something like:

/home/hts/tvheadend_convert_DRAFT.sh "%f" "%b" 

and then in your script replace "%f" with "$1" and "%b" with "$2"

Again, look at the script I pointed to above as an example - at the top of his script it shows what he used as the Post-processor command.

Also, you may want to add $1 or $2 to the email in the case you have multiple transcodings...

Which leads me to another thought. If you ever have multiple simultaneous transcodings, you should change the name of the logfile to be unique (i.e. maybe at $2.)

RE: Post-processing finish alert - Added by Edward Crosby over 7 years ago

I'm relatively new to scripting so what was going in that referenced link was a little over my head. I tried this:

And changed to this in my script:

#!/bin/bash
/usr/bin/HandBrakeCLI --input "$1" --output "/home/hts/converted/$2" --preset "High Profile" 2>&1 | tee -a pvrconvert$1.log
sleep 4
echo "PVR Converted" | mutt -e 'my_hdr From:[email protected]' -s "PVR log" [email protected] -a pvrconvert$1.log

The conversion completed with no problem but anything after that, even the log creation, did not execute.

RE: Post-processing finish alert - Added by Edward Crosby over 7 years ago

I haven't had the chance to mess around with this more but does anyone know why the conversion completed in the script but nothing else did. At this point I would just be happy with a log creation so that I can see how long the conversion takes.

RE: Post-processing finish alert - Added by Joe User over 7 years ago

You may need full path for mutt.

Also, "$1" contains the whole path, so you can't use it as part of a filename...

You can also add "date" commands. Something like:

#!/bin/bash

date > /home/hts/pvrconvert_$2.log

/usr/bin/HandBrakeCLI --input "$1" --output "/home/hts/converted/$2" --preset "High Profile" 2>&1 | tee -a        /home/hts/pvrconvert_$2.log
sleep 4
echo "PVR Converted" | /usr/bin/mutt -e 'my_hdr From:[email protected]' -s "PVR log" [email protected] -a     /home/hts/pvrconvert_$2.log

date >> /home/hts/pvrconvert_$2.log

Also you have to make sure that the hts user can send email...

    (1-10/10)