diff --git a/native/media/ffmpeg.js b/native/media/ffmpeg.js --- a/native/media/ffmpeg.js +++ b/native/media/ffmpeg.js @@ -81,19 +81,21 @@ transcodeVideo( ffmpegCommand: string, inputVideoDuration: number, - onTranscodingProgress: (percent: number) => void, + onTranscodingProgress?: (percent: number) => void, ): Promise<{ rc: number, lastStats: ?FFmpegStatistics }> { const duration = inputVideoDuration > 0 ? inputVideoDuration : 0.001; const wrappedCommand = async () => { RNFFmpegConfig.resetStatistics(); let lastStats; - RNFFmpegConfig.enableStatisticsCallback( - (statisticsData: FFmpegStatistics) => { - lastStats = statisticsData; - const { time } = statisticsData; - onTranscodingProgress(time / 1000 / duration); - }, - ); + if (onTranscodingProgress) { + RNFFmpegConfig.enableStatisticsCallback( + (statisticsData: FFmpegStatistics) => { + lastStats = statisticsData; + const { time } = statisticsData; + onTranscodingProgress(time / 1000 / duration); + }, + ); + } const ffmpegResult = await RNFFmpeg.execute(ffmpegCommand); return { ...ffmpegResult, lastStats }; }; diff --git a/native/media/media-utils.js b/native/media/media-utils.js --- a/native/media/media-utils.js +++ b/native/media/media-utils.js @@ -20,7 +20,7 @@ +hasWiFi: boolean, // Blocks return until we can confirm result has the correct MIME +finalFileHeaderCheck?: boolean, - +onTranscodingProgress: (percent: number) => void, + +onTranscodingProgress?: (percent: number) => void, }; type SharedMediaResult = { +success: true, diff --git a/native/media/video-utils.js b/native/media/video-utils.js --- a/native/media/video-utils.js +++ b/native/media/video-utils.js @@ -38,7 +38,7 @@ }; type VideoProcessConfig = { - +onTranscodingProgress: (percent: number) => void, + +onTranscodingProgress?: (percent: number) => void, }; type ProcessVideoResponse = { @@ -200,7 +200,7 @@ async function transcodeVideo( plan: ProcessPlan, duration: number, - onProgressCallback: number => void, + onProgressCallback?: number => void, ): Promise { const transcodeStart = Date.now(); let returnCode,