MCPcopy
hub / github.com/webadderallorg/Recordly / muxNativeVideoExportAudio

Function muxNativeVideoExportAudio

electron/ipc/export/native-video.ts:4068–4146  ·  view source on GitHub ↗
(
	videoPath: string,
	options: NativeVideoExportFinishOptions,
	onProgress?: (progress: NativeVideoAudioMuxProgress) => void,
	session?: NativeStaticLayoutExportSession,
)

Source from the content-addressed store, hash-verified

4066}
4067
4068export async function muxNativeVideoExportAudio(
4069 videoPath: string,
4070 options: NativeVideoExportFinishOptions,
4071 onProgress?: (progress: NativeVideoAudioMuxProgress) => void,
4072 session?: NativeStaticLayoutExportSession,
4073) {
4074 const audioMode = options.audioMode ?? "none";
4075 if (audioMode === "none") {
4076 return {
4077 outputPath: videoPath,
4078 metrics: {} as NativeVideoAudioMuxMetrics,
4079 };
4080 }
4081
4082 const ffmpegPath = getFfmpegBinaryPath();
4083 const metrics: NativeVideoAudioMuxMetrics = {};
4084 const tempArtifacts: string[] = [];
4085 let audioInputPath = options.audioSourcePath ?? null;
4086 const useEditedTrackFiltergraph =
4087 audioMode === "edited-track" && options.editedTrackStrategy === "filtergraph-fast-path";
4088
4089 if (audioMode === "edited-track" && !useEditedTrackFiltergraph) {
4090 if (!options.editedAudioData) {
4091 throw new Error("Edited audio data is missing for native export");
4092 }
4093
4094 const extension = getEditedAudioExtension(options.editedAudioMimeType);
4095 audioInputPath = path.join(
4096 app.getPath("temp"),
4097 `recordly-export-audio-${Date.now()}-${Math.random().toString(36).slice(2, 8)}${extension}`,
4098 );
4099 const tempAudioWriteStartedAt = getNowMs();
4100 await fs.writeFile(audioInputPath, Buffer.from(options.editedAudioData));
4101 metrics.tempEditedAudioWriteMs = getNowMs() - tempAudioWriteStartedAt;
4102 metrics.tempEditedAudioBytes = options.editedAudioData.byteLength;
4103 tempArtifacts.push(audioInputPath);
4104 }
4105
4106 if (!audioInputPath) {
4107 return {
4108 outputPath: videoPath,
4109 metrics,
4110 };
4111 }
4112
4113 const outputPath = path.join(
4114 path.dirname(videoPath),
4115 `${path.basename(videoPath, path.extname(videoPath))}-final.mp4`,
4116 );
4117
4118 const args = buildNativeVideoAudioMuxArgs(
4119 videoPath,
4120 audioInputPath,
4121 outputPath,
4122 options,
4123 onProgress ? { progressPipe: 2 } : {},
4124 );
4125

Callers 3

registerExportHandlersFunction · 0.90

Calls 6

getFfmpegBinaryPathFunction · 0.90
getEditedAudioExtensionFunction · 0.90
getNowMsFunction · 0.85
runFfmpegAudioMuxFunction · 0.85

Tested by

no test coverage detected