Bitrate JWplayer

北慕城南 提交于 2019-12-08 03:35:00

问题


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.


回答1:


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!



来源:https://stackoverflow.com/questions/24781580/bitrate-jwplayer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!