FFMPEG:是否有可能在新 API 中获得 coded_width?

标签 ffmpeg libavcodec libav libavformat

考虑以下代码(为简洁起见,不进行初始化)。

AVFormatContext *formatCtx;
int coded_width = formatCtx->streams[videoStreamIndex]->codec->coded_width;

在旧 API 中,可以获得 coded_widthcoded_height这边走。目前它已被弃用。有AVCodecParameters struct 但它仅提供:
int width
int height

这可能不同于
int coded_width
int coded_height

那么,是否可以在不使用已弃用 streams[videoStreamIndex]->codec 的情况下获得 coded_width ?

最佳答案

获取 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

关于FFMPEG:是否有可能在新 API 中获得 coded_width?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48794431/

相关文章:

ffmpeg - 如何使用 avprobe/ffprobe 检测音频采样率?

android - ffmpeg - 强制使用的过滤器

c - 在 libavcodec/ffmpeg 中使用并行解码器

ffmpeg - avcodec_find_decoder(CODEC_ID_MPEG2TS) 始终为 NULL

video - ffmpeg - 如何使用寻找并找到最近的 iframe 来捕获屏幕截图的时间戳?

c++ - 将 mp4 解码为原始帧 Windows C++

ffmpeg - libav/avconv 的平铺过滤器

android - 使用 ffmpeg4android 库压缩视频

video - 更改 USB 摄像头的比特率

ffmpeg - 覆盖多个 gif 和 png 并生成一个新的 gif