【问题标题】:Decoding G.729 using FFMPEG from RTP stream (PCAP)使用来自 RTP 流 (PCAP) 的 FFMPEG 解码 G.729
【发布时间】:2011-12-05 21:58:07
【问题描述】:

我有包含 RTP 数据的 pcap 文件,而 RTP 数据又是 G.729 编解码器的音频。有没有办法通过将它推入 FFMPEG 来解码这个流?这可能意味着我必须从 PCAP 文件中提取 RTP 有效负载数据,然后以某种方式将其传递给 FFMPEG。

任何指南和指针都非常感谢!

【问题讨论】:

    标签: networking ffmpeg ip rtp pcap


    【解决方案1】:

    va_g729_decoder.exe 仅适用于 win32。64 位窗口呢?

    【讨论】:

      【解决方案2】:

      您可以使用的步骤是:

      1. 提取 RTP/RTCP 数据包:使用 rtpbreak 之类的工具:http://dallachiesa.com/code/rtpbreak/
      2. 生成(使用和编辑器)要在 ffmpeg 或 mplayer 或 vlan 传递的 sdp 文件
      3. 使用 SDP 文件启动 ffmpeg(或 mplayer 或 vlan)
      4. 使用 rtpplay 在 ffmpeg 上流式传输 RTP/RTCP 数据包:http://www.cs.columbia.edu/irt/software/rtptools/

      但如果您的目标是“仅”pcap-audio 解码(使用 RTP G729 编解码器),那么您可以使用 videosnaf 或 xplico

      【讨论】:

        【解决方案3】:

        这不需要 ffmpeg,但我假设您并不真正关心音频是如何提取的...请查看 wireshark wiki 上的 How to Decode G729...

        1. 在 Wireshark 中,使用菜单“统计 -> RTP -> 显示所有流”。选择所需的流并按“分析”。

        2. 在下一个对话框屏幕中,按“保存有效负载...”。保存选项为 Format = .raw 和 Channel = forward。将文件命名为 sample.raw。

        3. 使用 Open G.729 解码器将 .raw 文件转换为 .pcm 格式。语法:va_g729_decoder.exe sample.raw sample.pcm。或者对于 Linux:wine va_g729_decoder.exe sample.raw sample.pcm。

        4. .pcm 文件包含 8000 Hz 的 16 位线性 PCM 样本。请注意,每个样本都是 Little-Endian 格式。要转换为 .au 格式,您需要做的就是在 24 字节 au 标头前添加,并将每个 PCM 样本转换为网络字节顺序(或 Big-Endian)。下面的 Perl 脚本可以解决问题。

        用法:perl pcm2au.pl inputFile outputFile

        $usage = "Usage: 'perl $0 <Source PCM File> <Destination AU File>' ";
        
        $srcFile = shift or die $usage;
        $dstFile = shift or die $usage;
        
        open(SRCFILE, "$srcFile") or die "Unable to open file: $!\n";
        binmode SRCFILE;
        
        open(DSTFILE, "> $dstFile") or die "Unable to open file: $!\n";
        binmode DSTFILE;
        
        ###################################
        # Write the AU header
        ###################################
        
        print DSTFILE  ".snd";
        
        $foo = pack("CCCC", 0,0,0,24);
        print DSTFILE  $foo;
        
        $foo = pack("CCCC", 0xff,0xff,0xff,0xff);
        print DSTFILE  $foo;
        
        $foo = pack("CCCC", 0,0,0,3);
        print DSTFILE  $foo;
        
        $foo = pack("CCCC", 0,0,0x1f,0x40);
        print DSTFILE  $foo;
        
        $foo = pack("CCCC", 0,0,0,1);
        print DSTFILE  $foo;
        
        #############################
        # swap the PCM samples
        #############################
        
        while (read(SRCFILE, $inWord, 2) == 2) {
        
            @bytes   = unpack('CC', $inWord);
            $outWord = pack('CC', $bytes[1], $bytes[0]);
            print DSTFILE  $outWord;
        }
        
        close(DSTFILE);
        close(SRCFILE);
        

        【讨论】:

        • 在我输入的时候检查一下 :)
        • 这给了我一个关于如何前进的想法。可能需要我做一些额外的编码才能把它变成一个程序。真的谢谢。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-07-17
        • 2014-05-22
        • 1970-01-01
        • 2018-08-24
        • 2019-06-26
        • 2017-04-11
        • 1970-01-01
        相关资源
        最近更新 更多