views:

584

answers:

5

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?

+1  A: 

Have tried the FFmpeg module? The transcode() method looks like it will do what you want.

daotoad
A: 

If you are on a unix based platform I'd look into using Gstreamer. It has perl bindings and it is fairly straightforward to set up a Gstreamer pipeline for converting audio video data.

See Gstreamer perl bindings and converting ogg to mp3 as an example.

Nick Haddad
A: 

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()?

Jon Ericson
You don't want to use system because it blocks until it is done. That could be a long time if you're converting videos.
brian d foy
A: 

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.

brian d foy
A: 

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.

Chas. Owens