ffmpeg 0.10.3 h264_mp4toannexb 异常
来源:互联网 发布:淘宝手机改好评怎么改 编辑:程序博客网 时间:2024/06/16 12:25
在使用
ffmpeg -i test.mp4 -ss 0 -t 10 -acodec copy -vcodec copy -vbsf h264_mp4toannexb -y test.ts
命令的时候, 部分视频会出现异常:
Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: Invalid argument
Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: Invalid argument
Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: Invalid argument
Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: Invalid argument
Failed to open bitstream filter h264_mp4toannexb for stream 0 with codec copy: Invalid argument
[mpegts @ 0x14eb0980] H.264 bitstream malformed, no startcode found, use the h264_mp4toannexb bitstream filter
av_interleaved_write_frame(): Invalid data found when processing input
需要调整
libavcodec/h264_mp4toannexb_bsf.c
解决。
调整为:
/* retrieve length coded size */ ctx->length_size = (*extradata++ & 0x3) + 1;//@alex// if (ctx->length_size == 3)// return AVERROR(EINVAL);
以及:
*poutbuf_size = 0; *poutbuf = NULL; do { ret= AVERROR(EINVAL); if (buf + ctx->length_size > buf_end) goto fail; if (ctx->length_size == 1) { nal_size = buf[0]; } else if (ctx->length_size == 2) { nal_size = AV_RB16(buf);//@alex// } else// nal_size = AV_RB32(buf);} else { for(nal_size = 0, unit_type = 0; unit_type < ctx->length_size; unit_type++)nal_size = (nal_size << 8) | buf[unit_type]; }
参考:
http://ffmpeg-users.933282.n4.nabble.com/MPEG-TS-trouble-td4491337.html
there is a bug in libavcodec/h264_mp4toannexb_bsf.c
when the ctx->length_size == 3 , the filter will report the error
"Invalid argument"
diff --git a/libavcodec/h264_mp4toannexb_bsf.c
b/libavcodec/h264_mp4toannexb_bsf.c
index 5085ecb..fa16f2a 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -82,8 +82,8 @@ static int
h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
/* retrieve length coded size */
ctx->length_size = (*extradata++ & 0x3) + 1;
- if (ctx->length_size == 3)
- return AVERROR(EINVAL);
+ // if (ctx->length_size == 3)
+ // return AVERROR(EINVAL);
/* retrieve sps and pps unit(s) */
unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */
@@ -146,8 +146,10 @@ pps:
nal_size = buf[0];
} else if (ctx->length_size == 2) {
nal_size = AV_RB16(buf);
- } else
- nal_size = AV_RB32(buf);
+ } else {
+ for(nal_size = 0, unit_type = 0;
unit_type<ctx->length_size; unit_type++)
+ nal_size = (nal_size << 8) | buf[unit_type];
+ }
buf += ctx->length_size;
unit_type = *buf & 0x1f;
- ffmpeg 0.10.3 h264_mp4toannexb 异常
- ffmpeg关于h264编码提示h264_mp4toannexb的问题
- ffmpeg av_register_all 异常
- ffmpeg av_register_all release版 异常
- 链接ffmpeg静态库出现undefined异常
- FFMPEG:利用ffmpeg转换3gp文件
- ffmpeg系列(3) ffmpeg命令详解
- ffmpeg学习3-- ffmpeg解码rtp流
- ffmpeg 安装时ERROR: libx264 not found 异常的解决
- ffmpeg视频编码(3)
- ffmpeg文档3
- ffmpeg(3) URL
- ffmpeg(3) AVIOContext
- ffmpeg(3) AVPacket
- [FFMPEG-3]移植到安卓
- RHEL6.3安装ffmpeg
- ffmpeg(3) AVIOContext
- ffmpeg Documentation-3 滤波器
- Linux 设备驱动 ====> 并发控制 --- 信号量与互斥体
- 设计模式的解析和实现(C++)之三-Builder模式
- Linux 设备驱动 ====> 并发控制 --- 自旋锁
- 矛盾和虚伪的女人啊
- 设计模式的解析和实现(C++)之四-Prototype模式
- ffmpeg 0.10.3 h264_mp4toannexb 异常
- Linux 设备驱动 ====> 并发控制 --- 原子操作
- 硬盘逻辑结构简介
- android 彻底关闭应用程序(back按键)
- 如何看懂ORACLE执行计划
- Linux 设备驱动 ====> 字符驱动
- 设计模式的解析和实现(C++)之五-Singleton模式
- Android开机自启动程序
- JavaScript 性能提升的13个小技巧