@honem/native-video-compressor 0.1.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.
- package/HonemNativeVideoCompressor.podspec +15 -0
- package/README.md +283 -0
- package/android/build.gradle +31 -0
- package/android/src/main/AndroidManifest.xml +15 -0
- package/android/src/main/java/com/honem/nativevideocompressor/VideoCompressor.java +488 -0
- package/android/src/main/java/com/honem/nativevideocompressor/VideoCompressorPlugin.java +72 -0
- package/dist/definitions.d.ts +76 -0
- package/dist/definitions.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -0
- package/dist/web.d.ts +6 -0
- package/dist/web.js +9 -0
- package/electron/README.md +53 -0
- package/electron/src/index.ts +4 -0
- package/electron/src/video-compressor.ts +202 -0
- package/ios/Plugin/Plugin.m +7 -0
- package/ios/Plugin/VideoCompressor.swift +378 -0
- package/ios/Plugin/VideoCompressorPlugin.swift +61 -0
- package/ios/VideoCompressor.podspec +14 -0
- package/package.json +64 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import AVFoundation
|
|
4
|
+
|
|
5
|
+
@objc(VideoCompressorPlugin)
|
|
6
|
+
public class VideoCompressorPlugin: CAPPlugin {
|
|
7
|
+
private let implementation = VideoCompressor()
|
|
8
|
+
|
|
9
|
+
@objc func compressVideo(_ call: CAPPluginCall) {
|
|
10
|
+
guard let inputPath = call.getString("inputPath") else {
|
|
11
|
+
call.reject("inputPath is required")
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let outputPath = call.getString("outputPath")
|
|
16
|
+
let quality = call.getString("quality", "medium")
|
|
17
|
+
let bitrate = call.getInt("bitrate")
|
|
18
|
+
let width = call.getInt("width")
|
|
19
|
+
let height = call.getInt("height")
|
|
20
|
+
let format = call.getString("format")
|
|
21
|
+
|
|
22
|
+
let startTime = Date()
|
|
23
|
+
|
|
24
|
+
implementation.compressVideo(
|
|
25
|
+
inputPath: inputPath,
|
|
26
|
+
outputPath: outputPath,
|
|
27
|
+
quality: quality,
|
|
28
|
+
bitrate: bitrate,
|
|
29
|
+
width: width,
|
|
30
|
+
height: height,
|
|
31
|
+
format: format,
|
|
32
|
+
completion: { result in
|
|
33
|
+
switch result {
|
|
34
|
+
case .success(let outputPath, let originalSize, let compressedSize):
|
|
35
|
+
let duration = Date().timeIntervalSince(startTime) * 1000
|
|
36
|
+
let compressionRatio = Double(originalSize) / Double(compressedSize)
|
|
37
|
+
|
|
38
|
+
call.resolve([
|
|
39
|
+
"outputPath": outputPath,
|
|
40
|
+
"originalSize": originalSize,
|
|
41
|
+
"compressedSize": compressedSize,
|
|
42
|
+
"compressionRatio": compressionRatio,
|
|
43
|
+
"duration": Int(duration)
|
|
44
|
+
])
|
|
45
|
+
case .failure(let error):
|
|
46
|
+
call.reject(error.localizedDescription)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@objc func deleteFile(_ call: CAPPluginCall) {
|
|
53
|
+
guard let path = call.getString("path") else {
|
|
54
|
+
call.reject("path is required")
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let success = implementation.deleteFile(path)
|
|
59
|
+
call.resolve(["success": success])
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Pod::Spec.new do |s|
|
|
2
|
+
s.name = 'HonemNativeVideoCompressor'
|
|
3
|
+
s.version = '0.1.0'
|
|
4
|
+
s.summary = 'Capacitor plugin for video compression using native platform APIs'
|
|
5
|
+
s.license = 'MIT'
|
|
6
|
+
s.homepage = 'https://github.com/honem/native-video-compressor'
|
|
7
|
+
s.author = 'honem'
|
|
8
|
+
s.source = { :git => 'https://github.com/honem/native-video-compressor.git', :tag => s.version.to_s }
|
|
9
|
+
s.source_files = 'Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
10
|
+
s.ios.deployment_target = '15.0'
|
|
11
|
+
s.dependency 'Capacitor'
|
|
12
|
+
s.swift_version = '5.1'
|
|
13
|
+
s.static_framework = true
|
|
14
|
+
end
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@honem/native-video-compressor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Capacitor plugin for video compression using native platform APIs (iOS AVFoundation, Android MediaCodec, Electron FFmpeg)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/",
|
|
9
|
+
"ios/",
|
|
10
|
+
"android/",
|
|
11
|
+
"electron/",
|
|
12
|
+
"HonemNativeVideoCompressor.podspec"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"watch": "tsc --watch",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"capacitor",
|
|
21
|
+
"capacitor-plugin",
|
|
22
|
+
"plugin",
|
|
23
|
+
"video",
|
|
24
|
+
"video-compression",
|
|
25
|
+
"compression",
|
|
26
|
+
"native",
|
|
27
|
+
"ios",
|
|
28
|
+
"android",
|
|
29
|
+
"electron",
|
|
30
|
+
"ffmpeg",
|
|
31
|
+
"mediacodec",
|
|
32
|
+
"avfoundation"
|
|
33
|
+
],
|
|
34
|
+
"author": "honem",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/honem/native-video-compressor.git"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/honem/native-video-compressor/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/honem/native-video-compressor#readme",
|
|
44
|
+
"capacitor": {
|
|
45
|
+
"ios": {
|
|
46
|
+
"src": "ios"
|
|
47
|
+
},
|
|
48
|
+
"android": {
|
|
49
|
+
"src": "android"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@capacitor/core": "^6.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@capacitor/core": "^6.2.0",
|
|
57
|
+
"typescript": "~5.9.3"
|
|
58
|
+
},
|
|
59
|
+
"optionalDependencies": {
|
|
60
|
+
"fluent-ffmpeg": "^2.1.2",
|
|
61
|
+
"@ffmpeg-installer/ffmpeg": "^1.1.0",
|
|
62
|
+
"@types/fluent-ffmpeg": "^2.1.24"
|
|
63
|
+
}
|
|
64
|
+
}
|