video: support new vod post api
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/504/head
parent
afd3cf937d
commit
51adf19eae
|
@ -196,20 +196,19 @@ class VideoController extends ApiBase
|
|||
|
||||
// Transcode video if allowed
|
||||
if ($transcode && !$this->config->getSystemValue('memories.vod.disable', true)) {
|
||||
try {
|
||||
// If video path not given, write to temp file
|
||||
if (!$liveVideoPath) {
|
||||
$liveVideoPath = tempnam(sys_get_temp_dir(), 'livevideo');
|
||||
file_put_contents($liveVideoPath, $blob);
|
||||
|
||||
register_shutdown_function(function () use ($liveVideoPath) {
|
||||
unlink($liveVideoPath);
|
||||
});
|
||||
$liveVideoPath = self::postFile($transcode, $blob)['path'];
|
||||
}
|
||||
|
||||
// If this is H.264 it won't get transcoded anyway
|
||||
if ($this->getUpstream($transcode, $liveVideoPath, 'max.mov') === 200) {
|
||||
if ($liveVideoPath && 200 === $this->getUpstream($transcode, $liveVideoPath, 'max.mov')) {
|
||||
exit;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Transcoding failed, just return the original video
|
||||
}
|
||||
}
|
||||
|
||||
// Make and send response
|
||||
|
@ -408,6 +407,33 @@ class VideoController extends ApiBase
|
|||
return $returnCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* POST to go-vod to create a temporary file.
|
||||
*
|
||||
* @param mixed $blob
|
||||
*/
|
||||
private static function postFile(string $client, $blob)
|
||||
{
|
||||
$url = self::getGoVodUrl($client, '/create', 'ignore');
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $blob);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$returnCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if (200 !== $returnCode) {
|
||||
throw new \Exception("Could not create temporary file ({$returnCode})");
|
||||
}
|
||||
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the goVod config JSON and put it to a file.
|
||||
*
|
||||
|
|
|
@ -20,7 +20,7 @@ mv "exiftool-$exifver" exiftool
|
|||
rm -rf *.zip exiftool/t exiftool/html
|
||||
chmod 755 exiftool/exiftool
|
||||
|
||||
govod="0.0.32"
|
||||
govod="0.0.33"
|
||||
echo "Getting go-vod $govod"
|
||||
wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-amd64"
|
||||
wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-aarch64"
|
||||
|
|
Loading…
Reference in New Issue