HandBrakeCLI fails to stop when finished, but that ain't all.

So I have my post processing script up and running and it works perfectly most of the time. But sometimes when the processing is finished HandBrake drops to a single processor and never stops. I have a quad core processor and for some reason HandBrake will continue running on a single processor until I kill it. I also have a postProcessorLock in my script that prevents any other shows from processing until the present one is finished.
This all works about 80% of the time then I get that HandBrake run away. This never happens when using HandBrake alone.

Here’s what my script looks like:

PGMNAME=/usr/bin/HandBrakeCLI
resolution=$(mkvinfo “$1” | grep “Pixel width” | awk '{print 5}') BASEPATH=(dirname "1") BASEFILE=(basename “1") FILENAME="{BASEFILE%%.*}”

while [ -f /tmp/postProcessLock ]
do
sleep 10
done

touch /tmp/postProcessLock

if [ “$resolution” -gt 1280 ]; then

    $PGMNAME -i "$1" -o "$BASEPATH/$FILENAME.mp4" -E copy --width 1280 --height 720 -s 1 --subtitle-burned --preset Normal
    rm /tmp/postProcessLock

else

    $PGMNAME -i "$1" -o "$BASEPATH/$FILENAME.mp4" -E copy -s 1 --subtitle-burned --preset Normal
    rm /tmp/postProcessLock

fi

#rm “$1”

Thanks

Is it the same command that hangs each time (i.e. > 1280 - the one with height and width specified)?

No it can be SD shows also.

I would log the output of handbrake to a file to see if it is doing something using handbrake_cmd >> handbrake.log 2>&1

Here’s what I discovered at the end of HandBrakeCLI That stopped the process at 1 second to go.

Encoding: task 1 of 1, 99.77 % (75.56 fps, avg 82.93 fps, ETA 00h00m01s)[ac3 @ 0x7f65b83ddf60] incomplete frame
[12:04:34] reader: done. 1 scr changes

[12:04:58] sync: got 53882 frames, 53957 expected

THree processors stopped and 1 continued at ETA 00h00m01s Because of an incomplete frame in ac3.

This is an incomplete frame downloaded by HDhomerun and I don’t know what to do about it.

This issue has been around for a few years in handbrake. It’s not always the audio that trips it up. Can be incomplete interlaced frames as well. There have been several work a rounds but I think most people who have these types of issues generally switch to ffmpeg instead of using HB. With ffmpeg the incomplete frames can be ignored which is generally fine at the end of the file.

BTW, are you not deinterlacing your 1080i recordings?

I have tried to use ffmpeg but I can’t figure out the command line option to burn the CC into the .mp4 file I am creating. If anyone could help me with ffmpeg script I would greatly appreciate it.
Please help, I am trying to get this setup for my wife so it will be simple to use when I’m gone and I’m running out of time. I’m not fishing for pity here, just stating a fact. I have been looking at Channel Master DVR’s but I have already purchased two HDHR Connects which will supply 4 tuners. Plus DVR’s have their own problems.

No I am not delnterlacing 1080i, I convert anything > 720 to 720…

Thanks.

Linux OS

CC isn’t supported by Plex so getting that into the MP4 isn’t going to do you any good. What you need to do is convert it to an SRT file which is a true subtitle format. Then Plex can use it.

BTW, not to discourage you, but if you don’t want to go through the pain of getting the script working 100% maybe you should check out the conversion scripts available in my thread in my sig. This will do all you ask for plus a whole lot more.

They’re for Windows, I use Linux

The scripts will work on Mac, Linux or Windows. Just basically need to replace the windows batch file and set the paths correctly. The scripts themselves are Python and will run on any of the 3 operating systems.

Well, I finally got this all worked out using ccextractor to extract the closed captions to .srt files and ffmprg to do the rest of the post-processing. I thank everyone for their help.