首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将音频和视频RTP数据合并到mp4文件中

将音频和视频RTP数据合并到mp4文件中
EN

Stack Overflow用户
提问于 2015-07-03 11:15:53
回答 1查看 1.6K关注 0票数 0

我正在接收音频和视频RTP数据通过套接字连接。现在,我想将视频和音频RTP数据合并到MP4文件中。我怎样才能做到这一点?我是否需要将视频RTP分别保存到h264和音频RTP中,然后将它们合并到MP4文件中?或者可以将音视频RTP直接合并到MP4文件中?

提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-04 14:15:12

您不需要创建单独的音频和视频文件来将它们修改为MP4 (或任何容器)。但是在您的程序中,您需要将H.264和PCMU帧从RTP数据包中提取出来,并将它们传输到FFMPEG。

总之,程序的伪代码应该是这样的,

代码语言:javascript
复制
Main {
    //Setup RTP receiver
    //Configure MP4 Muxer of FFMPEG (set input and oputput format), your input is H.264 and PCMU and output is MP4
    //avformat_alloc_output_context2
    //avformat_new_stream

    //Create Thread1 to read audio RTP packets
    //Create Thread2 to read video RTP packets

    //Complete writing MP4 file
    //av_write_trailer
}

Thread1 ()
{
    //Receive audio RTP packets
    //Form an Audio frame

    //Send the frame to muxer av_interleaved_write_frame
}

Thread1 ()
{
    //Receive video RTP packets
    //Form a video frame

    //Send the frame to muxer av_interleaved_write_frame
}

希望这些能帮上忙。在ffmpeg源代码中提供的Muxer示例将很有帮助。https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/muxing.c

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31205505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档