c++ - LIBAV MJPEG 编码和霍夫曼表
问题描述
我正在尝试使用 libav(ffmpeg) 使用 MJPEG 视频有效负载创建 RTP 流 示例代码非常简单,它适用于 MPEG1 我看到 MJPEG 中的编码有效,但是当我需要发送 mjpeg 帧时,RTP 发送者返回错误:
[rtp @ 000000878ca77aa0] RFC 2435 需要 jpeg 的标准 Huffman 表
我在 libav 标头中看到评论:
/**
* some codecs need / can use extradata like Huffman tables.
* MJPEG: Huffman tables
* rv10: additional flags
* MPEG-4: global headers (they can be in the bitstream or here)
* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
* than extradata_size to avoid problems if it is read with the bitstream reader.
* The bytewise contents of extradata must not depend on the architecture or CPU endianness.
* - encoding: Set/allocated/freed by libavcodec.
* - decoding: Set/allocated/freed by user.
*/
uint8_t *extradata;
int extradata_size;
但是如何更正填充霍夫曼表或初始化默认表。我必须为编码器设置标志吗?谢谢。
解决方案
您可以将 huffman 选项设置为 0,即:
ffmpeg -i /dev/video0 -input_format mjpeg -f v4l2 -pix_fmt yuvj420p -vcodec mjpeg -huffman 0 -f rtp "rtp://127.0.0.1:10000" -sdp_file sdp_file
推荐阅读
- java - 为什么会这样编译?我显然使用了错误的类型。Java中的类型安全发生了什么?
- c# - 是否可以将 Windows 窗体应用程序移植到 WPF 将其 Designer.cs 文件转换为 XAML 文件?
- reactjs - React SSR 和 ReactiveSearch
- broadleaf-commerce - 在 Admin 中所做的更改未反映在 api 结果中
- c# - 在 ML.net 中发布训练模型。从 TaxiFareExample 发布更改模型。'Features' 必须是已知大小的 R4 向量,但具有类型:Vec
- arduino - Arduino 打印格式 - 如何在循环中水平打印
- python - .plot(y=) 尽管改变了 y 的值,但给出了相同的图表
- json - 位图索引扫描始终后跟位图堆扫描以进行 JSON 字段查询
- .net - 在 .CPP 文件中用 C++/CLI 实现索引器的语法
- c# - Unity 中的 AutoFac InstancePerLifetimeScope() 是什么?