CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Perl, Backticks and Handbrake


New User

Oct 28, 2011, 9:32 PM

Post #1 of 3 (2189 views)
Perl, Backticks and Handbrake Can't Post

Hey Guys,

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:

$r = `\"c:/program files (x86)/handbrake/handbrakecli.exe\" -i \"C:/input.mkv\" -t 0`;
print "Printing out the return value...\n\n$r\n\ndone!\n";

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?

Veteran / Moderator

Oct 29, 2011, 6:18 AM

Post #2 of 3 (2129 views)
Re: [fluffybunny] Perl, Backticks and Handbrake [In reply to] Can't Post

Sounds like handbrake is outputting to stderr instead of stdout.

Try using the IPC::Open3 module instead of backticks.


Oct 31, 2011, 5:38 AM

Post #3 of 3 (1828 views)
Re: [fluffybunny] Perl, Backticks and Handbrake [In reply to] Can't Post

In addition to what FishMonger said, the result of the backticks would also be empty, if the program outputs directly to the console (i.e. using <conio> instead of <stdio>).


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives