Exemple #1
0
function hg_snap($time, $snapdir, $width, $height, $source, $times = 0, $spec_fname = '')
{
    $maxtimes = 2;
    if (!$spec_fname) {
        $spec_fname = $time;
    }
    $file = $spec_fname . '.jpg';
    $jpg = $snapdir . $file;
    $time1 = hg_mc_sec2format($time);
    $cmd = FFMPEG_CMD . ' -ss ' . $time1 . ' -s ' . $width . 'x' . $height . ' -y "' . $jpg . '" -i "' . $source . '" -vframes 1';
    exec($cmd, $out, $s);
    if (!is_file($snapdir . $file) && $times < $maxtimes) {
        $times = intval($times) + 1;
        $file = hg_snap($time - $times * 40, $snapdir, $width, $height, $source, $times, $spec_fname);
    }
    return $file;
}
Exemple #2
0
    error_output('009', '通信令牌错误');
}
$id = $_INPUT['vodid'];
if (!$id) {
    error_output('001', '未指定视频ID');
}
$video_dir = hg_num2dir($id);
$targerdir = TARGET_DIR . $video_dir . $id . '.ssm/';
hg_mkdir($targerdir);
$start = intval($_INPUT['start']);
$duration = intval($_INPUT['duration']);
$mp4 = $targerdir . $id . '.mp4';
if (!is_file($mp4)) {
    $cmd = '/usr/local/bin/mp4split -o ' . $mp4 . ' ' . $targerdir . $id . '.ismv';
    exec($cmd);
}
if (!is_file($mp4)) {
    error_output('002', '原视频文件丢失');
}
$start = hg_mc_sec2format($start);
$duration = hg_mc_sec2format($duration);
$new_flv = TARGET_DIR . $video_dir . $id . '.flv';
//-ss ' . $start . ' -t ' . $duration . '
$cmd = FFMPEG_CMD . ' -y -i ' . $mp4 . ' -acodec copy  -vcodec copy ' . $new_flv;
//$cmd = FFMPEG_CMD . ' -y -ss ' . $start . ' -t ' . $duration . ' -i ' . $mp4 . ' -sameq ' . $new_mp4;
exec($cmd, $out, $s);
if (!is_file($new_flv)) {
    error_output('003', 'flv视频文件未能生成');
}
$data = array('vodid' => $id, 'filepath' => $video_dir, 'filename' => $id . '.flv');
output($data);