Can I use ffmpeg from inside a Perl script without a system call?

By : Jared
Source: Stackoverflow.com
Question!

I'd like to convert mp3's to lower bitrates, as well as possibly convert video to mp3 using Perl. I looked at the ffmpeg module but it doesn't appear that it supports converting files, the only example I saw was grabbing pictures out of a video stream. Is there a way to do this in Perl with out using system() to call ffmpeg?

By : Jared


Answers

There is a project called pacpl which does a wide variety of audio and a least some video conversions. Looking at the source, it does use the system() command to run third-party utilities such as ffmpeg. I'm interested in doing conversions similar to what you asked about and I plan on trying out pacpl myself.

So far it seem like there are no pure Perl answers. All of the methods use some other conversion software. Which tells me it's probably more efficient to use some other program written in C.

So I would turn the question back to you: what is your reason for not wanting to use system()?



See the answers to Perl backtics vs system vs exec for a list of ways to interact with external programs. If you are looking for a Perl interface to that program I would suggest looking on CPAN.



Why do you want to avoid another process? I have a Perl script which does this for me and I fork a process for each video I want to convert. That way I can convert several videos at the same time and have my master Perl program do whatever else it needs to do.

You don't need to use system, which blocks until it is done. There are many other ways to communicate with external processes. See the perlipc documentation for details.



This video can help you solving your question :)
By: admin