2016-07-27 83 views
2

我已經編寫了使用NReco庫剪輯視頻的功能。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" 
       }); 
     } 

這是工作,並給我一個視頻,從視頻開始到我分配的最長持續時間。它不是從搜尋值位置開始到最大持續時間。有人能幫我解決這個問題嗎?

回答

2

我找到了這個問題的答案。願這幫助別人。

我使用的是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" 
       }); 
     } 
+0

更多樣品使用*** FFMpegConverter ***? –