<?php
$videofile
= (isset(
$_GET
['file'])) ?
strval
(
$_GET
['file']) : 'video.flv';
$image
=
substr
(
$videofile
, 0,
strlen
(
$videofile
) - 4);
$time
= (isset(
$_GET
['time'])) ?
strval
(
$_GET
['time']) : '00:00:01';
if
(!preg_match('/\d\d:\d\d:\d\d/',
$time
))
{
$time
=
"00:00:00"
;
}
if
(isset(
$_GET
['percent']))
{
$percent
=
$_GET
['percent'];
ob_start();
exec
(
"/usr/bin/ffmpeg -i \""
.
$videofile
.
"\" 2>&1"
);
$duration
= ob_get_contents();
ob_end_clean();
preg_match('/Duration: (.*?),/',
$duration
,
$matches
);
$duration
=
$matches
[1];
$duration_array
= split(':',
$duration
);
$duration
=
$duration_array
[0] * 3600 +
$duration_array
[1] * 60 +
$duration_array
[2];
$time
=
$duration
*
$percent
/ 100;
$time
=
intval
(
$time
/3600) .
":"
.
intval
((
$time
-(
intval
(
$time
/3600)*3600))/60) .
":"
. sprintf(
"%01.3f"
, (
$time
-(
intval
(
$time
/60)*60)));
}
$browser
= (isset(
$_GET
['browser'])) ?
strval
(
$_GET
['browser']) : 'true';
if
(
$browser
==
"true"
)
{
header('Content-Type: image/png');
exec
(
"/usr/bin/ffmpeg -vcodec png -i \""
.
$videofile
.
"\" -ss "
.
$time
.
" -vframes 1 -f image2 -"
);
}
else
{
exec
(
"/usr/bin/ffmpeg -vcodec png -i \""
.
$videofile
.
"\" -ss "
.
$time
.
" -vframes 1 -f image2 \""
.
$image
.
"\"%d.png"
);
}
?>