Hello.
I create mp4 file from 3gp:
$ '/usr/bin/ffmpeg' '-y' '-i' '/srv/www/wapinet.virt/web/static/file/2014/09/11//5411e1a96944b.3gp' '-threads' '4' '-vcodec' 'libx264' '-acodec' 'libmp3lame' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5412a75595fbevytvo/pass-5412a7559cece' '/srv/www/wapinet.virt/web/static/file/2014/09/11//5411e1a96944b.3gp.mp4'
Result:
ffmpeg version 0.10.11 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 4 2014 16:23:17 with gcc 4.4.7 20120313 (Red Hat 4.4.7-3)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-libass --enable-libcdio --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-runtime-cpudetect
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/srv/www/wapinet.virt/web/static/file/2014/09/11//5411e1a96944b.3gp':
Metadata:
major_brand : 3gp4
minor_version : 512
compatible_brands: 3gp4
creation_time : 1970-01-01 00:00:00
Duration: 00:00:23.10, start: 0.000000, bitrate: 219 kb/s
Stream #0:0(und): Video: h263 (s263 / 0x33363273), yuv420p, 176x144 [SAR 12:11 DAR 4:3], 209 kb/s, 15 fps, 15 tbr, 15 tbn, 29.97 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name :
VideoHandler
Stream #0:1(und): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, 1 channels, flt, 7 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name :
SoundHandler
[buffer @ 0x9306ea0] w:176 h:144 pixfmt:yuv420p tb:1/1000000 sar:12/11 sws_param:
Incompatible sample format 'flt' for codec 'libmp3lame', auto-selecting format 's16'
[libx264 @ 0x9315380] using SAR=12/11
[libx264 @ 0x9315380] using cpu capabilities: none!
[libx264 @ 0x9315380] ratecontrol_init: can't open stats file
Output #0, mp4, to '/srv/www/wapinet.virt/web/static/file/2014/09/11//5411e1a96944b.3gp.mp4':
Metadata:
major_brand : 3gp4
minor_version : 512
compatible_brands: 3gp4
creation_time : 1970-01-01 00:00:00
Stream #0:0(und): Video: h264, yuv420p, 176x144 [SAR 12:11 DAR 4:3], q=-1--1, pass 1, 1000 kb/s, 90k tbn, 15 tbc
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name :
VideoHandler
Stream #0:1(und): Audio: none, 8000 Hz, 1 channels, s16, 128 kb/s
Metadata:
creation_time : 1970-01-01 00:00:00
handler_name :
SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h263 -> libx264)
Stream #0:1 -> #0:1 (amrnb -> libmp3lame)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Any help? :sweat:
I added this hook for my code. This fixes my problem.
/**
* libmp3lame not supported sample_rate lower 16000
* firefox not play sample_rate lower 32000
*
* @param FFmpegAudio $media
* @return Video
*/
protected function addLibMp3LameFilter(FFmpegAudio $media)
{
$sampleRate = $media->getStreams()->audios()->first()->get('sample_rate');
if ($sampleRate < 32000) {
$media->addFilter(new AudioResamplableFilter(32000));
}
return $this;
}
Hi I'm having the same problem, where would I add this hook? and how would I invoke it?
thanks
@Gemorroj still actual?
@Gemorroj please mention where to add these codes and how to se it
@EmiiKhaos, @visakhsujathan, @sathio sorry for delay 馃
this issue steel actual for v0.11.1 pl 1 release.
i use windows 10x64, ffmpeg 3.4.2 (https://ffmpeg.zeranoe.com/builds/)
tested 3gp file: small.3gp.zip
example:
<?php
use FFMpeg\Format\Video\X264;
use FFMpeg\Filters\Audio\AudioResamplableFilter;
use FFMpeg\FFMpeg;
$ffmpeg = FFMpeg::create();
$media = $ffmpeg->open('path_to_original_file.3gp');
$format = new X264('libmp3lame'); // but now i use aac, with aac, the bug is not reproduced
// add workaround
// libmp3lame not supported sample_rate lower 16000
// firefox not play sample_rate lower 32000
$sampleRate = $media->getStreams()->audios()->first()->get('sample_rate');
if ($sampleRate < 32000) {
$media->addFilter(new AudioResamplableFilter(32000));
}
// end workaround
$media->save($format, 'path_to_converted_file.mp4');
I don't see where the bug lies in? Do you basically want us to set a default resample filter of 32000?
@jens1o no, I don't know what the right behavior is. Previously, libmp3lame was used and it did not convert the file. It is unclear why. You may need to call trigger_error or Exception, or add filter... That is, hint the user about the problem.
In any case, that would mean a breaking change :/