Ffmpeg
RTSP 通過 ffmpeg
我有 4 個無名 ip-cams 並且在擷取 rtsp 流時遇到了麻煩。隨機輸出文件甚至沒有創建。我正在通過 ffmpeg 擷取流。在帶有 snap ffmpeg 的 Ubuntu Server 18.04 和帶有普通 ffmpeg 的 Debian 7 上進行了嘗試。同樣的麻煩。
(/snap/bin/ffmpeg -y -use_wallclock_as_timestamps 1 -hide_banner -loglevel trace -i rtsp://192.168.0.16$1:554/11 -c:v copy -an -flags +global_header $VIDEO_FILE 2> $LOG_FOLDER/cam$1 ) &
嘗試過*-loglevel 調試*,但它只顯示成功的 RTSP 連接,僅此而已。使用*-loglevel 跟踪*,我注意到成功和失敗程序之間的區別。
Error: unable to open display Splitting the commandline. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-use_wallclock_as_timestamps' ... matched as AVOption 'use_wallclock_as_timestamps' with argument '1'. Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'. Reading option '-i' ... matched as input url with argument 'rtsp://192.168.0.161:554/11'. Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'. Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'. Reading option '-flags' ... matched as AVOption 'flags' with argument '+global_header'. Reading option '/home/melo/samba/video/19-03-07/cam1/16-06-11.mp4' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option hide_banner (do not show program banner) with argument 1. Applying option loglevel (set logging level) with argument trace. Successfully parsed a group of options. Parsing a group of options: input url rtsp://192.168.0.161:554/11. Successfully parsed a group of options. Opening an input file: rtsp://192.168.0.161:554/11. Probing rtsp score:100 size:0 [tcp @ 0x1b5cc40] No default whitelist set [tcp @ 0x1b5cc40] Original list of addresses: [tcp @ 0x1b5cc40] Address 192.168.0.161 port 554 [tcp @ 0x1b5cc40] Interleaved list of addresses: [tcp @ 0x1b5cc40] Address 192.168.0.161 port 554 [tcp @ 0x1b5cc40] Starting connection attempt to 192.168.0.161 port 554 [tcp @ 0x1b5cc40] Successfully connected to 192.168.0.161 port 554 [rtsp @ 0x1b5abc0] Sending: OPTIONS rtsp://192.168.0.161:554/11 RTSP/1.0 CSeq: 1 User-Agent: Lavf58.20.100 -- [rtsp @ 0x1b5abc0] ret=1 c=52 [R] [rtsp @ 0x1b5abc0] ret=1 c=54 [T] [rtsp @ 0x1b5abc0] ret=1 c=53 [S] [rtsp @ 0x1b5abc0] ret=1 c=50 [P] [rtsp @ 0x1b5abc0] ret=1 c=2f [/] [rtsp @ 0x1b5abc0] ret=1 c=31 [1] [rtsp @ 0x1b5abc0] ret=1 c=2e [.] [rtsp @ 0x1b5abc0] ret=1 c=30 [0] [rtsp @ 0x1b5abc0] ret=1 c=20 [ ] [rtsp @ 0x1b5abc0] ret=1 c=32 [2] [rtsp @ 0x1b5abc0] ret=1 c=30 [0] Last message repeated 1 times [rtsp @ 0x1b5abc0] ret=1 c=20 [ ] [rtsp @ 0x1b5abc0] ret=1 c=4f [O] [rtsp @ 0x1b5abc0] ret=1 c=4b [K] [rtsp @ 0x1b5abc0] ret=1 c=0d [ ] [rtsp @ 0x1b5abc0] ret=1 c=0a [ ] [rtsp @ 0x1b5abc0] line='RTSP/1.0 200 OK' [rtsp @ 0x1b5abc0] ret=1 c=43 [C] [rtsp @ 0x1b5abc0] ret=1 c=53 [S] [rtsp @ 0x1b5abc0] ret=1 c=65 [e] [rtsp @ 0x1b5abc0] ret=1 c=71 [q] [rtsp @ 0x1b5abc0] ret=1 c=3a [:] [rtsp @ 0x1b5abc0] ret=1 c=20 [ ] [rtsp @ 0x1b5abc0] ret=1 c=31 [1] [rtsp @ 0x1b5abc0] ret=1 c=0d [ ] [rtsp @ 0x1b5abc0] ret=1 c=0a [ ]
良好的編碼和成功過程中的一切清晰。
Error: unable to open display Splitting the commandline. Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. Reading option '-use_wallclock_as_timestamps' ... matched as AVOption 'use_wallclock_as_timestamps' with argument '1'. Reading option '-hide_banner' ... matched as option 'hide_banner' (do not show program banner) with argument '1'. Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'trace'. Reading option '-i' ... matched as input url with argument 'rtsp://192.168.0.163:554/11'. Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'. Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'. Reading option '-flags' ... matched as AVOption 'flags' with argument '+global_header'. Reading option '/home/melo/samba/video/19-03-07/cam3/16-06-11.mp4' ... matched as output url. Finished splitting the commandline. Parsing a group of options: global . Applying option y (overwrite output files) with argument 1. Applying option hide_banner (do not show program banner) with argument 1. Applying option loglevel (set logging level) with argument trace. Successfully parsed a group of options. Parsing a group of options: input url rtsp://192.168.0.163:554/11. Successfully parsed a group of options. Opening an input file: rtsp://192.168.0.163:554/11. Probing rtsp score:100 size:0 [tcp @ 0x18eec40] No default whitelist set [tcp @ 0x18eec40] Original list of addresses: [tcp @ 0x18eec40] Address 192.168.0.163 port 554 [tcp @ 0x18eec40] Interleaved list of addresses: [tcp @ 0x18eec40] Address 192.168.0.163 port 554 [tcp @ 0x18eec40] Starting connection attempt to 192.168.0.163 port 554 [tcp @ 0x18eec40] Successfully connected to 192.168.0.163 port 554 [rtsp @ 0x18ecbc0] Sending: OPTIONS rtsp://192.168.0.163:554/11 RTSP/1.0 CSeq: 1 User-Agent: Lavf58.20.100 -- [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=08 [] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=04 [?] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=01 [?] [rtsp @ 0x18ecbc0] ret=1 c=48 [H] [rtsp @ 0x18ecbc0] ret=1 c=02 [?] [rtsp @ 0x18ecbc0] ret=1 c=2a [*] [rtsp @ 0x18ecbc0] ret=1 c=e0 [à] [rtsp @ 0x18ecbc0] ret=1 c=bc [Œ] [rtsp @ 0x18ecbc0] ret=1 c=84 [] [rtsp @ 0x18ecbc0] ret=1 c=c0 [À] [rtsp @ 0x18ecbc0] ret=1 c=a8 [š] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=a3 [£] [rtsp @ 0x18ecbc0] ret=1 c=ff [ÿ] Last message repeated 9 times [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=08 [] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=04 [?] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=01 [?] [rtsp @ 0x18ecbc0] ret=1 c=48 [H] [rtsp @ 0x18ecbc0] ret=1 c=02 [?] [rtsp @ 0x18ecbc0] ret=1 c=2a [*] [rtsp @ 0x18ecbc0] ret=1 c=e0 [à] [rtsp @ 0x18ecbc0] ret=1 c=bc [Œ] [rtsp @ 0x18ecbc0] ret=1 c=84 [] [rtsp @ 0x18ecbc0] ret=1 c=c0 [À] [rtsp @ 0x18ecbc0] ret=1 c=a8 [š] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=a3 [£] [rtsp @ 0x18ecbc0] ret=1 c=ff [ÿ] Last message repeated 9 times [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=08 [] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=04 [?] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=01 [?] [rtsp @ 0x18ecbc0] ret=1 c=48 [H] [rtsp @ 0x18ecbc0] ret=1 c=02 [?] [rtsp @ 0x18ecbc0] ret=1 c=2a [*] [rtsp @ 0x18ecbc0] ret=1 c=e0 [à] [rtsp @ 0x18ecbc0] ret=1 c=bc [Œ] [rtsp @ 0x18ecbc0] ret=1 c=84 [] [rtsp @ 0x18ecbc0] ret=1 c=c0 [À] [rtsp @ 0x18ecbc0] ret=1 c=a8 [š] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=a3 [£] [rtsp @ 0x18ecbc0] ret=1 c=ff [ÿ] Last message repeated 9 times [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=08 [] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=04 [?] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=01 [?] [rtsp @ 0x18ecbc0] ret=1 c=48 [H] [rtsp @ 0x18ecbc0] ret=1 c=02 [?] [rtsp @ 0x18ecbc0] ret=1 c=2a [*] [rtsp @ 0x18ecbc0] ret=1 c=e0 [à] [rtsp @ 0x18ecbc0] ret=1 c=bc [Œ] [rtsp @ 0x18ecbc0] ret=1 c=84 [] [rtsp @ 0x18ecbc0] ret=1 c=c0 [À] [rtsp @ 0x18ecbc0] ret=1 c=a8 [š] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=a3 [£] [rtsp @ 0x18ecbc0] ret=1 c=ff [ÿ] Last message repeated 9 times [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=08 [] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=04 [?] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=01 [?] [rtsp @ 0x18ecbc0] ret=1 c=48 [H] [rtsp @ 0x18ecbc0] ret=1 c=02 [?] [rtsp @ 0x18ecbc0] ret=1 c=2a [*] [rtsp @ 0x18ecbc0] ret=1 c=e0 [à] [rtsp @ 0x18ecbc0] ret=1 c=bc [Œ] [rtsp @ 0x18ecbc0] ret=1 c=84 [] [rtsp @ 0x18ecbc0] ret=1 c=c0 [À] [rtsp @ 0x18ecbc0] ret=1 c=a8 [š] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=a3 [£] [rtsp @ 0x18ecbc0] ret=1 c=ff [ÿ] Last message repeated 9 times [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=08 [] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=06 [?] [rtsp @ 0x18ecbc0] ret=1 c=04 [?] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=01 [?] [rtsp @ 0x18ecbc0] ret=1 c=48 [H] [rtsp @ 0x18ecbc0] ret=1 c=02 [?] [rtsp @ 0x18ecbc0] ret=1 c=2a [*] [rtsp @ 0x18ecbc0] ret=1 c=e0 [à] [rtsp @ 0x18ecbc0] ret=1 c=bc [Œ] [rtsp @ 0x18ecbc0] ret=1 c=84 [] [rtsp @ 0x18ecbc0] ret=1 c=c0 [À] [rtsp @ 0x18ecbc0] ret=1 c=a8 [š] [rtsp @ 0x18ecbc0] ret=1 c=00 [[rtsp @ 0x18ecbc0] ret=1 c=a3 [£] [rtsp @ 0x18ecbc0] ret=1 c=ff [ÿ] Last message repeated 9 times
看起來像個狗屎。
日誌文件未滿,但我認為已經足夠了。這隨機出現在隨機凸輪上。
如何解決?
我自己找到了解決方案。我的問題是數據包的真實性。我嘗試添加強制 tcp 連接標誌(-rtsp_transport tcp)並且它有效。沒有問題了。