Okay so i have this idea for a weekend project where I want to transcode flv/mp4 streams directly into mp3 format.
How can I easily do that via PHP/Apache on a CentOS Server? (hopefully not as CPU intensive as FFMPEG) Any idea's are appreciated!
:)
Firstly,
ffmpeg
is the tool of choice for this. It's CPU-intensive because that's the nature of encoding video or audio.You can simply rip the stream (assuming original mp3 audio is in the stream) from the track and save it. I've used this
bash
snippet before for directories of*.flv
files:If the stream is not natively in mp3 format, you need to re-encode. Or perhaps you want a different bitrate, etc. This task will definitely consume more CPU than the former:
edit: to limit to one core:
taskset 1 ffmpeg <rest of args>
--taskset
is part of theutil-linux
package on Debian systems. You may also want torenice
the process, setting its priority value to something in the positive range (sounds backwards, but lowernice
value = more cpu time). As always,man taskset
,man renice
,man nice
.This is how you do what you want to do with ffmpeg from the shell -- implementing in PHP is left as an exercise for the reader.