FFmpeg multiplexer RTMP

hknmtt

FFmpeg multiplexer RTMP
« kdy: 23. 01. 2023, 00:11:06 »
Skusam rozbehat na localhoste ffmpeg tak aby som don streamoval video z OBS cez rtmp protokol a ten mi ho kovnertoval na hls stream. Nasiel som tento clanok https://www.martin-riedl.de/2018/08/24/using-ffmpeg-as-a-hls-streaming-server-part-1/

z coho mam

Kód: [Vybrat]
ffmpeg -listen 1 -i rtmp://127.0.0.1 -c:v libx264 -crf 21 -preset veryfast -c:a aac -b:a 128k -ac 2 -f hls -hls_time 4 -hls_playlist_type event stream.m3u8
Ale akosi to moc nefunguje. Ked spustim OBS stream tak to nic nerobi a po nejakom case to skape a vypluje mi to playlist s jednym kratkym videom ani neviem z ktoreho useku vysielania.

Toto mi to hodi do logu ale neviem z toho nic vycitat:

Kód: [Vybrat]
ffmpeg version 2022-03-03-git-72684d2c2d-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 11.2.0 (Rev7, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband
  libavutil      57. 22.100 / 57. 22.100
  libavcodec     59. 21.103 / 59. 21.103
  libavformat    59. 17.102 / 59. 17.102
  libavdevice    59.  5.100 / 59.  5.100
  libavfilter     8. 27.100 /  8. 27.100
  libswscale      6.  5.100 /  6.  5.100
  libswresample   4.  4.100 /  4.  4.100
  libpostproc    56.  4.100 / 56.  4.100
[rtmp @ 00000182856bef80] Unexpected stream , expecting 127.0.0.1
    Last message repeated 1 times
Input #0, flv, from 'rtmp://127.0.0.1':
  Metadata:
    fileSize        : 0
    audiochannels   : 2
    2.1             : false
    3.1             : false
    4.0             : false
    4.1             : false
    5.1             : false
    7.1             : false
    encoder         : obs-output module (libobs version 29.0.0)
  Duration: 00:00:00.00, start: 0.066000, bitrate: N/A
  Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 163 kb/s
  Stream #0:1: Video: h264 (High), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 2560 kb/s, 30 fps, 30 tbr, 1k tbn
[rtmp @ 0000018285df7100] Unexpected stream , expecting 127.0.0.1
    Last message repeated 1 times
Input #1, flv, from 'rtmp://127.0.0.1':
  Metadata:
    fileSize        : 0
    audiochannels   : 2
    2.1             : false
    3.1             : false
    4.0             : false
    4.1             : false
    5.1             : false
    7.1             : false
    encoder         : obs-output module (libobs version 29.0.0)
  Duration: 00:00:00.00, start: 0.066000, bitrate: N/A
  Stream #1:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 163 kb/s
  Stream #1:1: Video: h264 (High), yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 2560 kb/s, 30 fps, 30 tbr, 1k tbn
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
  Stream #0:1 -> #1:0 (h264 (native) -> h264 (libx264))
  Stream #0:0 -> #1:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000182861f3380] using SAR=1/1
[libx264 @ 00000182861f3380] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000182861f3380] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 00000182861f3380] 264 - core 164 r3094 bfc87b7 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=22 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=21.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, hls, to 'stream.m3u8ffmpeg':
  Metadata:
    fileSize        : 0
    audiochannels   : 2
    2.1             : false
    3.1             : false
    4.0             : false
    4.1             : false
    5.1             : false
    7.1             : false
    encoder         : Lavf59.17.102
  Stream #0:0: Video: h264, yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 90k tbn
    Metadata:
      encoder         : Lavc59.21.103 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc59.21.103 aac
[libx264 @ 0000018285f6ab80] using SAR=1/1
[libx264 @ 0000018285f6ab80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0000018285f6ab80] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0000018285f6ab80] 264 - core 164 r3094 bfc87b7 - H.264/MPEG-4 AVC codec - Copyleft 2003-2022 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=22 lookahead_threads=5 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=21.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #1, hls, to 'stream.m3u8':
  Metadata:
    fileSize        : 0
    audiochannels   : 2
    2.1             : false
    3.1             : false
    4.0             : false
    4.1             : false
    5.1             : false
    7.1             : false
    encoder         : Lavf59.17.102
  Stream #1:0: Video: h264, yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 30 fps, 90k tbn
    Metadata:
      encoder         : Lavc59.21.103 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  Stream #1:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc59.21.103 aac
rtmp://127.0.0.1: I/O error=0.0 size=N/A time=00:00:00.46 bitrate=N/A speed=11.5x
    Last message repeated 17 times
[hls @ 0000018285a5acc0] Opening 'stream0.ts' for writing
[hls @ 0000018285a5acc0] Opening 'stream.m3u8ffmpeg.tmp' for writing
[hls @ 0000018285b84440] Opening 'stream0.ts' for writing
[hls @ 0000018285b84440] Opening 'stream.m3u8.tmp' for writing
frame=   97 fps=0.0 q=-1.0 Lq=-1.0 size=N/A time=00:00:03.17 bitrate=N/A speed=5.96x
video:1023kB audio:100kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 00000182861f3380] frame I:1     Avg QP:16.88  size: 54256
[libx264 @ 00000182861f3380] frame P:25    Avg QP:19.81  size: 10358
[libx264 @ 00000182861f3380] frame B:71    Avg QP:22.75  size:  2958
[libx264 @ 00000182861f3380] consecutive B-frames:  1.0%  4.1%  0.0% 94.8%
[libx264 @ 00000182861f3380] mb I  I16..4: 37.4% 17.0% 45.6%
[libx264 @ 00000182861f3380] mb P  I16..4:  1.0%  7.2%  2.0%  P16..4: 15.5%  7.6%  4.2%  0.0%  0.0%    skip:62.4%
[libx264 @ 00000182861f3380] mb B  I16..4:  0.2%  1.6%  0.2%  B16..8:  9.7%  4.1%  0.5%  direct: 2.1%  skip:81.6%  L0:39.4% L1:46.6% BI:13.9%
[libx264 @ 00000182861f3380] 8x8 transform intra:62.5% inter:36.6%
[libx264 @ 00000182861f3380] coded y,uvDC,uvAC intra: 73.2% 56.4% 11.9% inter: 4.5% 3.4% 0.0%
[libx264 @ 00000182861f3380] i16 v,h,dc,p: 50% 19% 16% 15%
[libx264 @ 00000182861f3380] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 18% 11% 10%  5%  6%  5% 13%  8%
[libx264 @ 00000182861f3380] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 16% 12%  8%  8%  8%  6%  9%  5%
[libx264 @ 00000182861f3380] i8c dc,h,v,p: 45% 20% 21% 14%
[libx264 @ 00000182861f3380] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000182861f3380] kb/s:1294.62
[aac @ 0000018285d7b7c0] Qavg: 1365.021
[libx264 @ 0000018285f6ab80] frame I:1     Avg QP:16.88  size: 54256
[libx264 @ 0000018285f6ab80] frame P:25    Avg QP:19.81  size: 10358
[libx264 @ 0000018285f6ab80] frame B:71    Avg QP:22.75  size:  2958
[libx264 @ 0000018285f6ab80] consecutive B-frames:  1.0%  4.1%  0.0% 94.8%
[libx264 @ 0000018285f6ab80] mb I  I16..4: 37.4% 17.0% 45.6%
[libx264 @ 0000018285f6ab80] mb P  I16..4:  1.0%  7.2%  2.0%  P16..4: 15.5%  7.6%  4.2%  0.0%  0.0%    skip:62.4%
[libx264 @ 0000018285f6ab80] mb B  I16..4:  0.2%  1.6%  0.2%  B16..8:  9.7%  4.1%  0.5%  direct: 2.1%  skip:81.6%  L0:39.4% L1:46.6% BI:13.9%
[libx264 @ 0000018285f6ab80] 8x8 transform intra:62.5% inter:36.6%
[libx264 @ 0000018285f6ab80] coded y,uvDC,uvAC intra: 73.2% 56.4% 11.9% inter: 4.5% 3.4% 0.0%
[libx264 @ 0000018285f6ab80] i16 v,h,dc,p: 50% 19% 16% 15%
[libx264 @ 0000018285f6ab80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 18% 11% 10%  5%  6%  5% 13%  8%
[libx264 @ 0000018285f6ab80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 16% 12%  8%  8%  8%  6%  9%  5%
[libx264 @ 0000018285f6ab80] i8c dc,h,v,p: 45% 20% 21% 14%
[libx264 @ 0000018285f6ab80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000018285f6ab80] kb/s:1294.62
[aac @ 0000018285eb2600] Qavg: 1365.021

Zda sa akoby OBS neposielalo spravne stream, preto tam pise:
Kód: [Vybrat]
[rtmp @ 00000182856bef80] Unexpected stream , expecting 127.0.0.1
ale potom zase
Kód: [Vybrat]
    Last message repeated 1 times
Input #0, flv, from 'rtmp://127.0.0.1':

neviem no, pride mi to ze tam ten protokol nefunguje ako by mal. Navyse tne stream sam skonci aj ked OBS vysiela. V OBS mam adresu pre stream rtmp://127.0.0.1 ale ocividne to nieco nahra takze konektivita tam je, komunikuje to medzi sebou ale nieco nie je ok proste.
« Poslední změna: 23. 01. 2023, 08:10:46 od Petr Krčmář »


N 0

Re:FFmpeg multiplexer RTMP
« Odpověď #1 kdy: 23. 01. 2023, 13:58:12 »
Jak se povedlo nastavit výstup OBS jako rtmp server?
Měl jsem zato, že si musím spustit rtmp server mimo OBS a na ten pak nasměruji výstup z OBS.
Tak jsem to měl nastaveno při pokusech o přenos desktopu na televizi pomocí rtmp protokolu.
Použil jsem k tomu NMS https://www.npmjs.com/package/node-media-server


hknmtt

Re:FFmpeg multiplexer RTMP
« Odpověď #2 kdy: 23. 01. 2023, 15:05:15 »
OBS je vysielalac ktory pouzije rtmp protokol. ffmpeg je zase rtmp server.