- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用基于最新 FFmpeg git 源代码树的项目,并链接到 Zeranoe 在 https://ffmpeg.zeranoe.com/builds/ 发布的共享 DLL。
播放代码有效并循环。它播放 h265 文件(原始)、mpeg、avi 和 mpg 文件。然而,一旦 mp4 或 mkv 容器被指定为输入文件,无论里面有什么,编解码器都会转储大量错误。不管是 HEVC 还是 h264。
[h264 @ 00000000xyz] No start code is found
[h264 @ 00000000xyz] Error splitting the input into NAL units.
为了让一切变得非常奇怪,ffplay.exe 可以很好地播放这些文件。
我意识到我可能可以通过先将文件转换为原始格式来解决这个问题,但我希望能够读取和解析 mp4 文件。由于我使用的是 Zeraneo 的预构建库,我的猜测是在构建过程中没有启用某些东西,但我希望 ffplay 也会失败。我是否需要在 format_context 或 codec_context 中设置标志,或提供某种过滤器标识符?
播放良好的电影来自http://bbb3d.renderfarming.net/download.html , http://www.w6rz.net/和 http://www.sample-videos.com/
这些工作:
big_buck_bunny_480p_surround-fix.avi
bigbuckbunny_480x272.h265
作为 ffmpeg 的完全菜鸟,请帮助我了解问题所在以及如何修复它。如果预构建库是罪魁祸首,那么第二个问题是是否有人有方便的 cmake 设置来为 Windows X64 和 x32 调试和发布目标构建它。
这里是初始化ffmpeg的源码,供阅读
avdevice_register_all();
avfilter_register_all();
av_register_all();
avformat_network_init();
格式解析如下:
m_FormatContext = avformat_alloc_context();
if (avformat_open_input(&m_FormatContext, file.GetPath().ToString().c_str(), NULL, NULL) != 0)
{
//std::cout << "failed to open input" << std::endl;
success = false;
}
// find stream info
if (success)
{
if (avformat_find_stream_info(m_FormatContext, NULL) < 0)
{
//std::cout << "failed to get stream info" << std::endl;
success = false;
}
}
流打开如下:
m_VideoStream = avstream;
m_FormatContext = formatContext;
if (m_VideoStream)
{
m_StreamIndex = m_VideoStream->stream_identifier;
AVCodecParameters *codecpar = m_VideoStream->codecpar;
if (codecpar)
{
AVCodecID codec_id = codecpar->codec_id;
m_Decoder = avcodec_find_decoder(codec_id);
if (m_Decoder)
{
m_CodecContext = avcodec_alloc_context3(m_Decoder);
if (m_CodecContext)
{
m_CodecContext->width = codecpar->width;
m_CodecContext->height = codecpar->height;
m_VideoSize = i3(codecpar->width, codecpar->height,1);
success = 0 == avcodec_open2(m_CodecContext, m_Decoder, NULL);
if (success)
{
if(m_CodecContext)
{
int size = av_image_get_buffer_size(format, m_CodecContext->width, m_CodecContext->height, 1);
if (size > 0)
{
av_frame = av_frame_alloc();
gl_frame = av_frame_alloc();
uint8_t *internal_buffer = (uint8_t *)av_malloc(size * sizeof(uint8_t));
av_image_fill_arrays((uint8_t**)((AVPicture *)gl_frame->data), (int*) ((AVPicture *)gl_frame->linesize), internal_buffer, format, m_CodecContext->width, m_CodecContext->height,1);
m_Packet = (AVPacket *)av_malloc(sizeof(AVPacket));
}
}
}
if (!success)
{
avcodec_close(m_CodecContext);
avcodec_free_context(&m_CodecContext);
m_CodecContext = NULL;
m_Decoder = NULL;
m_VideoStream = NULL;
}
}
else
{
m_Decoder = NULL;
m_VideoStream = NULL;
}
}
}
}
单线程解码:
do
{
if (av_read_frame(m_FormatContext, m_Packet) < 0)
{
av_packet_unref(m_Packet);
m_AllPacketsSent = true;
}
else
{
if (m_Packet->stream_index == m_StreamIndex)
{
avcodec_send_packet(m_CodecContext, m_Packet);
}
}
int frame_finished = avcodec_receive_frame(m_CodecContext, av_frame);
if (frame_finished == 0)
{
if (!conv_ctx)
{
conv_ctx = sws_getContext(m_CodecContext->width,
m_CodecContext->height, m_CodecContext->pix_fmt,
m_CodecContext->width, m_CodecContext->height, format, SWS_BICUBIC, NULL, NULL, NULL);
}
sws_scale(conv_ctx, av_frame->data, av_frame->linesize, 0, m_CodecContext->height, gl_frame->data, gl_frame->linesize);
switch(format)
{
case AV_PIX_FMT_BGR32_1:
case AV_PIX_FMT_RGB32_1:
case AV_PIX_FMT_0BGR32:
case AV_PIX_FMT_0RGB32:
case AV_PIX_FMT_BGR32:
case AV_PIX_FMT_RGB32:
{
m_CodecContext->bits_per_raw_sample = 32; break;
}
default:
{
FWASSERT(format == AV_PIX_FMT_RGB32, "The format changed, update the bits per raw sample!"); break;
}
}
size_t bufferSize = m_CodecContext->width * m_CodecContext->height * m_CodecContext->bits_per_raw_sample / 8;
m_Buffer.Realloc(bufferSize, false, gl_frame->data[0]);
m_VideoSize = i3(m_CodecContext->width, m_CodecContext->height,1);
result = true;
// sends the image buffer straight to the locked texture here..
// glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, codec_ctx->width, codec_ctx->height, GL_RGB, GL_UNSIGNED_BYTE, gl_frame->data[0]);
}
av_packet_unref(m_Packet);
} while (m_Packet->stream_index != m_StreamIndex);
m_FrameDecoded = result;
感谢任何见解!
最佳答案
而不是在这里隐含地提供宽度和高度:
m_CodecContext->width = codecpar->width;
m_CodecContext->height = codecpar->height;
关于video - 使用 FFMPEG 解码 mp4/mkv 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39105571/
我有以下 json: {"results": [{"columns":["room_id","player_name","player_ip"], "types":["integer","text
我在 go 中获取格式不一致的 JSON 文件。例如,我可以有以下内容: {"email": "\"blah.blah@blah.com\""} {"email": "robert@gmail.com
JavaScript中有JSON编码/解码base64编码/解码函数吗? 最佳答案 是的,btoa() 和 atob() 在某些浏览器中可以工作: var enc = btoa("this is so
我在其中一个项目中使用了 Encog,但在解码 One-Of Class 时卡住了。该字段的规范化操作之一是 NormalizationAction.OneOf,它具有三个输出。当我评估时,我想解码预
在我的 previous question关于使用 serialize() 创建对象的 CSV 我从 jmoy 那里得到了一个很好的答案,他推荐了我的序列化文本的 base64 编码。这正是我要找的。
有些事情让我感到困惑 - 为什么 this image在每个浏览器中显示不同? IE9(和 Windows 照片查看器)中的图像: Firefox(和 Photoshop)中的图像: Chrome(和
是否可以在不知道它的类型( JAXBContext.newInstance(clazz) )的情况下解码一个类,或者什么是测试即将到来的正确方法? 我确实收到了从纯文本中解码的消息 - 字符串 传入的
我正在尝试使用 openSSL 库进行 Base64 解码,然后使用 CMS 来验证签名。 下面的代码总是将缓冲区打印为 NULL。 char signed_data[] = "MIIO"; int
我有一个带有 SEL 类型实例变量的类,它是对选择器的引用。在encodeWithCoder/initWithCoder中,如何编码/解码这种类型的变量? 最佳答案 您可以使用 NSStringFro
var url = 'http://www.googleapis.com/customsearch/v1?q=foo&searchType=image'; window.fetch(url) .t
我想知道Android 2.2、2.3和3,4支持的音频/视频格式列表。我也想知道哪些Android版本支持视频编码和解码。我经历了this link,但是关于编码和解码我并不清楚。 任何人的回答都是
我在其中一个项目中使用 Encog,但在解码 One-Of 类时遇到了困难。该字段的规范化操作之一是 NormalizationAction.OneOf,它具有三个输出。当我评估时,我想解码预测值。如
我正在尝试解码现有的 xml 文件,以便我可以正确处理数据,但 XML 结构看起来很奇怪。下面是 xml 示例以及我创建的对象。 11 266 AA1001 1
对 unicode 字符进行 URL 编码的常用方法是将其拆分为 2 %HH 代码。 (\u4161 => %41%61) 但是,unicode在解码时是如何区分的呢?您如何知道 %41%61 是 \
我正在尝试将 json 字符串解码为 Map。 我知道有很多这样的问题,但我需要非常具体的格式。例如,我有 json 字符串: { "map": { "a": "b",
我有一个查询,我认为需要像这样(解码会更大) SELECT firstName, lastName, decode(mathMrk, 80, 'A', mathMrk) as decodeMat
我知道PHP函数encode()和decode(),它们对我来说工作得很好,但我想在url中传递编码字符串,但encode确实返回特殊字符,如“=”、“”' “等等...... 这显然会破坏我的脚本,
我必须解码 Basic bW9uTG9naW46bW9uTW90RGVQYXNz 形式的 http 请求的授权 header 当我解码它时online ,我得到了正确的结果 monLogin:monM
这个问题已经有答案了: Decode Base64 data in Java (21 个回答) 已关闭 8 年前。 我想知道使用哪个库进行 Base64 编码/解码?我需要此功能足够稳定以供生产使用。
我正在尝试从 Arduino BT 解码 []byte,我的连接完美,问题是当我尝试解码数组时。我得到的只是这个字符�(发送的字节数相同)我认为问题出在解码上。我尝试使用 ASCII 字符集,但仍然存
我是一名优秀的程序员,十分优秀!