Php ffmpeg exec

-1

with code

$a = exec('"ffmpeg" -y -i "test.mp4" -ab 128k -s 640x480 -vcodec mpeg4 -acodec:a copy "output.mp4" 2>&1 ', $output, $error);

Input file was 82.21mb output file was 13.74mb

Output file is generated but video quality is very low and in mobile device video is not displayed only audio is being played

can anyone please help me with correct ffmpeg command for converting video file , so that output file should be 640*480 resolution, 128Kbps sound ,output file should be mp4 container video codec H.264 Audio codec AAC

Thanks Shilpa

using libx264 got error which says

 [52] => Stream mapping:
    [53] =>   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    [54] =>   Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
    [55] => Error while opening decoder for input stream #0:0 : Resource temporarily unavailable

any idea why this error occurs, is it due to ffmpeg not installed properly . this is my settings of ffmpeg which i got from phpinfo()

ffmpeg-php version  0.6.0-svn
ffmpeg-php built on     Oct 30 2014 22:27:42
ffmpeg-php gd support   enabled
ffmpeg libavcodec version   Lavc52.72.2
ffmpeg libavformat version  Lavf52.64.2
ffmpeg swscaler version     SwS0.11.0

Directive   Local Value Master Value
ffmpeg.allow_persistent 0   0
ffmpeg.show_warnings    0   0

shilpa

Posted 2015-06-24T21:36:20.467

Reputation: 1

I see that both input and output files are mp4 file hence ffmpeg -i input.mp4 -s 640x480 output.mp4 might be just more than enough – Darius – 2015-06-25T16:40:06.627

Answers

-1

Some really good information about h264 encoding here: https://trac.ffmpeg.org/wiki/Encode/H.264

A pretty good benchmark are the default presets which will be better than using an mpeg4 codec (which is what you are using in the original question).

Try:

ffmpeg -i test.mp4 -vf scale=640:480 -c:v libx264 -c:a libfdk_aac -ab 128k out.mp4

If that works for you, you can change the encoding settings for libx264 using the parameters in the link above. You can also change your audio codec too if it would help.

occvtech

Posted 2015-06-24T21:36:20.467

Reputation: 980