Is there a good way to tell if HandBrakeCLI actually encoded something?
I am working on a system to convert a bunch of .mov files to H.264 (using HandBrakeCLI) and webm (using ffmpeg) when generating .mov files. In general, everything is going well. I hung up the error detection. I want to know if one of the encodings failed so we can investigate, try again, etc.
To test the encoding error, I copied the text file to a .mov file and installed programs trying to encode it. Naturally they both cannot encode the file (I'm not sure what "success" would mean in this context ...) However, while ffmpeg reports this failure by setting its exit code to 1, HandBrakeCLI sets the exit code to 0, because that he came out clean. This is consistent with the HandBrakeCLI documentation , but it leaves me wondering how I can tell if HandBrakeCLI knows if it was unable to encode anything. The same documentation page suggests "If you want to control the HandBrake process, you must watch out for standard pipes", so now I get the effect I want by doing something like this:
HandBrakeCLI --preset 'Normal' --input bad.mov --output out.mv4 2>&1 | grep 'Encode done'
grep then sets the exit code to 0 if it finds a match, and 1 if it doesn't. But this seems rather barbaric: for example, the text "Encode done!" may change in a future release of HandBrake.
So who has a better way to tell if HandBrake has encoded something or not?
Some edited shell output is below for reference ...
$ ffmpeg -i 'develqueuedir/B_BH_120409.mov' 'develqueuedir/B_BH_120409.webm'
FFmpeg version 0.6.4-4:0.6.4-0ubuntu0.11.04.1, Copyright (c) 2000-2010 the Libav Developers
[snip]
develqueuedir/B_BH_120409.mov: Invalid data found when processing input
$ echo $?
1
$ HandBrakeCLI --preset 'Normal' --maxWidth 720 --optimize --input 'develqueuedir/B_BH_120409.mov' --output 'develqueuedir/B_BH_120409.mv4'
Output format couldn't be guessed from file name, using default.
[11:45:45] hb_init: starting libhb thread
HandBrake 0.9.6 (2012022900) - Linux x86_64 - http://handbrake.fr
Opening develqueuedir/B_BH_120409.mov...
[snip]
[11:45:45] libhb: scan thread found 0 valid title(s)
No title found.
HandBrake has exited.
$ echo $?
0
source to share
The short answer is no, you can find a detailed explanation on the HandBrake forum https://forum.handbrake.fr/viewtopic.php?f=12&t=18559&p=85529&hilit=return+code#p85529
adddition: I think there is a patch from user fonkprop that is being rejected by the devs if you really need it to contact this guy
source to share