react-native-compressor 1.10.0 → 1.10.1
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
|
|
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
|
-
|
|
266
|
+
dispatchGroup.leave()
|
|
267
267
|
}
|
|
268
268
|
})
|
|
269
|
-
}
|
|
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
|
-
|
|
276
|
+
dispatchGroup.leave()
|
|
278
277
|
}
|
|
279
278
|
})
|
|
280
|
-
}
|
|
281
|
-
audioSemaphore.signal()
|
|
282
|
-
}
|
|
279
|
+
}
|
|
283
280
|
|
|
284
|
-
|
|
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
|
-
|
|
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.10.
|
|
3
|
+
"version": "1.10.1",
|
|
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",
|