react-native-compressor 1.9.0 → 1.10.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -254,36 +254,31 @@ extension NextLevelSessionExporter {
254
254
  self._reader?.startReading()
255
255
  self._writer?.startSession(atSourceTime: self.timeRange.start)
256
256
 
257
- let audioSemaphore = DispatchSemaphore(value: 0)
258
- let videoSemaphore = DispatchSemaphore(value: 0)
257
+ let dispatchGroup = DispatchGroup()
259
258
 
260
259
  let videoTracks = asset.tracks(withMediaType: AVMediaType.video)
261
260
  if let videoInput = self._videoInput,
262
261
  let videoOutput = self._videoOutput,
263
262
  videoTracks.count > 0 {
263
+ dispatchGroup.enter()
264
264
  videoInput.requestMediaDataWhenReady(on: self._inputQueue, using: {
265
265
  if self.encode(readySamplesFromReaderOutput: videoOutput, toWriterInput: videoInput) == false {
266
- videoSemaphore.signal()
266
+ dispatchGroup.leave()
267
267
  }
268
268
  })
269
- } else {
270
- videoSemaphore.signal()
271
- }
269
+ }
272
270
 
273
271
  if let audioInput = self._audioInput,
274
272
  let audioOutput = self._audioOutput {
273
+ dispatchGroup.enter()
275
274
  audioInput.requestMediaDataWhenReady(on: self._inputQueue, using: {
276
275
  if self.encode(readySamplesFromReaderOutput: audioOutput, toWriterInput: audioInput) == false {
277
- audioSemaphore.signal()
276
+ dispatchGroup.leave()
278
277
  }
279
278
  })
280
- } else {
281
- audioSemaphore.signal()
282
- }
279
+ }
283
280
 
284
- DispatchQueue.global().async {
285
- audioSemaphore.wait()
286
- videoSemaphore.wait()
281
+ dispatchGroup.notify(queue: .global()) {
287
282
  DispatchQueue.main.async {
288
283
  self.finish()
289
284
  }
@@ -369,13 +364,20 @@ extension NextLevelSessionExporter {
369
364
 
370
365
  private func setupAudioOutput(withAsset asset: AVAsset) {
371
366
  let audioTracks = asset.tracks(withMediaType: AVMediaType.audio)
367
+ var audioTracksToUse: [AVAssetTrack] = []
372
368
 
373
369
  guard audioTracks.count > 0 else {
374
370
  self._audioOutput = nil
375
371
  return
376
372
  }
377
-
378
- self._audioOutput = AVAssetReaderAudioMixOutput(audioTracks: audioTracks, audioSettings: nil)
373
+ // Remove APAC tracks
374
+ for audioTrack in audioTracks {
375
+ let mediaSubtypes = audioTrack.formatDescriptions.filter { CMFormatDescriptionGetMediaType($0 as! CMFormatDescription) == kCMMediaType_Audio }.map { CMFormatDescriptionGetMediaSubType($0 as! CMFormatDescription) }
376
+ for mediaSubtype in mediaSubtypes where mediaSubtype != kAudioFormatAPAC {
377
+ audioTracksToUse.append(audioTrack)
378
+ }
379
+ }
380
+ self._audioOutput = AVAssetReaderAudioMixOutput(audioTracks: audioTracksToUse, audioSettings: nil)
379
381
  self._audioOutput?.alwaysCopiesSampleData = false
380
382
  self._audioOutput?.audioMix = self.audioMix
381
383
  if let reader = self._reader,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-compressor",
3
- "version": "1.9.0",
3
+ "version": "1.10.1-alpha.0",
4
4
  "description": "Compress Image, Video, and Audio same like Whatsapp & Auto/Manual Compression | Background Upload | Download File | Create Video Thumbnail",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -84,6 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@commitlint/config-conventional": "^17.0.2",
86
86
  "@evilmartians/lefthook": "^1.2.2",
87
+ "@expo/config-plugins": "^7.2.5",
87
88
  "@jamesacarr/eslint-formatter-github-actions": "^0.2.0",
88
89
  "@react-native-community/eslint-config": "^3.0.2",
89
90
  "@release-it/conventional-changelog": "^5.0.0",
@@ -104,8 +105,7 @@
104
105
  "react-native-builder-bob": "^0.20.0",
105
106
  "release-it": "^15.0.0",
106
107
  "turbo": "^1.10.7",
107
- "typescript": "^5.0.2",
108
- "@expo/config-plugins": "^7.2.5"
108
+ "typescript": "^5.0.2"
109
109
  },
110
110
  "resolutions": {
111
111
  "@types/react": "17.0.21"
@@ -117,7 +117,6 @@
117
117
  "engines": {
118
118
  "node": ">= 16.0.0"
119
119
  },
120
- "packageManager": "^yarn@1.22.15",
121
120
  "jest": {
122
121
  "preset": "react-native",
123
122
  "modulePathIgnorePatterns": [
@@ -197,12 +196,8 @@
197
196
  "name": "RNCompressorSpec",
198
197
  "type": "modules",
199
198
  "jsSrcsDir": "src"
200
- },
201
- {
202
- "name": "RNVideoCompressorSpec",
203
- "type": "modules",
204
- "jsSrcsDir": "src"
205
199
  }
206
200
  ]
207
- }
201
+ },
202
+ "packageManager": "yarn@4.5.3+sha512.3003a14012e2987072d244c720506549c1aab73ee728208f1b2580a9fd67b92d61ba6b08fe93f6dce68fd771e3af1e59a0afa28dd242dd0940d73b95fedd4e90"
208
203
  }