diff --git a/lib/types/media-types.js b/lib/types/media-types.js --- a/lib/types/media-types.js +++ b/lib/types/media-types.js @@ -97,7 +97,7 @@ +thumbHash?: string, }; -export type FFmpegStatistics = { +export type TranscodingStatistics = { // seconds of video being processed per second +speed: number, // total milliseconds of video processed so far @@ -107,12 +107,12 @@ }; export type TranscodeVideoMediaMissionStep = { - +step: 'video_ffmpeg_transcode', + +step: 'video_transcode', +success: boolean, +exceptionMessage: ?string, +time: number, // ms +newPath: ?string, - +stats: ?FFmpegStatistics, + +stats: ?TranscodingStatistics, }; export type VideoGenerateThumbnailMediaMissionStep = { diff --git a/native/android/build.gradle b/native/android/build.gradle --- a/native/android/build.gradle +++ b/native/android/build.gradle @@ -26,10 +26,6 @@ } } -ext { - ffmpegKitPackage = "min-lts" -} - allprojects { repositories { maven { diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj --- a/native/ios/Comm.xcodeproj/project.pbxproj +++ b/native/ios/Comm.xcodeproj/project.pbxproj @@ -1180,27 +1180,11 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Comm/Pods-Comm-frameworks.sh", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/ffmpegkit.framework/ffmpegkit", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libavcodec.framework/libavcodec", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libavdevice.framework/libavdevice", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libavfilter.framework/libavfilter", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libavformat.framework/libavformat", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libavutil.framework/libavutil", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libswresample.framework/libswresample", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/ffmpeg-kit-ios-min/libswscale.framework/libswscale", "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework/hermes", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ffmpegkit.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavcodec.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavdevice.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavfilter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavformat.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libavutil.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libswresample.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libswscale.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework", ); runOnlyForDeploymentPostprocessing = 0; diff --git a/native/ios/Podfile b/native/ios/Podfile --- a/native/ios/Podfile +++ b/native/ios/Podfile @@ -10,7 +10,6 @@ def common_comm_target_pods pod 'SQLCipher-Amalgamation', :path => '../../node_modules/@commapp/sqlcipher-amalgamation' pod 'react-native-video/VideoCaching', :podspec => '../node_modules/react-native-video' - pod 'ffmpeg-kit-react-native', :subspecs => ['min'], :podspec => '../node_modules/ffmpeg-kit-react-native' end post_integrate do |installer| diff --git a/native/ios/Podfile.lock b/native/ios/Podfile.lock --- a/native/ios/Podfile.lock +++ b/native/ios/Podfile.lock @@ -132,10 +132,6 @@ - React-Core (= 0.70.15) - React-jsi (= 0.70.15) - ReactCommon/turbomodule/core (= 0.70.15) - - ffmpeg-kit-ios-min (6.0) - - ffmpeg-kit-react-native/min (6.0.2): - - ffmpeg-kit-ios-min (= 6.0) - - React-Core - fmt (6.2.1) - glog (0.3.5) - hermes-engine (0.70.15) @@ -608,7 +604,6 @@ - EXUpdatesInterface (from `../../node_modules/expo-updates-interface/ios`) - FBLazyVector (from `../../node_modules/react-native/Libraries/FBLazyVector`) - FBReactNativeSpec (from `../../node_modules/react-native/React/FBReactNativeSpec`) - - ffmpeg-kit-react-native/min (from `../node_modules/ffmpeg-kit-react-native`) - glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (from `../../node_modules/react-native/sdks/hermes/hermes-engine.podspec`) - libevent (~> 2.1.12) @@ -671,7 +666,6 @@ SPEC REPOS: trunk: - DVAssetLoaderDelegate - - ffmpeg-kit-ios-min - fmt - libaom - libavif @@ -747,8 +741,6 @@ :path: "../../node_modules/react-native/Libraries/FBLazyVector" FBReactNativeSpec: :path: "../../node_modules/react-native/React/FBReactNativeSpec" - ffmpeg-kit-react-native: - :podspec: "../node_modules/ffmpeg-kit-react-native" glog: :podspec: "../../node_modules/react-native/third-party-podspecs/glog.podspec" hermes-engine: @@ -888,8 +880,6 @@ EXUpdatesInterface: bffd1ead18f0bab04fa784ca159c115607b8a23c FBLazyVector: 9cf707e46f9bd90816b7c91b2c1c8b8a2f549527 FBReactNativeSpec: 771fae43bc7b966ff4464a2a93407f666958a652 - ffmpeg-kit-ios-min: 4e9a088f4ee9629435960b9d68e54848975f1931 - ffmpeg-kit-react-native: 3cea88c9c5cfad62e1465279ea7d800dfbba3b00 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b hermes-engine: 2592781da1571e4375dfd897f9462638c2d0ceb9 @@ -962,6 +952,6 @@ Yoga: d6134eb3d6e3675afc1d6d65ccb3169b60e21980 ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5 -PODFILE CHECKSUM: e798997ef1aaf79a5061dcbe1ee62bb7df19b483 +PODFILE CHECKSUM: f76805dc4a3fa10f92a1a57ac8cd3105aec6708f COCOAPODS: 1.14.3 diff --git a/native/media/file-utils.js b/native/media/file-utils.js --- a/native/media/file-utils.js +++ b/native/media/file-utils.js @@ -27,7 +27,7 @@ import { getMessageForException } from 'lib/utils/errors.js'; import { stringToIntArray } from './blob-utils.js'; -import { ffmpeg } from './ffmpeg.js'; +import { mediaProcessingQueue } from './media-processing-queue.js'; const defaultInputs = Object.freeze({}); const defaultFields = Object.freeze({}); @@ -309,7 +309,7 @@ exceptionMessage; const start = Date.now(); try { - hasMultipleFrames = await ffmpeg.hasMultipleFrames(path); + hasMultipleFrames = await mediaProcessingQueue.hasMultipleFrames(path); success = true; } catch (e) { exceptionMessage = getMessageForException(e); diff --git a/native/media/ffmpeg.js b/native/media/media-processing-queue.js rename from native/media/ffmpeg.js rename to native/media/media-processing-queue.js --- a/native/media/ffmpeg.js +++ b/native/media/media-processing-queue.js @@ -1,5 +1,8 @@ // @flow -import type { FFmpegStatistics, VideoInfo } from 'lib/types/media-types.js'; +import type { + TranscodingStatistics, + VideoInfo, +} from 'lib/types/media-types.js'; import type { TranscodeOptions } from '../utils/media-module.js'; import { @@ -21,7 +24,7 @@ runCommand: () => Promise<void>, }; -class FFmpeg { +class MediaProcessingQueue { queue: QueuedCommand[] = []; currentCalls: CallCounter = { process: 0, probe: 0 }; @@ -83,7 +86,7 @@ outputPath: string, transcodeOptions: TranscodeOptions, onTranscodingProgress?: (percent: number) => void, - ): Promise<FFmpegStatistics> { + ): Promise<TranscodingStatistics> { const wrappedCommand = async () => { const stats = await transcodeVideo( inputPath, @@ -106,7 +109,7 @@ } getVideoInfo(path: string): Promise<VideoInfo> { - const wrappedCommand = () => FFmpeg.innerGetVideoInfo(path); + const wrappedCommand = () => MediaProcessingQueue.innerGetVideoInfo(path); return this.queueCommand('probe', wrappedCommand); } @@ -127,6 +130,6 @@ } } -const ffmpeg: FFmpeg = new FFmpeg(); +const mediaProcessingQueue: MediaProcessingQueue = new MediaProcessingQueue(); -export { ffmpeg }; +export { mediaProcessingQueue }; 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 @@ -16,8 +16,8 @@ } from 'lib/types/media-types.js'; import { getMessageForException } from 'lib/utils/errors.js'; -import { ffmpeg } from './ffmpeg.js'; import { temporaryDirectoryPath } from './file-utils.js'; +import { mediaProcessingQueue } from './media-processing-queue.js'; import { generateThumbhashStep } from './media-utils.js'; // These are some numbers I sorta kinda made up @@ -193,7 +193,7 @@ const thumbnailStart = Date.now(); let exceptionMessage; try { - await ffmpeg.generateThumbnail(path, thumbnailPath); + await mediaProcessingQueue.generateThumbnail(path, thumbnailPath); } catch (e) { exceptionMessage = getMessageForException(e); } @@ -214,7 +214,7 @@ const transcodeStart = Date.now(); let newPath, stats, exceptionMessage; try { - stats = await ffmpeg.transcodeVideo( + stats = await mediaProcessingQueue.transcodeVideo( plan.inputPath, plan.outputPath, { @@ -230,7 +230,7 @@ } return { - step: 'video_ffmpeg_transcode', + step: 'video_transcode', success: !exceptionMessage, exceptionMessage, time: Date.now() - transcodeStart, @@ -251,7 +251,8 @@ exceptionMessage; const start = Date.now(); try { - ({ codec, format, dimensions, duration } = await ffmpeg.getVideoInfo(path)); + ({ codec, format, dimensions, duration } = + await mediaProcessingQueue.getVideoInfo(path)); success = true; validFormat = validCodecs.includes(codec) && validFormats.includes(format); } catch (e) { diff --git a/native/package.json b/native/package.json --- a/native/package.json +++ b/native/package.json @@ -89,7 +89,6 @@ "expo-secure-store": "~12.0.0", "expo-splash-screen": "~0.17.4", "fastestsmallesttextencoderdecoder": "^1.0.22", - "ffmpeg-kit-react-native": "^6.0.2", "find-root": "^1.1.0", "invariant": "^2.2.4", "lib": "0.0.1", diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -12447,11 +12447,6 @@ resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.7.4.tgz#61587e5d958fdabb5a9368a302c25363f4f69f50" integrity sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw== -ffmpeg-kit-react-native@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/ffmpeg-kit-react-native/-/ffmpeg-kit-react-native-6.0.2.tgz#9eeac96ad89367c99480bd90431391405d4eb73e" - integrity sha512-r9uSmahq8TeyIb7fXf3ft+uUXyoeWRFa99+khjo0TAzWO9y0z9wU7eGnab9JLw1MmCB9v64o4yojNluJhVm9nQ== - figma-squircle@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/figma-squircle/-/figma-squircle-0.1.2.tgz#fa97de644131d99f2c42a2d8b70d56a36783c234"