Use client id for live photo transcodes
parent
15997dc793
commit
5550551e8a
|
@ -217,11 +217,11 @@ class VideoController extends ApiBase
|
||||||
$blob = $liveFile->getContent();
|
$blob = $liveFile->getContent();
|
||||||
$mime = $liveFile->getMimeType();
|
$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
|
// Only Apple uses HEVC for now, so pass this to the transcoder
|
||||||
// If this is H.264 it won't get transcoded anyway
|
// If this is H.264 it won't get transcoded anyway
|
||||||
$liveVideoPath = $liveFile->getStorage()->getLocalFile($liveFile->getInternalPath());
|
$liveVideoPath = $liveFile->getStorage()->getLocalFile($liveFile->getInternalPath());
|
||||||
if ($this->getUpstream('livephoto', $liveVideoPath, 'max.mp4')) {
|
if ($this->getUpstream($id, $liveVideoPath, 'max.mp4')) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,6 @@ const config_noTranscode = loadState(
|
||||||
<string>"UNSET"
|
<string>"UNSET"
|
||||||
) as boolean | string;
|
) 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
|
* Check if slide has video content
|
||||||
*
|
*
|
||||||
|
@ -153,7 +149,7 @@ class VideoContentSetup {
|
||||||
// Create hls sources if enabled
|
// Create hls sources if enabled
|
||||||
let sources: any[] = [];
|
let sources: any[] = [];
|
||||||
const baseUrl = generateUrl(
|
const baseUrl = generateUrl(
|
||||||
`/apps/memories/api/video/transcode/${clientId}/${fileid}`
|
`/apps/memories/api/video/transcode/${videoClientId}/${fileid}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!config_noTranscode) {
|
if (!config_noTranscode) {
|
||||||
|
|
14
src/main.ts
14
src/main.ts
|
@ -28,15 +28,16 @@ declare global {
|
||||||
|
|
||||||
var vidjs: typeof import("video.js").default;
|
var vidjs: typeof import("video.js").default;
|
||||||
var Plyr: typeof import("plyr");
|
var Plyr: typeof import("plyr");
|
||||||
|
var videoClientId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow global access to the router
|
||||||
globalThis.vuerouter = router;
|
globalThis.vuerouter = router;
|
||||||
|
|
||||||
|
// Cache these for better performance
|
||||||
globalThis.windowInnerWidth = window.innerWidth;
|
globalThis.windowInnerWidth = window.innerWidth;
|
||||||
globalThis.windowInnerHeight = window.innerHeight;
|
globalThis.windowInnerHeight = window.innerHeight;
|
||||||
|
|
||||||
Vue.use(VueVirtualScroller);
|
|
||||||
|
|
||||||
// CSP config for webpack dynamic chunk loading
|
// CSP config for webpack dynamic chunk loading
|
||||||
__webpack_nonce__ = window.btoa(getRequestToken());
|
__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
|
// We do not want the index.php since we're loading files
|
||||||
__webpack_public_path__ = generateFilePath("memories", "", "js/");
|
__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
|
// https://github.com/nextcloud/photos/blob/156f280c0476c483cb9ce81769ccb0c1c6500a4e/src/main.js
|
||||||
// TODO: remove when we have a proper fileinfo standalone library
|
// TODO: remove when we have a proper fileinfo standalone library
|
||||||
// original scripts are loaded from
|
// original scripts are loaded from
|
||||||
|
|
|
@ -244,7 +244,7 @@ export function getLivePhotoVideoUrl(p: IPhoto, transcode: boolean) {
|
||||||
let url = generateUrl(
|
let url = generateUrl(
|
||||||
`/apps/memories/api/video/livephoto/${p.fileid}?etag=${p.etag}&liveid=${p.liveid}`
|
`/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;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue