![](/img/trans.png)
[英]Not able to decode mp4 file using latest ffmpeg library : av_decode_video2
[英]FFmpeg decoding .mp4 video file
我正在一個項目中,該項目需要打開.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()
函數,我不能使用開放輸入.mp4檔案avformat_open_input()
因為它的會填充filename
中的一部分AVFormatContext
結構,輸入文件名,所以不能“寫入”到該文件中。 我曾嘗試使用av_guess_format()
嘗試不同的解決方案,但是當我使用dump_format()
轉儲格式時,我什么也沒得到,所以我找不到有關它正在使用哪種編解碼器的流信息。
因此,如果有人有任何建議,我將非常感謝。 先感謝您。
請參閱muxing docs中的“詳細說明”。 您:
您可以使用以下方法將視頻轉換為一系列損失圖像:
ffmpeg -i video.mp4 image-%05d.png
然后從一系列圖像返回到具有以下內容的視頻:
ffmpeg -i image-%05d.png video.mp4
該功能也可以通過包裝器使用。
您可以在以下位置看到類似的問題: 從MP4 / FLV中提取幀嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.