RTMP Server with live MP4 stream pushed via rtp or sdp

1,107 views
Skip to first unread message

jay

unread,
Jul 17, 2011, 12:50:11 AM7/17/11
to C++ RTMP Server
Hi,

I would like to run RTMP server with either ffmpeg or vlc feeding a
MP4 stream from an IP camera via UDP/TCP or RTP.

I tried the below command but didn't work.

openRTSP -v rtsp://ipcamera:7070/ | ffmpeg -i - -f flv
rtmp://localhost:1935/flvplayback/demo1

messages on the rtmp server
/opt/crtmpserver/sources/thelib/src/application/
baseclientapplication.cpp:161 Stream 7 of type NR with name ``
registered to application `flvplayback`

messages on the client side

Receiving streamed data (signal with "kill -HUP 8198" or "kill -USR1
8198" to terminate)...
[h264 @ 0x9d46340] max_analyze_duration 5000000 reached at 5000000
[h264 @ 0x9d46340] Estimating duration from bitrate, this may be
inaccurate

Seems stream 0 codec frame rate differs from container frame rate:
30.00 (30/1) -> 15.00 (30/2)
Input #0, h264, from 'pipe:':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: h264 (Baseline), yuvj420p, 640x480 [PAR 1:1
DAR 4:3], 15 fps, 15 tbr, 1200k tbn, 30 tbc

Thanks
Jay

C++ RTMP Server

unread,
Jul 17, 2011, 8:40:40 AM7/17/11
to c-rtmp...@googlegroups.com

On Jul 17, 2011, at 7:50 AM, jay wrote:

> Hi,
>
> I would like to run RTMP server with either ffmpeg or vlc feeding a
> MP4 stream from an IP camera via UDP/TCP or RTP.
>
> I tried the below command but didn't work.
>
> openRTSP -v rtsp://ipcamera:7070/ | ffmpeg -i - -f flv
> rtmp://localhost:1935/flvplayback/demo1

.... | ffmpeg -i - -f flv -metadata streamName=demo1 "tcp://localhost:6666"

You must either specify -f flv and put the output in the liveFLV acceptor in crtmpserver (like I just did), or go with RTMP approach without specifying -f flv, just the RTMP uri.

But I have one question... Why don't you put the rtsp URI directly into the externalStreams section in the config file? No external tools required


>
> messages on the rtmp server
> /opt/crtmpserver/sources/thelib/src/application/
> baseclientapplication.cpp:161 Stream 7 of type NR with name ``
> registered to application `flvplayback`
>
> messages on the client side
>
> Receiving streamed data (signal with "kill -HUP 8198" or "kill -USR1
> 8198" to terminate)...
> [h264 @ 0x9d46340] max_analyze_duration 5000000 reached at 5000000
> [h264 @ 0x9d46340] Estimating duration from bitrate, this may be
> inaccurate
>
> Seems stream 0 codec frame rate differs from container frame rate:
> 30.00 (30/1) -> 15.00 (30/2)
> Input #0, h264, from 'pipe:':
> Duration: N/A, bitrate: N/A
> Stream #0.0: Video: h264 (Baseline), yuvj420p, 640x480 [PAR 1:1
> DAR 4:3], 15 fps, 15 tbr, 1200k tbn, 30 tbc
>
> Thanks
> Jay
>

> You received this message because you are subscribed to "C++ RTMP Server" mailing list.
> To post to this group, send email to c-rtmp...@googlegroups.com
> To unsubscribe from this group, send email to
> c-rtmp-serve...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/c-rtmp-server?hl=en

------
Eugen-Andrei Gavriloaie
Web: http://www.rtmpd.com

jay

unread,
Jul 17, 2011, 9:42:44 AM7/17/11
to C++ RTMP Server
I tried that first. I am getting the error below.

http://pastebin.com/cFWN2PUd

C++ RTMP Server

unread,
Jul 17, 2011, 9:54:26 AM7/17/11
to c-rtmp...@googlegroups.com
Jay,

Thank you for the report. It seems to me that the camera considers one of the crtmpserver's RTSP request as bogus:

<STR name="reason">Bad Request</STR>
<UINT32 name="statusCode">400</UINT32>

Unfortunately, I didn't log that request inside the server. If you can, please create a complete dump of the network traffic and send it to me. You can do that with either wireshark or with the command below:

tcpdump -ni eth0 -w /tmp/dump.pcap tcp port 5544

Thank you for your patience

Cheers,
Andrei


On Jul 17, 2011, at 4:42 PM, jay wrote:

> I tried that first. I am getting the error below.
>
> http://pastebin.com/cFWN2PUd
>

C++ RTMP Server

unread,
Jul 17, 2011, 9:56:08 AM7/17/11
to c-rtmp...@googlegroups.com
Correction: the pcap command is this:

tcpdump -ni eth0 -w /tmp/dump.pcap tcp port 7070

(I typed in the wrong port number)


On Jul 17, 2011, at 4:42 PM, jay wrote:

> I tried that first. I am getting the error below.
>
> http://pastebin.com/cFWN2PUd
>

jay

unread,
Jul 17, 2011, 10:37:25 AM7/17/11
to C++ RTMP Server
Thanks Andrei. Here is the attachment.

http://static.ezcamlive.com/dump.pcap

C++ RTMP Server

unread,
Jul 17, 2011, 10:47:33 AM7/17/11
to c-rtmp...@googlegroups.com, jay
Wow! Something is going awfully wrong! Huge chunks of traffic are missing. There is either a hideous bug lurking inside crtmpser's guts or there is something wrong with the pcap file.

Either cases, that pcap is no use to me :(

Can you by chance make that camera available via internet? Can you do a simple port forward? If that is not possible, can I gat ssh access to your machine?

This is a very interesting situation that I want to investigate

So, please let me know by sending a response directly to me with the contact details, not to the mailing list

Cheers,
Andrei

On Jul 17, 2011, at 5:37 PM, jay wrote:

> Thanks Andrei. Here is the attachment.
>
> http://static.ezcamlive.com/dump.pcap
>

jay

unread,
Jul 17, 2011, 11:02:29 AM7/17/11
to C++ RTMP Server
I have opened the port 7070 to the camera and send you the URL
directly. Also I captured again with -s 65535 parameter

Please take a look at the capture file again.

C++ RTMP Server

unread,
Jul 17, 2011, 11:11:16 AM7/17/11
to c-rtmp...@googlegroups.com
Problem solved. I found a bug in crtmpserver as well and in the camera as well.

The camera doesn't support RTSP over TCP only over UDP. So. put forceTcp=false in config file

I'll make the final commit with the crtmpserver bug later this evening. I'll let you know when.

Thank you for the support

Cheers,
Andrei

jay

unread,
Jul 17, 2011, 11:19:25 AM7/17/11
to C++ RTMP Server
Thanks. That's great support.

C++ RTMP Server

unread,
Jul 17, 2011, 5:32:25 PM7/17/11
to c-rtmp...@googlegroups.com
Jay,

Try it now. Is working fine now. However, I still have some errors on SPS/PPS deep parsing. I don't know yet what's the cause: camera sending bogus packets or crtmpserver having a bug.

Don't forget about forceTcp=false because the RTSP server inside the camera doesn't support RTP over RTSP (implicitly TCP). It only does RTSP over TCP and RTP over UDP

Can you please let the camera rolling for the next 2 or 3 days? (I have some other stuff to do in the mean time :( )

Cheers,
Andrei

jay

unread,
Jul 17, 2011, 6:47:27 PM7/17/11
to C++ RTMP Server
Tried again with the latest code from trunk and also changed forceTcp
to false. Attached the tcpdump output again. I will leave the camera
running. Take your time.

C++ RTMP Server

unread,
Jul 17, 2011, 6:51:48 PM7/17/11
to c-rtmp...@googlegroups.com
Is it working? Also, I don't see the attachment

Cheers,
Andrei

jay

unread,
Jul 17, 2011, 10:31:59 PM7/17/11
to C++ RTMP Server
Sorry. forgot to mention that it didn't work. new capture is at
http://static.ezcamlive.com/dump.pcap

FYI VLC plays fine. I can send the capture from VLC if you want to
compare.

output is here
http://pastebin.com/SviyzuNp

Cheers,
Jay

C++ RTMP Server

unread,
Jul 18, 2011, 2:44:10 AM7/18/11
to c-rtmp...@googlegroups.com
Jay,

Are you sure you did the update? Because I made pretty important changes and the new pcap file is looking identical to the old one. Besides, here is working just fine now.

Cheers,
Andrei

jay

unread,
Jul 18, 2011, 7:15:02 AM7/18/11
to C++ RTMP Server
I did a svn update and ran cmake . and make. I will checkout again and
try later today.

jay

unread,
Jul 18, 2011, 7:38:57 AM7/18/11
to C++ RTMP Server
Excellent! It works now. I forgot to run sh cleanup.sh before.

Cheers,
Jay

C++ RTMP Server

unread,
Jul 18, 2011, 10:01:26 AM7/18/11
to c-rtmp...@googlegroups.com
is not excellent unfortunately... Is only good enough. I've detected serious problems inside SPS/PPS packets. crtmpserver does a deep parsing of those NAL types. And is unable to parse SPS. As a consequence, you don't have width/height extraction from SPS. Hence, the flash player doesn't know the size and stretches the video :(

To shade some light on that matter, I manually parsed SPS NAL and indeed, according to ISO 14496 part 10, the SPS ends prematurely. I tend to believe the camera is doing something nasty in there... Fortunately, the bug is not so critical and quicktime/vlc/crtmpserver/flashplayer can handle that. ffmpeg on the other hand, is not capable of doing playback from it :(

Cheers,
Andrei

jay

unread,
Jul 18, 2011, 9:20:40 PM7/18/11
to C++ RTMP Server
I changed below line in streamcapabilities.cpp and I don't see any
errors now.

READ_INT("cpb_size_scale", uint8_t, 3);
Message has been deleted

jay

unread,
Jul 18, 2011, 10:35:30 PM7/18/11
to C++ RTMP Server
still getting this error
/root/ezcam/crtmpserver/sources/thelib/src/protocols/rtp/streaming/
innetrtpstream.cpp:232 Bogus nalu

Also after about an hour of streaming, time stamp on the video changes
every 3-5 seconds or so. If I stop and play it starts streaming
correctly again.
Reply all
Reply to author
Forward
0 new messages