예제 #1
0
} else {
    $basename = $video->getFilenameWithoutExtension();
    $filename = "video/{$video->getGUID()}/{$basename}_{$resolution}.{$format}";
    // Create a new entity that represents the physical file
    $source = new VideoSource();
    $source->format = $format;
    $source->setFilename($filename);
    $source->setMimeType("video/{$format}");
    $source->resolution = $resolution;
    $source->bitrate = $bitrate;
    $source->owner_guid = $video->getOwnerGUID();
    $source->container_guid = $video->getGUID();
    $source->access_id = $video->access_id;
    $source->save();
}
try {
    $converter = new VideoConverter();
    $converter->setInputfile($video->getFilenameOnFilestore());
    $converter->setOutputfile($source->getFilenameOnFilestore());
    $converter->setResolution($resolution);
    $converter->setBitrate($bitrate);
    $converter->convert();
    $source->conversion_done = true;
    system_message(elgg_echo('video:convert:success', array($format)));
} catch (exception $e) {
    // Delete the faulty format
    $source->delete();
    $message = elgg_echo('VideoException:ConversionFailed', array($outputfile, $e->getMessage(), $converter->getCommand()));
    register_error($message);
}
forward("admin/video/view?guid={$guid}");