[英]FFmpeg decoding .mp4 video file
I'm working on a project that needs to open .mp4 file format, read it's frames 1 by 1, decode them and encode them with better type of lossless compression and save them into a file. 我正在一个项目中,该项目需要打开.mp4文件格式,将其帧一一读取,对其进行解码,并使用更好的无损压缩类型对其进行编码,然后将其保存到文件中。
Please correct me if i'm wrong with order of doing things, because i'm not 100% sure how this particular thing should be done. 如果我在做事顺序上有误,请指正我,因为我不是100%地确定该怎么做。 From my understanding it should go like this: 据我了解,它应该像这样:
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
So far i encountered couple of problems. 到目前为止,我遇到了几个问题。 For example, if i want to save a frame using av_interleaved_write_frame()
function, i can't open input .mp4 file using avformat_open_input()
since it's gonna populate filename
part of the AVFormatContext
structure with input file name and therefore i can't "write" into that file. 例如,如果我想用保存框架av_interleaved_write_frame()
函数,我不能使用开放输入.mp4档案avformat_open_input()
因为它的会填充filename
中的一部分AVFormatContext
结构,输入文件名,所以不能“写入”到该文件中。 I've tried different solution using av_guess_format()
but when i dump format using dump_format()
i get nothing so i can't find stream information about which codec is it using. 我曾尝试使用av_guess_format()
尝试不同的解决方案,但是当我使用dump_format()
转储格式时,我什么也没得到,所以我找不到有关它正在使用哪种编解码器的流信息。
So if anyone have any suggestions, i would really appreciate them. 因此,如果有人有任何建议,我将非常感谢。 Thank you in advance. 先感谢您。
See the "detailed description" in the muxing docs . 请参阅muxing docs中的“详细说明”。 You: 您:
You can convert a video to a sequence of losses images with: 您可以使用以下方法将视频转换为一系列损失图像:
ffmpeg -i video.mp4 image-%05d.png
and then from a series of images back to a video with: 然后从一系列图像返回到具有以下内容的视频:
ffmpeg -i image-%05d.png video.mp4
The functionality is also available via wrappers. 该功能也可以通过包装器使用。
You can see a similar question at: Extracting frames from MP4/FLV? 您可以在以下位置看到类似的问题: 从MP4 / FLV中提取帧吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.