OpenIPC / majestic

Majestic Community edition integration kit
MIT License
37 stars 5 forks source link

Majestic RTMP push does not work with MediaMTX, OvenMediaEngine and SRS #189

Open iGraveD opened 2 months ago

iGraveD commented 2 months ago

Required information

Issue description

Like libnginx-mod-rtmp, which I reported earlier, these media servers (MediaMTX, OvenMediaEngine and SRS) don't work with Majestic as a video source over RTMP protocol. While, for example, they perfectly work with FFmpeg.

Expectations

I expected that Majestic is compatible with majority of media server programs.

Steps to reproduce

With MediaMTX: 1) Download it from its release page, unpack and run. 2) Push a stream from OpenIPC / Majestic / Settings / Output to rtmp://[MediaMTX]/mystream. 3) Open http://[MediaMTX]:8889/mystream with your browser. 4) The video in the browser does not play. 5) Close streaming from OpenIPC / Majestic / Settings / Output. 6) Stream a movie with FFmpeg, like this:

ffmpeg -re -i ./video.avi -c:v libx264 -c:a aac -bf 0 -f flv rtmp:/[MediaMTX]/mystream

7) The video in the browser , which you opened earlier, starts playing.

With the same settings, RTMP stream from OpenIPC / Majestic perfectly works with YouTube.

Information to attach

video0:
  enabled: true
  codec: h264
  fps: 20
  bitrate: 4096
  rcMode: vbr
  gopSize: 1.0
  gopMode: normal
  profile: base
  size: 1920x1080
skilurius commented 1 month ago

Please test the following build: t31.lite.tar

MalgathThelamin commented 1 month ago

Majestic: master+91ad576, 2024-09-17

skilurius commented 1 month ago
MalgathThelamin commented 1 month ago
MalgathThelamin commented 1 month ago

SRS

When video does not play, it looks like this in the log file:

[2024-09-18 17:52:04.004][INFO][4671][4v5653rw] HTTP #0 192.168.1.205:55576 GET http://192.168.0.2:8080/myapp/mystream.m3u8, content-length=-1
[2024-09-18 17:52:04.004][WARN][4671][4v5653rw][2] http miss file=./objs/nginx/html/myapp/mystream.m3u8, pattern=/, upath=/myapp/mystream.m3u8

The ./objs/nginx/html/myapp/ folder contains only one file: mystream-0.ts.tmp.

When I push the video with ffmpeg, mystream.m3u8 file appears in the folder first, then mystream-#.ts files start to appear.

skilurius commented 1 month ago

I tested the following scenario:

docker run --rm -it -p 1935:1935 -p 8080:8080 ossrs/srs:6 objs/srs -c conf/docker.conf
docker run --rm -it -p 1935:1935 airensoft/ovenmediaengine:latest

cli -s .outgoing.server rtmp://192.168.1.85/app/live
ffprobe rtmp://192.168.1.85/app/live

SRS seems to work fine, but OvenMediaEngine requires more debugging.

I'm sorry, I don't understand. You mean, that Majestic doesn't send this metadata, it is by design and you are not planning to implement it?

This might follow at a later time, currently the most important part is to have overall compatibility with the listed applications.

Isn't Drop ts segment, sequence_no=0, uri=mystream-0.ts, duration=2147456875ms in the log file an error?

Indeed, this should be addressed on the next build

MalgathThelamin commented 1 month ago

Sorry, I am not familiar with Docker. I have compiled the latest version of SRS now from source according to the manual.

git clone -b develop https://github.com/ossrs/srs.git
cd srs/trunk
./configure
make
./objs/srs -c conf/srs.conf

Can you test this scenario, please?

srs.log

ffprobe shows the following output:

ffprobe rtmp://192.168.0.2/myapp/mystream

ffprobe version 5.1.6-0+deb12u1+rpt1 Copyright (c) 2007-2024 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --prefix=/usr --extra-version=0+deb12u1+rpt1 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --disable-mmal --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sand --enable-sdl2 --disable-sndio --enable-libjxl --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
[flv @ 0x5573a8ceb0] Video codec (0) is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[flv @ 0x5573a8ceb0] If you want to help, upload a sample of this file to https://streams.videolan.org/upload/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)
[flv @ 0x5573a8ceb0] Changing the codec id midstream is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[flv @ 0x5573a8ceb0] If you want to help, upload a sample of this file to https://streams.videolan.org/upload/ and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)
[flv @ 0x5573a8ceb0] Could not find codec parameters for stream 1 (Video: flashsv, bgr24): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options
Input #0, flv, from 'rtmp://localhost/myapp/mystream':
  Metadata:
    |RtmpSampleAccess: true
  Duration: N/A, start: 0.019000, bitrate: 128 kb/s
  Stream #0:0: Audio: aac, 44100 Hz, mono, fltp, 128 kb/s
  Stream #0:1: Video: flashsv, bgr24, 1k tbr, 1k tbn
skilurius commented 1 month ago

[flv @ 0x5573a8ceb0] Video codec (0) is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.

You need to update ffmpeg (to support H265) or use H264 instead.

Do you have a reference for OvenMediaEngine? I tested the following, which is working on SRS:

wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
ffmpeg -re -i BigBuckBunny.mp4 -c copy -f flv rtmp://192.168.1.85/app/live
ffprobe rtmp://192.168.1.85/app/live
MalgathThelamin commented 1 month ago

You need to update ffmpeg (to support H265) or use H264 instead.

Oh, my mistake. I completely forgot, that 2 days ago I noticed, that YouTube started accepting H265 stream from T31X (wasn't accepting a month ago), and forgot to switch back.

After switching Majestic back to H264:

srs.log

If I push a video with ffmpeg, HLS files are being created normally.

Do you have a reference for OvenMediaEngine?

Rephrase your question, please.

MalgathThelamin commented 1 month ago

I also noticed, that from time to time, the stream disappears

MalgathThelamin commented 1 month ago

I also noticed, that Majestic on ssc378de streams perfectly to all applications, including SRS (HLS at http://192.168.0.2:8080/myapp/mystream.m3u8) and OvenMediaEngine.

skilurius commented 1 month ago

Rephrase your question, please.

I mean if you have a working reference test to verify the initial function, for example:

docker run --rm -it -p 1935:1935 airensoft/ovenmediaengine:latest
wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
ffmpeg -re -i BigBuckBunny.mp4 -c copy -f flv rtmp://192.168.1.85/app/live
ffprobe rtmp://192.168.1.85/app/live

I also noticed, that Majestic on ssc378de streams perfectly to all applications, including SRS

Interesting, that could indicate a problem or incompatibility on the (ingenic) sdk. I will try to verify this later.

MalgathThelamin commented 1 month ago

I test OvenMediaEngine like this. My installation method is partially based on its documentation, but uses the latest source and does not install the program.

git clone https://github.com/AirenSoft/OvenMediaEngine
cd OvenMediaEngine/src
../misc/prerequisites.sh
make release
cd bin/RELEASE
mkdir conf
cp ../../../misc/conf_examples/Server.xml conf
./OvenMediaEngine

Publishing a video file:

wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
ffmpeg -re -i BigBuckBunny.mp4 -c copy -f flv rtmp://192.168.0.2/app/live
ffprobe http://192.168.0.2:3333/app/live/llhls.m3u8

The output shows a correct stream information. The video is playable at http://192.168.0.2:3333/app/live/llhls.m3u8.

Publishing a H264/AAC stream from ssc378de to rtmp://192.168.0.2/app/live. The ffprobe output is correct. The video is playable.

Publishing a H264/AAC stream from t31x to rtmp://192.168.0.2/app/live. ffprobe does not finish. The last line it outputs is:

[http @ 0x5586d02040] Opening 'http://192.168.0.2:3333/app/live/seg_1_236_audio_LY3jRMta_llhls.m4s?session=31_WR2Hxv8P' for reading

The video is not playable. ovenmediaengine.log is full of errors:

[2024-09-21 07:40:52.968] E [AW-LLHLS0:61186] FMP4 Packager | fmp4_storage.cpp:347  | LLHLS stream (#default#app/live) / track (0) - the duration of the segment being created exceeded twice the target segment duration (2147483682.0 ms | expected: 6000) because there were no IDR frames for a long time. This segment is forcibly created and may not play normally.
[2024-09-21 07:40:52.998] I [SPRTMP-t1935:61180] RTMPProvider | rtmp_chunk_parser.cpp:572  | Timestamp is rolled for stream id: 1: last TS: 15176267091929, parsed: 151733, new: 15178414575797
[2024-09-21 07:40:52.998] W [Decaac:61261] Transcoder | transcoder_filter.cpp:129  | Timestamp has changed abnormally.  15165529673569 -> 15176267091929