I created a script ages ago to loop through an input folder to find movie files then use handbrake to convert them into mkv at a particular bitrate. Recently, I've decided to make it a bit smarter to handle bluray conversion and dynamically adjust the bitrate to suit the source. How I've been doing this is to use backticks and mkvinfo (mkv toolnix) to get the frame size (1920x1080) and use that to calculate a bitrate, then feed that into a handbrake system call.

It's working pretty well, but I've noticed that handbrake automatically crops the output, which would change my bitrate calculation! So I thought that I should use handbrake to tell me what it will crop it to (using backticks) instead of mkvinfo, which is where I ran into drama! If I run a simple script:

I get the backtick command executing and I see the result printed to the screen, but $r is empty! What would cause the backtick return value to be empty? Is there an easier way of doing what I want to do?