c - FFmpeg - C - 编码视频 - 设置纵横比

标签 c ffmpeg video-encoding libavcodec libavformat

我正在从 mp2 解码视频并编码为 mp4。

原始文件:

视频:mpeg2video(主)([2][0][0][0]/0x0002),yuv420p,720x576 [SAR 64:45 DAR 16:9]

生成的文件:

视频:mpeg4(简单配置文件)(mp4v/0x7634706D),yuv420p,720x576 [SAR 1:1 DAR 5:4]

如您所见,分辨率没有改变,但宽高比改变了。

我的问题是如何设置这些值(SAR 和/或 DAR)?

最佳答案

要设置输出纵横比,您可以使用“-aspect”选项,参见ffmpeg documentation .

-aspect[:stream_specifier] aspect (output,per-stream)’

    Set the video display aspect ratio specified by aspect.

    aspect can be a floating point number string, or a string of the form num:den, where num and den are the numerator and denominator of the aspect ratio. For example "4:3", "16:9", "1.3333", and "1.7777" are valid argument values.

    If used together with ‘-vcodec copy’, it will affect the aspect ratio stored at container level, but not the aspect ratio stored in encoded frames, if it exists.

关于c - FFmpeg - C - 编码视频 - 设置纵横比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18376283/

相关文章:

c++ - 自定义缓冲区的字节顺序

c - 是否可以实现不执行任何系统调用的 C 程序?

android - 使用 ffmpeg 进行视频转换后在 iPhone 上播放视频

api - 如何使用 ffmpeg av_interleaved_write_frame() 写入 x264_encoder_encode() 生成的 NAL

ffmpeg - 不一致的 libx264 I 帧间隔。为什么?

比较 C 中的 float

c - 在 _Generic 之前,C 对 main 的不同签名是如何支持的?

ffmpeg - 使用ffmpeg合并视频时切换效果出现错误

linux - 在 Windows、Linux 或 Mac 上以编程方式捕获单独程序的窗口

ffmpeg - 什么是实时 4k 视频编码的最佳库/SDK?