in reply to Re: Passing an in memory scalar to an external command as an argument
in thread Passing an in memory scalar to an external command as an argument

I would suggest:

use IO::Pipe; my $pipe = IO::Pipe->new(); $pipe->writer(qw(ffmpeg -i pipe:0)); print $pipe $mp3;

to avoid the shell being used to launch ffmpeg.

  • Comment on Re^2: Passing an in memory scalar to an external command as an argument
  • Download Code

Replies are listed 'Best First'.
Re^3: Passing an in memory scalar to an external command as an argument
by Rodster001 (Pilgrim) on Apr 08, 2015 at 22:38 UTC
    I like that solution. But I need to capture stdout also (so I am actually using open2 for this). Can I write and read using IO::Pipe? The docs look like it is one or the other.

      It is possible, but open2 is easier:

      $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'ffmpeg', '-i', 'pipe:0');