Home > other >  Extract Screenshots with Timestamp with PHP-FFMpeg
Extract Screenshots with Timestamp with PHP-FFMpeg

Time:02-10

I'm using PHP-FFMpeg and try to create Screenshot Thumbnails of a Video with a timestamp on it.

I have a working command for my cmd which does exactly what I want (generate 12 Images with a timestamp on it):

.\ffmpeg.exe -i ".\video.mp4" -vf "fps=1/'$(.\ffprobe.exe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 .\video.mp4)'*12,drawtext=fontfile=C\\:/Windows/Fonts/Arial.ttf:fontsize=45:fontcolor=yellow:box=1:boxcolor=black:x=(W-tw)/2:y=H-th-10:text='%{pts\:hms}'" -vsync vfr thumb_d.jpg

Now I try to implement this command with PHP-FFMpeg so I can use a webform on my server but I can't figuere it out... My attempt looks like this:

$video = $ffmpeg->open("video.mp4");
$video
  ->filters()
  ->custom($draw_filter)
  ->extractMultipleFrames(\FFMpeg\Filters\Video\ExtractMultipleFramesFilter::FRAMERATE_EVERY_SEC, __DIR__);
$video->save(new FFMpeg\Format\Video\X264(), __DIR__ . '\\thumb.mp4');

But that creates over 300 Images on a 10 sec Clip and these images don't have the timestamp on it, but the output clip has the timestamps in it an stutters like it used the framesetting from the extractMultipleFrames() function...

What am I doing wrong?

CodePudding user response:

  •  Tags:  
  • Related