-
Notifications
You must be signed in to change notification settings - Fork 943
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1357 from uragirii/lambda-codec
- Loading branch information
Showing
19 changed files
with
316 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import type {ImageFormat, StillImageFormat} from '@remotion/renderer'; | ||
|
||
const deriveExtensionFromFilename = ( | ||
filename: string | null | ||
): StillImageFormat | null => { | ||
if (filename?.endsWith('.png')) { | ||
return 'png'; | ||
} | ||
|
||
if (filename?.endsWith('.jpg')) { | ||
return 'jpeg'; | ||
} | ||
|
||
if (filename?.endsWith('.jpeg')) { | ||
return 'jpeg'; | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export const determineFinalImageFormat = ({ | ||
downloadName, | ||
outName, | ||
configImageFormat, | ||
cliFlag, | ||
isLambda, | ||
}: { | ||
downloadName: string | null; | ||
outName: string | null; | ||
configImageFormat: ImageFormat | null; | ||
cliFlag: ImageFormat | null; | ||
isLambda: boolean; | ||
}): {format: StillImageFormat; source: string} => { | ||
const outNameExtension = deriveExtensionFromFilename(outName); | ||
const downloadNameExtension = deriveExtensionFromFilename(downloadName); | ||
|
||
const outNameDescription = isLambda ? 'S3 output key' : 'out name'; | ||
|
||
if ( | ||
outNameExtension && | ||
downloadNameExtension && | ||
outNameExtension !== downloadNameExtension | ||
) { | ||
throw new TypeError( | ||
`Image format mismatch: ${outName} was given as the ${outNameDescription} and ${downloadName} was given as the download name, but the extensions don't match.` | ||
); | ||
} | ||
|
||
if (downloadNameExtension) { | ||
if (cliFlag && downloadNameExtension !== cliFlag) { | ||
throw new TypeError( | ||
`Image format mismatch: ${downloadName} was given as the download name, but --image-format=${cliFlag} was passed. The image formats must match.` | ||
); | ||
} | ||
|
||
return {format: downloadNameExtension, source: 'Download name extension'}; | ||
} | ||
|
||
if (outNameExtension) { | ||
if (cliFlag && outNameExtension !== cliFlag) { | ||
throw new TypeError( | ||
`Image format mismatch: ${outName} was given as the ${outNameDescription}, but --image-format=${cliFlag} was passed. The image formats must match.` | ||
); | ||
} | ||
|
||
return {format: outNameExtension, source: 'Out name extension'}; | ||
} | ||
|
||
if (cliFlag === 'none') { | ||
throw new TypeError( | ||
'The --image-format flag must not be "none" for stills.' | ||
); | ||
} | ||
|
||
if (cliFlag !== null) { | ||
return {format: cliFlag, source: '--image-format flag'}; | ||
} | ||
|
||
if (configImageFormat !== null && configImageFormat !== 'none') { | ||
return {format: configImageFormat, source: 'Config file'}; | ||
} | ||
|
||
return {format: 'png', source: 'Default'}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ac3cd1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
remotion – ./
remotion-git-main-remotion.vercel.app
remotion.vercel.app
remotion-remotion.vercel.app
www.remotiondocs.com
remotiondocs.com
remotion.dev
v3.remotion.dev
www.remotion.dev