Results 1 to 6 of 6

Thread: GetLiveStreamTranscoderList works, but GetLiveStreamTranscoder returns null

  1. Default GetLiveStreamTranscoderList works, but GetLiveStreamTranscoder returns null

    Note: This question has been asked before in http://www.wowza.com/forums/showthre...nscoded-stream but was never answered (in the forums)
    class StreamListener implements IMediaStreamActionNotify2 {
      // ...
      
      @Override
      public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
        String[] transcoders = stream.getLiveStreamTranscoderList().split(",");
    
        if (stream.isTranscodeResult() == true) {
          for (String transcoderName : transcoders) {
            getLogger().info("Ingrex SmilFactory: stream " + streamName + " has transcoder: " + transcoderName);
    
            ILiveStreamTranscoder transcoder = stream.getLiveStreamTranscoder(transcoderName);
    
            if (transcoder == null)
              break;
    
            getLogger().info("Ingrex SmilFactory: stream " + streamName + " has source stream: " + transcoder.getStreamName());
          }
        }
      }
    }
    How can it be that variable transcoderName within the for() loop returns "transcoder" (a valid string that represents the transcoder name), while stream.getLiveStreamTranscoder(transcoderName) returns null?

    Wowza Streaming Engine 4.0.3 build 10989

  2. #2

    Default

    Hi,

    I suspect as you are calling it on the transcoded stream, rather than the non transcoded stream. Looking at the API it suggests that this is only available for non transcoded streams.

    Andrew.

  3. Default

    Tried the following code instead; but "transcoder" is still NULL!
    @Override
    public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
      String[] transcoders = stream.getLiveStreamTranscoderList().split(",");
    
      if (stream.isTranscodeResult()) 
        return;
    
      for (String transcoderName : transcoders) {
        getLogger().info("Stream " + streamName + " has transcoder: " + transcoderName);
    
        ILiveStreamTranscoder transcoder = stream.getLiveStreamTranscoder(transcoderName);
    
        if (transcoder == null) {
          getLogger().info("Ingrex SmilFactory: sorry, transcoder for stream " + streamName + " is NULL");
          continue;
        }
    
        getLogger().info("Ingrex SmilFactory: stream " + streamName + " has source stream: " + transcoder.getStreamName());
      }
    }

  4. #4

    Default

    Hi,

    A couple of things

    getLiveStreamTranscoder actually requires a stream name, not a transcoder name, documentation could be better and i'll flag that up.

    The code

    String[] transcoders = stream.getLiveStreamTranscoderList().split(",");

    returns all available transcoder named objects, of which 99.9% of the time you will get back transcoder.

    So if you do something like

    	public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
    		{
    			String[] transcoders = stream.getLiveStreamTranscoderList().split(",");
    	
    			  // assume streamName is <source>_<rendition>
    			if (stream.isTranscodeResult() )
    				{
    				String sourceStream = streamName.split("_")[0];
    				IMediaStream sourceStreamobj = stream.getStreams().getStream(sourceStream);
    				for (String transcoderName : transcoders) 
    					{
    				    getLogger().info("Stream " + streamName + " has transcoder: " + transcoderName);
    				    ILiveStreamTranscoder transcoder = sourceStreamobj.getLiveStreamTranscoder(transcoderName);
    				    if (transcoder == null) 
    				    	{
    				    	getLogger().info("Ingrex SmilFactory: sorry, transcoder for stream " + streamName + " is NULL");
    				    	continue;
    				    	}
    				    getLogger().info("Ingrex SmilFactory: stream " + streamName + " has source stream: " + sourceStreamobj.getName()+" transcoder object '"+transcoder);
    					}
    				}
    		}
    That should return the getLiveStreamTranscoder although not entirely sure its what you are after.

    Andrew.

  5. Default

    I don't see how your code is different from mine, except that you've added a line that splits the streamname on underscore and tries to find the source stream for the transcoded stream. Besides of that, you're still trying to get the ILiveStreamTranscoder object from the source stream, which I already tried in my previous post. However, what your write above the code sample looks controversial to the code sample itself: if getLiveStreamTranscoder takes a streamname, not a transcodername, it would mean that stream.getLiveStreamTranscoder("teststream") would return the ILiveStreamTranscoder instance instead of stream.getLiveStreamTranscoder("transcoder")

    My intention is: if I have a transcoded stream, I want to be able to find the source stream from that WITHOUT having to do a split on the streamname. Splitting on underscore is a weak solution; e.g. your sample code will fail if someone uses a streamname "test_stream".

  6. #6

    Default

    Hi,

    Yes you are completely correct. I mis-read both documentation and my testing, unfortunately the problem when trying to do multiple things at the same time.

    The object you can only ever get back is the transcoder object, which is not the transcoder object for each stream, but the overall transcoder object inherited.

    From a stream you can not determine where the source of the transcoding is.

    To determine transcoded streams the simplest way is to use ILiveStreamTranscoderNotify when the transcoding session starts up. You get the source stream and using ILiveStreamTranscoderActionNotify you can then also determine the destination stream name.

    I must apologise for the confusion and how you are trying to determine source stream there, wont work from a simple stream object.

    Andrew.

Similar Threads

  1. GetAppInstance returns null!
    By Atmapuri in forum Wowza Streaming Server Java API
    Replies: 3
    Last Post: 04-23-2014, 11:42 AM
  2. Live stream works everywhere except iOS HLS (where only audio works).
    By chocis in forum Live Streaming and Encoders
    Replies: 3
    Last Post: 04-23-2014, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •