Encoding H264 media and broadcasting to a RTMP server (Red5 or other)

79 views
Skip to first unread message

Art Clarke

unread,
Feb 2, 2010, 2:54:58 PM2/2/10
to re...@osflash.org, red5in...@googlegroups.com
Hi folks,

Lots of people have been asking.  Here's how to use the latest Xuggler as a 'open-source' replacement for Adobe Flash Media Encoder:
http://blog.xuggle.com/2010/02/02/new-rtmp-tutorial/

- Art

--
http://www.xuggle.com/
xu‧ggle (zŭ' gl) v. To freely encode, decode, and experience audio and video.

Use Xuggle to get the power of FFmpeg in Java.

Andy Shaules

unread,
Feb 2, 2010, 3:04:40 PM2/2/10
to red5in...@googlegroups.com
Awesome one stop sample page!
 
Doesnt ffmpeg also have VFW and Dshow device handling?
 
can you fire up a live device publish?

Art Clarke

unread,
Feb 2, 2010, 3:07:41 PM2/2/10
to red5in...@googlegroups.com
inline.

On Tue, Feb 2, 2010 at 12:04 PM, Andy Shaules <bowl...@gmail.com> wrote:
Awesome one stop sample page!
 
Thanks.
 
Doesnt ffmpeg also have VFW and Dshow device handling?

If has VFW support but IMO it kinda blows.  You can use FFmpeg or Xuggler with it though -- see the other tutorials on accessing webcams.
 
 
can you fire up a live device publish?

Depends on if it supports VFW.

- Art

Zayzon, Gergely

unread,
Feb 2, 2010, 5:01:41 PM2/2/10
to red5in...@googlegroups.com
Excuse me for my lack of knowledge and understanding in this respect,
but could someone tell me what options are there if one wants to publish
live mpeg4 stream to a streaming server (like our beloved Red5)? Suppose
I want to enter the 21st century and get rid of sorenson in a (flash)
chat application? If I correctly put the chunks of information together,
the only way is to stop using flash on the publishing point? Is it so?

Thanks,
Gergely Zayzon

Maciej Sawicki

unread,
Feb 2, 2010, 5:10:29 PM2/2/10
to red5in...@googlegroups.com
On Tue, Feb 2, 2010 at 23:01, Zayzon, Gergely <ger...@harras.be> wrote:
>If I correctly put the chunks of information together, the only
> way is to stop using flash on the publishing point? Is it so?
>
Exactly, h263 is max what You can get from flashplayer for publishing.

regards,
Maciej Sawicki

Виталий Ищенко

unread,
Feb 3, 2010, 12:47:19 PM2/3/10
to red5in...@googlegroups.com
Are there any reasons, why you are compiling ffmpeg without optimizations?

Art Clarke

unread,
Feb 3, 2010, 1:54:28 PM2/3/10
to red5in...@googlegroups.com
Sorry, the download version (3.4) actually uses all optimizations.

I wrote the tutorial cutting and pasting from my dev environment (you'll notice I'm using xuggler 4.0 for the examples), and my dev machine currently has optimizations off because I'm actively developing a different feature and want debugging symbols and no optimizations for easier debugging.

Andrew Voronin

unread,
Feb 5, 2010, 4:21:06 AM2/5/10
to red5in...@googlegroups.com

What minimal version of xaggler that supports this feature ?

Thx.
Andrew.
--
View this message in context: http://old.nabble.com/Encoding-H264-media-and-broadcasting-to-a-RTMP-server-%28Red5-or--other%29-tp27426421p27465345.html
Sent from the Red5 - Interest/Users mailing list archive at Nabble.com.

Art Clarke

unread,
Feb 5, 2010, 9:37:29 AM2/5/10
to red5in...@googlegroups.com
Xuggler 3.4.

- Art

Andrew Voronin

unread,
Feb 8, 2010, 10:11:28 AM2/8/10
to red5in...@googlegroups.com

Hm. Already get an error when "ffmpeg -i avatar.flv -re -acodec copy
-vcodec copy -f flv rtmp://localhost/oflaDemo/testStream":

[INFO] [Launcher:/installer] org.red5.server.service.Installer - Installer
servi
ce created
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Connecting
to: [W
ebScope@9dca26 Depth = 1, Path = '/default', Name = 'vod']
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Connecting
to: [W
ebScope@18346a3 Depth = 1, Path = '/default', Name = 'oflaDemo']
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Connecting
to: [W
ebScope@9dca26 Depth = 1, Path = '/default', Name = 'vod']
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Remembering
clien
t buffer on stream: 0
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Connecting
to: [W
ebScope@18346a3 Depth = 1, Path = '/default', Name = 'oflaDemo']
[INFO] [NioProcessor-1] org.red5.server.net.rtmp.RTMPHandler - Connecting
to: [W
ebScope@18346a3 Depth = 1, Path = '/default', Name = 'oflaDemo']
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream -
Provider
connect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream -
Stream st
art
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream -
Provider
connect
[ERROR] [NioProcessor-1] org.red5.server.net.rtmp.codec.RTMPProtocolDecoder
- Er
ror decoding buffer
org.red5.server.net.protocol.ProtocolException: Error during decoding
at
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtoco
lDecoder.java:203) [red5.jar:na]
at
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeBuffer(RTMPP
rotocolDecoder.java:122) [red5.jar:na]
at
org.red5.server.net.rtmp.codec.RTMPMinaProtocolDecoder.decode(RTMPMin
aProtocolDecoder.java:61) [red5.jar:na]
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Prot
ocolCodecFilter.java:225) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessage
Received(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(Def
aultIoFilterChain.java:46) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.mes
sageReceived(DefaultIoFilterChain.java:793) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFi
lterAdapter.java:119) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessage
Received(DefaultIoFilterChain.java:434) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageRece
ived(DefaultIoFilterChain.java:426) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(Abstract
PollingIoProcessor.java:638) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(Abstr
actPollingIoProcessor.java:598) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(Abstr
actPollingIoProcessor.java:587) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(Ab
stractPollingIoProcessor.java:61) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run
(AbstractPollingIoProcessor.java:969) [mina-core-2.0.0-RC1.jar:na]
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnabl
e.java:64) [mina-core-2.0.0-RC1.jar:na]
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886) [na:1.6.0_14]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908) [na:1.6.0_14]
at java.lang.Thread.run(Thread.java:619) [na:1.6.0_14]
Caused by: java.lang.IllegalArgumentException: null
at java.nio.Buffer.limit(Buffer.java:249) [na:1.6.0_14]
at org.red5.io.amf.Input.bufferToString(Input.java:275)
[red5.jar:na]
at org.red5.io.amf.Input.getString(Input.java:258) [red5.jar:na]
at org.red5.io.amf.Input.readPropertyName(Input.java:565)
[red5.jar:na]
at org.red5.io.amf.Input.readKeyValues(Input.java:351) [red5.jar:na]
at org.red5.io.amf.Input.readSimpleObject(Input.java:501)
[red5.jar:na]
at org.red5.io.amf.Input.readObject(Input.java:537) [red5.jar:na]
at
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeStreamMetada
ta(RTMPProtocolDecoder.java:978) [red5.jar:na]
at
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeMessage(RTMP
ProtocolDecoder.java:564) [red5.jar:na]
at
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodePacket(RTMPP
rotocolDecoder.java:385) [red5.jar:na]
at
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtoco
lDecoder.java:190) [red5.jar:na]
... 18 common frames omitted
[WARN] [NioProcessor-1] org.red5.server.net.rtmp.codec.RTMPProtocolDecoder -
Clo
sing connection because decoding failed: RTMPMinaConnection from 127.0.0.1 :
110
1 to localhost (in: 3821 out 3521 )
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream - Close
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream -
Provider
disconnect
[INFO] [NioProcessor-1] org.red5.server.stream.ClientBroadcastStream -
Provider
disconnect

----------------------------------------------
Red5 Server 1.0.0 RC1 $Rev: 4033 $ (http://code.google.com/p/red5/)
FFmpeg version SVN-r21566-xuggle-3.4.843


--
View this message in context: http://old.nabble.com/Encoding-H264-media-and-broadcasting-to-a-RTMP-server-%28Red5-or--other%29-tp27426421p27501325.html

Art Clarke

unread,
Feb 8, 2010, 12:19:23 PM2/8/10
to re...@osflash.org, red5in...@googlegroups.com
Hi Larry,

Lots of folks are reporting this error with Red5-trunk; I don't know what's causing it, but hopefully a solution will emerge (patches welcome).  To be completely open I'm unlikely to have cycles anytime soon to devote to figuring this out on Red5 (working mostly with Wowza and FMS right now), but someone else in the community might (hint hint to all those folks who just ask questions -- get involved and FIX).

As for 0.8, I have not tested nor will we.  0.8 has so many known issues that are fixed in trunk that it's really not worth it (for example, timestamps are fundamentally WRONG in all versions of Red5 prior to 0.9).

- Art

On Mon, Feb 8, 2010 at 9:15 AM, Larry Sanderson <larry.s...@gmail.com> wrote:
Thanks for all the hard work, Art!  I have been playing around with the new tutorial, and I'm having some integration issues with the latest Red-5.  

I have tried all combinations of red-5 trunk/0.9.0 and xuggler trunk/3.4 and they consistently give errors when streaming an flv into red-5 using xuggler's ffmpeg.  (Error decoding the RTMP protocol,  IllegalArgumentException: null in java.nio.Buffer.limit(Buffer.java:249), called from org.red5.io.amf.Input.bufferToString(Input.java:275).  Full stack trace below)

I am about to dig in and start debugging this but I have no idea how far I'll get, or how quickly it will happen, so I thought I'd drop a line here and see if anyone is already investigating.

Also, Red-5 0.8.0 does digest the latest xuggler's/ffmpeg's rtmp stream without error.  (though, there appears to be some sync issues in the playback).

-Larry

_______________________________________________
Red5 mailing list
Re...@osflash.org
http://osflash.org/mailman/listinfo/red5_osflash.org



_______________________________________________
Red5 mailing list
Re...@osflash.org
http://osflash.org/mailman/listinfo/red5_osflash.org

Nick Chadwick

unread,
Feb 8, 2010, 5:26:41 PM2/8/10
to re...@osflash.org, red5in...@googlegroups.com
On 9 February 2010 04:23, Larry Sanderson <larry.s...@gmail.com> wrote:

On Mon, Feb 8, 2010 at 12:19 PM, Art Clarke <acl...@xuggle.com> wrote:
Hi Larry,

Lots of folks are reporting this error with Red5-trunk; I don't know what's causing it, but hopefully a solution will emerge (patches welcome).  To be completely open I'm unlikely to have cycles anytime soon to devote to figuring this out on Red5 (working mostly with Wowza and FMS right now), but someone else in the community might (hint hint to all those folks who just ask questions -- get involved and FIX).

Got any hints to get us started? More than happy to go rootlin' around in the Red5 underbrush, but if you've got some tips on where to look first that'd be awesome.
 

As for 0.8, I have not tested nor will we.  0.8 has so many known issues that are fixed in trunk that it's really not worth it (for example, timestamps are fundamentally WRONG in all versions of Red5 prior to 0.9).

Good to know, thanks.  (Actually, I saw posts on xuggler explaining the above, which is why I posted to a red-5 list).

I have every intention of figuring this out and submitting a patch.  Let's see if my skills can keep up with my confidence :-)

_______________________________________________
Red5 mailing list
Re...@osflash.org
http://osflash.org/mailman/listinfo/red5_osflash.org


Regards,

-Nick

Art Clarke

unread,
Feb 8, 2010, 5:28:52 PM2/8/10
to red5in...@googlegroups.com, re...@osflash.org
I'd start with where the exception in that stacktrace showed up.  Also, try to get a 100% reproducible test-case and file a trac bug.

- Art

Art Clarke

unread,
Feb 11, 2010, 1:29:00 AM2/11/10
to re...@osflash.org, red5in...@googlegroups.com
I tested and applied Larry's great fix in r4037; Thanks Larry!

- Art

On Mon, Feb 8, 2010 at 8:13 PM, Larry Sanderson <larry.s...@gmail.com> wrote:
Solved it....

http://trac.red5.org/ticket/693

Summary: On the NOTIFY rtmp message type, ffmpeg/xuggler is sending the encoding parameters as an RTMP Mixed Array (aka ECMA-Array according to the spec).  Red-5 was blindly assuming the params were sent in as an Object.

I added a bit of logic to distinguish between the two.

Mondain

unread,
Feb 11, 2010, 9:02:00 AM2/11/10
to red5in...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages