我通过此命令将时间戳叠加到 mp4 视频中
ffmpeg -nostdin -i input.mp4 -c:v libx264 -profile:v baseline -vf "drawtext=x=(w-(max_glyph_w*13))/2: y=H-h/10:fontcolor=white:fontsize=h/14:box=1:boxcolor=0x000000AA:text='%{pts\\:hms}'" -y -vsync 0 output.mkv
问题是输出视频没有保留原始视频的 PTS,相反,很多帧具有相同的 PTS,这很奇怪。
例如,为了获取视频的 PTS,我使用了ffprobe -select_streams v -show_packets tmp_timestamp.mkv | grep pts_time
,结果是
pts_time=0.000000
pts_time=0.000000
pts_time=0.251000
pts_time=0.251000
pts_time=0.251000
pts_time=0.251000
pts_time=0.502000
pts_time=0.502000
pts_time=1.004000
pts_time=1.004000
pts_time=1.004000
pts_time=1.004000
pts_time=1.004000
pts_time=1.004000
pts_time=1.255000
pts_time=1.255000
pts_time=1.255000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.506000
pts_time=1.757000