ffmpeg를 통한 RTSP

ffmpeg를 통한 RTSP

이름 없는 IP 카메라가 4개 있는데 rtsp 스트림을 캡처하는 데 문제가 있습니다. 무작위 출력 파일도 생성되지 않습니다. ffmpeg를 통해 스트림을 캡처하고 있습니다. Ubuntu Server 18.04에서는 스냅 ffmpeg를, Debian 7에서는 일반 ffmpeg를 사용해 보았습니다. 같은 문제.

(/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 ) &

시험을 마친-로그 수준 디버깅그러나 성공적인 RTSP 연결만 표시되며 그 이상은 표시되지 않습니다. 그리고-로그 수준 추적성공한 프로세스와 실패한 프로세스의 차이점을 발견했습니다.

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

똥 같아.
로그 파일이 불완전하지만 충분하다고 생각합니다. 이것은 임의의 카메라와 함께 무작위로 나타납니다.
어떻게 고치나요?

답변1

나는 해결책을 스스로 찾았습니다. 내가 겪고 있는 문제는 패킷의 진위 여부입니다. 강제 TCP 연결 플래그를 추가해 보았습니다(-rtsp_transport TCP) 작동합니다. 괜찮아요.

관련 정보