video: support new vod post api
Signed-off-by: Varun Patil <varunpatil@ucla.edu>pull/504/head
parent
afd3cf937d
commit
51adf19eae
|
@ -196,19 +196,18 @@ class VideoController extends ApiBase
|
||||||
|
|
||||||
// Transcode video if allowed
|
// Transcode video if allowed
|
||||||
if ($transcode && !$this->config->getSystemValue('memories.vod.disable', true)) {
|
if ($transcode && !$this->config->getSystemValue('memories.vod.disable', true)) {
|
||||||
// If video path not given, write to temp file
|
try {
|
||||||
if (!$liveVideoPath) {
|
// If video path not given, write to temp file
|
||||||
$liveVideoPath = tempnam(sys_get_temp_dir(), 'livevideo');
|
if (!$liveVideoPath) {
|
||||||
file_put_contents($liveVideoPath, $blob);
|
$liveVideoPath = self::postFile($transcode, $blob)['path'];
|
||||||
|
}
|
||||||
|
|
||||||
register_shutdown_function(function () use ($liveVideoPath) {
|
// If this is H.264 it won't get transcoded anyway
|
||||||
unlink($liveVideoPath);
|
if ($liveVideoPath && 200 === $this->getUpstream($transcode, $liveVideoPath, 'max.mov')) {
|
||||||
});
|
exit;
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
// If this is H.264 it won't get transcoded anyway
|
// Transcoding failed, just return the original video
|
||||||
if ($this->getUpstream($transcode, $liveVideoPath, 'max.mov') === 200) {
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,6 +407,33 @@ class VideoController extends ApiBase
|
||||||
return $returnCode;
|
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.
|
* 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
|
rm -rf *.zip exiftool/t exiftool/html
|
||||||
chmod 755 exiftool/exiftool
|
chmod 755 exiftool/exiftool
|
||||||
|
|
||||||
govod="0.0.32"
|
govod="0.0.33"
|
||||||
echo "Getting go-vod $govod"
|
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-amd64"
|
||||||
wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-aarch64"
|
wget -q "https://github.com/pulsejet/go-vod/releases/download/$govod/go-vod-aarch64"
|
||||||
|
|
Loading…
Reference in New Issue