問題描述
如何輕鬆識別流是視頻還是圖片【ffmpeg庫】 (How to easily recognize whether stream is video or image [ffmpeg library])
Having an AVStream object how should I reliably distinguish whether this is video or image stream?
I've tried to use duration. If it's 0 ‑ we are having image (system constraints allows for such assumption). But it turns out that duration have special meaning for images ‑ the number of images stored in file.
Is there any tricks to detect image stream more reliably?
‑‑‑‑‑
參考解法
方法 1:
At first guess, I would suggest examining the AVStream‑>codec‑>pix_fmt
enumeration (see enum PixelFormat
link for more information). You should be able to trim down the values that are for images and videos. Most videos (MPEG‑2/4, MOV) typically store their frames in PIX_FMT_YUV420P
format.
I'll find you the answer tomorrow when I'm back on my development system.