簡體   English   中英

FFmpeg iOS - >輸出文件無效

[英]FFmpeg iOS -> output file is invalid

我正在使用以下庫將mkv轉換為mp4: https//github.com/SterlingOnLoop/FFmpegWrapper

- (void)convertUsingFFmpegWrapper {
    NSString *mp4Extension = @"mp4";
    NSString *mkvExtension = @"mkv";

    NSString *videoName = @"file1";
//    NSString *videoName = @"file2";

    NSString *mkvVideoFilePath = [[NSBundle mainBundle] pathForResource:videoName ofType:mkvExtension];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = paths[0];
    NSString *mp4VideoFilePath = [NSString stringWithFormat:@"%@/%@.%@", documentsDirectory, videoName, mp4Extension];

    FFmpegWrapper *ffmpegWrapper = [[FFmpegWrapper alloc] init];
    NSDictionary *options = @{kFFmpegInputFormatKey: mkvExtension, kFFmpegOutputFormatKey: mp4Extension};
    [ffmpegWrapper convertInputPath:mkvVideoFilePath outputPath:mp4VideoFilePath options:options progressBlock:nil completionBlock:^(BOOL success, NSError *error) {
        if (success && !error) {
            // delete mp4 file
        } else if (error) {
            NSLog(@"Error during .MKV -> .MP4 conversion occured: %@", error.localizedDescription);
        } else {
            NSLog(@"Unknown error during .MKV -> .MP4 conversion occured.");
        }
    }];
}

以下是LLDB關於自動檢測到的編解碼器類型的值:

(lldb) po inputStream.codecName
aac

(lldb) po outputStream.codecName
aac

我應該在這里提一下,在Linux上,產生最初的文件與下列編解碼器: vaapiencode_h264視頻和faac的聲音。

問題是文件根本不起作用。 我在控制台中獲得了大量日志,其中最重要的是:

[aac @ 0x7f7f65019200] Format aac detected only with low score of 1, misdetection possible!

在庫中,使用以下函數:

int streamInfoValue = avformat_find_stream_info(inputFormatContext, NULL);

確切地說,這條線與日志完全混亂。 顯然,如果沒有這行,我會收到帶有無效參數的錯誤。

打開該行時,將生成.mp4文件。 它持續> 5分鍾,而輸入文件長11秒。 它無法在我的Mac上使用VLC播放(似乎已被破壞)。 我得到以下錯誤(我粘貼了一些錯誤,可以在這里找到完整的跟蹤, 這里引用它太長了):

[aac @ 0x7ff07c00b000] More than one AAC RDB per ADTS frame is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[aac @ 0x7ff07c00b000] channel element 0.0 is not allocated
[aac @ 0x7ff07c00b000] Sample rate index in program config element does not match the sample rate index configured by the container.
[aac @ 0x7ff07c00b000] Inconsistent channel configuration.
[aac @ 0x7ff07c00b000] get_buffer() failed
[aac @ 0x7ff07c00b000] channel element 3.10 is not allocated
[aac @ 0x7ff07c00b000] Reserved bit set.
[aac @ 0x7ff07c00b000] invalid band type
[aac @ 0x7ff07c00b000] Number of scalefactor bands in group (50) exceeds limit (41).
[aac @ 0x7ff07c00b000] Reserved bit set.
[aac @ 0x7ff07c00b000] Number of bands (7) exceeds limit (4).
[aac @ 0x7ff07c00b000] Reserved bit set.
[aac @ 0x7ff07c00b000] Dependent coupling is not supported together with LTP

知道如何簡單地將mkv轉換為mp4嗎? 我不知道為什么會出錯。 我聲稱該文件不是aac,但linux使用這種編碼,所以它應該是有效的。

我檢查了你的檔案。 我能看到的主要問題是:

  • 沒有音頻比特率(即:應設置128kbps)
  • 不知何故,元數據將AAC版本列為4(這甚至意味着什么?)。
  • 編解碼器ID應為40但在MKV的元數據中,它被列為A_AAC/MPEG4/LC
  • 字節中的通道位置沒有標志(即:前L + R)

無論如何ffmpeg(命令行)轉換你的MKV沒有任何錯誤。
讓我知道這個新的重新編碼的MP4版本是否適合您。

ffmpeg設置很簡單: ffmpeg -i mkv_demo.mkv -c:v copy demo_new.mp4

不幸的是我不在iOS中編碼,因此我無法向您顯示“固定”代碼。 也許有人可以在以后幫忙。 看看這個額外提示的其他答案 (讓它像上面顯示的命令行代碼段一樣工作)...

暫無
暫無

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

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