LIBAV MJPEG 编码和 huffman table

LIBAV MJPEG encoding and huffman table

我正在尝试使用 libav(ffmpeg) 创建带有 MJPEG 视频负载的 RTP 流 示例代码非常简单,适用于 MPEG1 我看到 MJPEG 中的编码有效,但是当我需要发送 mjpeg 时 帧 RTP 发件人 returns 我的错误:

[rtp @ 000000878ca77aa0] RFC 2435 requires standard Huffman tables for jpeg

我在 libav 中看到评论 header:

/**
     * 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