如何使用 FFMPEG 保存 rtsp 流而不丢包
Posted
技术标签:
【中文标题】如何使用 FFMPEG 保存 rtsp 流而不丢包【英文标题】:How to save rtsp stream without packet loss by using FFMPEG 【发布时间】:2016-11-18 06:33:22 【问题描述】:我正在使用 FFMPEG 保存实时摄像机流。当我尝试保存视频时,一些数据包丢失,因此视频无法正常播放。我正在使用以下 FFMPEG Library
我发送的命令是-
String[] cmd = "-y", "-i", "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", "-c:v", "libx264", "-acodec", "aac","-t", time, file_path;
execFFmpegBinary(cmd);
我也在尝试这个命令,但结果是一样的
String[] cmd = "-y", "-rtsp_transport", "tcp", "-i", "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov", "-c:v", "libx264", "-preset", "slow", "-b:v", "500k", "-maxrate", "500k", "-bufsize", "3000k", "-vf", "scale=-1:480", "-threads", "0", "-codec:a", "libfdk_aac", "-b:a", "128k", "-t", time, file_path;
这里是命令输出的日志-
07-15 15:16:55.180 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.180 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 455 packets
07-15 15:16:55.190 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.190 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 16 packets
07-15 15:16:55.300 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.300 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 13 packets
07-15 15:16:55.310 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] mb_type 58 in P slice too large at 31 16
07-15 15:16:55.320 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] error while decoding MB 31 16
07-15 15:16:55.330 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] concealing 918 DC, 918 AC, 918 MV errors in P frame
07-15 15:16:55.330 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.330 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 55 packets
07-15 15:16:55.340 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.340 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 19 packets
07-15 15:16:55.340 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.350 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 1 packets
07-15 15:16:55.350 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x458737c0] out of range intra chroma pred mode at 7 28
07-15 15:16:55.350 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x458737c0] error while decoding MB 7 28
07-15 15:16:55.360 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x458737c0] concealing 402 DC, 402 AC, 402 MV errors in P frame
07-15 15:16:55.360 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] P sub_mb_type 8 out of range at 28 14
07-15 15:16:55.370 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] error while decoding MB 28 14
07-15 15:16:55.370 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] concealing 1011 DC, 1011 AC, 1011 MV errors in P frame
07-15 15:16:55.380 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45afe200] cbp too large (132) at 12 20
07-15 15:16:55.380 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45afe200] error while decoding MB 12 20
07-15 15:16:55.390 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45afe200] concealing 757 DC, 757 AC, 757 MV errors in P frame
07-15 15:16:55.640 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 173 fps=3.6 q=28.0 size= 657kB time=00:00:23.84 bitrate= 225.8kbits/s speed=0.502x
07-15 15:16:55.840 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.910 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 520 packets
07-15 15:16:55.920 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.920 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 2 packets
07-15 15:16:55.920 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:55.920 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 56 packets
07-15 15:16:55.930 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x4581bb60] concealing 800 DC, 800 AC, 800 MV errors in P frame
07-15 15:16:56.010 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] concealing 311 DC, 311 AC, 311 MV errors in P frame
07-15 15:16:56.720 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 174 fps=3.6 q=28.0 size= 674kB time=00:00:23.88 bitrate= 231.0kbits/s speed=0.497x
07-15 15:16:57.050 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 175 fps=3.6 q=28.0 size= 675kB time=00:00:29.00 bitrate= 190.6kbits/s speed=0.596x
07-15 15:16:57.350 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 177 fps=3.6 q=28.0 size= 686kB time=00:00:30.36 bitrate= 185.1kbits/s speed=0.617x
07-15 15:16:58.610 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 182 fps=3.6 q=28.0 size= 703kB time=00:00:30.56 bitrate= 188.3kbits/s speed=0.609x
07-15 15:16:59.120 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:59.120 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 23 packets
07-15 15:16:59.190 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 184 fps=3.6 q=28.0 size= 709kB time=00:00:30.64 bitrate= 189.6kbits/s speed=0.602x
07-15 15:16:59.200 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] concealing 69 DC, 69 AC, 69 MV errors in P frame
07-15 15:16:59.370 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:59.440 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 35 packets
07-15 15:16:59.440 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x458737c0] concealing 338 DC, 338 AC, 338 MV errors in I frame
07-15 15:16:59.920 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 187 fps=3.6 q=28.0 size= 716kB time=00:00:30.76 bitrate= 190.7kbits/s speed=0.595x
07-15 15:16:59.920 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:16:59.990 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 20 packets
07-15 15:16:59.990 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45afe200] concealing 489 DC, 489 AC, 489 MV errors in P frame
07-15 15:17:01.980 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 190 fps=3.5 q=28.0 size= 737kB time=00:00:30.88 bitrate= 195.4kbits/s speed=0.575x
07-15 15:17:01.980 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:01.980 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 35 packets
07-15 15:17:02.060 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:02.060 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 10 packets
07-15 15:17:02.230 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:02.230 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 10 packets
07-15 15:17:02.270 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] dquant out of range (124) at 15 35
07-15 15:17:02.270 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] error while decoding MB 15 35
07-15 15:17:02.280 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] concealing 79 DC, 79 AC, 79 MV errors in P frame
07-15 15:17:02.280 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:02.280 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 76 packets
07-15 15:17:02.290 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] concealing 805 DC, 805 AC, 805 MV errors in P frame
07-15 15:17:02.510 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:02.510 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 40 packets
07-15 15:17:02.600 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 194 fps=3.6 q=28.0 size= 747kB time=00:00:31.04 bitrate= 197.1kbits/s speed=0.57x
07-15 15:17:02.610 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:02.610 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 60 packets
07-15 15:17:02.610 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x458737c0] concealing 526 DC, 526 AC, 526 MV errors in P frame
07-15 15:17:02.620 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x4581bb60] concealing 197 DC, 197 AC, 197 MV errors in P frame
07-15 15:17:03.380 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 195 fps=3.5 q=28.0 size= 751kB time=00:00:31.08 bitrate= 198.1kbits/s speed=0.562x
07-15 15:17:03.570 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:03.640 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 474 packets
07-15 15:17:03.640 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:03.650 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 109 packets
07-15 15:17:03.650 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x4581bb60] negative number of zero coeffs at 28 22
07-15 15:17:03.650 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x4581bb60] error while decoding MB 28 22
07-15 15:17:03.660 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x4581bb60] concealing 651 DC, 651 AC, 651 MV errors in P frame
07-15 15:17:03.660 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x458737c0] concealing 1074 DC, 1074 AC, 1074 MV errors in P frame
07-15 15:17:03.920 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 195 fps=3.5 q=28.0 size= 751kB time=00:00:31.08 bitrate= 198.1kbits/s speed=0.557x
07-15 15:17:05.530 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 199 fps=3.5 q=25.0 size= 766kB time=00:00:32.84 bitrate= 191.2kbits/s speed=0.573x
07-15 15:17:06.250 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 202 fps=3.5 q=22.0 size= 784kB time=00:00:32.96 bitrate= 194.8kbits/s speed=0.568x
07-15 15:17:07.130 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 205 fps=3.5 q=28.0 size= 800kB time=00:00:33.08 bitrate= 198.2kbits/s speed=0.562x
07-15 15:17:08.960 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 207 fps=3.4 q=28.0 size= 811kB time=00:00:35.32 bitrate= 188.0kbits/s speed=0.581x
07-15 15:17:09.560 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:09.560 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 133 packets
07-15 15:17:09.660 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 210 fps=3.4 q=28.0 size= 817kB time=00:00:35.84 bitrate= 186.8kbits/s speed=0.584x
07-15 15:17:09.670 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:09.670 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 14 packets
07-15 15:17:09.680 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] concealing 410 DC, 410 AC, 410 MV errors in I frame
07-15 15:17:09.770 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x4581bb60] concealing 72 DC, 72 AC, 72 MV errors in P frame
07-15 15:17:10.730 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:10.730 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 24 packets
07-15 15:17:10.740 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:10.740 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 56 packets
07-15 15:17:11.410 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 212 fps=3.4 q=28.0 size= 819kB time=00:00:35.92 bitrate= 186.8kbits/s speed=0.574x
07-15 15:17:11.510 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.510 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 14 packets
07-15 15:17:11.510 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] concealing 77 DC, 77 AC, 77 MV errors in P frame
07-15 15:17:11.520 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 213 fps=3.4 q=28.0 size= 820kB time=00:00:35.96 bitrate= 186.8kbits/s speed=0.568x
07-15 15:17:11.520 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.520 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 10 packets
07-15 15:17:11.670 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.720 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 82 packets
07-15 15:17:11.730 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.730 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 41 packets
07-15 15:17:11.740 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45c42680] concealing 1343 DC, 1343 AC, 1343 MV errors in I frame
07-15 15:17:11.740 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.750 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 240 packets
07-15 15:17:11.890 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.900 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 7 packets
07-15 15:17:11.900 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:11.900 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 63 packets
07-15 15:17:11.940 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] out of range intra chroma pred mode at 42 32
07-15 15:17:11.950 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] error while decoding MB 42 32
07-15 15:17:11.960 25713-25713/com.github.sampleffmpeg V/output: progress : [h264 @ 0x45ab8020] concealing 187 DC, 187 AC, 187 MV errors in P frame
07-15 15:17:12.420 25713-25713/com.github.sampleffmpeg V/output: progress : [rtsp @ 0x420391c0] max delay reached. need to consume packet
07-15 15:17:12.420 25713-25713/com.github.sampleffmpeg V/output: progress : [NULL @ 0x4203ba00] RTP: missed 9 packets
07-15 15:17:12.830 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 217 fps=3.4 q=24.0 size= 881kB time=00:00:36.12 bitrate= 199.7kbits/s speed=0.562x
07-15 15:17:32.710 25713-25713/com.github.sampleffmpeg V/output: progress : frame= 217 fps=2.6 q=-1.0 Lsize= 1192kB time=00:00:59.48 bitrate= 164.2kbits/s speed=0.703x
07-15 15:17:32.720 25713-25713/com.github.sampleffmpeg V/output: progress : video:1190kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.207405%
07-15 15:17:32.820 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] frame I:4 Avg QP:17.76 size: 23826
07-15 15:17:32.820 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] frame P:141 Avg QP:20.25 size: 7361
07-15 15:17:32.830 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] frame B:72 Avg QP:23.59 size: 1173
07-15 15:17:32.830 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] consecutive B-frames: 54.4% 1.8% 6.9% 36.9%
07-15 15:17:32.840 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] mb I I16..4: 23.2% 42.9% 34.0%
07-15 15:17:32.840 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] mb P I16..4: 3.6% 3.2% 1.9% P16..4: 27.9% 6.4% 4.8% 0.0% 0.0% skip:52.3%
07-15 15:17:32.850 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] mb B I16..4: 0.1% 0.1% 0.0% B16..8: 20.2% 1.0% 0.3% direct: 1.1% skip:77.2% L0:42.5% L1:53.9% BI: 3.7%
07-15 15:17:32.860 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] 8x8 transform intra:38.4% inter:29.9%
07-15 15:17:32.860 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] coded y,uvDC,uvAC intra: 49.0% 31.1% 15.6% inter: 12.9% 10.5% 1.3%
07-15 15:17:32.870 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] i16 v,h,dc,p: 72% 6% 5% 17%
07-15 15:17:32.870 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 45% 16% 17% 2% 4% 3% 4% 5% 3%
07-15 15:17:32.880 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 19% 15% 5% 6% 4% 10% 9% 6%
07-15 15:17:32.880 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] i8c dc,h,v,p: 46% 12% 40% 3%
07-15 15:17:32.880 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] Weighted P-Frames: Y:0.0% UV:0.0%
07-15 15:17:32.890 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] ref P L0: 78.9% 6.1% 9.5% 5.6%
07-15 15:17:32.890 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] ref B L0: 87.4% 9.5% 3.1%
07-15 15:17:32.890 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] ref B L1: 95.5% 4.5%
07-15 15:17:32.900 25713-25713/com.github.sampleffmpeg V/output: progress : [libx264 @ 0x420a54c0] kb/s:163.45
07-15 15:17:32.900 25713-25713/com.github.sampleffmpeg V/output: SUCCESS with output : ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/i686-linux-android- --arch=x86 --cpu=i686 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/x86 --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -march=i686' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[udp @ 0x4203b040] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[udp @ 0x4203c040] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
Input #0, rtsp, from 'rtsp://81.109.95.91:3000/stream':
Metadata:
title : Session streamed with GStreamer
comment : rtsp-server
Duration: N/A, start: 0.080000, bitrate: N/A
Stream #0:0: Video: h264 (Constrained Baseline), yuv420p, 720x576, 25 fps, 25 tbr, 90k tbn, 180k tbc
[libx264 @ 0x420a54c0] using cpu capabilities: none!
[libx264 @ 0x420a54c0] profile High, level 3.0
[libx264 @ 0x420a54c0] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to '/storage/emulated/0/recording15072016-031605.mkv':
Metadata:
title : Session streamed with GStreamer
comment : rtsp-server
encoder : Lavf57.25.100
Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 720x576, q=-1--1, 25 fps, 1k tbn, 25 tbc
Metadata:
encoder : Lavc57.24.102 libx264
Side data:
unknown side data type 10 (24 bytes)
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
frame= 23 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
[rtsp @ 0x420391c0] max delay reached. need to consume packet
[NULL @ 0x4203ba00] RTP: missed 29 packets
[h264 @ 0x45afe200] concealing 104 DC, 104 AC, 104 MV errors in P frame
frame= 42 fps= 41 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 47 fps= 17 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 52 fps= 14 q=28.0 size= 36kB time=00:00:00.24 bitrate=1231.4kbits/s speed=0.0655x
frame= 55 fps= 12 q=28.0 size= 46kB time=00:00:00.36 bitrate=1036.1kbits/s speed=0.0783x
[rtsp @ 0x420391c0] max delay reached. need to con
如何保存高质量的rtsp流而不丢包?任何帮助将不胜感激。
【问题讨论】:
在您使用 android 之前,是否有一些 ffmpeg 构建可以在测试流上运行而不会丢失? IMO 您对作为 ffmpeg 的狭窄子集的 lib 构建有疑问。是否有更广泛的 mpeg 实现处理相同的流? 尝试在 ffmpeg 命令中提高帧率 @RobertRowntree 我正在提高帧速率,但问题是一样的。实际上,当我通过虚拟 url 并保存 2 分钟或 5 分钟的视频时,它会保存 2 分钟或 5 分钟的视频长度但是当我在某处播放此视频时,它会冻结并再次继续。但是当我浏览我的应用程序实时网址并保存视频时,视频会像这样跳过(例如 22 秒到 35 秒,40 秒到 55 秒) . 来自 rtsp 模块的大量“最大延迟”消息。也许这意味着您需要一个更快的多核 CPU,它可以消耗所有这些帧而不会落后。将您的 ffmpeg 安装在更快的盒子上并运行相同的表达式,看看它是否消耗相同的输入而没有所有的数据包丢失/丢包.. android 上的 ffmpeg 由于其限制而速度较慢......电池,小型设备。好的 linux 机器上的帧速率容量将是你在 android 上的 10 倍。 我们将-reorder_queue_size
设置为4000
,将-max_delay
设置为10000000
,这减少了丢失数据包的数量,但并没有完全解决问题。我们为我们正在做的演示/演示而构建了这个,只需要说“足够好!”™。
【参考方案1】:
如何保存高质量的rtsp流而不丢包?
不要重新编码。按原样保存。
ffmpeg -y -i "$source" -c copy -t "$time" "$filepath"
【讨论】:
【参考方案2】:我遇到了完全相同的问题,但我终于找到了解决方案:
只需在-i
选项之前添加-rtsp_transport tcp
,而不是之后!
这个命令对我有用:
./ffmpeg_g -rtsp_transport tcp -i rtsp://192.168.5.163:554/live/av0 -c copy /root/test.ts
【讨论】:
呃,使用-rtsp_transport tcp
会让事情变得更糟。当然,它减少了拖影,但它会错过很多帧,跳过整秒的视频。
如果有人只想从实时流中捕获 1 帧,这非常有效!无丢包:ffmpeg -y -rtsp_transport tcp -i rtsp://<username>:<password>@<ip_address>/live[/<path>] -frames:v 1 test.jpg
-rtsp_transport tcp
也为我解决了这个问题。 TCP
和 UDP
之间的主要区别在于 TCP 会为收到的数据包发送收据,因此不会丢失数据包(流量控制)。 UDP
如果您只是实时观看视频流并且不会为一些冻结而烦恼,那就更好了。如果您正在下载流然后使用-rtsp_transport tcp
,这将确保没有数据包丢失【参考方案3】:
您必须在输入命令之前移动传输/tcp,使其看起来像这样:
ffmpeg -rtsp_transport tcp -i $source -acodec copy -vcodec copy $output
【讨论】:
以上是关于如何使用 FFMPEG 保存 rtsp 流而不丢包的主要内容,如果未能解决你的问题,请参考以下文章