RTMP Authentication against FMS

Questions involving a Windows version of FFmpeg.
howard64
Posts: 5
Joined: Tue Sep 18, 2012 11:44 am

RTMP Authentication against FMS

Post by howard64 » Tue Sep 18, 2012 11:57 am

I have been asked to set up a system that will stream to the Akamai CDN servers. Unfortunately they require authentication to allow the streaming. I can do it with FMLE but I am not able to do it with FFmpeg, which is down to librtmp not having support for the proceedure.

With many thanks to help from this forum I have been able to set up the mingw toolchain and compile a minimal version of FFmpeg with a patched version or librtmp. The patch is from http://lab.condensa.ru/rtmp.patch which is discribed on this page http://support.condensa.ru/index.php?/K ... cle/View/4

I can see that this version does progress with the authentication but fails on the password. I have confirmed that I am using the correct password by checking it in FMLE but it just gets rejected from the patched FFmpeg.

Has anyone had any experience with this patch ?

As I am new to the process of compiling applications please ask anything you need to know about what I did.

Thanks
Howard

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: RTMP Authentication against FMS

Post by rogerdpack » Tue Sep 18, 2012 4:04 pm

if you're streaming to an http:// source (or can) you could compare the packets off the wire to see where they differ perhaps.
Also has this patch been submitted to librtmp?
-r

howard64
Posts: 5
Joined: Tue Sep 18, 2012 11:44 am

Re: RTMP Authentication against FMS

Post by howard64 » Tue Sep 18, 2012 4:22 pm

I need to publish an RTMP stream to the Akamai CDN. We are taking the source from a BlackMagic TV Studio via MX Light.

Unfortunately the current builds of FFmpeg don't have the authentication patch otherwise I would have expected everything to work and hence my forray into compiling a custom version.

Anyway, I can do some packet capturing with wireshark and take a look but I'm not really shure what I'm looking at as it will be encoded somehow.

And a big thank you to yourself for the script that did the build. I just commented out all of the build_* bits that I didn't need and it worked a treat.

-- Howard

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: RTMP Authentication against FMS

Post by rogerdpack » Tue Sep 18, 2012 6:07 pm

what is mx light?

howard64
Posts: 5
Joined: Tue Sep 18, 2012 11:44 am

Re: RTMP Authentication against FMS

Post by howard64 » Wed Sep 19, 2012 4:49 pm

MX Light is a nice piece of software created by Richard Freemantle that interfaces with the Black Magic TV Studio and H264 Pro Recorder over USB and takes the H.264 stream they produce, then can either record it to HDD or stream it via rtmp to CDN's. It seems to work well and comes with presets for Justin.tv Ustream and LiveStream, and it is fairly easy to add your own presets if required.

It uses ffmpeg to do and transcoding of frame size, frame rate and bit rate.

It makes it all nice and easy to use.

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: RTMP Authentication against FMS

Post by rogerdpack » Wed Sep 19, 2012 9:18 pm

To answer your original question, no, I don't have any experience with that patch, but if you get it to work do let us know. I would also suggest adding some print out debug statements to make sure it's getting the right password...

howard64
Posts: 5
Joined: Tue Sep 18, 2012 11:44 am

Re: RTMP Authentication against FMS

Post by howard64 » Sat Sep 22, 2012 11:43 am

I have had some luck with getting it working. The patch seems to be able to use OpenSSL, GnuTLS or PolarSSL but when it came down to it GnuTLS failed to somehow send back the correct information to FMS for the password. So I recompiled it using OpenSSL and that works. I am now able to authenticate and stream to the Akamai servers from the command line.

The next step was to use my version of ffmpeg with MX Light.

This isn't working because it needs ffmpeg to be compiled with pthreads according to a couple of warnings that I get about some options "overrun_nonfatal" and "circular_buffer_size"

Command line:
"C:\\Users\\Howard\\Documents\\CountryElectronics\\LiveStream\\MXLight-1.4.1\\utils\\ffmpeg_rtmpauth_openssl.exe" -v info -report -f mpegts -i "udp://127.0.0.1:1234?localaddr=127.0.0.1&localport=1234&pkt_size=32768&fifo_size=350000&buffer_size=67108864&overrun_nonfatal=1&connect=1" -re -vcodec libx264 -b:v 600k -vprofile high -s 640x360 -copyts -acodec libvo_aacenc -ar 44100 -ab 64k -bsf aac_adtstoasc -f flv "rtmp://p.<ACCOUNT>.i.akamaientrypoint.net/EntryPoint flashver=FME/3.0\\20(compatible;\\20FMSc\\201.0)\\ live=true pubUser=<USERNAME> pubPasswd=<PASSWORD> playpath=<STREAM_NAME>"
ffmpeg version N-44604-gc1f3a4d Copyright (c) 2000-2012 the FFmpeg developers
built on Sep 19 2012 23:23:36 with gcc 4.7.1 (GCC)
configuration: --enable-memalign-hack --arch=x86 --target-os=mingw32 --cross-prefix=/home/ubuntu/Software/sandbox/mingw-w64-i686/bin/i686-w64-mingw32- --pkg-config=pkg-config --enable-gpl --enable-version3 --enable-libx264 --enable-libxvid --enable-libmp3lame --enable-libvo-aacenc --enable-libvpx --extra-libs=-lws2_32 --extra-libs=-lpthread --enable-zlib --extra-libs=-lwinmm --extra-libs=-lgdi32 --enable-librtmp --enable-gnutls --disable-optimizations --enable-mmx --disable-postproc --enable-runtime-cpudetect
libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 56.100 / 54. 56.100
libavformat 54. 27.101 / 54. 27.101
libavdevice 54. 2.100 / 54. 2.100
libavfilter 3. 16.104 / 3. 16.104
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
[udp @ 01c18900] 'overrun_nonfatal' option was set but it is not supported on this build (pthread support is required)
[udp @ 01c18900] 'circular_buffer_size' option was set but it is not supported on this build (pthread support is required)
[mpegts @ 01c18400] stream=0 stream_type=1b pid=1011 prog_reg_desc=HDMV
[mpegts @ 01c18400] stream=1 stream_type=f pid=1100 prog_reg_desc=HDMV
[mpegts @ 01c18400] File position before avformat_find_stream_info() is 0
[h264 @ 01c14fa0] Increasing reorder buffer to 1
[h264 @ 01c14fa0] no picture ooo
[h264 @ 01c14fa0] no picture ooo
[h264 @ 01c14fa0] no picture
[mpegts @ 01c18400] max_analyze_duration 5000000 reached at 5013333
[mpegts @ 01c18400] Estimating duration from bitrate, this may be inaccurate
[mpegts @ 01c18400] File position after avformat_find_stream_info() is 3580648
Input #0, mpegts, from 'udp://127.0.0.1:1234?localaddr=127.0.0.1&localport=1234&pkt_size=32768&fifo_size=350000&buffer_size=67108864&overrun_nonfatal=1&connect=1':
Duration: N/A, start: 0.800033, bitrate: 256 kb/s
Program 1
Stream #0:0[0x1011], 169, 1/90000: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x1100], 237, 1/90000: Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, stereo, s16, 256 kb/s


I removed the bit "&fifo_size=350000&buffer_size=67108864&overrun_nonfatal=1" from the command line and it stops the errors but still doesn't work.

So I am now in need of help to re-compile but using pthreads. Can you give any guidance ?

I need a static build and only require aac, mp3 and x264 I believe. The build I made was done using your script but modified to apply the patch for the rtmp authentication.

Do I need to change to way in which Mingw is compile to include ptheads ?

Any help would be most appreciated.

I guess that this thread ought to be moved to the compilation issues section now.
Last edited by howard64 on Sun Oct 07, 2012 8:25 am, edited 2 times in total.

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: RTMP Authentication against FMS

Post by rogerdpack » Mon Sep 24, 2012 7:52 pm

Let me see if I can get it to work with win32-pthreads...

and what patch are you referring to?

Did you try polarssl?

Oops never mind ffmpeg can't use polarssl. But maybe rtmp can be made to use polarssl, and ffmpeg compiled without gnutls. Hmm...in your working example were you saying you compiled ffmpeg without --enable-gnutls but I guess rtmp underneath was compiled with GNUTLS enabled so my guess is that FFmpeg doesn't use rtmp's SSL layer, but just provides its own. Hmm...

-r

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: RTMP Authentication against FMS

Post by rogerdpack » Mon Sep 24, 2012 9:02 pm

Ok the latest version at https://github.com/rdp/ffmpeg-windows-build-helpers will compile with win32-pthreads (kind of experimental at this point) so...I guess if you use that script, remove the "--enable-gnutls" and add --enable-openssl or the like you may have a working (probably non redistributable) option :)
-roger-

rogerdpack
Posts: 1878
Joined: Fri Aug 05, 2011 9:56 pm

Re: RTMP Authentication against FMS

Post by rogerdpack » Tue Sep 25, 2012 3:25 pm

Ok I tested what I believe is x264 using win32-pthreads with FFmpeg using win32-pthreads overnight and it seemed stable, at least. I haven't done any speed testing yet, but it seems at least in the ballpark of other threading options.

Post Reply