2

I am having trouble to make jwplayer work with different bitrates.

For each video, I am creating new output files with different suffixes that have lower bitrates: For instance, Output 1 (high bitrate): test-original.mp4 Output 2 (medium bitrate): test-medium.mp4 Output 2 (low bitrate): test-low.mp4

The output file names are dynamic as the users can upload as many different video files as they want.

jwplayer configuration:

jwplayer('video-container').setup({
    'sources':[
       {'file': "rtmps://" + server + "/mp4:" + media + "-original.mp4?t=" + t}
    ],
    startparam: "start",
    'autostart':false,
    'controlbar':'bottom',
    'viral.onpause':false,
    'viral.oncomplete':false,
    'viral.allowmenu':false,
    'width':'470',
    'height':'320',
    'abouttext':''
});

My question is how should I change this so that automatically jwplayer plays the video with the appropriate bitrate depending on the user's bandwith.

As I cannot test this (only in production) , would this change suffice or what is required?:

jwplayer('video-container').setup({
    'sources':[
       {'file': rtmps + "://" + server + "mp4:" + media + "-original.mp4?t=" + t},
       {'file': rtmps + "://" + server + "mp4:" + media + "-medium.mp4?t=" + t},
       {'file': rtmps + "://" + server + "mp4:" + media + "-low.mp4?t=" + t}
    ],
    startparam: "start",
    'autostart':false,
    'controlbar':'bottom',
    'viral.onpause':false,
    'viral.oncomplete':false,
    'viral.allowmenu':false,
    'width':'470',
    'height':'320',
    'abouttext':''
});

I am using the latest version of jwplayer. Any help will be appreciated.

kandan
  • 715
  • 2
  • 12
  • 39

1 Answers1

4

For RTMP, you need to use a SMIL manifest.

http://support.jwplayer.com/customer/portal/articles/1430398-adaptive-rtmp-streaming

This is the player code:

jwplayer("myElement").setup({
    file: "/assets/myVideo.smil",
    image: "/assets/myVideo.jpg",
    height: 360,
    width: 640
});

This is the SMIL:

<smil>
  <head>
    <meta base="rtmp://example.com/vod/" />
  </head>
  <body>
    <switch>
      <video src="myVideo-high.mp4" height="720" system-bitrate="2000000" width="1280" />
      <video src="myVideo-medium.mp4" height="360" system-bitrate="800000" width="640" />
      <video src="myVideo-low.mp4" height="180" system-bitrate="300000" width="320" />
    </switch>
  </body>
</smil>

Don't use HDS / F4M as one of the sources, as the player doesn't support it.

And for HLS, you need to create a HLS manifest with multiple bitrates in it, as well.

http://support.jwplayer.com/customer/portal/articles/1430240-hls-adaptive-streaming

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1600000,RESOLUTION=1280x720,NAME="720p HD"
1280/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=832000,RESOLUTION=640x360,NAME="360p SD"
640/prog_index.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=320000,RESOLUTION=320x180,NAME="180p 3G"
320/prog_index.m3u8

Hope this helps!

emaxsaun
  • 4,191
  • 2
  • 13
  • 13
  • Hello, thanks for your answer. I don't understand how to create the SMIL file. If I put that file in the streaming server then the video returned is always "myVideo.mp4" but the video filename is dynamic in my case so i don't see how can achieve this.. :( cheers – kandan Jul 16 '14 at 14:59
  • The smil needs to be created for RTMP. How are you dynamically creating the streams now? – emaxsaun Jul 16 '14 at 15:10
  • I am dynamically putting videos in the streaming server, in an output folder. The filenames are numbered sequentally like 1.mp4, 2.mp4, etc. I don't see how to generate dynamically an xml i can invoke from a javascript file and that contains the file name. Also i have a list of file names within the sources attribute as to support serveral browsers so i use rtmps, http, etc. – kandan Jul 16 '14 at 15:14
  • You would need to do the same thing then, but in the SMIL format. Here is a sample one you can use as a template - http://www.longtailvideo.com/sites/default/files/jw6-manifest.smil – emaxsaun Jul 16 '14 at 15:16
  • thank you about this. You know if it is possible from a js file to call to do a java call that would return the xml? I don't have xml stored in the server and the webapp that plays the videos(with the jwplayer) is in a different machine from the streaming server(unfortunately) :( – kandan Jul 16 '14 at 18:47
  • It has to be a smil file (xml), stored on the server. – emaxsaun Jul 16 '14 at 19:00
  • Thanks a lot for your help, very kind. I managed to return an XML from java basically using servlet mapping annotations. I shall try testing as from a slow mobile phone the low bitrate file is ignored :(( i am using Wowza sorry i did not mention. If you have a clue, current mapping in the smil file is mp4:normal.mp4(system-bitrate="1600000"),mp4:medium.mp4(system-bitrate="800000"),mp4:low.mp4(system-bitrate="400000"),(mp4:vlow.mp4" system-bitrate="100000") – kandan Jul 17 '14 at 19:56
  • Hellos yes i have but not sure if is viewable from outside: https://svc.mat.meganexus.com/neo_1_0/mis/generateSmilRtmps/video.smil returns " " and even tough the first bitrate is huge it always return the first video file not the second one. – kandan Jul 18 '14 at 11:57
  • The video file is returned by a streaming server (wowza) so i am not sure if there is something to make in this server as well :( – kandan Jul 18 '14 at 12:11
  • Hello again. Sorry cannot provide that link as is an internal link here not viewable from outside :( basically i have: file: 'http://server/video.smil' where video.smil returns two sources, one with system-bitrate very high (to test it does not get played, but it does :() and the other with system-bitrate 200000. You know if those bitrate have to match the real video bitrates or can be different so we could for instance return a high quality video to a low bandwith and the other way round? – kandan Jul 21 '14 at 10:18
  • Sorry, I really need to see an actual example in order to debug properly. – emaxsaun Jul 21 '14 at 14:43
  • I realised in this case all – kandan Aug 02 '14 at 16:41
  • Great, glad you got it, np. – emaxsaun Aug 04 '14 at 05:15