ffmpeg 分段复用器产生无法播放的 HEVC 视频输出

ffmpeg segment muxer produces unplayable HEVC video outputs

我正在尝试使用 ffmpeg 处理来自 USB 网络摄像头的流视频数据。该过程涉及将原始数据编码为 hevc 格式。到目前为止我能做到的。 但是现在,我想将处理后的数据分成 10 秒的块,并将其保存在一个单独的文件中。这应该重复,直到我 kill/interrupt 手动执行该过程。

ffmpeg -i /dev/video1 -f segment -segment_times 10 -c:v hevc cam_1_%02d.mp4

上面的代码确实创建了多个文件,但只有第一个文件可以使用 vlc 读取;其他文件看起来已损坏。

当我执行 运行 命令时,我可以看到以下消息:-

Stream mapping:  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) Press [q] to stop, [?] for help Past duration 0.601555 too largeN/A time=00:00:14.63 bitrate=N/A dup=11 drop=0      Past duration
0.601463 too large Past duration 0.601555 too largeN/A time=00:00:15.16 bitrate=N/A dup=11 drop=0     Past duration 0.601585 too large
    Last message repeated 1 times Past duration 0.601646 too large Past duration 0.601677 too large Past duration 0.601707 too largeN/A time=00:00:15.66 bitrate=N/A dup=11 drop=0

我在这里错过了什么?

添加-reset_timestamps 1输出选项。来自 segment muxer documentation:

Reset timestamps at the beginning of each segment, so that each segment will start with near-zero timestamps. It is meant to ease the playback of the generated segments. May not work with some combinations of muxers/codecs. It is set to 0 by default.

另外,考虑把-segment_times改成-segment_time,因为你是一个时间值。