Wowza Community

Using Xuggler/FFmpeg encoding with Wowza

Hello,

is Xuggle capable of transcoding the live video and broadcasting it to Wowza?

Hi,

I am trying to publish a screencapture video to wowza. I have a code, but it stop at a certain point. It canot process the following line:

int bytesDecoded = videoDecoder.decodeVideo(videoPicture, packet, 0);

If you can help me in this matter please let me know.

When I tried the code (from here: http://www.brokenmill.com/2010/08/xuggler-rtmp-howto/comment-page-1/#comment-14350) , I get an error on line 34 (real-work part – when a decodeVideo() method is called.)

This is the line that xuggler writes out:

13:24:43.759 [Thread-2] ERROR org.ffmpeg – [mpeg4 @ 045B74A0] header damaged

java.lang.Exception: Cannot decode video picture (pacet size: 43629)

Before that I create the IBuffer from a screenshot. This is what I do:

BufferedImage screen = robot.createScreenCapture(areaToRecord);

BufferedImage image = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), TYPE_3BYTE_BGR);

image.getGraphics().drawImage(sourceImage, 0, 0, null);

ByteArrayOutputStream baos = new ByteArrayOutputStream();

ImageIO.write(image, “jpg”, baos);

baos.flush();

byte[] data = baos.toByteArray();

baos.close();

IBuffer iBuffer = IBuffer.make(null, data, 0, data.length);

IPacket packet = IPacket.make(iBuffer);

packet.setTimeStamp(timeStamp);

packet.setKeyPacket(true);

packet.setTimeBase(IRational.make(1,1000));

packet.setTimeStamp(timeStamp);

packet.setDuration(tsInterval);

packet.setPts(lastVideoPts);

packet.setDts(lastVideoPts);

packet.setPosition(lastPos);

lastPos += data.length;

videoFrameCnt++;

int pksz = packet.getSize();

packet.setComplete(true, pksz);

IVideoPicture videoPicture = IVideoPicture.make(IPixelFormat.Type.YUV420P, width, height);

int bytesDecoded = videoDecoder.decodeVideo(videoPicture, packet, 0);

if (bytesDecoded < 0) {

throw new Exception("Cannot decode video picture (pacet size: " + pksz + “)”);

}

Can you please let me now what I am doing incorrectly? Ultimately I would like to publish this to a wowza server. I tried to take out the decoding and resampling part and just send the packet (created from the IBuffer) to the output stream. The server accepted it, but the file saved on the server was not playable.

Thanks,

Zoltan

This is very easy. Take a look at the VideoChat example in the [install-dir]/examples folder.

Charlie

Hopefully someone else will jump in. I have no idea.

Charlie

I really don’t know. I kind of doubt that FFMPEG has implemented RTMP authentication.

Charlie

You could do it like that, or you can do it like this:

netconnection.connect(“rtmp://ip/app”,“username”,“password”);

Take a look at these posts:

http://www.wowza.com/community/t/-/111

http://www.wowza.com/forums/showthread.php?t=7812

Richard

I think you can use another IP. Try:

udp://0.0.0.1:1935

Richard

I’m not sure what you are doing, streaming live converting h.263 to h.264. It is possible to get comparable quality in that conversion with ffmpeg, but it would always be better start with the source.

Maybe Art will respond to this thread as well. I’m not sure about xuggle.

Richard

Try SecureURLParams instead

https://www.wowza.com/docs/how-to-secure-publishing-from-an-rtmp-encoder-that-does-not-support-authentication-modulesecureurlparams

You will put querystring after the application part, before the stream name

Richard

Hi, I m able to stream live with xuggler and wowza

but the problem is that output stream has poor video quality

I have made few changes in presets files as well but no result

Can anyone help me in improving the quality?

I dont want quality to be improved when converting from h263 to h264 but atleast it should maintain the quality

Can anybody tell me , is it necessary to have degraded quality incase of transcoding from H263 to h264 format?

Thanks

Can you give a hint how to publish a livestream with Xuggler, using the commandline in Linux, to Wowza?

It is possible to stream a file with Xuggler to Wowza, but i havent found a way to do a livestream with Xuggler. It should be possible, i think :stuck_out_tongue:

Yes, it is possible to set up a livestream with Xuggle’s ffmpeg build. I strongly recommend reading the tutorial @xuggle posted carefully.

To capture and stream a dv source or webcam you could try using dvgrab and pipe its output to ffmpeg. For example:

dvgrab - | ffmpeg -i - -re [your encoding params] -f flv rtmp://localhost/live/testStream

Actually, I haven’t tried this myself. But it should work. Hope that helps.

Can you give a hint how to publish a livestream from, for example, a webcam to Wowza?

I think Xuggler is the only RTMP streaming encoder that works with Linux

Okay, i think i wasn`t that clear :smiley:

What i wanted to ask;

Can you give a hint how to publish a livestream with Xuggler, using the commandline in Linux, to Wowza?

It is possible to stream a file with Xuggler to Wowza, but i havent found a way to do a livestream with Xuggler. It should be possible, i think :stuck_out_tongue:

No problem, thanks for thinking with me :slight_smile:

Yes, it is possible to set up a livestream with Xuggle’s ffmpeg build. I strongly recommend reading the tutorial @xuggle posted carefully.

To capture and stream a dv source or webcam you could try using dvgrab and pipe its output to ffmpeg. For example:

dvgrab - | ffmpeg -i - -re [your encoding params] -f flv rtmp://localhost/live/testStream

Actually, I haven’t tried this myself. But it should work. Hope that helps.

Thanks for thinking with me, but it doesnt seem to work. I got the error:

“pipe:: Unknown format”

When I hit google with that error, i notice that i`m not the only one with that error lol :smiley:

Allright, i got things going. I can stream with only the use of ffmpeg. I didn`t need dvgrab. I got a new quest;

Is it possible to give the username and password in the RTMP URL?

Something like;

rtmp://ipaddress/something/stream.stream?username=a&password=b

How about ffmpeg?

I got a new issue aswell;

I got ffmpeg working, so it can publish a stream to wowza :slight_smile: But how to publish multiple streams? Let me clarify myself;

I can publish a stream with rtmp://ipaddress/something/something.stream. In something.stream is one line that says: “udp://0.0.0.0:1935”.

But how to publish another stream? When i make someting2.stream with udp://0.0.0.0:1935", i`m getting the error; already in use (doh).

How to solve this issue?

Hm … an empty stream file does work too :confused:

I got FFMPEG working on LINUX publishing it to the Wowzaserver with something like;

ffmpeg -i /dev/video0 -qscale 1 -r 25 -vcodec libx264 -vpre fastfirstpass -b 636k -aspect 4:3 -s 640x480 -ar 44100 -ab 64k -async 1 -g 6 -f flv -threads 2 rtmp://ip/app/camera

Now i want to try to authenticate the publishing side to the server. I got it working with Flash Media Encoder (windows) with the following application config:

<Module>
<Name>ModuleRTMPAuthenticate</Name>
<Description>ModuleRTMPAuthenticate</Description>
<Class>com.wowza.wms.plugin.security.ModuleRTMPAuthenticate</Class>
</Module>

and the

<Property>
<Name>rtmpEncoderAuthenticateFile</Name>
<Value>${com.wowza.wms.context.VHostConfigHome}/conf/${com.wowza.wms.context.Application}/publish.password</Value>
/Property>

This is working fine under windows; a popup appears and i can start publishing the stream after giving the credentials.

Now i want to pass the authentication parameters with FFMPEG in Linux to Wowza, so i can authenticate the publishing side under linux. Is there a way to do this?