首页 文章

切割mp4 h264视频文件,无需重新编码

提问于
浏览
2

我正在寻找一种方法来分割或剪切用h264编码的mp4视频文件,而无需重新编码 . 到目前为止,为了编辑mp4 h264编码文件,我使用了Microsoft Expression Encoder 4 Pro . 问题是,我总是要重新编码文件,如果我只想剪切或拆分视频文件,这需要时间,不必要的时间 . 任何帮助或指向正确的方向表示赞赏 .

2 回答

  • 4

    libmp4v2为您提供构建某些内容的原语 . 我不知道这样做的免费现成解决方案,尽管只要你切割I帧边界就可以相对容易地实现 .

  • 0

    我不知道如何在不重新编码(转码)的情况下拆分视频,但在Windows 8上转码视频已经内置:

    要修剪文件,请调用aysnc方法PrepareFileTranscodeAsync,然后在PrepareTranscodeResult对象上调用TranscodeAsync方法 .

    例如:

    async void TrimFile(StorageFile srcFile, StorageFile destFile)
    {
        MediaEncodingProfile profile =
            MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p);
    
        MediaTranscoder transcoder = new MediaTranscoder();
    
        // Set the start of the trim.
        transcoder.TrimStartTime = new TimeSpan(0, 0, 1);
    
        // Set the end of the trim.
        transcoder.TrimStopTime = new TimeSpan(0, 0, 9);
    
        PrepareTranscodeResult prepareOp = await
            transcoder.PrepareFileTranscodeAsync(srcFile, destFile, profile);
    
        if (prepareOp.CanTranscode)
        {
            var transcodeOp = prepareOp.TranscodeAsync();
            transcodeOp.Progress +=
                new AsyncActionProgressHandler<double>(TranscodeProgress);
            transcodeOp.Completed +=
                new AsyncActionWithProgressCompletedHandler<double>(TranscodeComplete);
        }
        else
        {
            switch (prepareOp.FailureReason)
            {
                case TranscodeFailureReason.CodecNotFound:
                    OutputText("Codec not found.");
                    break;
                case TranscodeFailureReason.InvalidProfile:
                    OutputText("Invalid profile.");
                    break;
                default:
                    OutputText("Unknown failure.");
                    break;
            }
        }
    }
    

    How to trim a video file (Windows Store apps using C#/VB/C++ and XAML)

    对于较旧的Windows,也可以Splicer(使用DirectShow.Net) .

    希望它可以帮助某人 .

相关问题