ffmpeg sync

This commit is contained in:
overtake
2022-01-14 13:55:58 +04:00
parent 7f78d57780
commit d3a399ed6a
13 changed files with 174 additions and 70 deletions

View File

@@ -1,5 +1,9 @@
import Foundation
#if !os(macOS)
import UIKit
#else
import AppKit
#endif
import CoreMedia
import SwiftSignalKit
import FFMpegBinding
@@ -57,7 +61,7 @@ public final class SoftwareVideoSource {
private var enqueuedFrames: [(MediaTrackFrame, CGFloat, CGFloat, Bool)] = []
private var hasReadToEnd: Bool = false
public init(path: String) {
public init(path: String, hintVP9: Bool) {
let _ = FFMpegMediaFrameSourceContextHelpers.registerFFMpegGlobals
var s = stat()
@@ -74,7 +78,9 @@ public final class SoftwareVideoSource {
self.path = path
let avFormatContext = FFMpegAVFormatContext()
if hintVP9 {
avFormatContext.forceVideoCodecId(FFMpegCodecIdVP9)
}
let ioBufferSize = 64 * 1024
let avIoContext = FFMpegAVIOContext(bufferSize: Int32(ioBufferSize), opaqueContext: Unmanaged.passUnretained(self).toOpaque(), readPacket: readPacketCallback, writePacket: nil, seek: seekCallback)