ffmpeg php get frame / image after half time of the video or after 40 seconds -
hello having code in php , want image after 50% of duration of video , duration of video in variable have installed ffmpeg in php , computer
the page has following code
require 'vendor/autoload.php'; //ececute ffmpeg generate mp4 exec('ffmpeg -i '.$uploadfile.' -f mp4 -s 896x504 '.$new_flv.''); //execute ffmpeg , create thumb exec('ffmpeg -i '.$uploadfile.' -f mjpeg -vframes 71 -s 768x432 -an '.$new_image_path.'');
i want image after 50% of duration of video , store video duration in variable
please give me suggestions stuck on here
first need video duration in second , need multiply total second 0.5 half.
try one:
$total_sec = exec("ffprobe -loglevel error -show_streams inputfile.mp4 | grep duration | cut -f2 -d="); $total_half_sec = $total_sec * 0.5; exec("ffmpeg -i source.mp4 -f mjpeg -vframes $total_half_sec -s 768x432 -an destination.jpg");
for more info here https://www.ffmpeg.org/ffmpeg-all.html
Comments
Post a Comment