hi there,
i get weird results while trancoding. basically i would like to create mobile-friendly 360p version of following source video:
43,5MB
H264 MPEG-4 AVC (part 10) (avc1)
resolution: 960x720
i'm using this code:
$video->filters()->resize(new Dimension(480, 360), 'width')->synchronize();
$format = new \FFMpeg\Format\Video\X264();
$format->setKiloBitrate(800);
$format->setAudioCodec('libmp3lame');
$format->setAudioChannels(2);
$format->setAudioKiloBitrate(128);
and here are the details of the conversion:
66,9MB
H264 MPEG-4 AVC (part 10) (avc1)
res: 480x360
any ideas why the resulting file is larger than source?
I think https://github.com/PHP-FFMpeg/PHP-FFMpeg/blob/c64c9e764b80de104a3ebe5a199967ee738eb17d/src/FFMpeg/Media/Video.php#L87-L110 is the problem. To clarify, can you transcode it in the command line and tell use the size?
@jens1o you mean transcode in CLI using the same params as generated by PHP_FFMpeg?
@kminek Well, yeah. You could also try to leave out all parameters PHP-FFMPEG appends.
Closed due to inactivity.
Hi there,
sorry for late reply. Here are the details:
input.mp4 (74MB - 1280x720) - http://www11.zippyshare.com/v/xEyhVyjw/file.html
now i'm trying to resize input down to 240p:
$video = FFMpeg::create()->open($input);
$video
->filters()
->resize(new Dimension(320, 240), ResizeFilter::RESIZEMODE_SCALE_WIDTH)
->synchronize()
;
$format = new X264();
$format->setKiloBitrate(800);
$format->setAudioCodec($format->getAvailableAudioCodecs()[0]);
$format->setAudioChannels(2);
$format->setAudioKiloBitrate(128);
$video->save($format, $output);
and resulting files is larger that input. Note that this happens only for certain files (others are
indeed smaller).
i also tested pure CLI conversion with following command (https://trac.ffmpeg.org/wiki/Scaling):
ffmpeg -i input.mp4 -vf scale=-2:240 output.mp4
and output is 50% smaller than input so it works fine.
will check this now, please hang on for a moment :)
yap... can indeed reproduce it. 馃樂
that's quite bad... because I do not want to touch the video encoding part of php-ffmpeg in the 0.x tree(neither I'm sure which setting is the root cause for this), because it is quite critical and personally I do not trust the tests that much anymore, although I'm still in love with them. Will mark this as bug and assign this to the upcoming 1.x milestone. But I do not know yet when we will be able to publish it.
I'm sorry. :/
no problem, thx for you time and looking forward to 1.x milestone :)
Is it not fixed yet? I tried with few mp4 files, and saw the same effect. The converted files are larger than the input! Example:
Original (1920x1080): 77.7 MB
From the library:
352x240: 37.9 MB
858x480: 78.5 MB
Compressed (I thought!): 111.2 MB
I used getFinalCommand() instead of save.
$video->save() also almost has the same effect...
Through command line:
352x240: 15 MB
858x480: 21 MB
Compressed: 43 MB
What's wrong with the library?
Most helpful comment
yap... can indeed reproduce it. 馃樂
that's quite bad... because I do not want to touch the video encoding part of php-ffmpeg in the 0.x tree(neither I'm sure which setting is the root cause for this), because it is quite critical and personally I do not trust the tests that much anymore, although I'm still in love with them. Will mark this as bug and assign this to the upcoming 1.x milestone. But I do not know yet when we will be able to publish it.
I'm sorry. :/