HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了FFmpeg iOS – >输出文件无效大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用以下库将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关于自动检测到的编解码器类型的值:@H_696_10@

(lldb) po inputStream.codecName
aac

(lldb) po outputStream.codecName
aac

我应该在这里提一下,原来该文件是在Linux上使用以下编解码器生成的:用于视频的vaapiencode_h264和用于声音的faac.@H_696_10@

问题是文件根本不起作用.我在控制台中获得了大量日志,其中最重要的是:@H_696_10@

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

在库中,使用以下函数:@H_696_10@

int streamInfoValue = avformat_find_stream_info(inputFormatContext,null);

确切地说,这条线与日志完全混乱.显然,如果没有这行,我会收到带有无效参数的错误.@H_696_10@

打开该行时,将生成.mp4文件.它持续> 5分钟,而输入文件是11秒长.它无法在我的Mac上使用VLC播放(似乎已被破坏).我得到了以下错误(我粘贴了一些错误,完整的跟踪可以找到here,这里引用的时间太长了):@H_696_10@

[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使用这种编码,所以它应该是有效的.@H_696_10@

解决方法

我检查了你的档案.我能看到的主要问题是:

>没有音频比特率(即:应设置128kbps)
>不知何故,元数据将AAC版本列为4(这甚至意味着什么?).
>编解码器ID应为40,但在MKV的元数据中,它被列为A_AAC / MPEG4 / LC
>字节中的通道位置没有标志(即:Front L R)@H_696_10@

无论如何ffmpeg(命令行)转换你的MKV没有任何错误.让我知道这个新的re-encoded MP4版本是否适合你.@H_696_10@

ffmpeg设置很简单:ffmpeg -i mkv_demo.mkv -c:v copy demo_new.mp4@H_696_10@

不幸的是我不在iOS中编码,因此我无法向您显示“固定”代码.也许有人可以在以后帮忙.看看这个其他Answer的额外提示(让它像上面显示的命令行代码段一样工作)…@H_696_10@

大佬总结

以上是大佬教程为你收集整理的FFmpeg iOS – >输出文件无效全部内容,希望文章能够帮你解决FFmpeg iOS – >输出文件无效所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。