phpvideotoolkit-v2 icon indicating copy to clipboard operation
phpvideotoolkit-v2 copied to clipboard

Cannot convert to animated gif

Open sonnb opened this issue 9 years ago • 7 comments

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?

sonnb avatar May 02 '15 09:05 sonnb

It will work if in the output filename I put %d.

sonnb avatar May 11 '15 10:05 sonnb

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?

buggedcom avatar May 15 '15 18:05 buggedcom

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);

sonnb avatar May 21 '15 17:05 sonnb

Are you buy any chance running this on a windows environment?

buggedcom avatar May 27 '15 19:05 buggedcom

Yes you are right. I am developing on Win8.1 using Xampp.

sonnb avatar May 28 '15 16:05 sonnb

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.

buggedcom avatar May 28 '15 17:05 buggedcom

Thanks for let me know.

sonnb avatar May 28 '15 17:05 sonnb