将 IP 摄像机 RTSP 流录制到 .mp4 文件

将 IP 摄像机 RTSP 流录制到 .mp4 文件

我想知道是否有人可以帮助我找出以下场景中我做错了什么。所以我的目标是将 IP 摄像机的 RTSP 流录制到 .mp4 文件中。我有 4 台 Vstarcam-C7824 摄像机。如果我打开流,它们都可以正常工作rtsp://user:pass@ipaddress/udp/av0_0,我可以看到视频并听到音频。我的问题是将其中 2 台摄像机的流录制到 mp4 文件中。另外 2 台工作正常。所以我使用以下命令:

ffmpeg -nostdin -i rtsp://user:pass@ipaddress/udp/av0_0 -map 0 -c:v copy -c:a mp2 -y -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 ./video-%M.%S.mp4 -loglevel verbose

这一直制作 5 秒长的视频。问题是,这只对我的 2 台相机有效。我可以查看录音并听到音频。其他 2 台相机我只能在播放录音时听到音频。这些相机都是同一型号。也许这与相机提供的流有关。相机使用的编解码器是:

Video - Codec: H264 - MPEG-4 AVC (part 10) (h264)

Audio - Codec: PCM ALAW (alaw)

以下是使用摄像头的 ffmpeg 命令的输出,可以播放其录制的文件:

    C:\Users\dellpc\Desktop\records>ffmpeg -i rtsp://user:[email protected]/udp/av0_0 -map 0 -c:v copy -c:a mp2 -y -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 ./video-%M.%S.mp4 -loglevel verbose
ffmpeg version 2021-08-18-git-dbe40478e2-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  4.101 / 57.  4.101
  libavcodec     59.  5.100 / 59.  5.100
  libavformat    59.  4.101 / 59.  4.101
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8.  2.100 /  8.  2.100
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
[tcp @ 0000023d4d80e940] Starting connection attempt to 10.10.10.7 port 554
[tcp @ 0000023d4d80e940] Successfully connected to 10.10.10.7 port 554
[rtsp @ 0000023d4d80e280] SDP:
v=0
o=VSTC 3838537728 3838537728 IN IP4 10.10.10.7
s=streamed by the VSTARCAM RTSP server
e=NONE
c=IN IP4 0.0.0.0
t=0 0
m=video 0 RTP/AVP 96
b=AS:1024
a=control:track0
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4d001f;sprop-parameter-sets=Z00AH52oFAFum4CAgKAAAAMAIAAAAwHwgA==,aO48gA==
m=audio 0 RTP/AVP 8
b=AS:64
a=control:track1
a=rtpmap:8 PCMA/8000/1


[rtsp @ 0000023d4d80e280] setting jitter buffer size to 500
    Last message repeated 1 times
[h264 @ 0000023d4d813440] Reinit context to 1280x720, pix_fmt: yuvj420p
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://user:[email protected]/udp/av0_0':
  Metadata:
    title           : streamed by the VSTARCAM RTSP server
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1280x720, 7.50 fps, 18.92 tbr, 90k tbn
  Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> mp2 (native))
Press [q] to stop, [?] for help
[graph_0_in_0_1 @ 0000023d4f7fe100] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 0000023d4d8be340] auto-inserting filter 'auto_aresample_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_aresample_0 @ 0000023d4fae3a40] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:s16 r:16000Hz
[segment @ 0000023d4d8a6d40] Selected stream id:0 type:video
[segment @ 0000023d4d8a6d40] Opening './video-30.02.mp4' for writing
Output #0, segment, to './video-%M.%S.mp4':
  Metadata:
    title           : streamed by the VSTARCAM RTSP server
    encoder         : Lavf59.4.101
  Stream #0:0: Video: h264 (Main), 1 reference frame, yuvj420p(pc, bt709, progressive, left), 1280x720 (0x0), q=2-31, 7.50 fps, 18.92 tbr, 15360 tbn
  Stream #0:1: Audio: mp2, 16000 Hz, mono, s16, delay 481, 160 kb/s
    Metadata:
      encoder         : Lavc59.5.100 mp2
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:0; previous: 6062, current: 0; changing to 6063. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:0 pts_time:0 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:1152 pts_time:0.072 frame:0
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:0; previous: 6063, current: 1690; changing to 6064. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:0; previous: 6064, current: 3195; changing to 6065. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:0; previous: 6065, current: 4132; changing to 6066. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:0; previous: 6066, current: 5683; changing to 6067. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:2304 pts_time:0.144 frame:0
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:1; previous: 1823, current: 415; changing to 1824. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:2305 pts_time:0.144063 frame:0
[segment @ 0000023d4d8a6d40] Non-monotonous DTS in output stream 0:1; previous: 1824, current: 1567; changing to 1825. This may result in incorrect timestamps in the output file.
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:2306 pts_time:0.144125 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:3200 pts_time:0.2 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:4352 pts_time:0.272 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:5504 pts_time:0.344 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:1 pts:6656 pts_time:0.416 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' starts with packet stream:0 pts:6524 pts_time:0.42474 frame:0
[segment @ 0000023d4d8a6d40] segment:'./video-30.02.mp4' count:0 ended=1.74x
[AVIOContext @ 0000023d4d875380] Statistics: 2 seeks, 5 writeouts
[segment @ 0000023d4d8a6d40] Opening './video-30.05.mp4' for writing
[segment @ 0000023d4d8a6d40] segment:'./video-30.05.mp4' starts with packet stream:0 pts:80933 pts_time:5.26908 frame:60
[segment @ 0000023d4d8a6d40] segment:'./video-30.05.mp4' count:1 ended=1.28x
[AVIOContext @ 0000023d4d8a2e40] Statistics: 2 seeks, 5 writeouts
[segment @ 0000023d4d8a6d40] Opening './video-30.11.mp4' for writing
[segment @ 0000023d4d8a6d40] segment:'./video-30.11.mp4' starts with packet stream:0 pts:162310 pts_time:10.5671 frame:120
[segment @ 0000023d4d8a6d40] segment:'./video-30.11.mp4' count:2 ended=1.23x
[AVIOContext @ 0000023d4faeb180] Statistics: 2 seeks, 4 writeouts
frame=  145 fps= 14 q=-1.0 Lsize=N/A time=00:00:12.65 bitrate=N/A speed=1.22x
video:558kB audio:240kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (rtsp://user:[email protected]/udp/av0_0):
  Input stream #0:0 (video): 145 packets read (570989 bytes);
  Input stream #0:1 (audio): 77 packets read (98560 bytes); 77 frames decoded (98560 samples);
  Total: 222 packets (669549 bytes) demuxed
Output file #0 (./video-%M.%S.mp4):
  Output stream #0:0 (video): 145 packets muxed (570989 bytes);
  Output stream #0:1 (audio): 171 frames encoded (196992 samples); 171 packets muxed (246240 bytes);
  Total: 316 packets (817229 bytes) muxed
Exiting normally, received signal 2.

C:\Users\dellpc\Desktop\records>

下面是使用摄像机录制的文件的 ffmpeg 命令输出,其中没有显示视频,只能听到音频。

    C:\Users\dellpc\Desktop\records>ffmpeg -i rtsp://user:[email protected]/udp/av0_0 -map 0 -c:v copy -c:a mp2 -y -f segment -segment_time 5 -reset_timestamps 1 -strftime 1 ./video-%M.%S.mp4 -loglevel verbose
ffmpeg version 2021-08-18-git-dbe40478e2-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libglslang --enable-vulkan --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      57.  4.101 / 57.  4.101
  libavcodec     59.  5.100 / 59.  5.100
  libavformat    59.  4.101 / 59.  4.101
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8.  2.100 /  8.  2.100
  libswscale      6.  0.100 /  6.  0.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
[tcp @ 000002257d8ae940] Starting connection attempt to 10.10.10.14 port 554
[tcp @ 000002257d8ae940] Successfully connected to 10.10.10.14 port 554
[rtsp @ 000002257d8ae280] SDP:
v=0
o=VSTC 3838538240 3838538240 IN IP4 10.10.10.14
s=streamed by the VSTARCAM RTSP server
e=NONE
c=IN IP4 0.0.0.0
t=0 0
m=video 0 RTP/AVP 96
b=AS:1536
a=control:track0
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=00f004;sprop-parameter-sets=6QDwBE/LCAAAH0gAB1TgIAAAAAA=,AAAAAA==
m=audio 0 RTP/AVP 8
b=AS:64
a=control:track1
a=rtpmap:8 PCMA/8000/1


[rtsp @ 000002257d8ae280] setting jitter buffer size to 500
    Last message repeated 1 times
[h264 @ 000002257d8b3440] Invalid NAL unit 0, skipping.
    Last message repeated 1 times
[rtsp @ 000002257d8ae280] max delay reached. need to consume packet
[rtsp @ 000002257d8ae280] RTP: missed 56 packets
[rtsp @ 000002257d8ae280] max delay reached. need to consume packet
[rtsp @ 000002257d8ae280] RTP: missed 1 packets
[h264 @ 000002257d8b3440] Reinit context to 1920x1088, pix_fmt: yuv420p
Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://user:[email protected]/udp/av0_0':
  Metadata:
    title           : streamed by the VSTARCAM RTSP server
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: h264 (Main), 1 reference frame, yuv420p(progressive, left), 1920x1080 (1920x1088), 30 fps, 25 tbr, 90k tbn
  Stream #0:1: Audio: pcm_alaw, 8000 Hz, mono, s16, 64 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_alaw (native) -> mp2 (native))
Press [q] to stop, [?] for help
[graph_0_in_0_1 @ 000002257d96eec0] tb:1/8000 samplefmt:s16 samplerate:8000 chlayout:0x4
[format_out_0_1 @ 000002257d96cf80] auto-inserting filter 'auto_aresample_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_aresample_0 @ 000002257d96d080] ch:1 chl:mono fmt:s16 r:8000Hz -> ch:1 chl:mono fmt:s16 r:16000Hz
[segment @ 000002257f7e4d40] Selected stream id:0 type:video
[segment @ 000002257f7e4d40] Opening './video-38.03.mp4' for writing
Output #0, segment, to './video-%M.%S.mp4':
  Metadata:
    title           : streamed by the VSTARCAM RTSP server
    encoder         : Lavf59.4.101
  Stream #0:0: Video: h264 (Main), 1 reference frame, yuv420p(progressive, left), 1920x1080 (0x0), q=2-31, 30 fps, 25 tbr, 15360 tbn
  Stream #0:1: Audio: mp2, 16000 Hz, mono, s16, delay 481, 160 kb/s
    Metadata:
      encoder         : Lavc59.5.100 mp2
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:0 pts_time:0 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:1152 pts_time:0.072 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:2304 pts_time:0.144 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:3456 pts_time:0.216 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:4608 pts_time:0.288 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:5760 pts_time:0.36 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:6912 pts_time:0.432 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:8064 pts_time:0.504 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:9216 pts_time:0.576 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:10368 pts_time:0.648 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:11520 pts_time:0.72 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:12672 pts_time:0.792 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:13824 pts_time:0.864 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:14976 pts_time:0.936 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:16128 pts_time:1.008 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:17280 pts_time:1.08 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:18432 pts_time:1.152 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:19584 pts_time:1.224 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:20736 pts_time:1.296 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:21888 pts_time:1.368 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:23040 pts_time:1.44 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:24192 pts_time:1.512 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:25344 pts_time:1.584 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:26496 pts_time:1.656 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:27648 pts_time:1.728 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:28800 pts_time:1.8 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:29952 pts_time:1.872 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:31104 pts_time:1.944 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:32256 pts_time:2.016 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:33408 pts_time:2.088 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:34560 pts_time:2.16 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:35712 pts_time:2.232 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:36864 pts_time:2.304 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:38016 pts_time:2.376 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:39168 pts_time:2.448 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:40320 pts_time:2.52 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:41472 pts_time:2.592 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:42624 pts_time:2.664 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:43776 pts_time:2.736 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:44928 pts_time:2.808 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:46080 pts_time:2.88 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:47232 pts_time:2.952 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:48384 pts_time:3.024 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:49536 pts_time:3.096 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:50688 pts_time:3.168 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:51840 pts_time:3.24 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:52992 pts_time:3.312 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:54144 pts_time:3.384 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:55296 pts_time:3.456 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:56448 pts_time:3.528 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:57600 pts_time:3.6 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:58752 pts_time:3.672 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:59904 pts_time:3.744 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:61056 pts_time:3.816 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:62208 pts_time:3.888 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:1 pts:63360 pts_time:3.96 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' starts with packet stream:0 pts:61902 pts_time:4.03008 frame:0
[segment @ 000002257f7e4d40] segment:'./video-38.03.mp4' count:0 ended=2.41x
[AVIOContext @ 000002257f69b0c0] Statistics: 2 seeks, 6 writeouts
[segment @ 000002257f7e4d40] Opening './video-38.07.mp4' for writing
[segment @ 000002257f7e4d40] segment:'./video-38.07.mp4' starts with packet stream:0 pts:123342 pts_time:8.03008 frame:100
[segment @ 000002257f7e4d40] segment:'./video-38.07.mp4' count:1 ended=1.66x
[AVIOContext @ 000002257f7e3bc0] Statistics: 2 seeks, 5 writeouts
[segment @ 000002257f7e4d40] Opening './video-38.11.mp4' for writing
[segment @ 000002257f7e4d40] segment:'./video-38.11.mp4' starts with packet stream:0 pts:184782 pts_time:12.0301 frame:200
[segment @ 000002257f7e4d40] segment:'./video-38.11.mp4' count:2 ended=1.45x
[AVIOContext @ 000002257f7e3500] Statistics: 2 seeks, 7 writeouts
[segment @ 000002257f7e4d40] Opening './video-38.15.mp4' for writing
[segment @ 000002257f7e4d40] segment:'./video-38.15.mp4' starts with packet stream:0 pts:246222 pts_time:16.0301 frame:300
[segment @ 000002257f7e4d40] segment:'./video-38.15.mp4' count:3 ended=1.35x
[AVIOContext @ 000002257f7e33c0] Statistics: 2 seeks, 6 writeouts
frame=  397 fps= 27 q=-1.0 Lsize=N/A time=00:00:19.84 bitrate=N/A speed=1.35x
video:1950kB audio:374kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (rtsp://user:[email protected]/udp/av0_0):
  Input stream #0:0 (video): 496 packets read (2278651 bytes);
  Input stream #0:1 (audio): 120 packets read (153600 bytes); 120 frames decoded (153600 samples);
  Total: 616 packets (2432251 bytes) demuxed
Output file #0 (./video-%M.%S.mp4):
  Output stream #0:0 (video): 397 packets muxed (1997267 bytes);
  Output stream #0:1 (audio): 266 frames encoded (306432 samples); 266 packets muxed (383040 bytes);
  Total: 663 packets (2380307 bytes) muxed
Exiting normally, received signal 2.

C:\Users\dellpc\Desktop\records>

我自己注意到的唯一区别是流之间的 FPS 和分辨率差异。这可能与此有关吗?

任何意见都值得赞赏!

泰穆尔

答案1

我遇到了同样的问题,并通过确保它使用 TCP 连接解决了该问题,方法是-rtsp_transport tcp在之前添加-i,因此:

ffmpeg -nostdin -rtsp_transport tcp -i rtsp://user:pass@ipaddress/udp/av0_0 -map 0 ...

相关内容