简体   繁体   English

无需重新编码即可剪切mp4 h264视频文件

[英]Cutting mp4 h264 video file without reencoding

I am searching for a way to split or cut a mp4 video file encoded with h264, without reencoding. 我正在寻找一种方法来拆分或剪切用h264编码的mp4视频文件,而无需重新编码。 So far for editing a mp4 h264 encoded file I used Microsoft Expression Encoder 4 Pro. 到目前为止,为了编辑mp4 h264编码的文件,我使用了Microsoft Expression Encoder 4 Pro。 The problem is, that I always have to reencode the file and this takes time, unnecessary time if I only want to cut or split the video file. 问题是,我总是必须重新编码文件,如果我只想剪切或分割视频文件,这将花费一些时间和不必要的时间。 Any help or pointing into the right direction is appreciated. 任何帮助或指向正确的方向表示赞赏。

I do not know how to split video without re-encoding (transcoding) but on Windows 8 transcoding a video has been built-in: 我不知道如何在不进行重新编码(转码)的情况下分割视频,但是在Windows 8上已对视频进行了转码:

To trim the file, call the aysnc method PrepareFileTranscodeAsync and then call the TranscodeAsync method on the PrepareTranscodeResult object. 要修剪文件,请调用aysnc方法PrepareFileTranscodeAsync,然后在PrepareTranscodeResult对象上调用TranscodeAsync方法。

For example: 例如:

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) 如何修剪视频文件(使用C#/ VB / C ++和XAML的Windows Store应用程序)

It is also possible to Splicer (uses DirectShow.Net ) for older Windows. 对于较旧的Windows,也可以使用Splicer (使用DirectShow.Net )。

Hopefully it helps someone. 希望它可以帮助某人。

libmp4v2 gives you the primitives to build something to do this yourself. libmp4v2为您提供了一些原语来构建一些自己执行的操作。 Im not aware of a free off the shelf solution that does just this, though it would be relatively easy to implement as long as you are cutting on I frame boundaries. 我不知道一个可以做到这一点的免费现成的解决方案,尽管只要您突破I帧的边界,实现起来就相对容易。

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

相关问题 怎么播放这个视频:BigBuckBunny为H264自适应比特率MP4设置720p - How to play this video : BigBuckBunny as H264 Adaptive Bitrate MP4 Set 720p 解码h264视频 - Decode h264 video 如何将动态ASF视频文件转换为MP4或Windows Phone支持的任何其他格式的H.264编码的视频 - How to convert on the fly ASF video file to H.264-encoded video in MP4 or any other format supported by Windows Phone 我如何获取任何视频文件的帧率,比特率(wmv,mov,H.264,mp4) - How can i get Frame rate, Bitrate of any video file(wmv,mov,H.264,mp4) 在directx 11中渲染h264视频帧 - Render h264 video frames in directx 11 用于 H264 音频/视频流的 RTSP 客户端 - RTSP Client for H264 Audio/Video Stream 当我有原始 H264 帧和时间戳时,如何创建视频 stream? - How to create a video stream when I have raw H264 frames and timestamps? 强制Mpeg2Demultiplexer使用ffdshow渲染H264数字电视视频 - Forcing Mpeg2Demultiplexer to use ffdshow to render H264 Digital TV Video 将H.264帧混合到MP4中时,Windows 7下的Media Foundation IMFSinkWriter :: Finalize()方法失败 - Media Foundation IMFSinkWriter::Finalize() method fails under Windows 7 when muxing H.264 frames into MP4 H264-&gt;使用.NET的容器 - H264 -> Container using .NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM