简体   繁体   English

如何使用FFMPEG将视频的第一帧转换为I帧,然后将其余部分转换为P帧?

[英]How can I convert the first frame of a video to an I-frame and the rest to P-frames with FFMPEG?

I'd like to try to do some datamoshing like this tutorial . 我想尝试做一些像本教程这样的数据整理。 But I'd like to be able to do it programatically, so instead of vdub and avidemux, I'd like to figure out how to do as many parts of this process as I can with ffmpeg and/or other command-line tools. 但是我希望能够以编程方式进行操作,因此我想找出如何使用ffmpeg和/或其他命令行工具尽可能多地完成此过程,而不是vdub和avidemux。

The first problem I am having is that when I use the ffdshow codec rev 3556 with VDub it just outputs a broken video. 我遇到的第一个问题是,当我将ffdshow编解码器rev 3556与VDub一起使用时,它只会输出损坏的视频。 I feel like I got close to getting what I want, which is frame 0 as an I-frame and all the rest as P-frames with the following command 我觉得我快要得到想要的东西了,使用以下命令将第0帧作为I帧,将其余所有帧作为P帧。

ffmpeg -i input.mp4 -force_key_frames 00:00:00.000 output.avi

There are a couple of problems with this... 这个有几个问题...

1) I get B-frames too, which don't work with that type of data-moshing 1)我也得到了B帧,不适用于这种类型的数据交换

2) There's still I-frames every 10 or so frames 2)每10帧左右仍有I帧

I feel like the problem is that I need to use a certain codec to encode the video in and also that -force_key_frames probably just enforces the addition of extra keyframe(I-frames) but doesn't prevent other I-frames from being created. 我觉得问题在于我需要使用特定的编解码器对视频进行编码,而且-force_key_frames可能只是强制添加额外的关键帧(I帧),而不会阻止其他I帧的创建。

Try using the -keyint flag. 尝试使用-keyint标志。 I believe you can sent a minimum GOP length (key interval length). 我相信您可以发送最小GOP长度(密钥间隔长度)。

You would need to know how many frames are in your file, and you could try setting your minimum key interval to that length. 您可能需要知道文件中有多少帧,并且可以尝试将最小关键帧间隔设置为该长度。

IE = keyint=[KEY INTERVAL VALUE]:min-keyint=[MINIMUM KEY INTERVAL VALUE] IE = keyint=[KEY INTERVAL VALUE]:min-keyint=[MINIMUM KEY INTERVAL VALUE]

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

相关问题 如何使用 FFmpeg、无损并保持相同的总帧数来更改视频帧速率? - How can I change a video frame rate with FFmpeg, lossless and keeping the same total number of frames? 如何用 ffmpeg 循环一帧? 所有其他帧应该指向第一个没有变化,可能就像一个回避 - How can I loop one frame with ffmpeg? All the other frames should point to the first with no changes, maybe like a recusion H.264 I-Frame更换 - H.264 I-Frame replacement 从P和B框架中创建I框架 - Create I Frame out of P and B frames 如何在视频的第一帧之前放置静止图像? - How can I place a still image before the first frame of a video? 如何将视频的第一帧保存为图像? - How can I save first frame of a video as image? 如何使用 ffmpeg 将图像帧转换为视频? - How do I convert image frames into a video using ffmpeg? 如何使用ffmpeg从YUV视频中提取帧(或垂直帧) - How to extract frames(or a perticular frame) from a YUV video using ffmpeg 使用 ffmpeg 重复视频的第一帧 - repeating the first frame of a video with ffmpeg 如何在不重写整个视频文件的情况下仅替换流中的一个数据帧? (FFmpeg) - How can I replace only one data frame from stream without rewriting whole video file ? (FFmpeg)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM