[FFmpeg-user] RTSP to Twitch

Michael Shaffer mikeshaffer at gmail.com
Wed Mar 10 21:12:49 EET 2021


On Wed, Mar 10, 2021 at 6:56 AM Sébastien Bonaimé <s.bonaime at gmail.com>
wrote:

> Hi,
>
> I would like to stream a Revotech H6EV200-S-30-L 0S77
> (
> https://www.desertcart.com.my/products/57000744-revotech-hd-1920-x-1080p-2-0mp-indoor-ip-camera-mini-type-security-metal-camera-onvif-p2p-ip-cctv-cam-system-i706-black
> )
> camera pointing to a bird nest through my raspberry pi4 to my twitch
> channel.
>
> First, I need to configure CBR or VBR in the camera. Using ffprobe
> with the url of the camera I have the following results:
> VBR 3072 smart_codec enable
>     Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive),
> 1920x1080, 25 fps, 25 tbr, 90k tbn, 180k tbc
> CBR 3072 smart_codec enable
>     Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive),
> 1920x1080, 25 tbr, 90k tbn, 180k tbc
>
> FFmpeg version is
> ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg
> developers
>   built with gcc 8 (Raspbian 8.3.0-6+rpi1)
>
> included x264 codec are : libx264 libx264rgb h264_omx h264_v4l2m2m
> h264_vaapi
>
> Here is my command line
>
> url='rtsp://user:password@192.168.1.32:8554/0/av0'
> twitch_url='rtmp://cdg.contribute.live-video.net/app/MY_twith_key'
>
>      QUAL="ultrafast"  # one of the many FFMPEG preset
>      CBR="3500k" # constant bitrate (should be between 1000k - 3000k)
>
>         ffmpeg  -probesize  10M  -rtsp_transport tcp -thread_queue_size
> 1000k \
>                   -i $url \
>                 -vsync 0 -enc_time_base -1 \
>                  -bufsize 1024k -preset "$QUAL" \
>                 -b:v $CBR  -minrate $CBR -maxrate $CBR   -keyint_min 24 -g
> 24 \
>                 -crf 10  -c:v libx264    \
>                 -f flv $twitch_url
>
>
> With camera in CBR mode, I can't reach 25 FPS but only 14. And the
> stream to twitch does not last more than ew seconds. What can I do to
> improve the command ?
>
> Thanks
>
> [rtsp @ 0x8952e0] Missing PPS in sprop-parameter-sets, ignoring
> Input #0, rtsp, from 'rtsp://user:password@192.168.1.32:8554/0/av0':
>   Metadata:
>     title           : Session Streamed by LIBZRTSP
>     comment         : 0
>   Duration: N/A, start: 0.040000, bitrate: N/A
>     Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive),
> 1920x1080, 25 fps, 25 tbr, 90k tbn, 180k tbc
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> [libx264 @ 0x8fd140] MB rate (734400000) > level limit (16711680)
> [libx264 @ 0x8fd140] using cpu capabilities: ARMv6 NEON
> [libx264 @ 0x8fd140] profile Constrained Baseline, level 6.2
> [libx264 @ 0x8fd140] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC
> codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html -
> options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1
> psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1
> 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0
> threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
> interlaced=0
> bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=24
> keyint_min=13 scenecut=0 intra_refresh=0 rc_lookahead=0 rc=crf
> mbtree=0 crf=10.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4
> vbv_maxrate=3500 vbv_bufsize=1024 crf_max=0.0 nal_hrd=none filler=0
> ip_ratio=1.40 aq=0
> Output #0, flv, to 'rtmp://cdg.contribute.live-video.net/app/MY_twith_key
> ':
>   Metadata:
>     title           : Session Streamed by LIBZRTSP
>     comment         : 0
>     encoder         : Lavf58.20.100
>     Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007),
> yuvj420p(pc), 1920x1080, q=-1--1, 3500 kb/s, 25 fps, 1k tbn, 90k tbc
>     Metadata:
>       encoder         : Lavc58.35.100 libx264
>     Side data:
>       cpb: bitrate max/min/avg: 3500000/0/3500000 buffer size: 1024000
> vbv_delay: -1
> [libx264 @ 0x8fd140] non-strictly-monotonic PTS
> frame=  190 fps= 14 q=23.0 size=    3136kB time=00:00:08.88
> bitrate=2892.7kbits/s speed=0.66x
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".

In the camera settings, set the bitrate to the maximum your connection can
handle. Then use the “stream copy” mode in ffmpeg.

Currently, your command is trying to re-encode the video on a Raspberry Pi,
which is kind of underpowered for that task. It can handle stream copy mode
fine though.


More information about the ffmpeg-user mailing list