Results 1 to 4 of 4

Thread: Get stream extension by media reader

  1. #1

    Default Get stream extension by media reader


    My doubt is comed from the post :
             private String getExtension(IMediaStream stream, String ext)
    		if (ext == null)
    			String mediaReaderType = stream.getExt().toLowerCase();
    			MediaReaderItem mediaReaderItem = stream.getStreams().getVHost().getMediaReaders().getMediaReaderDef(mediaReaderType);
    			return mediaReaderItem.getFileExtension();
    		return ext;
    	public void onWriteComplete(IMediaStream stream, File file)
    		if (fileMoverDestinationPath != null)
    			String streamName = FileUtils.toValidFilename(stream.getName());
    			String streamExt = getExtension(stream, fileMoverFileExtension);
    What's the difference of stream.getExt()/getExtension(stream,null) method?

    Last edited by spiritsoul; 08-19-2013 at 08:07 PM.

  2. #2



    When you play a file based stream on Wowza, the stream is opened by a MediaReader. When recording a stream, it is written to by a MediaWriter. The MediaReaders and MediaWriters are the interfaces between the file and Wowza.

    There are different MediaReaders and MediaWriters for each type of file format that Wowza supports. To determine which one to use for a particular file, Wowza will ignore the file extension completely in most cases as these are not reliable and instead just use the prefix that is supplied. If there is no prefix then the default Reader or Writer for the player requesting the stream will be used. This is an flv reader or writer for rtmp players or any publishers and an mp4 reader or writer for other players.

    stream.getExt() actually returns the prefix value that was used to create the stream. This must be one of the types defined in conf/MediaReaders.xml. Most of the time, this will match the actual file extension but sometimes it wont, depending on the MediaReader.

    mediaReaderItem.getFileExtension() gets the actual file extension associated with this mediaReader. When files are recorded, it is this extension that is used so you can be pretty confident that the recorded file will have the right extension.

    There are MediaReaders for specific purposes such as reading metadata from a file so these have special prefixes but the same file extension as the main MediaReader.

    MP4 and FLV are actually file container formats and each can be referenced with different file extensions outside of Wowza. mp4, mov, m4v, m4a, 3gp, aac are all valid file extensions for an mp4 container format. All of these would be prefixed by mp4: to use in Wowza.

    It is all a bit confusing because most of the time, the extension matches the prefix but the file will not play if the prefix is not supplied and it is not the default file format. Some players, such as JW Player will automatically add the prefix if it is not set.

    When playing back, as long as you remember to prefix every stream name unless it is actually an flv then you should be fine.

    For the onWriteComplete handler, you should be able to trust stream.getExt() as this is what should have been used to record the stream. You can validate this against the file name that was recorded.


  3. #3


    Hi Roger

    Thank your detail explanation. Could I conclude that the most case stream.getExt() diff from getExtension(stream,null) is caused by player that add a MediaReader-unknown prefix into the stream ?
    Stream myfile.m4v
    Stream m4v:myfile.m4v
    In this case we have to add an entry of MediaReader that named m4v and assign file type to mp4
    			<Description>MP4 Media Reader</Description>
    				....(all same as the mp4)
    not sure if my understanding is right, please correct me if anything wrong.


    Last edited by spiritsoul; 08-19-2013 at 11:39 PM.

  4. #4



    The prefix won't get added automatically by looking at the actual file extension so I am not quite sure what doing this will actually achieve as you will still have to add the prefix.


Similar Threads

  1. FMLE stream name extension and bitrate enhancing
    By ricemb in forum Live Streaming and Encoder Discussion
    Replies: 1
    Last Post: 01-20-2014, 08:28 PM
  2. media reader timecode change on fly
    By notreg in forum Server-side Modules and Code Samples Discussion
    Replies: 3
    Last Post: 10-15-2012, 05:26 AM
  3. Is there an easy way to remove the .stream extension?
    By Bencredible in forum Server-side Modules and Code Samples Discussion
    Replies: 1
    Last Post: 01-17-2012, 06:22 PM
  4. unable to stream rtsp live stream url without extension
    By Rashmi in forum Live Streaming and Encoder Discussion
    Replies: 1
    Last Post: 12-26-2011, 06:38 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