I am using a Raspberry Pi 3B+ to record video from a ActiA31 security camera (connected vie a power-over-ethernet router). The camera is set to record at 29.97 fps. The command I am using is
sudo /usr/local/bin/ffmpeg -i rtsp://username:pwd@IPaddress -t 10 -vcodec copy -acodec copy outputfile.mp4
The video does record, but the metadata of the recorded video shows as slightly different framerate (fps). The output is below(using 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)
Why is the fps different than the tbr?
I've copied the output from the original ffmpeg command here in hopes that it will help solve the question. I've tried using the option '-use_wallclock_as_timestamps 1 ' but it didn't result in anything different. I am using the video for velocity analysis and need the framerate to be exactly whatever the camera is recording at, hence I can't set my own framerate. I am also getting some 'Invalid NAL' errors but those seem to be pretty common from what I've seen on 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%
fps
indicates the average framerate.