[FFmpeg-user] FFmpeg 2-pass libx264 encoding with php? possible?

surekin surekin at gmx.at
Sun May 20 23:18:59 CEST 2012

maybe somebody of you can help me out!
My problem is, i need to convert many movies as they come to either mp4 or
flv to be able to stream(!) perfectly afterwards. I don`t know anything
about the videos before they get to encoding, and the script should be run
by Cronjob automatically. And now i am experimenting a lot with different
FFMPEG settings to achieve this!

The latest info i got was a HQ 2pass encoding technique-as i am not having
the preset for HQ availiable i had to search for the whole shell command.
These are the commands which should be done, but FFMPEG is stopping without
a reason, and the output file has a size of 0 after finishing. I watched the
process and have seen that the filesize goes up to the same size it would
have when i just do the pass 1 and then back to zero and finishes: no output

for info: if i do each command seperatly they work smoothly!

$convert_call_pass_1 = $ffmpegPath . " -y -i " . $video_to_convert . " -r
30000/1001 -b 2M -bt 4M -vcodec libx264 -pass 1 -vpre fast_firstpass -an
-passlogfile passlogs/passlog_ffmpeg " . $converted_video . " 2>&1";

$convert_call_pass_2 = $ffmpegPath . " -y -i " . $video_to_convert . " -r
24000/1001 -b 6144k -bt 8192k -vcodec libx264 -pass 2 -flags +loop
-me_method umh -g 250 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -bf 16
-b_strategy 1 -i_qfactor 0.71 -cmp +chroma -subq 8 -me_range 16 -coder 1
-sc_threshold 40 -flags2 +bpyramid+wpred+mixed_refs+dct8x8+fastpskip
-keyint_min 25 -refs 4 -trellis 1 -directpred 3 -partitions
+parti8x8+parti4x4+partp8x8+partb8x8 -an -passlogfile
passlogs/passlog_ffmpeg " . $converted_video . " 2>&1";

exec($convert_call_pass_1, $output);
exec($convert_call_pass_2, $output);

What am i doing wrong? is it wrong to call both execs one after another?

Is there a better solution for the problem with different incoming movies?
mp4 encoding is not a must...could also be flv!

Thanx in advance!

View this message in context: http://ffmpeg-users.933282.n4.nabble.com/FFmpeg-2-pass-libx264-encoding-with-php-possible-tp4647274.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.

More information about the ffmpeg-user mailing list