使用ffmpeg从h264删除帧速率/持续时间元数据

问题描述 投票:0回答:1

我需要没有帧率和持续时间元数据的H264编码视频,因为这些是在外部存储和计算的。

这是我使用的:

ffmpeg -r 30 -f image2 -i xyz -c:v libx264 -f h264 1579516080101.h264

这是mediainfo返回的内容:

General
Complete name                            : 1579516080101.h264
Format                                   : AVC
Format/Info                              : Advanced Video Codec
File size                                : 866 KiB
Duration                                 : 1 s 0 ms
Overall bit rate                         : 7 096 kb/s

Video
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 4 frames
Duration                                 : 1 s 0 ms
Bit rate                                 : 7 096 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Variable
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.114
Stream size                              : 866 KiB (100%)

如何删除这些条目?我尝试了-map_metadata -1并没有设置帧速率,但是这导致使用默认帧速率25。

谢谢

video ffmpeg
1个回答
0
投票

我可以通过修改ffmpeg源代码并重新编译来解决此问题。

需要注释掉的相关位在于:FFmpeg/libavcodec/h264_metadata_bsf.c 171行及以后:

if (ctx->tick_rate.num && ctx->tick_rate.den) {
    int num, den;

    av_reduce(&num, &den, ctx->tick_rate.num, ctx->tick_rate.den,
              UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);

    sps->vui.time_scale        = num;
    sps->vui.num_units_in_tick = den;

    sps->vui.timing_info_present_flag = 1;
    need_vui = 1;
}
© www.soinside.com 2019 - 2024. All rights reserved.