Skip to content

Instantly share code, notes, and snippets.

@subhashdasyam
Created January 19, 2017 08:25
Show Gist options
  • Save subhashdasyam/c1e136c12ae9f9e0855222d6defadd72 to your computer and use it in GitHub Desktop.
Save subhashdasyam/c1e136c12ae9f9e0855222d6defadd72 to your computer and use it in GitHub Desktop.
FFmpeg PHP
<?php
$ffmpegpath = "ffmpeg.exe";
$input = 'wattan.flv';
$output = 'wattan.jpg';
if (make_jpg($input, $output)){
echo 'success';
}else{
echo 'bah!';
}
function make_jpg($input, $output, $fromdurasec="01") {
global $ffmpegpath;
if(!file_exists($input)) return false;
$command = "$ffmpegpath -i $input -an -ss 00:00:$fromdurasec -r 1 -vframes 1 -f mjpeg -y $output";
@exec( $command, $ret );
if(!file_exists($output)) return false;
if(filesize($output)==0) return false;
return true;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment