m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.96k stars 449 forks source link

New error while trying to RTMP stream. #276

Closed evilalmus closed 1 year ago

evilalmus commented 1 year ago

Thank you for getting the fix in for #274 so quickly. I am no longer getting that error. Now that I am past that I am seeing two new issues.

The first time I try to start a stream I get this error: 2023-04-03 15:35:34,436 DEBG 'neko' stdout output: 0:05:37.063166498 19 0x14ddd4002b60 ERROR rtmp :0:: RTMP URL: No :// in URL! This is not a big deal, I can just change my stream key.

One that fails, if I try to start the stream again, instead of the above I get this error: 2023-04-03 15:36:48,798 DEBG 'neko' stdout output: 0:06:51.412981893 19 0x14ddc4004300 ERROR rtmp :0:: RTMP_ReadPacket, failed to read RTMP packet header I know the target is working as I can stream to it from OBS on this same network, If there is something else I am missing or doing wrong, I am unable to figure out what it is.

m1k1o commented 1 year ago

Didn't see this error before. But No :// in URL!looks quite specific. I assume your target starts with rtmp://. Maybe OBS is flexible enough to automatically add that if you didn't provide it.

You could use m1k1o/neko:latest so non-GPU image if that works. So that we can see if that problem with this image or generally gstreamer issue.

evilalmus commented 1 year ago

The url I am putting in does include rtmp:// the full URL for my target is: rtmp://live.g33k.bar/live/ I only get that error on the first attempt after a reboot. On following attempts I get the other error. Here is the full copy/paste of the log when I try again:

2023-04-04 14:31:26,493 DEBG 'neko' stdout output:
2:31PM INF starting pipeline module=capture src="flvmux name=mux ! rtmpsink location='rtmp://live.g33k.bar/live/<stream key removed> live=1' pulsesrc device=audio_output.monitor ! audio/x-raw,channels=2 ! audioconvert !  audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux." submodule=broadcast url=rtmp://live.g33k.bar/live/<stream key removed>

2023-04-04 14:31:26,495 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] client.c: Created 4 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.

2023-04-04 14:31:26,496 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] source-output.c: Trying to change sample spec
I: [pulseaudio] source.c: Cannot update sample spec, SOURCE_IS_RUNNING, will keep using s16le and 48000 Hz
I: [pulseaudio] speex.c: Choosing speex quality setting 1.

2023-04-04 14:31:26,496 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] source-output.c: Created output 4 "Record Stream" on audio_output.monitor with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] source-output.c:     media.name = "Record Stream"
I: [pulseaudio] source-output.c:     application.name = "neko"
I: [pulseaudio] source-output.c:     native-protocol.peer = "UNIX socket client"
I: [pulseaudio] source-output.c:     native-protocol.version = "33"
I: [pulseaudio] source-output.c:     application.process.id = "19"
I: [pulseaudio] source-output.c:     application.process.user = "neko"
I: [pulseaudio] source-output.c:     application.process.host = "3e9150099656"
I: [pulseaudio] source-output.c:     application.process.binary = "neko"
I: [pulseaudio] source-output.c:     application.language = "C"
I: [pulseaudio] source-output.c:     window.x11.display = ":99.0"
I: [pulseaudio] source-output.c:     application.process.machine_id = "ebe1faa4718c31b5bc0f21b7642b1712"
I: [pulseaudio] protocol-native.c: Final latency 20.00 ms = 10.00 ms + 10.00 ms

2023-04-04 14:31:26,771 DEBG 'neko' stdout output:
15:47:24.238690503    19 0x14ca58280760 ERROR                   rtmp :0:: RTMP_ReadPacket, failed to read RTMP packet header
evilalmus commented 1 year ago

I'll try the non gpu version now and let you know.

evilalmus commented 1 year ago

Rebuilt with m1k1o/neko:latest Now, the first time I try to start the stream I don't get any error I just get this:

2023-04-04 14:40:10,019 DEBG 'neko' stdout output:
2:40PM INF starting pipeline module=capture src="flvmux name=mux ! rtmpsink location=' live=1' pulsesrc device=audio_output.monitor ! audio/x-raw,channels=2 ! audioconvert !  audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux." submodule=broadcast url=

2023-04-04 14:40:13,140 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] client.c: Created 1 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.

Then, if I get the stop button and try again I get:

2023-04-04 14:40:36,202 DEBG 'neko' stdout output:
2:40PM INF starting pipeline module=capture src="flvmux name=mux ! rtmpsink location='rtmp://live.g33k.bar/live/<stream key removed> live=1' pulsesrc device=audio_output.monitor ! audio/x-raw,channels=2 ! audioconvert !  audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux." submodule=broadcast url=rtmp://live.g33k.bar/live/<stream key removed>

2023-04-04 14:40:36,205 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] client.c: Created 2 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.

2023-04-04 14:40:36,206 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] source-output.c: Trying to change sample spec
I: [pulseaudio] source.c: Cannot update sample spec, SOURCE_IS_RUNNING, will keep using s16le and 48000 Hz

2023-04-04 14:40:36,206 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] speex.c: Choosing speex quality setting 1.
I: [pulseaudio] source-output.c: Created output 1 "Record Stream" on audio_output.monitor with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] source-output.c:     media.name = "Record Stream"
I: [pulseaudio] source-output.c:     application.name = "neko"
I: [pulseaudio] source-output.c:     native-protocol.peer = "UNIX socket client"
I: [pulseaudio] source-output.c:     native-protocol.version = "34"
I: [pulseaudio] source-output.c:     application.process.id = "12"
I: [pulseaudio] source-output.c:     application.process.user = "neko"
I: [pulseaudio] source-output.c:     application.process.host = "3d30cd4f5ec3"
I: [pulseaudio] source-output.c:     application.process.binary = "neko"
I: [pulseaudio] source-output.c:     application.language = "C"
I: [pulseaudio] source-output.c:     window.x11.display = ":99.0"
I: [pulseaudio] source-output.c:     application.process.machine_id = "83ada6ed3b045cc3ba943d55642b16b1"
I: [pulseaudio] protocol-native.c: Final latency 20.00 ms = 10.00 ms + 10.00 ms

However, the stream does not start on the target. I did try again and specified the port number in the URL (just in case, even though I am using the default) so that it looks like this: rtmp://live.g33k.bar:1935/live/<stream key removed> and I get the same result.

m1k1o commented 1 year ago

You can enable gstreamer debug by adding env GST_DEBUG=*:3 to see more relevant information.

evilalmus commented 1 year ago

Tried that. Now, on the first attempt after the reboot I get this:

2023-04-04 14:52:43,733 DEBG 'neko' stdout output:
2:52PM INF starting pipeline module=capture src="flvmux name=mux ! rtmpsink location=' live=1' pulsesrc device=audio_output.monitor ! audio/x-raw,channels=2 ! audioconvert !  audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux." submodule=broadcast url=

2023-04-04 14:52:43,977 DEBG 'neko' stdout output:
0:01:14.897057525    12 0x14ebe0005a90 ERROR                   rtmp :0:: RTMP URL: No :// in url!
0:01:14.897072735    12 0x14ebe0005a90 WARN                rtmpsink gstrtmpsink.c:356:gst_rtmp_sink_uri_set_uri:<rtmpsink0> error: Failed to parse URI ' live=1'

2023-04-04 14:52:44,362 DEBG 'neko' stdout output:
0:01:15.281716225    12 0x14ebe0005a90 WARN                rtmpsink gstrtmpsink.c:159:gst_rtmp_sink_start:<rtmpsink0> error: Please set URI for RTMP output
0:01:15.281730435    12 0x14ebe0005a90 WARN                rtmpsink gstrtmpsink.c:159:gst_rtmp_sink_start:<rtmpsink0> error: No URI set before starting
0:01:15.281743496    12 0x14ebe0005a90 WARN                basesink gstbasesink.c:5865:gst_base_sink_change_state:<rtmpsink0> error: Failed to start

2023-04-04 14:52:44,370 DEBG 'neko' stdout output:
0:01:15.290112460    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:838:gst_audio_base_src_create:<pulsesrc0> create DISCONT of 31200 samples at sample 2189760
0:01:15.290126141    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:841:gst_audio_base_src_create:<pulsesrc0> warning: Can't record audio fast enough
0:01:15.290129471    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:841:gst_audio_base_src_create:<pulsesrc0> warning: Dropped 31200 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

I hit stop and try again and get this:

2023-04-04 14:53:40,105 DEBG 'neko' stdout output:
2:53PM INF starting pipeline module=capture src="flvmux name=mux ! rtmpsink location='rtmp://live.g33k.bar/live/<stream key removed> live=1' pulsesrc device=audio_output.monitor ! audio/x-raw,channels=2 ! audioconvert !  audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux." submodule=broadcast url=rtmp://live.g33k.bar/live/<stream key removed>

2023-04-04 14:53:40,467 DEBG 'neko' stdout output:
0:02:11.387394511    12 0x14ebe003ced0 WARN                    rtmp :0:: Unknown protocol!

2023-04-04 14:53:41,372 DEBG 'neko' stdout output:
0:02:12.292493981    12 0x14ebe003ced0 WARN                    rtmp :0:: Unknown protocol!

2023-04-04 14:53:41,451 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] client.c: Created 2 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.

2023-04-04 14:53:41,452 DEBG 'neko' stdout output:
0:02:12.371852628    12 0x14ec040061e0 WARN              aggregator gstaggregator.c:2046:gst_aggregator_query_latency_unlocked:<mux> Latency query failed

2023-04-04 14:53:41,591 DEBG 'neko' stdout output:
0:02:12.493640054    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:838:gst_audio_base_src_create:<pulsesrc0> create DISCONT of 60000 samples at sample 4924320
0:02:12.493655355    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:841:gst_audio_base_src_create:<pulsesrc0> warning: Can't record audio fast enough
0:02:12.493658535    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:841:gst_audio_base_src_create:<pulsesrc0> warning: Dropped 60000 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

2023-04-04 14:53:41,591 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] source-output.c: Trying to change sample spec
I: [pulseaudio] source.c: Cannot update sample spec, SOURCE_IS_RUNNING, will keep using s16le and 48000 Hz

2023-04-04 14:53:41,591 DEBG 'neko' stdout output:
0:02:12.500057854    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:838:gst_audio_base_src_create:<pulsesrc0> create DISCONT of 11040 samples at sample 4935840
0:02:12.500066145    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:841:gst_audio_base_src_create:<pulsesrc0> warning: Can't record audio fast enough
0:02:12.500069295    12 0x14ec40010c60 WARN            audiobasesrc gstaudiobasesrc.c:841:gst_audio_base_src_create:<pulsesrc0> warning: Dropped 11040 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.
0:02:12.502074841    12 0x14ec04006300 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<pulsesrc2:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:02:12.502074651    12 0x14ec040062a0 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<ximagesrc2:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:02:12.502108232    12 0x14ec040061e0 WARN              aggregator gstaggregator.c:2046:gst_aggregator_query_latency_unlocked:<mux> Latency query failed
0:02:12.502140183    12 0x14ec040061e0 WARN              aggregator gstaggregator.c:2046:gst_aggregator_query_latency_unlocked:<mux> Latency query failed

2023-04-04 14:53:42,020 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] speex.c: Choosing speex quality setting 1.
I: [pulseaudio] source-output.c: Created output 1 "Record Stream" on audio_output.monitor with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] source-output.c:     media.name = "Record Stream"
I: [pulseaudio] source-output.c:     application.name = "neko"
I: [pulseaudio] source-output.c:     native-protocol.peer = "UNIX socket client"
I: [pulseaudio] source-output.c:     native-protocol.version = "34"
I: [pulseaudio] source-output.c:     application.process.id = "12"
I: [pulseaudio] source-output.c:     application.process.user = "neko"
I: [pulseaudio] source-output.c:     application.process.host = "b40ca5fd4860"
I: [pulseaudio] source-output.c:     application.process.binary = "neko"
I: [pulseaudio] source-output.c:     application.language = "C"
I: [pulseaudio] source-output.c:     window.x11.display = ":99.0"
I: [pulseaudio] source-output.c:     application.process.machine_id = "83ada6ed3b045cc3ba943d55642b16b1"

2023-04-04 14:53:42,020 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] protocol-native.c: Final latency 20.00 ms = 10.00 ms + 10.00 ms

2023-04-04 14:53:42,060 DEBG 'neko' stdout output:
0:02:12.980298067    12 0x14ec040061e0 FIXME               basesink gstbasesink.c:3384:gst_base_sink_default_event:<rtmpsink1> stream-start event without group-id. Consider implementing group-id handling in the upstream elements
0:02:12.980330188    12 0x14ec040061e0 WARN                  flvmux gstflvmux.c:1549:gst_flv_mux_write_header:<mux> downstream did not handle seeking query
0:02:12.980335538    12 0x14ec040061e0 WARN                  flvmux gstflvmux.c:1555:gst_flv_mux_write_header:<mux> downstream is not seekable, but streamable=false. Will ignore that and create streamable output instead

2023-04-04 14:53:43,207 DEBG 'neko' stdout output:
0:02:14.126807680    12 0x14ec040061e0 ERROR                   rtmp :0:: RTMP_ReadPacket, failed to read RTMP packet header
0:02:14.126840011    12 0x14ec040061e0 WARN                rtmpsink gstrtmpsink.c:293:gst_rtmp_sink_render:<rtmpsink1> error: Could not connect to RTMP stream "'rtmp://live.g33k.bar/live/<stream key removed> live=1'" for writing

2023-04-04 14:53:43,207 DEBG 'neko' stdout output:
0:02:14.126868502    12 0x14ec040061e0 FIXME             aggregator gstaggregator.c:1365:gst_aggregator_aggregate_func:<mux> Subclass should call gst_aggregator_selected_samples() from its aggregate implementation.
0:02:14.126945174    12 0x14ec04006300 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<pulsesrc2> error: Internal data stream error.
0:02:14.126947844    12 0x14ec040062a0 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<ximagesrc2> error: Internal data stream error.
0:02:14.126952514    12 0x14ec04006300 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<pulsesrc2> error: streaming stopped, reason error (-5)
0:02:14.126955425    12 0x14ec040062a0 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<ximagesrc2> error: streaming stopped, reason error (-5)
0:02:14.126991436    12 0x14ec040062a0 WARN                   queue gstqueue.c:990:gst_queue_handle_sink_event:<queue2> error: Internal data stream error.
0:02:14.126996536    12 0x14ec040062a0 WARN                   queue gstqueue.c:990:gst_queue_handle_sink_event:<queue2> error: streaming stopped, reason error (-5)
m1k1o commented 1 year ago

Looks interestingerror: Failed to parse URI ' live=1'. Though it should work on non-gpu version. If not, then its probably gstreamer error. Could you also start non-GPU with those logs to see why that one is not working?

evilalmus commented 1 year ago

That was the non-GPU version. I haven't switched back to the GPU image yet. The logs from https://github.com/m1k1o/neko/issues/276#issuecomment-1496654001 are using m1k1o/neko:latest

m1k1o commented 1 year ago

That's even more strange! I thought they were from GPU because rtmp :0:: RTMP URL: No :// in url! was not in https://github.com/m1k1o/neko/issues/276#issuecomment-1496644589 so even default log level must be different between those gstreamer versions.

In that case it does not seem that there is anything different in GPU image after all. And there was no change in broadcast pipeline for months, and it did work before. So most likely some new gstreamer version and something changed there.

I'll try to replicate it tomorrow and try to find, what might cause that. Since RTMP is a proprietary network protocol, maybe it was intentionally removed from packages in meanwhile, but I haven't found any sources for gstreamer regarding this.

evilalmus commented 1 year ago

Looking back over the logs and just making a stab in the dark: Could not connect to RTMP stream "'rtmp://live.g33k.bar/live/<stream key removed> live=1'" for writing could the extra quotes in there be an issue? Should it be "rtmp://live.g33k.bar/live/ live=1"

m1k1o commented 1 year ago

There is similar issue with rtsp-simple-server. Maybe your ingest source uses that? https://github.com/m1k1o/neko/issues/205

EDIT: Looks like it's fixed in v0.21.2: https://github.com/aler9/mediamtx/issues/1177

evilalmus commented 1 year ago

Yeah, more information. Just to test I setup a restream.io account and I am able to stream there: here is the log:

2023-04-05 14:36:04,724 DEBG 'neko' stdout output:
2:36PM INF starting pipeline module=capture src="flvmux name=mux ! rtmpsink location='rtmp://seattle.restream.io/live/re_2058945_35dbe1b5388b5e44130e live=1' pulsesrc device=audio_output.monitor ! audio/x-raw,channels=2 ! audioconvert !  audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux." submodule=broadcast url=rtmp://seattle.restream.io/live/re_2058945_35dbe1b5388b5e44130e

2023-04-05 14:36:04,724 DEBG 'neko' stdout output:
0:05:42.963088258    20 0x148824005860 WARN                    rtmp :0:: Unknown protocol!

2023-04-05 14:36:04,777 DEBG 'neko' stdout output:
0:05:43.015952405    20 0x148860066c70 WARN                    rtmp :0:: Unknown protocol!

2023-04-05 14:36:04,777 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] client.c: Created 4 "Native client (UNIX socket client)"
I: [pulseaudio] protocol-native.c: Client authenticated anonymously.

2023-04-05 14:36:04,778 DEBG 'neko' stdout output:
0:05:43.016901572    20 0x148824022920 WARN              aggregator gstaggregator.c:2104:gst_aggregator_query_latency_unlocked:<mux> Latency query failed

2023-04-05 14:36:04,778 DEBG 'neko' stdout output:
0:05:43.017002755    20 0x14884401b920 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<ximagesrc4:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id

2023-04-05 14:36:04,778 DEBG 'neko' stdout output:
0:05:43.017032556    20 0x148824000c00 FIXME                default gstutils.c:4025:gst_pad_create_stream_id_internal:<pulsesrc4:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:05:43.017065407    20 0x148824022920 WARN              aggregator gstaggregator.c:2104:gst_aggregator_query_latency_unlocked:<mux> Latency query failed

2023-04-05 14:36:04,778 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] source-output.c: Created output 4 "Record Stream" on audio_output.monitor with sample spec s16le 2ch 44100Hz and channel map front-left,front-right
I: [pulseaudio] source-output.c:     media.name = "Record Stream"
I: [pulseaudio] source-output.c:     application.name = "neko"
I: [pulseaudio] source-output.c:     native-protocol.peer = "UNIX socket client"
I: [pulseaudio] source-output.c:     native-protocol.version = "33"

2023-04-05 14:36:04,778 DEBG 'pulseaudio' stdout output:
I: [pulseaudio] source-output.c:     application.process.id = "20"
I: [pulseaudio] source-output.c:     application.process.user = "neko"
I: [pulseaudio] source-output.c:     application.process.host = "2e722240dc46"
I: [pulseaudio] source-output.c:     application.process.binary = "neko"
I: [pulseaudio] source-output.c:     application.language = "C"
I: [pulseaudio] source-output.c:     window.x11.display = ":99.0"
I: [pulseaudio] source-output.c:     application.process.machine_id = "ebe1faa4718c31b5bc0f21b7642b1712"
I: [pulseaudio] protocol-native.c: Final latency 20.00 ms = 10.00 ms + 10.00 ms

2023-04-05 14:36:05,012 DEBG 'neko' stdout output:
0:05:43.250312198    20 0x148824022920 WARN                  flvmux gstflvmux.c:1549:gst_flv_mux_write_header:<mux> downstream did not handle seeking query
0:05:43.250339478    20 0x148824022920 WARN                  flvmux gstflvmux.c:1555:gst_flv_mux_write_header:<mux> downstream is not seekable, but streamable=false. Will ignore that and create streamable output instead
0:05:43.250413001    20 0x148824022920 FIXME               basesink gstbasesink.c:3395:gst_base_sink_default_event:<rtmpsink3> stream-start event without group-id. Consider implementing group-id handling in the upstream elements

2023-04-05 14:36:07,713 DEBG 'neko' stdout output:
0:05:45.952148621    20 0x148824022920 FIXME             aggregator gstaggregator.c:1412:gst_aggregator_aggregate_func:<mux> Subclass should call gst_aggregator_selected_samples() from its aggregate implementation.

2023-04-05 14:36:07,720 DEBG 'neko' stdout output:
0:05:45.958433688    20 0x148824000c00 WARN            audiobasesrc gstaudiobasesrc.c:844:gst_audio_base_src_create:<pulsesrc4> create DISCONT of 125244 samples at sample 129654
0:05:45.958450409    20 0x148824000c00 WARN            audiobasesrc gstaudiobasesrc.c:847:gst_audio_base_src_create:<pulsesrc4> warning: Can't record audio fast enough
0:05:45.958453309    20 0x148824000c00 WARN            audiobasesrc gstaudiobasesrc.c:847:gst_audio_base_src_create:<pulsesrc4> warning: Dropped 125244 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

2023-04-05 14:36:07,743 DEBG 'neko' stdout output:
0:05:45.982283949    20 0x148824022920 WARN                  flvmux gstflvmux.c:1247:gst_flv_mux_buffer_to_tag_internal:<mux:sink_0> Got backwards dts! (0:00:00.092000000 < 0:00:02.933000000)

That last warning about Got backwards dts! repeats over and over in the log, also in restream.io I get a warning to "check your keyframe interval" with a recommendation to set it to "2".

While I was typing this I saw your note about rtsp-simple-server. The ingester I am using is owncast (https://owncast.online/) I'll have to do some digging to see what it is using.

m1k1o commented 1 year ago

This then is entirely issue with Gstreamer or pipeline.

You can take whole broadcast pipeline and add it as env NEKO_BROADCAST_PIPELINE to neko. This is the default one:

-e "NEKO_BROADCAST_PIPELINE=flvmux name=mux ! rtmpsink location='{url} live=1'
  pulsesrc device={device}
    ! audio/x-raw,channels=2
    ! audioconvert
    ! voaacenc
    ! mux.
  ximagesrc display-name={display} show-pointer=true use-damage=false
    ! video/x-raw,framerate=25/1
    ! videoconvert
    ! queue
    ! x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast
    ! mux."

You can change and find the best for you, gstreamer has quite good docs. Try it with/without quotes and modify encoding parameters. If you could find better pipeline, you could create PR. Additionally, also broadcast could be GPU encoded, that is currently not the case.

Got backwards dts!

There is some discussion about that: https://gstreamer-devel.narkive.com/9bTl7L8g/dts-going-backward-at-some-conditions

I get a warning to "check your keyframe interval" with a recommendation to set it to "2".

As you can see now, key-int-max is set to 60 meaning every 60 frames keyframe is set. Setting it to 2 would drastically increase bitrate.

P.S.: {display} is always :99.0 in default conf, and {device} is audio_output.monitor. You could set -e "NEKO_BROADCAST_PIPELINE={url}" and put your full, resolved gstreamer pipeline to URL input and it will be started. That means you don't need to restart neko when testing pipelines.

evilalmus commented 1 year ago

That did it. Changing the NEKO_BROADCAST_PIPELINE = flvmux name=mux ! rtmpsink location={url} pulsesrc device={device} ! audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name={display} show-pointer=false use-damage=false ! video/x-raw,framerate=28/1 ! videoconvert ! queue ! x264enc bframes=0 key-int-max=0 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux. got it working for me with owncast. I see what you mean that the broadcast in not GPU encoded, it does use a lot of CPU to do that. Next I'll be trying to figure out how to get GPU encoding working for the broadcast.

Thank you for the help. You can close this out, and hopefully, that pipeline above will help out anyone else that's having this same problem.

evilalmus commented 1 year ago

Update: this works for using nvenc: flvmux name=mux ! rtmpsink location={url} pulsesrc device={device} ! audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. ximagesrc display-name={display} show-pointer=false use-damage=false ! video/x-raw,framerate=30/1 ! videoconvert ! queue ! video/x-raw,format=NV12 ! nvh264enc name=encoder preset=low-latency-hq gop-size=25 spatial-aq=true temporal-aq=true bitrate=2800 vbv-buffer-size=2800 rc-mode=6 ! h264parse config-interval=-1 ! video/x-h264,stream-format=byte-stream,profile=high ! h264parse ! mux.

Although, nvidia-smi is showing no processes, so I'm not 100% sure it is working correctly. nvida-smi isn't even showing the process for the main display, so I'm not sure that means anything.

m1k1o commented 1 year ago

I doubt it would work with nvh264enc if GPU was not available. It would probably fail.