How can I read a live webstream in java using xuggle? (I can do it in ffmpeg, just not xuggle)
Asked Answered
B

1

8

So if I run:

ffmpeg -t 10 -re -i "rtmp://170.93.143.150/rtplive/ app=rtplive/ playpath=e000990f025f0075004d823633235daa swfUrl=http://www.chart.state.md.us/video/mediaplayer/player.swf pageUrl=http://www.chart.state.md.us/video/video.asp?feed=e000990f025f0075004d823633235daa stop=5000 flashver=`LNX 11,2,202,262` live=true" test.flv -report

It gives me a 5 second snapsnot of video from that webstream that gets put into test.flv. Now I would like to do the same thing in java using xuggle except everytime I try and open the container it errors out on me and sets x to -1:

 public IMediaReader grabStream(IMediaReader reader) throws IOException
  {
    String rtmp = "rtmp://170.93.143.150/rtplive/";
    rtmp = rtmp + " app=rtplive/";
    rtmp = rtmp + " playpath=e000990f025f0075004d823633235daa";
    rtmp = rtmp + " swfUrl=http://www.chart.state.md.us/video/mediaplayer/player.swf";
    rtmp = rtmp + " pageUrl=http://www.chart.state.md.us/video/video.asp?feed=e000990f025f0075004d823633235daa";
    rtmp = rtmp + " flashver=`LNX 11,2,202,262`";
    rtmp = rtmp + " live=true";

    IContainer container = IContainer.make();
    IMediaReader newReader = ToolFactory.makeReader(container);

    int x = container.open(rtmp, IContainer.Type.READ, null, true, false);

    if (x < 0)
    {
      IError ie = IError.make(x);
      System.out.println("Open error: " + ie.getType().toString());
      throw new RuntimeException("failed to open with error" + x);
    }

    return newReader;
  }

Maybe the best way to do it is to stream in ffmpeg to a xuggle container using inputstream somehow? Or maybe there is another way to stream in a webstream to java?

Backstage answered 14/2, 2013 at 16:12 Comment(0)
E
6

The rtmp source string should be in the following format

String rtmpSourceUrl = "rtmp://hostname/appName/streamName"; 

Then I would recommend creating the reader like the following

IContainerFormat inFormat = IContainerFormat.make();
inFormat.setInputFormat("flv"); // set the input format to avoid FFMPEG
                                    // probing
IMediaReader reader = ToolFactory.makeReader(rtmpSourceUrl);
reader.setQueryMetaData(false);
reader.setBufferedImageTypeToGenerate(-1);
reader.getContainer().setForcedVideoCodec(ID.CODEC_ID_FLV1);
reader.getContainer().open(rtmpSourceUrl , IContainer.Type.READ, inFormat,
            true, false);

Does this solve your problem?

Eccrinology answered 25/2, 2013 at 17:44 Comment(4)
rtmp://170.93.143.150/rtplive/e000990f025f0075004d823633235daa should probably work then assuming this is the streamNameEccrinology
According to groups.google.com/forum/?fromgroups=#!searchin/xuggler-users/… those parameters that I have are correct. It should just pass the urlString into librtmp.Backstage
I also tried the creating the reader how you suggested, and no luck, any other ideas?Backstage
What error do you get, we are using this in production code + error handlingEccrinology

© 2022 - 2024 — McMap. All rights reserved.