I just noticed Periscope Producer capability to accept live streaming from external sources.
A quick test with ffmpeg fails to fit bitrate requirements of 160kbps max for audio. Periscope says my audio bitrate is "475.243 kbps", while allowd max is 160kbps.
"testsrc" creates a test pattern video and "sine" filter generates a 440Hz tone with beeps. I tried various settings to limit video and audio bitrate, but none seems to work. Here's the latest test:
ffmpeg -f lavfi -i testsrc=rate=30:size=960x540,format=yuv420p \
-f lavfi -i "sine=frequency=440:sample_rate=44100:beep_factor=4" \
-vf "
drawtext
=fontfile='/Library/Fonts/MyriadPro-Regular.otf'
:fontcolor='#ff6600'
:fontsize=64
:text='%{pts}'
:x='w/2 - text_w/2'
:y='h/2 - text_h/2'
" \
-c:v libx264 \
-crf:v 26 \
-preset:v fast \
-pix_fmt yuv420p \
-x264opts keyint=60:no-scenecut=1 \
-maxrate:v 600k \
-bufsize:v 1400k \
-bt:v 100k \
-g 60 \
-b:v 600k \
-c:a aac \
-bt:a 10k \
-b:a 128k \
-y -hide_banner \
-f flv \
-flvflags no_duration_filesize \
rtmp://de.pscp.tv:80/x/MYSECRETKEY
Please advice how to limit aac audio bitrate so it fits under 160kbps?
ffmpeg displays this while running:
Input #0, lavfi, from 'testsrc=rate=30:size=960x540,format=yuv420p':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 960x540 [SAR 1:1 DAR 16:9], 30 tbr, 30 tbn, 30 tbc
Input #1, lavfi, from 'sine=frequency=440:sample_rate=44100:beep_factor=4':
Duration: N/A, start: 0.000000, bitrate: 705 kb/s
Stream #1:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fcd5b050800] using SAR=1/1
[libx264 @ 0x7fcd5b050800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fcd5b050800] profile High, level 3.1
[libx264 @ 0x7fcd5b050800] 264 - core 148 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 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=12 lookahead_threads=2 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=60 keyint_min=6 scenecut=0 intra_refresh=0 rc_lookahead=30 rc=crf mbtree=1 crf=26.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=600 vbv_bufsize=2400 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
Output #0, flv, to 'rtmp://de.pscp.tv:80/x/MYSECRETKEY':
Metadata:
encoder : Lavf57.71.100
Stream #0:0: Video: h264 (libx264) ([7][0][0][0] / 0x0007), yuv420p(progressive), 960x540 [SAR 1:1 DAR 16:9], q=-1--1, 600 kb/s, 30 fps, 1k tbn, 30 tbc
Metadata:
encoder : Lavc57.89.100 libx264
Side data:
cpb: bitrate max/min/avg: 600000/0/600000 buffer size: 2400000 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, mono, fltp, 128 kb/s
Metadata:
encoder : Lavc57.89.100 aac
frame= 8146 fps=156 q=32.0 size= 10323kB time=00:04:29.93 bitrate= 313.3kbits/s speed=5.17x
[SOLVED] My fault: missed the -re flag that would limit speed of reading the generators at a speed of playback. My ffmpeg was streaming data to Periscope much faster than the playback, thus exceeding the bitrate limits. Following is the working code:
ffmpeg \
-re \
-f lavfi \
-i testsrc=rate=30:size=960x540,format=yuv420p \
-re \
-f lavfi \
-i "sine=frequency=440:sample_rate=44100:beep_factor=4" \
-vf "
drawtext
=fontfile='/Library/Fonts/MyriadPro-Regular.otf'
:fontcolor='#ff6600'
:fontsize=64
:text='%{pts}'
:x='w/2 - text_w/2'
:y='h/2 - text_h/2'
" \
-c:v libx264 \
-crf:v 22 \
-preset:v fast \
-pix_fmt yuv420p \
-x264opts keyint=60:no-scenecut=1 \
-maxrate:v 600k \
-bufsize:v 2400k \
-g 60 \
-c:a aac \
-ac 2 \
-b:a 96k \
-maxrate:a 96k \
-bufsize:a 192k \
-f flv \
-flvflags no_duration_filesize \
-y -hide_banner \
rtmp://de.pscp.tv:80/x/MYSECRETCODE
-re
flag that would limit speed of reading the generators at a speed of playback. My ffmpeg was streaming data to Periscope much faster than the playback, thus exceeding the bitrate limits.