我正在使用 Raspberry Pi 3B+ 录制 ActiA31 安全摄像头(通过以太网供电路由器连接)的视频。摄像头设置为以 29.97 fps 录制。我使用的命令是
sudo /usr/local/bin/ffmpeg -i rtsp://username:pwd@IPaddress -t 10 -vcodec copy -acodec copy outputfile.mp4
视频确实录制了,但录制视频的元数据显示帧速率 (fps) 略有不同。输出如下(使用 ffprobe):
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 2048x1536, 12074 kb/s, 30.02 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
为什么 fps 与 tbr 不同?
我已将原始 ffmpeg 命令的输出复制到此处,希望它能帮助解决问题。我尝试使用选项“-use_wallclock_as_timestamps 1”,但结果并没有什么不同。我正在使用视频进行速度分析,需要帧速率与摄像机录制的帧速率完全相同,因此我无法设置自己的帧速率。我还收到一些“无效 NAL”错误,但从我在 stackexchange 上看到的情况来看,这些错误似乎很常见。
pi@raspberrypi:~/lspiv/scripts $ ffmpeg version N-94564-gaac382e9e5 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
configuration: --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
libavutil 56. 33.100 / 56. 33.100
libavcodec 58. 55.100 / 58. 55.100
libavformat 58. 30.100 / 58. 30.100
libavdevice 58. 9.100 / 58. 9.100
libavfilter 7. 58.100 / 7. 58.100
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[h264 @ 0x1e31790] Invalid NAL unit 0, skipping.
[h264 @ 0x1e31790] Invalid NAL unit 8, skipping.
Last message repeated 5 times
[h264 @ 0x1e329e0] Invalid NAL unit 0, skipping.
[h264 @ 0x1e329e0] Invalid NAL unit 8, skipping.
Last message repeated 1 times
[h264 @ 0x1e329e0] Invalid NAL unit 0, skipping.
[h264 @ 0x1e329e0] Invalid NAL unit 8, skipping.
[rtsp @ 0x1e2e390] decoding for stream 1 failed
Input #0, rtsp, from 'rtsp://username:pwd@IPaddress':
Metadata:
title : Video Server Session
Duration: N/A, start: 0.033344, bitrate: N/A
Stream #0:0: Video: h264 (High), yuvj420p(pc, bt709, progressive), 2048x1536, 59.94 tbr, 90k tbn, 180k tbc
Stream #0:1: Video: h264 (High), yuvj420p(pc, bt709, progressive), 320x240, 90k tbr, 90k tbn, 180k tbc
Output #0, mp4, to '/home/pi/lspiv/video_ops/saved_videos/19860501_20200226_112619.mp4':
Metadata:
title : Video Server Session
encoder : Lavf58.30.100
Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 2048x1536, q=2-31, 59.94 tbr, 90k tbn, 90k tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[mp4 @ 0x1e90670] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
[mp4 @ 0x1e90670] Non-monotonous DTS in output stream 0:0; previous: 0, current: 0; changing to 1. This may result in incorrect timestamps in the output file.
frame= 301 fps= 63 q=-1.0 Lsize= 412kB time=00:00:09.99 bitrate= 337.9kbits/s speed=2.09x
video:409kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.871962%
答案1
您是否尝试过使用输入选项-r
?
ffmpeg -r 30 -i rtsp://...
或29,97
ffmpeg -r 30000/1001 -i rtsp://...