合并的音频和视频RTP数据转换成MP4文件 [英] Merge audio and video RTP data into mp4 file

查看:2819
本文介绍了合并的音频和视频RTP数据转换成MP4文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过套接字连接接收音频和视频RTP数据。现在,我要合并的视频和音频RTP数据转换成MP4文件。我怎样才能做到这一点?我是否需要单独保存视频到RTP H264和音频RTP到PCMU,后来合并到这些MP4文件?或者是有可能以音视频RTP合并成MP4文件直接?

I am receiving audio and video RTP data through socket connection. Now I want to merge the video and audio RTP data into MP4 file. How can I achieve this? Do I need to save the video RTP into h264 and audio RTP into PCMU separately and later merge these into MP4 file? Or is it possible to merge audio-video RTP into MP4 file directly?

在此先感谢!

推荐答案

您不需要创建单独的音频和视频文件,给他们混流为MP4(或容器)。但是,在你的程序,你需要做H.264和PCMU帧出RTP数据流,并将它们转移到FFMPEG。

You don't need to create separate audio and video files to mux them to MP4 (or any container). But in your program you need to make H.264 and PCMU frames out of the RTP packets and transfer them to FFMPEG.

因此​​,在总结,你的程序的伪code应该是这样的,

So in summary you program's pseudo code should look like this,

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 an Audio frame

    //Send the frame to muxer av_interleaved_write_frame
}

希望这些帮助。在ffmpeg的源$ C ​​$ C可MUXER例子会有所帮助。
https://github.com/FFmpeg/FFmpeg/blob/master /doc/examples/muxing.c

这篇关于合并的音频和视频RTP数据转换成MP4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆