Hi Rob,

I've set it up just as you recommended. I also opened up the module file it
did seem that I was trying to look for a value it was not returning,
however, I could not really test if it was working or not. I could not debug
it. To me, it seemed even a little advanced. The file was not created in the
end, and the script ended far too quickly to have actually even attempted to
run ffmpeg it seems. Or maybe the options change, because as far I know,
with my brief experience with ffmpeg, the command line options change from
version to version, a lot. I'm supposin that could be a cause too.

Thank you for your help,

Nasser

On Sun, Mar 23, 2008 at 8:08 PM, Rob Dixon <[EMAIL PROTECTED]> wrote:

> Nasser wrote:
> > Hello,
> > I've written a little perl script based on the example at the
> > FFmpeg::Command cpan page. The code is as follows:
>
> Always
>
> use strict;
> use warnings;
>
> and declare all of your variables using 'my' close to their point of
> use. That will stop a lot of simple errors from occurring.
>
> > use FFmpeg::Command;
> > use Carp;
>
> Why are you using Carp here? A call to die should be sufficient.
>
> > $input_file = "/tmp/NS051.avi";
> > print "Input file: $input_file\n";
> >
> > $output_file = "/tmp/NS051.m4v";
> > print "Output file: $output_file\n";
> >
> > print "Creating new ffmpeg command instance...";
> > $ffmpeg = FFmpeg::Command->new('/usr/local/bin/ffmpeg') || die("unable
> > to create instance.\n");
> > print "success.\n";
> >
> > print "Setting up file input options...";
> > $ffmpeg->input_options({file => $input_file}) || Carp::cluck "unable
> > to set options:\n";
>
> Looking at the documentation for this module, it doesn't say anything
> about the methods' return values anywhere. Why do you think it will
> return a true value for success?
>
> > print "done.\n";
> >
> > print "Setting up the timeout to 300 seconds...";
> > $ffmpeg->timeout(300) || Carp::cluck("unable to set timeout.\n");;
> > print "done.\n";
> >
> > #convert a video into ipod playable format.
> > print "Setting up the file output options...";
> > $ffmpeg->output_options({file => $output_file,device => 'ipod'}) ||
> > Carp::cluck("unable to set options.\n");;
> > print "done.\n";
> >
> > print "Executing the ffmpeg command, with the selected options...";
> > $ffmpeg->exec() || die("unable to execute.\n");
> > print "completed.\n"
> > exit;
> >
> > ------
> > When I run it, I get this:
> >
> > Input file: /tmp/NS051.avi
> > Output file: /tmp/NS051.m4v
> > Creating new ffmpeg command instance...success.
> > unable to set options:
> >  at /home/rock/bin/shazam line 20
> > Setting up file input options...done.
> > Setting up the timeout to 300 seconds...done.
> > unable to set options.
> >  at /home/rock/bin/shazam line 32
> > Setting up the file output options...done.
> > Executing the ffmpeg command, with the selected options...unable to
> > execute.
> >
> > -----
> > Now what I don't understand is why I get the "unable to set options:"
> > before "Setting up file input options" even though in the script the
> > later should have been executed before, so the error message should at
> > least have appeared after the "Setting up file input options".
>
> You are buffering the output to STDOUT, and it will only get flushed
> when the buffer is full. You can setup automatic flushing with:
>
> use IO::Handle;
> autoflush STDOUT;
>
> at the start of your code.
>
> > The second thing is, how come setting up the options failed? It is
> > somewhat exactly like the example given on the page at
> > http://search.cpan.org/~mizzy/FFmpeg-Command-0.07/lib/FFmpeg/Command.pm<http://search.cpan.org/%7Emizzy/FFmpeg-Command-0.07/lib/FFmpeg/Command.pm>
> >
> > What am I doing wrong? Or is there a problem with the actual module?
>
> Maybe there's a problem with the module, maybe not. You are certainly
> testing for undocumented return values. Did your program create an
> output file?
>
> HTH,
>
> Rob
>

Reply via email to