Use client id for live photo transcodes

cap
Varun Patil 2022-11-29 14:09:48 -08:00
parent 15997dc793
commit 5550551e8a
4 changed files with 16 additions and 10 deletions

View File

@ -217,11 +217,11 @@ class VideoController extends ApiBase
$blob = $liveFile->getContent();
$mime = $liveFile->getMimeType();
if ($this->request->getParam('transcode') && !$this->config->getSystemValue('memories.no_transcode', true)) {
if (($id = $this->request->getParam('transcode')) && !$this->config->getSystemValue('memories.no_transcode', true)) {
// Only Apple uses HEVC for now, so pass this to the transcoder
// If this is H.264 it won't get transcoded anyway
$liveVideoPath = $liveFile->getStorage()->getLocalFile($liveFile->getInternalPath());
if ($this->getUpstream('livephoto', $liveVideoPath, 'max.mp4')) {
if ($this->getUpstream($id, $liveVideoPath, 'max.mp4')) {
exit;
}
}

View File

@ -12,10 +12,6 @@ const config_noTranscode = loadState(
<string>"UNSET"
) as boolean | string;
// Generate client id for this instance
// Does not need to be cryptographically secure
const clientId = Math.random().toString(36).substring(2, 15).padEnd(12, "0");
/**
* Check if slide has video content
*
@ -153,7 +149,7 @@ class VideoContentSetup {
// Create hls sources if enabled
let sources: any[] = [];
const baseUrl = generateUrl(
`/apps/memories/api/video/transcode/${clientId}/${fileid}`
`/apps/memories/api/video/transcode/${videoClientId}/${fileid}`
);
if (!config_noTranscode) {

View File

@ -28,15 +28,16 @@ declare global {
var vidjs: typeof import("video.js").default;
var Plyr: typeof import("plyr");
var videoClientId: string;
}
// Allow global access to the router
globalThis.vuerouter = router;
// Cache these for better performance
globalThis.windowInnerWidth = window.innerWidth;
globalThis.windowInnerHeight = window.innerHeight;
Vue.use(VueVirtualScroller);
// CSP config for webpack dynamic chunk loading
__webpack_nonce__ = window.btoa(getRequestToken());
@ -46,6 +47,15 @@ __webpack_nonce__ = window.btoa(getRequestToken());
// We do not want the index.php since we're loading files
__webpack_public_path__ = generateFilePath("memories", "", "js/");
// Generate client id for this instance
// Does not need to be cryptographically secure
globalThis.videoClientId = Math.random()
.toString(36)
.substring(2, 15)
.padEnd(12, "0");
Vue.use(VueVirtualScroller);
// https://github.com/nextcloud/photos/blob/156f280c0476c483cb9ce81769ccb0c1c6500a4e/src/main.js
// TODO: remove when we have a proper fileinfo standalone library
// original scripts are loaded from

View File

@ -244,7 +244,7 @@ export function getLivePhotoVideoUrl(p: IPhoto, transcode: boolean) {
let url = generateUrl(
`/apps/memories/api/video/livephoto/${p.fileid}?etag=${p.etag}&liveid=${p.liveid}`
);
if (transcode) url += "&transcode=1";
if (transcode) url += `&transcode=${videoClientId}`;
return url;
}