如何将帧写入视频文件? [英] How to write frames to a video file?

查看:180
本文介绍了如何将帧写入视频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个从相机读取帧的应用程序,修改它们并将其保存到视频文件中。我打算用ffmpeg来做。很少有关于ffmpeg的文档。我找不到办法有没有知道如何做?



我需要在unix,C或C ++中完成。有没有可以提供一些说明?



谢谢。



编辑:



对不起,我没有写清楚。我想要一些开发人员API将帧写入视频文件。我打开相机流,我得到每一帧,然后我将它们保存在一个视频文件中,这些API可以在ffmpeg的公共apis中使用。所以使用命令行工具实际上并没有帮助我。我在ffmpeg src文件夹下看到了output_example.c。这是非常好的,我可以直接复制代码的一些部分,而不改变。我还在寻找一种更简单的方法。



此外,我正在考虑将我的应用移植到iPhone,据我所知,只有ffmpeg已经移植到iPhone上。 GStreamer基于glib,它都是GNU的东西。我不知道我是否可以在iPhone上工作。所以ffmpeg现在还是最好的选择。



任何评论都表示赞赏。

解决方案

这可能有助于您开始 - 文档可用,但更新的功能往往在ffmpeg的手册页中记录。 / p>

框架需要按顺序编号。

  ffmpeg -f image2 -r 25 -i frame_%d.jpg -vcodec libx264 -vpre hq -crf 22 video.mp4 




  • -f 定义格式

  • -r 定义帧速率

  • -i 定义输入文件/ s ... %d 指定编号文件..添加0的
    指定填充

  • -vcodec 选择视频编解码器

  • -vpre 指定使用一个名为hq的预设

  • -crf 指定一个速率控制方法,用于定义x264流如何
    编码

  • video.mp4 是输出文件


I am currently writing an application that read frames from camera, modify them, and save them into a video file. I'm planing to do it with ffmpeg. There's rarely a documentation about ffmpeg. I can't find a way. Does any know how to do it?

I need it to be done on unix, and in C or C++. Does any can provide some instructions?

Thanks.

EDIT:

Sorry, I haven't write clearly. I want some developer APIs to write frames to a video file. I open up camera stream, I get every single frame, then I save them into a video file with those APIs available in ffmpeg's public apis. So using command line tool actually doesn't help me. And I've seen output_example.c under the ffmpeg src folder. It's pretty great that I may copy some parts of the code directly without change. And I am still looking for a easier way.

Also, I'm thinking of porting my app to iPhone, as far as I know, only ffmpeg has been ported on iPhone. GStreamer is based on glib, and it's all GNU stuff. I'm not sure if I can get it work on iPhone. So ffmpeg is still the best choice for now.

Any comments is appreciated.

解决方案

This might help get you started - the documentation is available, but newer features tend to be documented in ffmpeg's man pages.

The frames need to be numbered sequentially.

ffmpeg -f image2 -r 25 -i frame_%d.jpg -vcodec libx264 -vpre hq -crf 22 video.mp4

  • -f defines the format
  • -r defines the frame rate
  • -i defines the input file/s ... %d specifies numbered files .. add 0's to specify padding
  • -vcodec selects the video codec
  • -vpre specifies use of a preset called hq
  • -crf specifies a rate control method, used to define how the x264 stream is encoded
  • video.mp4 is the output file

这篇关于如何将帧写入视频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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