( ffmpegPath: string, encodingMode: NativeExportEncodingMode, )
| 3943 | } |
| 3944 | |
| 3945 | export async function resolveNativeVideoEncoder( |
| 3946 | ffmpegPath: string, |
| 3947 | encodingMode: NativeExportEncodingMode, |
| 3948 | ) { |
| 3949 | if ( |
| 3950 | cachedNativeVideoEncoder?.ffmpegPath === ffmpegPath && |
| 3951 | cachedNativeVideoEncoder?.encodingMode === encodingMode |
| 3952 | ) { |
| 3953 | return cachedNativeVideoEncoder.encoderName; |
| 3954 | } |
| 3955 | |
| 3956 | const availableEncoders = await getAvailableNativeVideoEncoders(ffmpegPath); |
| 3957 | const candidates = [ |
| 3958 | ...new Set([...getPreferredNativeVideoEncoders(process.platform), "libx264"]), |
| 3959 | ]; |
| 3960 | |
| 3961 | for (const encoderName of candidates) { |
| 3962 | if (!availableEncoders.has(encoderName)) { |
| 3963 | continue; |
| 3964 | } |
| 3965 | |
| 3966 | if (await probeNativeVideoEncoder(ffmpegPath, encoderName, encodingMode)) { |
| 3967 | setCachedNativeVideoEncoder({ ffmpegPath, encodingMode, encoderName }); |
| 3968 | return encoderName; |
| 3969 | } |
| 3970 | } |
| 3971 | |
| 3972 | throw new Error("No usable FFmpeg encoder was available for native export"); |
| 3973 | } |
| 3974 | |
| 3975 | export function canCopyAudioCodecIntoMp4(codec?: string | null) { |
| 3976 | const normalized = (codec ?? "").trim().toLowerCase(); |
no test coverage detected