Hi there,

this is my first message on this list, so please bear with me.
I have access to a h.264 encoder that will supply a few rtmp streams
corresponding to the various HDMI inputs it has. It is supposed to use
ffmpeg by the way (TBS2605).
Anyway... I have a Linux machine, and my goal is to:
 - grab one of these streams, add audio coming from a USB sound card
(FocusRite 2i4 2nd Gen), and stream that to YouTube while recording on
the disk too.
 - grab two of these streams, compose them on top of a template, add
audio (like in https://youtu.be/01nM2Shnyz0?t=1638), stream that to
YouTube while recording on the disk too.

For the time being, I have managed to stream to YouTube, but the
YouTube platform is not happy with my stream quality, saying "The
stream's current bitrate (1653.00 Kbps) is lower than the recommended
bitrate. We recommend that you use a stream bitrate of 4500 Kbps.".
The bitrate that is output by the encoder is supposed to be 4000Kbps.
The ffmpeg command I have gives me around 2200/2400Kbps.
So I guess I made a mess and decoded with my command the h.264 stream
before encoding again... as the speed is around 0.962x, and the CPU is
quite busy. I thought there was no need to decode/encode to add an
audio stream (but I have no idea what I'm doing, as you had already
guessed ;-) ).

I recompiled the 4.2 ffmpeg release sources on this very machine.

Here is the kind of output I get:
ffmpeg version 4.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
  configuration: --enable-gpl --enable-version3 --disable-static
--enable-shared --enable-small --enable-avisynth --enable-chromaprint
--enable-frei0r --enable-gmp --enable-gnutls --enable-ladspa
--enable-libaom --enable-libass --enable-libcaca --enable-libcdio
--enable-libcodec2 --enable-libfontconfig --enable-libfreetype
--enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack
--enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopenmpt --enable-libopus
--enable-libpulse --enable-librsvg --enable-librubberband
--enable-librtmp --enable-libshine --enable-libsnappy --enable-libsoxr
--enable-libspeex --enable-libssh --enable-libtesseract
--enable-libtheora --enable-libtwolame --enable-libv4l2
--enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxvid --enable-libxml2 --enable-libzmq --enable-libzvbi
--enable-lv2 --enable-libmysofa --enable-openal --enable-opencl
--enable-opengl --enable-libdrm --enable-nonfree --enable-libfdk-aac
--enable-libbluray --extra-libs='-lnettle -lhogweed -lgmp'
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, flv, from 'rtmp://192.168.1.211:1935/live/stream0':
  Duration: N/A, start: 15024.271000, bitrate: N/A
    Stream #0:0: Video: h264, yuv420p(progressive), 1920x1080, 30 fps,
30 tbr, 1k tbn
    Stream #0:1: Audio: aac, 48000 Hz, stereo, fltp
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'default':
  Duration: N/A, start: 1568033472.683289, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[libx264 @ 0x559c4df3e780] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x559c4df3e780] profile High, level 4.0
[libx264 @ 0x559c4df3e780] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4
AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7
psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1
8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2
threads=6 lookahead_threads=1 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=2 keyint=60
keyint_min=6 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=3.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=7000
vbv_bufsize=512 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40
aq=1:1.00
Output #0, flv, to 'rtmp://a.rtmp.youtube.com/live2/dh5g-r8tf-x5qy-cse8':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007),
yuv420p, 1920x1080, q=-1--1, 5000 kb/s, 30 fps, 1k tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 7000000/0/5000000 buffer size: 512000
vbv_delay: -1
    Stream #0:1: Audio: mp3 (libmp3lame) ([2][0][0][0] / 0x0002),
48000 Hz, stereo, fltp, 712 kb/s
    Metadata:
      encoder         : Lavc58.54.100 libmp3lame
frame=  621 fps= 27 q=40.0 size=    5451kB time=00:00:20.73
bitrate=2153.8kbits/s speed=0.904x

And here is my command to stream from the h.264 encoded stream while
adding audio coming from the USB Sound card. It is based on this gist
https://gist.github.com/olasd/9841772 :
VBR="5000k"
FPS="30"
ffmpeg -i "$SOURCE" -thread_queue_size 2048 -f pulse -i default
-vcodec h264 -r 30 -g $(($FPS * 2)) -b:v $VBR  -maxrate 7000k -threads
6 -crf 3 -b:a 712000 -bufsize 512k -f flv "$YOUTUBE_URL/$KEY"

If you have any pointer to help me, please let me know. I've been
reading quite a lot for a while regarding ffmpeg, but I can't seem to
understand the basics.

Best regards,
-- 
Bruno Verachten
_______________________________________________
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to