AlexxIT / go2rtc

Ultimate camera streaming application with support RTSP, RTMP, HTTP-FLV, WebRTC, MSE, HLS, MP4, MJPEG, HomeKit, FFmpeg, etc.
https://github.com/AlexxIT/Blog
MIT License
4.25k stars 346 forks source link

ffmpeg vaapi encoding in LXC Proxmox Container with NeoLink ReoLink camera #973

Closed sredfern closed 6 months ago

sredfern commented 6 months ago

Version: 1.8.5

System Config

Problem: When I try to start the stream I get the error "webrtc/offer: streams: exec: exit status 1" What's interesting is you can see ffmpeg listed in the process list for intel_gpu_top come up 3 times. This matches with the logs on 3 attempts. Sadly the error message isnt very descriptive and I'm unable to work out how to troubleshoot it further.

hardware and #hardware=vaapi yield the same result. Let me know if you'd like to see a log without #hardware=vaapi.

Add > FFmpeg Hardware:

OK  ffmpeg:...#video=h264#hardware=vaapi
ERROR   ffmpeg:...#video=h265#hardware=vaapi
OK  ffmpeg:...#video=mjpeg#hardware=vaapi
ERROR   ffmpeg:...#video=h264#hardware=cuda
ERROR   ffmpeg:...#video=h265#hardware=cuda

config:

streams:
    front_porch: ffmpeg:rtsp://192.168.86.109:8554/frontPorch/main#video=h264#rotate=180#video=h264#hardware=vaapi
    front_porch_sub: ffmpeg:rtsp://192.168.86.109:8554/frontPorch/sub#audio=opus#video=h264#rotate=180#hardware
    side_north: ffmpeg:rtsp://192.168.86.109:8554/sideNorth/main#audio=opus#video=h264#rotate=180
    side_north_sub: ffmpeg:rtsp://192.168.86.109:8554/sideNorth/sub#audio=opus#video=h264#rotate=180
webrtc:
    candidates:
      - 192.168.86.176:8555
rtsp:
  default_query: mp4

log:
  level: trace  # default level
  api: error
  exec: trace
  ngrok: trace
  rtsp: trace
  streams: trace
  webrtc: trace
  format: text

Confirmed ffmpeg vaapi encoding works on the container from the stream:

root@go2rtc:~#
ffmpeg -hide_banner -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -allowed_media_types video+audio -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent "go2rtc/ffmpeg" -rtsp_flags prefer_tcp -i rtsp://192.168.86.109:8554/frontPorch/main -vf 'format=nv12|vaapi,hwupload' -c:v h264_vaapi -profile:v high -level:v 4.1 -g 50 -bf 0 -c:a libopus -application:a lowdelay -b:a 128k -ar 48000 output.mp4
Input #0, rtsp, from 'rtsp://192.168.86.109:8554/frontPorch/main':
  Metadata:
    title           : Session streamed with GStreamer
    comment         : rtsp-server
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: hevc (Main), yuvj420p(pc, bt709), 3840x2160, 20 fps, 20 tbr, 90k tbn
  Stream #0:1: Audio: pcm_s16be, 16000 Hz, stereo, s16, 512 kb/s
File 'output.mp4' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (pcm_s16be (native) -> opus (libopus))
Press [q] to stop, [?] for help
Output #0, mp4, to 'output.mp4':
  Metadata:
    title           : Session streamed with GStreamer
    comment         : rtsp-server
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), vaapi(pc, bt709, progressive), 3840x2160, q=2-31, 20 fps, 10240 tbn
    Metadata:
      encoder         : Lavc59.37.100 h264_vaapi
  Stream #0:1: Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, s16, 128 kb/s
    Metadata:
      encoder         : Lavc59.37.100 libopus
...
frame=  259 fps= 27 q=-0.0 Lsize=   32797kB time=00:00:16.20 bitrate=16579.9kbits/s dup=55 drop=0 speed=1.67x

When encoding that video I can see it in "intel_gpu_top"

intel-gpu-top: Intel Skylake (Gen9) @ /dev/dri/card0 - 1102/1103 MHz;   0% RC6;  2.13/ 9.54 W;      243 irqs/s

      IMC reads:     5264 MiB/s
     IMC writes:     2313 MiB/s

         ENGINES     BUSY                                                                                                    MI_SEMA MI_WAIT
       Render/3D    0.00% |                                                                                                |      0%      0%
         Blitter    0.00% |                                                                                                |      0%      0%
           Video  100.00% |████████████████████████████████████████████████████████████████████████████████████████████████|      0%      0%
    VideoEnhance    0.00% |                                                                                                |      0%      0%

   PID              NAME           Render/3D                     Blitter                       Video                    VideoEnhance
  4638            ffmpeg |                           ||                           ||██████████████████████████▏||                           |

I tried to set a custom ffmpeg config but I'm not super experienced in ffmpeg commands order:

(addition to config)

ffmpeg:
    bin: ffmpeg  # Modify if your ffmpeg binary is in a different location
    h264: "-codec:v h264_vaapi -profile:v high -level:v 4.1 -g 50 -bf 0"  # Hardware-accelerated H.264
    opus: "-codec:a libopus -application:a lowdelay -b:a 128k -ar 48000"  # Opus audio
    mycodec: "-hide_banner -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -allowed_media_types video+audio"
    myinput: " -fflags nobuffer -flags low_delay -timeout 5000000 -i {input}"
    myraw: "-vf 'format=nv12|vaapi,hwupload'"  # VAAPI hardware transcoding and output

But this gave an error that looked worse.

vainfo

root@go2rtc:~# vainfo
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD

neolink config:

cat neolink.toml
bind = "0.0.0.0"

# Uncomment to enable MQTT
[mqtt]
broker_addr = "192.168.86.141"
port = 1883
credentials = ["neolink", ""]

[[cameras]]
name = "frontPorch"
username = "admin"
password = ""
address = "192.168.55.227"
mqtt.discovery.topic = "homeassistant"
mqtt.discovery.features = ["floodlight"]

[[cameras]]
name = "sideNorth"
username = "admin"
password = ""
address = "192.168.55.107"
mqtt.discovery.topic = "homeassistant"
mqtt.discovery.features = ["floodlight"]

Error Log:

29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/offer
29/2/2024, 11:28:50 pm  debug   [webrtc] new consumer src=front_porch
29/2/2024, 11:28:50 pm  trace   [webrtc] offer:
v=0
o=- 3141677963199131890 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=extmap-allow-mixed
a=msid-semantic: WMS
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 103 104 105 106 107 108 109 127 35
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:Wd8y
a=ice-pwd:ijtuRUBbjagVZ5gie9xdRrU8
a=ice-options:trickle
a=fingerprint:sha-256 71:E9:67:1C:AA:DE:C6:23:61:6A:2F:31:82:14:71:CB:28:71:F4:C6:07:4F:EE:15:56:32:F0:71:8D:44:A9:C5
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 urn:3gpp:video-orientation
a=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 H264/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=fmtp:96 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640c1f
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 H264/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 H264/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=fmtp:100 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=640c1f
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:103 rtx/90000
a=fmtp:103 apt=102
a=rtpmap:104 VP8/90000
a=rtcp-fb:104 goog-remb
a=rtcp-fb:104 transport-cc
a=rtcp-fb:104 ccm fir
a=rtcp-fb:104 nack
a=rtcp-fb:104 nack pli
a=rtpmap:105 rtx/90000
a=fmtp:105 apt=104
a=rtpmap:106 VP9/90000
a=rtcp-fb:106 goog-remb
a=rtcp-fb:106 transport-cc
a=rtcp-fb:106 ccm fir
a=rtcp-fb:106 nack
a=rtcp-fb:106 nack pli
a=fmtp:106 profile-id=0
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=106
a=rtpmap:108 red/90000
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:127 ulpfec/90000
a=rtpmap:35 flexfec-03/90000
a=rtcp-fb:35 goog-remb
a=rtcp-fb:35 transport-cc
a=fmtp:35 repair-window=10000000
m=audio 9 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:Wd8y
a=ice-pwd:ijtuRUBbjagVZ5gie9xdRrU8
a=ice-options:trickle
a=fingerprint:sha-256 71:E9:67:1C:AA:DE:C6:23:61:6A:2F:31:82:14:71:CB:28:71:F4:C6:07:4F:EE:15:56:32:F0:71:8D:44:A9:C5
a=setup:actpass
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:9 urn:ietf:params:rtp-hdrext:sdes:mid
a=recvonly
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:126 telephone-event/8000
29/2/2024, 11:28:50 pm  trace   [streams] check cons=0 media=video, sendonly, H264, RTX, VP8, VP9, RED, ULPFEC, FLEXFEC-03
29/2/2024, 11:28:50 pm  debug   [exec] run url=exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -allowed_media_types video -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://192.168.86.109:8554/frontPorch/main -map 0:v:0? -c:v:0 h264_vaapi -g 50 -bf 0 -profile:v:0 high -level:v:0 4.1 -sei:v:0 0 -map 0:v:0? -c:v:1 h264_vaapi -g 50 -bf 0 -profile:v:1 high -level:v:1 4.1 -sei:v:1 0 -an -vf "format=vaapi|nv12,hwupload,format=vaapi|nv12,hwupload,transpose_vaapi=4,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12" -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=mse
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [mp4] new WS/MSE consumer codecs=avc1.640029,avc1.64002A,avc1.640033,hvc1.1.6.L153.B0,mp4a.40.2,mp4a.40.5
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3266464316 1 udp 2122194687 75f9644e-561c-45cd-8a6b-c1e8360a5fec.local 62178 typ host generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [streams] check cons=1 media=video, sendonly, H264, H265
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2784229777 1 udp 2122262783 05dd3d5c-fb30-48af-8cae-e09079cd90e5.local 57642 typ host generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2784229777 1 udp 2122262783 92030aa8-92ea-4e89-b5aa-54bfaa386f7d.local 56724 typ host generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2784229777 1 udp 2122262783 ead36a78-7e91-44b7-a607-383ab5985904.local 63771 typ host generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3266464316 1 udp 2122194687 5da1834c-5e07-441d-a82f-a0bc4f0678ec.local 51119 typ host generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2784229777 1 udp 2122262783 6e6aad9c-c6dc-4db9-812e-3c5303882d6d.local 56708 typ host generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3266464316 1 udp 2122194687 1a47b8b3-b195-45a0-9fcb-5bf74ee058ae.local 60684 typ host generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3266464316 1 udp 2122194687 a40f329a-0a26-4689-b723-68fc3c9f1006.local 61283 typ host generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2668205608 1 udp 1686055167 2406:3400:219:1e00:1fd:dd86:9320:73c5 63771 typ srflx raddr :: rport 0 generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:280940467 1 udp 1685987071 220.233.64.73 61283 typ srflx raddr 0.0.0.0 rport 0 generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:280940467 1 udp 1685987071 220.233.64.73 51119 typ srflx raddr 0.0.0.0 rport 0 generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2668205608 1 udp 1686055167 2406:3400:219:1e00:1fd:dd86:9320:73c5 57642 typ srflx raddr :: rport 0 generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:280940467 1 udp 1685987071 220.233.64.73 62178 typ srflx raddr 0.0.0.0 rport 0 generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2668205608 1 udp 1686055167 2406:3400:219:1e00:1fd:dd86:9320:73c5 56724 typ srflx raddr :: rport 0 generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:2668205608 1 udp 1686055167 2406:3400:219:1e00:1fd:dd86:9320:73c5 56708 typ srflx raddr :: rport 0 generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:280940467 1 udp 1685987071 220.233.64.73 60684 typ srflx raddr 0.0.0.0 rport 0 generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3162351780 1 tcp 1518214911 75f9644e-561c-45cd-8a6b-c1e8360a5fec.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3678149385 1 tcp 1518283007 fa278034-af00-4c2a-92c5-68a9bd254420.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3162351780 1 tcp 1518214911 75f9644e-561c-45cd-8a6b-c1e8360a5fec.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3162351780 1 tcp 1518214911 75f9644e-561c-45cd-8a6b-c1e8360a5fec.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3678149385 1 tcp 1518283007 4e08e674-2076-4f5d-8523-d6be30658f5c.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3678149385 1 tcp 1518283007 f1e294b4-d569-4dd6-912e-d8971019acc5.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3162351780 1 tcp 1518214911 75f9644e-561c-45cd-8a6b-c1e8360a5fec.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 1 network-cost 50
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=candidate:3678149385 1 tcp 1518283007 314a6661-3bb3-4f5e-8fd7-8f42037ea2f8.local 9 typ host tcptype active generation 0 ufrag Wd8y network-id 2 network-cost 50
29/2/2024, 11:28:50 pm  trace   [api.ws] msg type=webrtc/candidate
29/2/2024, 11:28:50 pm  trace   [webrtc] remote candidate=
29/2/2024, 11:28:55 pm  trace   [streams] skip prod=ffmpeg:rtsp://192.168.86.109:8554/frontPorch/main#video=h264#rotate=180#video=h264#hardware=vaapi error=exec: exit status 1
29/2/2024, 11:28:55 pm  trace   [streams] check cons=0 media=audio, sendonly, OPUS/48000/2, RED/48000/2, G722/8000, PCMU/8000, PCMA/8000, CN/8000, TELEPHONE-EVENT/48000, TELEPHONE-EVENT/8000, L16, PCML
29/2/2024, 11:28:55 pm  debug   [exec] run url=exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -allowed_media_types video -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://192.168.86.109:8554/frontPorch/main -map 0:v:0? -c:v:0 h264_vaapi -g 50 -bf 0 -profile:v:0 high -level:v:0 4.1 -sei:v:0 0 -map 0:v:0? -c:v:1 h264_vaapi -g 50 -bf 0 -profile:v:1 high -level:v:1 4.1 -sei:v:1 0 -an -vf "format=vaapi|nv12,hwupload,format=vaapi|nv12,hwupload,transpose_vaapi=4,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12" -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}
29/2/2024, 11:29:00 pm  trace   [streams] skip prod=ffmpeg:rtsp://192.168.86.109:8554/frontPorch/main#video=h264#rotate=180#video=h264#hardware=vaapi error=exec: exit status 1
29/2/2024, 11:29:00 pm  debug   [webrtc] add consumer error=streams: exec: exit status 1
29/2/2024, 11:29:00 pm  debug   [exec] run url=exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -allowed_media_types video -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://192.168.86.109:8554/frontPorch/main -map 0:v:0? -c:v:0 h264_vaapi -g 50 -bf 0 -profile:v:0 high -level:v:0 4.1 -sei:v:0 0 -map 0:v:0? -c:v:1 h264_vaapi -g 50 -bf 0 -profile:v:1 high -level:v:1 4.1 -sei:v:1 0 -an -vf "format=vaapi|nv12,hwupload,format=vaapi|nv12,hwupload,transpose_vaapi=4,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12" -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}
29/2/2024, 11:29:04 pm  debug   [streams] can't stop none producer
29/2/2024, 11:29:04 pm  trace   [streams] skip prod=ffmpeg:rtsp://192.168.86.109:8554/frontPorch/main#video=h264#rotate=180#video=h264#hardware=vaapi error=exec: exit status 1
29/2/2024, 11:29:04 pm  trace   [streams] check cons=1 media=audio, sendonly, MPEG4-GENERIC
29/2/2024, 11:29:04 pm  debug   [exec] run url=exec:ffmpeg -hide_banner -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -hwaccel vaapi -hwaccel_output_format vaapi -hwaccel_flags allow_profile_mismatch -allowed_media_types video -fflags nobuffer -flags low_delay -timeout 5000000 -user_agent go2rtc/ffmpeg -rtsp_flags prefer_tcp -i rtsp://192.168.86.109:8554/frontPorch/main -map 0:v:0? -c:v:0 h264_vaapi -g 50 -bf 0 -profile:v:0 high -level:v:0 4.1 -sei:v:0 0 -map 0:v:0? -c:v:1 h264_vaapi -g 50 -bf 0 -profile:v:1 high -level:v:1 4.1 -sei:v:1 0 -an -vf "format=vaapi|nv12,hwupload,format=vaapi|nv12,hwupload,transpose_vaapi=4,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12,scale_vaapi=out_color_matrix=bt709:out_range=tv:format=nv12" -user_agent ffmpeg/go2rtc -rtsp_transport tcp -f rtsp {output}
29/2/2024, 11:29:05 pm  trace   undefined error=websocket: close 1001 (going away): WebSocket is closed due to suspension. caller=github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:120
29/2/2024, 11:29:09 pm  trace   [streams] skip prod=ffmpeg:rtsp://192.168.86.109:8554/frontPorch/main#video=h264#rotate=180#video=h264#hardware=vaapi error=exec: exit status 1
29/2/2024, 11:29:09 pm  debug   [streams] can't stop none producer

Thanks for any help, even getting some better logging on why it's exiting would be a win. I don't really understand "can't stop none producer" and why it's limited to when I'm using go2rtc vs running the ffmpeg command directly.

Thanks

AlexxIT commented 6 months ago

Hi. Logs for exec trace should show reason, why ffmpeg fail. I can see it in your config. But I can't see it in your logs

sredfern commented 6 months ago

Do you mean can’t? I’ll have a go at reinstalling the lxc container. I used an image from the internet. I’ll hand roll the next one.

AlexxIT commented 6 months ago

Yes. I can't see ffmpeg raw logs in the go2rtc logs. They shown only via exec: trace

sredfern commented 6 months ago

Looks like it's a driver issue.

Following commands from here

apt-get install -y gpg-agent wget
wget -qO - https://repositories.intel.com/graphics/intel-graphics.key | apt-key add -
echo "deb [arch=$( dpkg --print-architecture )] https://repositories.intel.com/graphics/ubuntu focal main" | sudo tee /etc/apt/sources.list.d/intelgraphics.list
sudo apt-get update
sudo apt-get install \
intel-opencl-icd \
intel-level-zero-gpu level-zero \
intel-media-va-driver-non-free libmfx1
root@go2rtc:~# vainfo
error: can't connect to X server!
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_15
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.5.0 (7e9cc59)
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Simple            : VAEntrypointEncSlice
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointFEI
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointFEI
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline: VAEntrypointFEI
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointFEI

No problems with go2rtc! Thanks for the amazing support in helping me track this down. Hope this issue is useful for someone else in the future.

Still no idea why trace didn't work.