+async function guessVideoPathWithExtension (tmpPath: string, sourceExt: string) {
+ if (!isVideoFileExtnameValid(sourceExt)) {
+ throw new Error('Invalid video extension ' + sourceExt)
+ }
+
+ const extensions = [ sourceExt, '.mp4', '.mkv', '.webm' ]
+
+ for (const extension of extensions) {
+ const path = tmpPath + extension
+
+ if (await pathExists(path)) return path
+ }
+
+ throw new Error('Cannot guess path of ' + tmpPath)
+}
+