请考虑以下代码(为简洁起见,不进行初始化)。
AVFormatContext *formatCtx;
int coded_width = formatCtx->streams[videoStreamIndex]->codec->coded_width;
在旧API中,可以通过这种方式获得coded_width
和coded_height
。目前它已被弃用。有AVCodecParameters
结构但它只提供:
int width
int height
可能与
不同int coded_width
int coded_height
那么,是否可以在不使用已弃用streams[videoStreamIndex]->codec
的情况下获得coded_width?
答案 0 :(得分:0)
获取coded_width和coded_height如果您运行,也可以使用ffprobe
:
ffprobe -show_streams -i video.mp4
你会得到一个包含coded_width&的流对象。 coded_height:
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=9772827/468627200
codec_tag_string=avc1
codec_tag=0x31637661
width=1280
height=720
coded_width=1280
coded_height=720
has_b_frames=2
答案 1 :(得分:0)
根据最新的doxygen文档,这些仍然有效,目前在ffmpeg中使用:
宣言(没有deprecated
pragma):
https://www.ffmpeg.org/doxygen/trunk/structAVCodecContext.html#ae3c157e97ff15d46e898a538c6bc7f09
用于:
https://www.ffmpeg.org/doxygen/trunk/qsvdec_8c-example.html#a21
希望有所帮助。
答案 2 :(得分:0)
对于迟到的回复,我深表歉意。根据@the kamilz FFMPEG: Is it possible to get coded_width in new API? 的回应,最好的解决方案似乎只是在头文件中抑制此警告。 (我使用的是 gcc 编译器)。
<块引用>#pragma GCC 诊断忽略了“-Wdeprecated-declarations”