简体   繁体   English

如何使用Aforge.Net AviWriter创建mp4视频

[英]How to create mp4 video using Aforge.Net AviWriter

I'm using Aforge.net library to capture video from Webcam and create .avi files using XVID. 我正在使用Aforge.net库从网络摄像头捕获视频并使用XVID创建.avi文件。

Code snippet that I'm using (this is not the full code) - 我正在使用的代码段(这不是完整的代码)-

writer = new AVIWriter("XVID");

public void StartCapture()
{
            videoSource.Start();
            writer.FrameRate = 30;
            writer.Open(videoFilename, frameWidth, frameHeight);
}

public void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
            writer.AddFrame((Bitmap)eventArgs.Frame);
}

public void EndCapture()
{
            if (!(videoSource == null))
            {
                if (videoSource.IsRunning)
                {
                    videoSource.SignalToStop();
                    videoSource = null;
                    writer.Close();
                }
            }

}

My next requirement is to show this video in a embedded player on browser. 我的下一个要求是在浏览器的嵌入式播放器中显示此视频。 After googl-ing I found that only DivX web player can play avi files from browser. 谷歌搜索后,我发现只有DivX Web Player可以从浏览器播放avi文件。 However I would like to use HTML5 video tag to play the video so that my video plays in all browsers and I don't have to install separate plugins for each IE, Firefox, Safari etc. 但是,我想使用HTML5视频标签来播放视频,这样我的视频就可以在所有浏览器中播放,而且我不必为每个IE,Firefox,Safari等都安装单独的插件。

It would be great help if someone can give pointers on how to create mp4 video file using Aforge.net or any windows commandline tool that would convert my avi file into mp4. 如果有人可以使用Aforge.net或任何将我的avi文件转换为mp4的Windows命令行工具提供有关如何创建mp4视频文件的指导,那将是非常有用的帮助。

I'm using AVIWriter too with x264 to create AVI video then using ffmpeg CLI to convert video container to MP4. 我也在x264上使用AVIWriter创建AVI视频,然后使用ffmpeg CLI将视频容器转换为MP4。

You can install ffmpeg CLI from here: http://www.ffmpeg.org/download.html 您可以从此处安装ffmpeg CLI: http//www.ffmpeg.org/download.html

And use this command: "-i %input -c:v copy %output" 并使用以下命令:“ -i%input -c:v复制%output”

Replace %input with your AVI file path and %output with result file path with MP4 extension. 将%input替换为AVI文件路径,将%output替换为具有MP4扩展名的结果文件路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM