我正在开发一个需要打开 .mp4 文件格式、逐帧读取帧、解码它们并使用更好的无损压缩类型对其进行编码并将它们保存到文件中的项目。
如果我做事的顺序有误,请纠正我,因为我不是 100% 确定应该如何做这件事。据我了解,它应该是这样的:
1. Open input .mp4 file
2. Find stream info -> find video stream index
3. Copy codec pointer of found video stream index into AVCodecContext type pointer
4. Find decoder -> allocate codec context -> open codec
5. Read frame by frame -> decode the frame -> encode the frame -> save it into a file
到目前为止,我遇到了几个问题。例如,如果我想使用
av_interleaved_write_frame()
保存帧功能,我无法使用 avformat_open_input()
打开输入 .mp4 文件因为它将填充filename
AVFormatContext
的一部分具有输入文件名的结构,因此我无法“写入”该文件。我使用 av_guess_format()
尝试了不同的解决方案但是当我使用 dump_format()
转储格式时我什么也没得到,所以我找不到有关它使用哪个编解码器的流信息。因此,如果有人有任何建议,我将不胜感激。先感谢您。
最佳答案
请参阅 muxing docs 中的“详细说明”。你:
关于c - FFmpeg 解码 .mp4 视频文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35771821/