remove zero padding from chunks file names
- rename index to chunkIndex
This commit is contained in:
parent
0a43d7a160
commit
98d90a6442
@ -25,7 +25,7 @@ class ChunkedRecorder: NSObject {
|
|||||||
let outputURL: URL
|
let outputURL: URL
|
||||||
let onChunkReady: ((Chunk) -> Void)
|
let onChunkReady: ((Chunk) -> Void)
|
||||||
|
|
||||||
private var index: UInt64 = 0
|
private var chunkIndex: UInt64 = 0
|
||||||
|
|
||||||
init(url: URL, onChunkReady: @escaping ((Chunk) -> Void)) throws {
|
init(url: URL, onChunkReady: @escaping ((Chunk) -> Void)) throws {
|
||||||
outputURL = url
|
outputURL = url
|
||||||
@ -61,13 +61,11 @@ extension ChunkedRecorder: AVAssetWriterDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func saveSegment(_ data: Data) {
|
private func saveSegment(_ data: Data) {
|
||||||
defer {
|
let name = "\(chunkIndex).mp4"
|
||||||
index += 1
|
|
||||||
}
|
|
||||||
let name = String(format: "%06d.mp4", index)
|
|
||||||
let url = outputURL.appendingPathComponent(name)
|
let url = outputURL.appendingPathComponent(name)
|
||||||
save(data: data, url: url)
|
save(data: data, url: url)
|
||||||
onChunkReady(url: url, type: .data(index: index))
|
onChunkReady(url: url, type: .data(index: chunkIndex))
|
||||||
|
chunkIndex += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
private func save(data: Data, url: URL) {
|
private func save(data: Data, url: URL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user