delete comparison code, react-native-compressor
This commit is contained in:
+3
@@ -39,6 +39,7 @@ object VideoProber {
|
||||
// Get codec and frame rate from MediaExtractor for more accuracy
|
||||
val extractor = MediaExtractor()
|
||||
var codec = "unknown"
|
||||
var mimeType = "video/mp4"
|
||||
var extractedFrameRate = frameRate
|
||||
|
||||
try {
|
||||
@@ -52,6 +53,7 @@ object VideoProber {
|
||||
val format = extractor.getTrackFormat(i)
|
||||
val mime = format.getString(MediaFormat.KEY_MIME)
|
||||
if (mime?.startsWith("video/") == true) {
|
||||
mimeType = mime
|
||||
codec = mime.removePrefix("video/")
|
||||
if (format.containsKey(MediaFormat.KEY_FRAME_RATE)) {
|
||||
extractedFrameRate = format.getInteger(MediaFormat.KEY_FRAME_RATE).toFloat()
|
||||
@@ -79,6 +81,7 @@ object VideoProber {
|
||||
"duration" to durationSeconds,
|
||||
"bitrate" to effectiveBitrate,
|
||||
"fileSize" to fileSize,
|
||||
"mimeType" to mimeType,
|
||||
"codec" to codec,
|
||||
"hasAudio" to hasAudio,
|
||||
"frameRate" to extractedFrameRate.toDouble(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import AVFoundation
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
struct VideoProber {
|
||||
static func probe(url: URL) async throws -> [String: Any] {
|
||||
@@ -49,6 +50,14 @@ struct VideoProber {
|
||||
fileSize = 0
|
||||
}
|
||||
|
||||
// MIME type from file extension
|
||||
let mimeType: String
|
||||
if let utType = UTType(filenameExtension: url.pathExtension) {
|
||||
mimeType = utType.preferredMIMEType ?? "video/mp4"
|
||||
} else {
|
||||
mimeType = "video/mp4"
|
||||
}
|
||||
|
||||
// Bitrate: use estimated data rate, or calculate from file size
|
||||
let durationSeconds = CMTimeGetSeconds(duration)
|
||||
var bitrate = Int(estimatedDataRate)
|
||||
@@ -62,6 +71,7 @@ struct VideoProber {
|
||||
"duration": durationSeconds,
|
||||
"bitrate": bitrate,
|
||||
"fileSize": fileSize,
|
||||
"mimeType": mimeType,
|
||||
"codec": codec,
|
||||
"hasAudio": hasAudio,
|
||||
"frameRate": nominalFrameRate,
|
||||
|
||||
@@ -4,6 +4,7 @@ export type VideoMetadata = {
|
||||
duration: number // seconds
|
||||
bitrate: number // bps
|
||||
fileSize: number // bytes
|
||||
mimeType: string
|
||||
codec: string
|
||||
hasAudio: boolean
|
||||
frameRate: number
|
||||
|
||||
Reference in New Issue
Block a user