如何使用 Media Foundation 将 RTP H.264 有效负载转换为可播放文件 [英] How to convert RTP H.264 payload into playable file using Media Foundation

查看:25
本文介绍了如何使用 Media Foundation 将 RTP H.264 有效负载转换为可播放文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法来从使用托管媒体聚合接收的 H.264 RTPFrames(有效负载类型 96)制作视频文件 - https://net7mma.codeplex.com/.

I need a way to be able to make a video file from H.264 RTPFrames (Payload Type 96) that I receive using the Managed Media Aggregation - https://net7mma.codeplex.com/.

我正在尝试在托管代码中使用媒体基础.

I am trying to use media foundation in managed code.

我看到了 http://mfnet.sourceforge.net/ 但我找不到怎么做它.我在某个论坛看到有人说在 C# 托管代码中使用 Media Foundation dll 更好.

I saw http://mfnet.sourceforge.net/ but I couldn't find how to do it. I saw that someone said in some forum that it is better to use the Media Foundation dlls in C# managed code.

有人有这方面的工作经验吗?

Does anybody have any experience working with this?

我尝试使用 VLCDotNet 将 h264 帧放入视频文件 - 这是我的代码

I an trying to use the VLCDotNet to put the h264 frames into a video file - here is my code

private void StoreFile()
{

    Vlc.DotNet.Core.VlcContext.LibVlcDllsPath = @"C:\Users\Ofek\Desktop\VideoLAN\VLC";
    Vlc.DotNet.Core.VlcContext.Initialize();

    media1 = new Vlc.DotNet.Core.Medias.LocationMedia("rtsp://192.168.30.11/1.mkv");         

    media1.AddOption(":sout=#transcode{vcodec=theo,vb=800,
    scale=1,acodec=flac,ab=128,channels=2,samplerate=44100}:std{access=file,mux=ogg,
    dst=D:\\123.mp4}");

    VlcControl control = new VlcControl();
    control.Media = media1;
    control.Play();
}

问题是文件已创建,但无法播放.我正在寻找将 H264 流保存到 mp4 文件的命令 解码它.有什么想法吗?

The Issue is that the file is created, but its not playable. I am looking for the command to save the H264 stream to a mp4 file without decoding it. any ideas?

推荐答案

尝试将流作为进程在后台播放.

Try playing the stream in the background as a process.

Process vlc;
vlc = Process.Start("C://Program Files//Videolan//VLC//VLC.exe", "rtsp://192.168.30.11/1.mkv\" --qt-start-minimized --sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:file{dst=C://folder//filename.mp4,no-overwrite}");
Thread.Sleep(9000);
vlc.kill();

这篇关于如何使用 Media Foundation 将 RTP H.264 有效负载转换为可播放文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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