- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频 Assets 和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法:
private func doMerge(arrayVideos:[AVAsset], arrayAudios:[AVAsset], animation:Bool, completion:@escaping Completion) -> Void {
var insertTime = kCMTimeZero
var audioInsertTime = kCMTimeZero
var arrayLayerInstructions:[AVMutableVideoCompositionLayerInstruction] = []
var outputSize = CGSize.init(width: 0, height: 0)
// Determine video output size
for videoAsset in arrayVideos {
let videoTrack = videoAsset.tracks(withMediaType: AVMediaTypeVideo)[0]
let assetInfo = orientationFromTransform(transform: videoTrack.preferredTransform)
var videoSize = videoTrack.naturalSize
if assetInfo.isPortrait == true {
videoSize.width = videoTrack.naturalSize.height
videoSize.height = videoTrack.naturalSize.width
}
outputSize = videoSize
}
// Init composition
let mixComposition = AVMutableComposition.init()
for index in 0..
// Get video track
guard let videoTrack = arrayVideos[index].tracks(withMediaType: AVMediaTypeVideo).first else { continue }
// Get audio track
var audioTrack:AVAssetTrack?
if index < arrayAudios.count {
if arrayAudios[index].tracks(withMediaType: AVMediaTypeAudio).count > 0 {
audioTrack = arrayAudios[index].tracks(withMediaType: AVMediaTypeAudio).first
}
}
// Init video & audio composition track
let videoCompositionTrack = mixComposition.addMutableTrack(withMediaType: AVMediaTypeVideo, preferredTrackID: Int32(kCMPersistentTrackID_Invalid))
let audioCompositionTrack = mixComposition.addMutableTrack(withMediaType: AVMediaTypeAudio, preferredTrackID: Int32(kCMPersistentTrackID_Invalid))
LÀM {
let startTime = kCMTimeZero
let duration = arrayVideos[index].duration
// Add video track to video composition at specific time
try videoCompositionTrack.insertTimeRange(CMTimeRangeMake(startTime, duration), of: videoTrack, at: insertTime)
// Add audio track to audio composition at specific time
var audioDuration = kCMTimeZero
if index < arrayAudios.count {
audioDuration = arrayAudios[index].duration
}
if let audioTrack = audioTrack {
LÀM {
try audioCompositionTrack.insertTimeRange(CMTimeRangeMake(startTime, audioDuration), of: audioTrack, at: audioInsertTime)
}
catch {
print(error.localizedDescription)
}
}
// Add instruction for video track
let layerInstruction = videoCompositionInstructionForTrack(track: videoCompositionTrack, asset: arrayVideos[index], standardSize: outputSize, atTime: insertTime)
// Hide video track before changing to new track
let endTime = CMTimeAdd(insertTime, duration)
if animation {
let timeScale = arrayVideos[index].duration.timescale
let durationAnimation = CMTime.init(seconds: 1, preferredTimescale: timeScale)
layerInstruction.setOpacityRamp (fromStartOpacity: 1.0, toEndOpacity: 0.0, timeRange: CMTimeRange.init(start: endTime, duration: durationAnimation))
}
else {
layerInstruction.setOpacity(0, at: endTime)
}
arrayLayerInstructions.append(layerInstruction)
// Increase the insert time
audioInsertTime = CMTimeAdd(audioInsertTime, audioDuration)
insertTime = CMTimeAdd(insertTime, duration)
}
catch {
print("Load track error")
}
}
// Main video composition instruction
let mainInstruction = AVMutableVideoCompositionInstruction()
mainInstruction.timeRange = CMTimeRangeMake(kCMTimeZero, insertTime)
mainInstruction.layerInstructions = arrayLayerInstructions
// Main video composition
let mainComposition = AVMutableVideoComposition()
mainComposition.instructions = [mainInstruction]
mainComposition.frameDuration = CMTimeMake(1, 30)
mainComposition.renderSize = outputSize
// Export to file
let path = NSTemporaryDirectory().appending("mergedVideo.mp4")
let exportURL = URL.init(fileURLWithPath: path)
// Remove file if existed
FileManager.default.removeItemIfExisted(exportURL)
// Init exporter
let exporter = AVAssetExportSession.init(asset: mixComposition, presetName: AVAssetExportPresetHighestQuality)
exporter?.outputURL = exportURL
exporter?.outputFileType = AVFileTypeQuickTimeMovie//AVFileType.mp4
exporter?.shouldOptimizeForNetworkUse = false //true
exporter?.videoComposition = mainComposition
// Do export
exporter?.exportAsynchronously(completionHandler: {
DispatchQueue.main.async {
self.exportDidFinish(exporter: exporter, videoURL: exportURL, completion: completion)
}
})
}
fileprivate func exportDidFinish(exporter:AVAssetExportSession?, videoURL:URL, completion:@escaping Completion) -> Void {
if exporter?.status == AVAssetExportSessionStatus.completed {
print("Exported file: \(videoURL.absoluteString)")
completion(videoURL,nil)
}
else if exporter?.status == AVAssetExportSessionStatus.failed {
completion(videoURL,exporter?.error)
print(exporter?.error as Any)
}
}
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-16976), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1c065fb30 {Error Domain=NSOSStatusErrorDomain Code=-16976 "(null)"}}
1 Câu trả lời
我有完全相同的错误,并且仅在运行 iOS11 的 iPhone 5S 模拟器上。我通过将导出操作的质量设置从“最高”(AVAssetExportPresetHighestQuality)更改为 来修复它“通过”(AVAssetExportPresetPassthrough) (保持原始质量):
/// try to start an export session and set the path and file type
if let exportSession = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetPassthrough) { /* AVAssetExportPresetHighestQuality */
exportSession.outputURL = videoOutputURL
exportSession.outputFileType = AVFileType.mp4
exportSession.shouldOptimizeForNetworkUse = true
exportSession.exportAsynchronously(completionHandler: {
switch exportSession.status {
case .failed:
if let _error = exportSession.error {
// !!!used to fail over here with 11800, -16976 codes, if using AVAssetExportPresetHighestQuality. But works fine when using: AVAssetExportPresetPassthrough
failure(_error)
}
....
关于ios - 错误域=AVFoundationErrorDomain 代码=-11800 "The operation could not be completed"{错误域=NSOSStatusErrorDomain 代码=-16976 "(null)"},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51239586/
Tôi cố gắng hiểu mã [c code -> assembly] void node::Check( data & _data1, vector& _data2) { -> push ebp -> mov ebp,esp ->
Tôi cần chạy mã từ một tệp văn bản trong bối cảnh của biểu mẫu hiện tại (mã). Một trong những yêu cầu là phải có mã tạo ra một điều khiển mới và thêm nó vào biểu mẫu hiện tại. Ví dụ, trong Form1.cs: sử dụng System.Windows.Forms; ..
Tôi có mã C++ này và đã chuyển đổi nó thành mã C# (.net Framework 4). Có ai có thể cho tôi một số mẹo về phương thức malloc, free và sprintf không? int monate = ee; d
Tôi có vấn đề với mã máy chủ web của tôi #include #include #include #include #include #include #include #include int
Với mã html sau, mã CSS nào sẽ in nghiêng phần tử thứ ba trong danh sách (tức là từ "beautiful")? Tất nhiên, tôi có thể cung cấp cho phần tử này một id hoặc một lớp, nhưng mã html phải giữ nguyên. Cảm ơn
đóng cửa. Câu hỏi này không đáp ứng được hướng dẫn của Stack Overflow. Hiện tại câu hỏi này không chấp nhận câu trả lời. Chúng tôi không chấp nhận những câu hỏi tìm kiếm lời khuyên về sách, công cụ, thư viện phần mềm, v.v. Bạn có thể chỉnh sửa câu hỏi để có thể trả lời bằng các sự kiện và trích dẫn. Đã đóng cửa cách đây 7 năm.
Tôi đang cố gắng tạo một macro để tránh lặp lại mã và bình luận. Tôi đã thử cách này: #define GrowOnPage(any Page, any Component) Component.Width := Page.Surfa
Tôi đang cố gắng "dịch" mã C++ cũ của mình sang C# như tiêu đề bài viết gợi ý. Vấn đề là tôi mới học C# và không phải mọi thứ đều giống như C++. Trong C++, các giải pháp này hoạt động tốt, nhưng trong C# thì không. TÔI
Khi hoạt động trên Windows 10, trình định dạng ngôn ngữ R dường như không hoạt động trong Visual Studio Code. Tôi đã thử hỗ trợ R cho Visual Studio Code và RT
Tôi đang làm một số báo cáo (đếm) và tôi phải lấy số lượng các tham số khác nhau. Rất đơn giản nhưng nhàm chán. Ví dụ truy vấn với một tham số: qCountsEmployee = ( "select count(*) from %s where
Vài ngày gần đây tôi đã cố gắng gỡ lỗi mạng từ d00m. Tôi sắp hết ý tưởng/gợi ý rồi và tôi hy vọng những người dùng SO khác có kinh nghiệm quý báu có thể giúp ích cho tôi. Tôi ước mình có thể cung cấp mọi thông tin có liên quan, nhưng cá nhân tôi không thể kiểm soát được môi trường máy chủ. Mọi thứ bắt đầu khi người dùng chú ý đến ứng dụng của chúng tôi
Tôi có một tệp app.js chứa mã chế độ amd dojo sau: require(["dojo/dom", ..], function(dom){ dom.byId('someId').i
Tôi hơi bối rối về tùy chọn "code=sm_X" trong câu lệnh "-gencode". Ví dụ: tùy chọn biên dịch NVCC -gencode arch=compute_13,code=sm_13 có tác dụng gì để nhúng thư viện? chỉ một
Tôi đang sử dụng khung X-editable cho biểu mẫu của mình. Nhưng tôi có một số câu hỏi. $(document).ready(function() { $('.access').editable({
Tôi đã học Flask/Python thông qua hướng dẫn này http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wo
Tôi muốn sử dụng Vim và EMACS cho CNC, G-code và M-code. Có cú pháp hoặc chế độ nào trong Vim hoặc EMACS để xử lý loại mã này không? Câu trả lời hay nhất Một số tìm kiếm nhanh chóng dẫn tôi đến vim này và điều này
đóng cửa. Câu hỏi này không đáp ứng được hướng dẫn của Stack Overflow. Hiện tại câu hỏi này không chấp nhận câu trả lời. Bạn có muốn cải thiện câu hỏi này không? Cập nhật câu hỏi để nó phù hợp với chủ đề của Stack Overflow. Đã đóng cửa cách đây 7 năm. Cải thiện điều này
Câu hỏi này đã có câu trả lời tại đây: Bật tính năng đánh dấu markdown trong Vim (5 câu trả lời) Đã đóng 6 năm trước. Khi tôi chỉnh sửa tệp READM có chứa mã Markdown trong Vim
Tôi đang phát triển một ứng dụng video bằng Swift3 iOS. Về cơ bản, tôi phải hợp nhất các nội dung video và âm thanh có hiệu ứng mờ dần thành một và lưu vào thư viện ảnh trên iPhone. Để làm điều này tôi sử dụng phương pháp sau: private func d
đường ống { đại lý bất kỳ giai đoạn nào { giai đoạn ('Xây dựng') { các bước { e
Tôi là một lập trình viên xuất sắc, rất giỏi!