NReco视频剪辑 [英] NReco video cut

查看:408
本文介绍了NReco视频剪辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public void SplitVideo(string SourceFile,string DestinationFile, int StartTime,int EndTime)
{
var ffMpegConverter = new FFMpegConverter();
ffMpegConverter.ConvertMedia(SourceFile,null,DestinationFile,null,
new ConvertSettings()
{
Seek = StartTime,
MaxDuration =(EndTime-StartTime) / chunk duration
VideoCodec =copy,
AudioCodec =copy
});
}

这是工作,并给我一个从视频开始的视频到我指定的最长持续时间。它不是从寻找值位置开始到最大持续时间。有些人可以帮助我。

解决方案

我找到了这个问题的答案。可能这有助于某人。



我正在使用worong编解码器。您必须根据要转换的文件类型使用正确的编解码器类型。这里我使用的是mp4文件。所以我不得不使用
libx264和mp3。 Beelow是示例代码

  public void SplitVideo(string SourceFile,string DestinationFile,int StartTime,int EndTime)
{
var ffMpegConverter = new FFMpegConverter();
ffMpegConverter.ConvertMedia(SourceFile,null,DestinationFile,null,
new ConvertSettings()
{
Seek = StartTime,
MaxDuration =(EndTime-StartTime) / chunk duration
VideoCodec =libx264,
AudioCodec =mp3
});
}


I have written a function to cut a video using NReco library.

public void SplitVideo(string SourceFile,string DestinationFile,int StartTime,int EndTime)
        {
            var ffMpegConverter = new FFMpegConverter();
            ffMpegConverter.ConvertMedia(SourceFile, null, DestinationFile, null,
                new ConvertSettings()
                {
                    Seek = StartTime,
                    MaxDuration = (EndTime-StartTime), // chunk duration
                    VideoCodec = "copy",
                    AudioCodec = "copy"
                });
        }

This is working and give me a video starting from the beginning of the video to the max duration i have assign. It is not starting from the seek value position and to the max duration. Can some one help me on this.

解决方案

I have found the answer for this issue. May this help someone.

I was using worong codecs. You have to use correct codec type according to the file type you are converting. here i am using a mp4 file. So i had to use libx264 and mp3. Beelow is the sample code

public void SplitVideo(string SourceFile,string DestinationFile,int StartTime,int EndTime)
        {
            var ffMpegConverter = new FFMpegConverter();
            ffMpegConverter.ConvertMedia(SourceFile, null, DestinationFile, null,
                new ConvertSettings()
                {
                    Seek = StartTime,
                    MaxDuration = (EndTime-StartTime), // chunk duration
                    VideoCodec = "libx264",
                    AudioCodec = "mp3"
                });
        }

这篇关于NReco视频剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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