FFmpeg拼接文件时报错channel element 1.0 is not allocated的分析思路和解决方法
本文出处:http://blog.csdn.net/chaijunkun/article/details/117535933,转载请注明。由于本人不定期会整理相关博文,会对相应内容作出完善。因此强烈建议在原始出处查看此文。
拼接视频文件时的一个报错
书接上回,在上一篇文章:FFmpeg实现音视频同步的精准片段拼接中我在最后提到了使用concat方式拼接多段视频文件的方法。主要还是由于目前的自动化任务中,视频数量不可控。直接使用concat滤镜来进行拼接,内存会被撑爆,因此使用了ffmpeg -f concat -i manifest.txt这样的方式来进行拼接。
但是在拼接过程中,出现了以下的一段报错:
...正常编码信息...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000017079753400] Auto-inserting h264_mp4toannexb bitstream filter0 speed=1.45x
[aac @ 0000017075f0acc0] channel element 1.0 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 0000017075f0acc0] channel element 1.4 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input
[h264 @ 0000017075f22700] No start code is found.
[h264 @ 0000017075f22700] Error splitting the input into NAL units.
...以下重复上述错误信息...
主要是“channel element 1.0 is not allocated”,当然中间的数字是可变的,既然报错了,那么就打开FFmpeg的源码,来看看在哪里报这段错误,最终,我在libavcodec/aacdec_template.c中找到了这段错误的细节:
const int elem_type = aac_channel_layout_map[chan_config-1][i][0];
const int elem_id = aac_channel_layout_map[chan_config-1][i][1];
if (!(che=get_che(ac, elem_type, elem_id))) {av_log(ac->avctx, AV_LOG_ERROR,"channel element %d.%d is not allocated\n",elem_type, elem_id);return AVERROR_INVALIDDATA;
}
本错误在处理aac编码的音频流时发生,由于concat过程中,所有流的布局都是以第一个文件为准,那么后续所有文件的流布局必须也和第一个文件相同。例如有如下清单文件:
# manifest.txt
file 'video_01.mp4'
file 'video_02.mp4'
通过ffprobe命令查看流的布局信息:
ffprobe -show_streams -of json video_01.mp4
发现流的布局为:
"index": 0,
"codec_name": "h264",
"codec_type": "video",
...
"index": 1,
"codec_name": "aac",
"codec_type": "audio",
可以看到,流的布局:
0:视频流;
1:音频流。
再查看第二个文件的流布局:
"index": 0,
"codec_name": "aac",
"codec_type": "audio",
...
"index": 1,
"codec_name": "h264",
"codec_type": "video",
可以看到,流的布局:
0:音频流;
1:视频流。
···
流的顺序不一致,导致拼接失败。因此,只要统一顺序就可以了。一般习惯视频文件的第一个流为视频流,第二个流为音频流。
ffmpeg -i video_02.mp4 -c copy -map "0:v" -map "0:a" video_remapping_02.mp4
然后拼接时使用:
# manifest.txt
file 'video_01.mp4'
file 'video_remapping_02.mp4'
命令:
ffmpeg -f concat -i manifest.txt -c copy concat.mp4
FFmpeg拼接文件时报错channel element 1.0 is not allocated的分析思路和解决方法相关推荐
- vs2019运行项目时报错出现MSB6006 “CL.exe”已退出,代码为 2。解决方法
vs2019运行项目时报错出现MSB6006 "CL.exe"已退出,代码为 2.解决方法 其他人写过很多解决办法,排除配置文件的问题.主要问题就两个,一个是非空函数调用未指定返回 ...
- 运行nrm包 nrm ls 时报错无法查询到可选择的镜像源地址的问题及解决方法
node 运行nrm包 nrm ls 时报错无法查询到可选择的镜像源地址问题 1.安装 npm install nrm -g 2.运行 nrm ls 2.1 显示的报错 例如以下形式 PS C:\Us ...
- CC3200 Debug时报错:Unable to launch CCS debug-session based on current selection.的解决方法
错误:Unable to launch CCS debug-session based on current selection. 某文件路径/xxx.ccxml dose not exist in ...
- window环境下mysql导入sql文件时报错:ERROR: ASCII '\0' appeared in the statement
错误信息: ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mo ...
- python3.x执行post请求时报错“POST data should be bytes or an iterable of bytes...”的解决方法...
使用python3.5.1执行post请求时,一直报错"POST data should be bytes or an iterable of bytes. It cannot be of ...
- 执行ssh命令时报错CANNOT LINK EXECUTABLE “ssh“ library “libcrypto.so.1.1“ not found解决方法
1. 删除 openssh 2. 安装 openssl 3. 安装 openssh 卸载:pkg uninstall 包名
- 关于mysql添加外键的时候报错_MySQL添加外键时报错:1215 Cannot add the foreign key constraint的一个可能解决方法...
今天给设计好的班级表和专业表以及院系表添加外键时,报了这样一个错误 ** 1215 Cannot add the foreign key constraint ** 去百度搜了一圈,说可能时因为字段类 ...
- Mysql导入数据库时报错ERROR: Unknown command '\0'
文章目录 前言 测试环境 数据库版本 系统版本 问题出现过程 问题结果过程 总结 前言 之前查询数据问题时多次使用过数据库导出导入命令,从来没发生过这种错误,那是一个风和日丽的上午,忽然来了一个紧急的 ...
- 普元 AppServer 6.5 将springboot应用部署到应用服务器,上传文件时报错:Caused by: org.springframework.web.multipart.Multipar
[问题] springboot应用部署到应用服务器后,上传文件时报错: Caused by: org.springframework.web.multipart.MultipartException: ...
- python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multib
python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multib ...
最新文章
- linux时间同步_如何在Ubuntu上使用FreeFileSync同步文件
- Linux Kernel中gicv3实现:SPIs中断routing到指定的CPU
- 软考-信息系统项目管理师-战略管理
- 如何去调试前端JS代码?以Chrome谷歌浏览器为例
- python爬虫提取a标签_Python爬虫库BeautifulSoup获取对象(标签)名,属性,内容,注释
- Sublime Text 快捷键使用
- SynchronousQueue详解
- 打docker镜像_从安全到镜像流水线,Docker 最佳实践与反模式一览
- VRRP和HSRP在企业网中的应用
- java+fseek+函数_fseek函数的功能
- python代码写好了怎么运行-python代码如何运行
- Helm 3 完整教程(二十一):Helm 创建和引用子模板
- 修改注册表解决 Win7 DbgView 不显示调试信息
- Matlab中imhist函数的使用及图像直方图的概念
- 整人代码好玩到没朋友
- java-等差等比求和
- QT中的this指针什么意思?namespace又是什么意思?
- 【c语言】算数转换解析+试题
- 使用pg_repack实现在线vacuum
- 通过路由器子接口实现 VLAN 间的互访