Cli conversion hangs when using for loop

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
handbrake_turn
Posts: 4
Joined: Sun Nov 16, 2014 1:22 pm

Cli conversion hangs when using for loop

Post by handbrake_turn »

Hi all,

I have a very simple handbrake loop that I'm trying to use to convert batches of files to .mp4. The script looks like this:

Code: Select all

for video in `ls "/media/TV Shows/Folder With Spaces"`; do $(HandBrakeCLI -v -i '/media/TV Shows/Folder With Spaces/'${video} -o '/media/Downloads/Handbrake Outputs/'${video%.vob}.mp4 -t 1 --angle 1 -f mp4  --loose-anamorphic  --modulus 2 -e x264 -q 22 -r 24 --pfr -a 1 -E faac -6 auto -R Auto -B 128 -D 0 --gain 0 --audio-fallback ffac3 --x264-preset=slow  --x264-tune="film"  --h264-level="4.1"  --verbose=1); done
I'm running this on FreeBSD. The strange thing I'm finding is that if I run the handbrake command on its own (no loop), it works as expected. Whenever I try to run it in the loop, things appear to proceed as normal, but the conversion hangs at:

Code: Select all

x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX XOP FMA4 SSEMisalign LZCNT
x264 [info]: profile High, level 4.1
Normally I would see a progress % below, as I do when running it on its own, but the next line is just blank.

I'm running the loop under the same user, with identical privileges, and all messages shown are the same until I get the hang.

Any ideas what might be causing this?
Last edited by handbrake_turn on Thu Nov 20, 2014 4:25 pm, edited 1 time in total.
handbrake_turn
Posts: 4
Joined: Sun Nov 16, 2014 1:22 pm

Re: Cli conversion hangs when using for loop

Post by handbrake_turn »

As a quick update to this, it appears the problem is actually not as big as I originally thought; HandBrakeCLI isn't hanging, it's actually transcoding but not displaying the progress. No idea why it would do this when it's in a loop (and displays all other messages), when it displays without issue when it's not in a loop.

Is there any way to force a progress update?
mduell
Veteran User
Posts: 8198
Joined: Sat Apr 21, 2007 8:54 pm

Re: Cli conversion hangs when using for loop

Post by mduell »

Progress goes to stdout. The activity log you're seeing goes to stderr.

I'm not familiar enough with your platform to say why stderr is appearing but not stdout.
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: Cli conversion hangs when using for loop

Post by AlBundy »

Try to remove the subshell around the handbrake-call.

Btw. it seems that you current version converts not only test.vob to test.mp4 it converts also test.mp4 to test.mp4.mp4
Post Reply