簡體   English   中英

使用ASScreenRecorder的AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer

[英]AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer using ASScreenRecorder

我正在嘗試使用ASScreenRecorder錄制屏幕。 問題是,有時這會起作用,有時會顯示警告:由於此行代碼, 無法將緩沖區寫入視頻到日志中:

BOOL success = [_avAdaptor appendPixelBuffer:pixelBuffer withPresentationTime:time];
                    if (!success) {
                        NSLog(@"Warning: Unable to write buffer to video");
               }

它不一致返回NO。 知道為什么嗎? 以及如何解決呢?

我已經提到了大多數相關問題,但對我沒有任何幫助。 這是帶有未解決問題的庫: https : //github.com/alskipp/ASScreenRecorder/issues/15

我發現一個解決方案可能不是有效的解決方案,但它為我解決了問題。 將線程休眠0.001(選擇任何timeInterval,該線程對我有用,而幀中沒有任何明顯的跳躍)

BOOL success = [_avAdaptor appendPixelBuffer:pixelBuffer withPresentationTime:time];
[NSThread sleepForTimeInterval:0.001]; // this line added
      if (!success){
            NSLog(@"Warning: Unable to write buffer to video");
      }

我希望將來能找到更好的解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM