Opened 9 years ago

Last modified 5 years ago

#5011 new defect

ffmpeg native RTMP protocol implementation fails to parse app and playpath from some Wowza URIs

Reported by: Ignasi Rius Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: rtmp librtmp
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I am trying to publish on a live RTMP publishing point (wowza) on the following URI:

rtmp://foo.bar.foo.barserver.net/foo-user-4-live01/_definst_/doPublish=abab2de0fe/hello
(** Please, note that I changed the real server address for security reasons.)

The problem is that if I compile ffmpeg WITHOUT support for librtmp (no -enable_librtmp flag) it doesn't work. However, when using librtmp it works.

Trying to figure out what was going on I found out the following:

  • Native ffmpeg RTMP and librtmp impementations parse in a different way the app and playpath from this URI. In particular, librtmp does it right and native implementations doesn't. Here are the details:
Native RTMP:
app= foo-user-4-live01/_definst_
fname= doPublish=abab2de0fe/hello

libRTMP:
app= foo-user-4-live01/_definst_/doPublish=abab2de0fe
fname= hello
  • Having a quick look at the source code, I wonder if it might be related to the "_definst_" thing in rtmpproto.c on the following function ?
static int do_llnw_auth(RTMPContext *rt, const char *user, const char *nonce)

Here you have the command line I am using and the output with verbose level for both native rtmp and librtmp versions:

NATIVE RTMP :

ffmpeg -i test.mp4 -f flv -v verbose rtmp://foo.bar.foo.barserver.net/foo-user-4-live01/_definst_/doPublish=abab2de0fe/hello
ffmpeg version 2.7 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (Rev5, Built by MSYS2 project)
  configuration: --disable-gpl --enable-shared --enable-libfdk-aac --target-os=mingw32 --disable-iconv --disable-zlib --disable-bzlib
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.26.101
  Duration: 01:02:54.64, start: 0.360000, bitrate: 4999 kb/s
    Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p, 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 4998 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
rtmp://foo.bar.foo.barserver.net/foo-user-4-live01/_definst_/doPublish=abab2de0fe/hello: Input/output error

LIBRTMP :

ffmpeg version N-71066-ga2dd2d7 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --disable-static --enable-shared --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
  libavutil      54. 20.101 / 54. 20.101
  libavcodec     56. 29.100 / 56. 29.100
  libavformat    56. 26.101 / 56. 26.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 13.101 /  5. 13.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.26.101
  Duration: 01:02:54.64, start: 0.360000, bitrate: 4999 kb/s
    Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p, 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 4998 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Parsing...
Parsed protocol: 0
Parsed host    : foo.bar.foo.barserver.net
Parsed app     : foo-user-4-live01/_definst_/doPublish=abab2de0fe
RTMP_Connect1, ... connected, handshaking
HandShake: Type Answer   : 03
HandShake: Server Uptime : 96850052
HandShake: FMS Version   : 3.0.1.1
HandShake: Handshaking finished....
RTMP_Connect1, handshaked
Invoking connect
HandleServerBW: server BW = 2500000
HandleClientBW: client BW = 2500000 2
HandleCtrl, received ctrl. type: 0, len: 6
HandleCtrl, Stream Begin 0
HandleChangeChunkSize, received: chunk size change to 512
RTMP_ClientPacket, received: invoke 261 bytes
(object begin)
Property: <Name:           no-name., STRING:    _result>
Property: <Name:           no-name., NUMBER:    1.00>
Property: <Name:           no-name., OBJECT>
(object begin)
Property: <Name:             fmsVer, STRING:    FMS/3,5,7,7009>
Property: <Name:       capabilities, NUMBER:    31.00>
Property: <Name:               mode, NUMBER:    1.00>
(object end)
Property: <Name:           no-name., OBJECT>
(object begin)
Property: <Name:              level, STRING:    status>
Property: <Name:               code, STRING:    NetConnection.Connect.Success>
Property: <Name:        description, STRING:    Connection succeeded.>
Property: <Name:               data, ECMA_ARRAY>
(object begin)
Property: <Name:            version, STRING:    3,5,7,7009>
(object end)
Property: <Name:           clientid, NUMBER:    1018124079.00>
Property: <Name:     objectEncoding, NUMBER:    0.00>
(object end)
(object end)
HandleInvoke, server invoking <_result>
HandleInvoke, received result for method call <connect>
Invoking releaseStream
Invoking FCPublish
Invoking createStream
RTMP_ClientPacket, received: invoke 141 bytes
(object begin)
Property: <Name:           no-name., STRING:    onFCPublish>
Property: <Name:           no-name., NUMBER:    0.00>
Property: NULL
Property: <Name:           no-name., OBJECT>
(object begin)
Property: <Name:              level, STRING:    status>
Property: <Name:               code, STRING:    NetStream.Publish.Start>
Property: <Name:        description, STRING:    FCPublish to stream barcelona.>
Property: <Name:           clientid, NUMBER:    1018124079.00>
(object end)
(object end)
HandleInvoke, server invoking <onFCPublish>
RTMP_ClientPacket, received: invoke 29 bytes
(object begin)
Property: <Name:           no-name., STRING:    _result>
Property: <Name:           no-name., NUMBER:    4.00>
Property: NULL
Property: <Name:           no-name., NUMBER:    1.00>
(object end)
HandleInvoke, server invoking <_result>
HandleInvoke, received result for method call <createStream>
Invoking publish
HandleCtrl, received ctrl. type: 0, len: 6
HandleCtrl, Stream Begin 1
RTMP_ClientPacket, received: invoke 129 bytes
(object begin)
Property: <Name:           no-name., STRING:    onStatus>
Property: <Name:           no-name., NUMBER:    0.00>
Property: NULL
Property: <Name:           no-name., OBJECT>
(object begin)
Property: <Name:              level, STRING:    status>
Property: <Name:               code, STRING:    NetStream.Publish.Start>
Property: <Name:        description, STRING:    Publishing barcelona.>
Property: <Name:           clientid, NUMBER:    1018124079.00>
(object end)
(object end)
HandleInvoke, server invoking <onStatus>
HandleInvoke, onStatus: NetStream.Publish.Start
[graph 0 input from stream 0:0 @ 0000000002341220] w:1920 h:1080 pixfmt:yuv420p tb:1/12800 fr:25/1 sar:1/1 sws_param:flags=2
Output #0, flv, to 'rtmp://foo.bar.foo.barserver.net/foo-user-4-live01/_definst_/doPublish=abab2de0fe/hello':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf56.26.101
    Stream #0:0(und): Video: flv1 (flv), 1 reference frame ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 1k tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc56.29.100 flv
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> flv1 (flv))
Press [q] to stop, [?] for help

(....... I cut it here but it basically works)

Change History (3)

comment:1 by Carl Eugen Hoyos, 9 years ago

Please confirm that the issue is reproducible with current FFmpeg git head.

comment:2 by Ignasi Rius, 9 years ago

Yes it is reproducible with current ffmpeg git head using the following compiler flags (probably any flags would work as long as you don't include librtmp):

--disable-gpl --enable-shared --enable-libfdk-aac --target-os=mingw32 --disable-iconv --disable-zlib --disable-bzlib

comment:3 by zermok, 5 years ago

Just found this ticket reporting the same of mine on Adobe Media Server
https://trac.ffmpeg.org/ticket/7689

Note: See TracTickets for help on using tickets.