[FFmpeg-user] simplest possible rtmp -> dash example

James Northrup jim at vsiwest.com
Wed Mar 20 14:50:50 EET 2019


my usecase is streaming a continuous live radio station broadcast.


on the (station) side(ubuntu 16.04) , it appears ffmpeg understands  rtmp
well enough to send a well formed tcp socket
----------------
host1 at ubuntu:/tmp$ ffmpeg  -re -fflags +genpts  -stream_loop -1  -i
http://localhost/storage/audio/2018/10/713b8ade-517
2-4fa0-8c92-d3441339c3f2.mp3 -streaming 1
rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts
ffmpeg version N-93399-g9e62e1a Copyright (c) 2000-2019 the FFmpeg
developers
 built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
 configuration: --prefix=/home/primedev/ffmpeg_build
--extra-cflags=-I/home/primedev/ffmpeg_build/include --extra-ldflags=-L
/home/primedev/ffmpeg_build/lib --extra-libs='-lpthread -lm'
--bindir=/home/primedev/bin --disable-ffplay --enable-bzlib --en
able-ffmpeg --enable-gpl --enable-iconv --enable-libfdk-aac
--enable-libmp3lame --enable-libopus --enable-libsnappy --enable-
libssh --enable-nonfree --enable-openssl --enable-version3 --enable-zlib
--enable-libfreetype --enable-libtwolame --enable-li
bvpx --enable-avresample --enable-librsvg --enable-libx264
--enable-libvorbis --enable-libtheora --enable-gpl
 libavutil      56. 26.100 / 56. 26.100
 libavcodec     58. 47.103 / 58. 47.103
 libavformat    58. 26.101 / 58. 26.101
 libavdevice    58.  6.101 / 58.  6.101
 libavfilter     7. 48.100 /  7. 48.100
 libavresample   4.  0.  0 /  4.  0.  0
 libswscale      5.  4.100 /  5.  4.100
 libswresample   3.  4.100 /  3.  4.100
 libpostproc    55.  4.100 / 55.  4.100
Input #0, mp3, from '
http://localhost/storage/audio/2018/10/713b8ade-5172-4fa0-8c92-d3441339c3f2.mp3
':
 Metadata:
   encoder         : Lavf58.18.101
 Duration: 00:00:07.81, start: 0.025057, bitrate: 128 kb/s
   Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
   Metadata:
     encoder         : Lavc58.30
Stream mapping:
 Stream #0:0 -> #0:0 (mp3 (mp3float) -> mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to 'rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts':
 Metadata:
   encoder         : Lavf58.26.101
   Stream #0:0: Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s
   Metadata:
     encoder         : Lavc58.47.103 mp2
size=     483kB time=00:00:09.31 bitrate= 424.8kbits/s speed=   1x
video:0kB audio:436kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 10.808728%
Exiting normally, received signal 2.


on content CDN side(ubuntu 18.04) , rtmp (not librtmp) sort of seems to
hang (until ctrl-c on one end)
----------
root at iZk1a5ci0kk435ovla0ylgZ:/tmp# ffmpeg  -v 999 -timeout 99999 -i
'rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts'  -c:0:a li
bfdk_aac -b:0:a 32k -profile:0:a aac_he_v2  -seg_duration 5 -remove_at_exit
1 -extra_window_size 6 -use_timeline 1 -streaming
1    -adaptation_sets 'id=0,streams=a'  -hls_playlist 1  x.mpd
ffmpeg version N-93399-g9e62e1a Copyright (c) 2000-2019 the FFmpeg
developers
 built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
 configuration: --prefix=/root/ffmpeg_build
--extra-cflags=-I/root/ffmpeg_build/include
--extra-ldflags=-L/root/ffmpeg_build
/lib --extra-libs='-lpthread -lm' --bindir=/root/bin --disable-ffplay
--enable-bzlib --enable-ffmpeg --enable-gpl --enable-ic
onv --enable-libfdk-aac --enable-libmp3lame --enable-libopus
--enable-libsnappy --enable-libssh --enable-nonfree --enable-ope
nssl --enable-version3 --enable-zlib --enable-libfreetype
--enable-libtwolame --enable-libvpx --enable-avresample --enable-li
brsvg --enable-libx264 --enable-libvorbis --enable-libtheora --enable-gpl
 libavutil      56. 26.100 / 56. 26.100
 libavcodec     58. 47.103 / 58. 47.103
 libavformat    58. 26.101 / 58. 26.101
 libavdevice    58.  6.101 / 58.  6.101
 libavfilter     7. 48.100 /  7. 48.100
 libavresample   4.  0.  0 /  4.  0.  0
 libswscale      5.  4.100 /  5.  4.100
 libswresample   3.  4.100 /  3.  4.100
 libpostproc    55.  4.100 / 55.  4.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with
argument '999'.
Reading option '-timeout' ... matched as AVOption 'timeout' with argument
'99999'.
Reading option '-i' ... matched as input url with argument
'rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts'.
Reading option '-c:0:a' ... matched as option 'c' (codec name) with
argument 'libfdk_aac'.
Reading option '-b:0:a' ... matched as option 'b' (video bitrate (please
use -b:v)) with argument '32k'.
Reading option '-profile:0:a' ... matched as option 'profile' (set profile)
with argument 'aac_he_v2'.
Reading option '-seg_duration' ... matched as AVOption 'seg_duration' with
argument '5'.
Reading option '-remove_at_exit' ... matched as AVOption 'remove_at_exit'
with argument '1'.
Reading option '-extra_window_size' ... matched as AVOption
'extra_window_size' with argument '6'.
Reading option '-use_timeline' ... matched as AVOption 'use_timeline' with
argument '1'.
Reading option '-streaming' ... matched as AVOption 'streaming' with
argument '1'.
Reading option '-adaptation_sets' ... matched as AVOption 'adaptation_sets'
with argument 'id=0,streams=a'.
Reading option '-hls_playlist' ... matched as AVOption 'hls_playlist' with
argument '1'.
Reading option 'x.mpd' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 999.
Successfully parsed a group of options.
Parsing a group of options: input url
rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts.
Successfully parsed a group of options.
Opening an input file: rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts.
[NULL @ 0x563b2147e340] Opening
'rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts' for reading
[rtmp @ 0x563b2147ef00] No default whitelist set
[tcp @ 0x563b2147f9c0] No default whitelist set
[rtmp @ 0x563b2147ef00] Proto = rtmp, path = /tmp/x.ts, app = tmp, fname =
x.ts
[rtmp @ 0x563b2147ef00] New incoming chunk size = 128
[rtmp @ 0x563b2147ef00] Unknown packet type received 0xFF
[rtmp @ 0x563b2147ef00] Deleting stream...
rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts: Input/output error
root at iZk1a5ci0kk435ovla0ylgZ:/tmp#

here's where some laborious experiementation with 3 different ubuntu
releases (16,18,19) seem to repel librtmp-dev pkgconfig from apt.  i don't
conclusively find a pointer to the enhanced librtmp i should be building,
however it appears that I'm limitted to using rtmp or an untested "HTTP"
sender protocol from the commercial vmix bundled ffmpeg upstream (not yet
tested).

 other addendum:

-ab 32k says use -b:a ...
-b:a says...
Reading option '-b:0:a' ... matched as option 'b' (video bitrate (please
use -b:v)) with argument '32k'.

the posted attempts are the result of some trial and error, "simplest
possible" probably looks like

ffmpeg  -timeout 99999 -i 'rtmp://iZk1a5ci0kk435ovla0ylgZ:9000/tmp/x.ts'
x.mpd

however rtmp seems to be impacted and beleaguered with inbound unknown
chunk types


More information about the ffmpeg-user mailing list