phpvideotoolkit-v2
phpvideotoolkit-v2 copied to clipboard
Cannot convert to animated gif
Hello,
I followed the example but unable to produce an animated gif. I tryied php, gifsicle and convert.
It keeps throwing:
[image2 @ 0000000003005520] Could not get frame filename number 2 from pattern 'path\temp\phpvideotoolkit_anigif_9k8fz_xfD197.tmp. 12d._i.._u.12364_63x7d_1430558687.u_.png' (either set updatefirst or use a pattern like %03d within the filename pattern)
av_interleaved_write_frame(): Invalid argument
frame= 2 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.08 bitrate=N/A dup=1 drop=0
If I try: setVideoMaxFrames(1) it can produce a gif file but not animated.
Do you have any idea about this?
It will work if in the output filename I put %d.
there must be a bug in the %index to %d conversion that do phpvideotoolkit does. I've made a note of it and will try to fix when I have the time. In order to aid me, can you post the full script you are using?
Yes of course.
$config = new PHPVideoToolkit\Config(
array(
'ffmpeg' => 'PATH',
'ffprobe' => 'PATH',
'gifsicle' => 'PATH',
'convert' => 'PATH',
'temp_directory' => 'internal_data/temp',
'gif_transcoder' => 'gifsicle',
'gif_transcoder_convert_use_dither' => false
),
true
);
$tempFile = tempnam('internal_data/temp', 'xf');
$videoAnimated = new PHPVideoToolkit\Video($videoPath, $config);
$outputPath = $frameTempFile.'.gif';
$outputFormat = PHPVideoToolkit\Format::getFormatFor($outputPath, $config, 'ImageFormat');
$outputFormat->setVideoFrameRate(12);
$parser = new PHPVideoToolkit\FfmpegParser($config);
$outputFormat->setQualityVsStreamabilityBalanceRatio('QUALITY');
$endTimeCode = new PHPVideoToolkit\Timecode($this->getFrameCount() > 5 ? 5 : $this->getFrameCount());
$this->_video->extractSegment(new PHPVideoToolkit\Timecode(0), $endTimeCode)->save($outputPath, $outputFormat, PHPVideoToolkit\Media::OVERWRITE_EXISTING);
Are you buy any chance running this on a windows environment?
Yes you are right. I am developing on Win8.1 using Xampp.
seems to be something to do with in a windows environment the % sign is somehow replaced out with a ' ' (space). I've made a note of it and will look into it but I have no idea when.
Thanks for let me know.