Всем привет. Искал искал не нашел, возможно кто-то сталкивался. Нужно организовать стриминг по протоколу RTSP, кодек AAC.
Сначала попробовал через голый ffmpeg - все играет отлично. Потом настроил стрим в ffserver, запустил и тишина. Если поменять кодек с
AudioCodec aac
на
AudioCodec libmp3lame
то mp3 стримится нормально.
Более подробно:
Сначала стриминг «голым» ffmpeg-ом
ffmpeg -hide_banner -v verbose -re -i test.mp4 -acodec aac -strict -2 -f rtp rtp://127.0.0.1:1234 > stream.sdp
Routing option strict to both codec and muxer layer
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Duration: 00:09:08.73, start: 0.000998, bitrate: 135 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 133 kb/s (default)
Metadata:
handler_name : SoundHandler
[graph 0 input from stream 0:0 @ 0x7f9450f012a0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
Output #0, rtp, to 'rtp://127.0.0.1:1234':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Stream #0:0(und): Audio: aac, 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc56.60.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
size= 217kB time=00:00:13.39 bitrate= 132.5kbits/s
Все играет.
ffplay -hide_banner -v verbose ./stream.sdp
Input #0, sdp, from './stream.sdp':0KB vq= 0KB sq= 0B f=0/0
Metadata:
title : No Name
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Audio: aac (LC), 44100 Hz, stereo, fltp
[ffplay_abuffer @ 0x7fb431d12480] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
[ffplay_abuffersink @ 0x7fb431d24da0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'ffplay_abuffer' and the filter 'ffplay_abuffersink'
[auto-inserted resampler 0 @ 0x7fb431d250a0] ch:2 chl:stereo fmt:fltp r:44100Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
2016-02-11 13:32:58.178 ffplay[20427:16225541] 13:32:58.178 WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
[ffplay_abuffer @ 0x7fb431c383c0] tb:1/44100 samplefmt:fltp samplerate:44100 chlayout:0x3
[ffplay_abuffersink @ 0x7fb431c5a5c0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'ffplay_abuffer' and the filter 'ffplay_abuffersink'
[auto-inserted resampler 0 @ 0x7fb431c5a8c0] ch:2 chl:stereo fmt:fltp r:44100Hz -> ch:2 chl:stereo fmt:s16 r:44100Hz
6.63 M-A: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
Конфиг ffserver-а
# ffserver.conf
HTTPPort 8001
HTTPBindAddress 127.0.0.1
RTSPBindAddress 127.0.0.1
RTSPPort 8002
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
<Feed ch1.ffm>
File tmp/ch1.ffm
FileMaxSize 120k
</Feed>
<Stream stream>
Feed ch1.ffm
Format rtp
Metadata title "My new stream"
Strict -2
AudioCodec aac
AudioBitRate 128
AudioChannels 2
AudioSampleRate 44100
AVOptionAudio flags +global_header
NoVideo
</Stream>
Отправляю стрим
ffmpeg -hide_banner -re -i test.mp4 -acodec aac http://127.0.0.1:8001/ch1.ffm
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf56.40.101
Duration: 00:09:08.73, start: 0.000998, bitrate: 135 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 133 kb/s (default)
Metadata:
handler_name : SoundHandler
[tcp @ 0x7ffc7050bae0] Connection to tcp://localhost:8001 failed (Connection refused), trying next address
[tcp @ 0x7ffc7040b740] Connection to tcp://localhost:8001 failed (Connection refused), trying next address
Output #0, ffm, to 'http://localhost:8001/ch1.ffm':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
creation_time : 2016-02-11 13:36:01
encoder : Lavf56.40.101
Stream #0:0(und): Audio: aac (libfaac), 44100 Hz, stereo, s16, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc56.60.100 libfaac
Stream mapping:
Stream #0:0 -> #0:0 (aac (native) -> aac (libfaac))
Press [q] to stop, [?] for help
size= 144kB time=00:00:08.38 bitrate= 140.7kbits/s
А играть не хочет
➜ ffplay -hide_banner -v verbose rtsp://127.0.0.1:8002/stream
[rtsp @ 0x7fef12867e00] SDP:aq= 0KB vq= 0KB sq= 0B f=0/0
v=0
o=- 0 0 IN IP4 127.0.0.1
s=My new stream
c=IN IP4 0.0.0.0
t=0 0
a=tool:libavformat 56.40.101
m=audio 0 RTP/AVP 96
b=AS:128
a=rtpmap:96 MPEG4-GENERIC/44100/2
a=fmtp:96 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=1210
a=control:streamid=0
nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
ffmpeg version 2.8.6 Copyright (c) 2000-2016 the FFmpeg developers
built with Apple LLVM version 7.0.2 (clang-700.1.81)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.8.6 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfaac --enable-ffplay --enable-libfdk-aac --enable-nonfree --enable-vda
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
Пробовал разные версии ffmpeg. Подскажите, куда копать, если кто сталкивался. Спасибо.
P.S. Так же пробовал стримить через ffmpeg+wowza, для проверки, стрим играет отлично. Сравнивал RTSP запрос/ответы но ничего не нашел подозрительного.