Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bandwidth parameter is not propagated to HLS EXT-X-STREAM-INF:BANDWIDTH #389

Closed
synologic opened this issue Apr 28, 2018 · 9 comments
Closed
Assignees
Labels
status: archived Archived and locked; will not be updated status: working as intended The behavior is intended; this is not a bug

Comments

@synologic
Copy link

System info

Operating System: Debian 8.10
Shaka Packager Version: version v2.0.3-ef93a1d-release

Issue and steps to reproduce the problem

Packager Command:
'in=udp://127.0.0.1:10001,stream=video,segment_template=out/video_1920_1080_$Bandwidth$_$Time$.ts,playlist_name=1920_1080.m3u8,bandwidth=4000000'

Extra steps to reproduce the problem?
None

What is the expected result?
#EXT-X-STREAM-INF:BANDWIDTH=4000000,CODECS="avc1.64001f,mp4a.40.2",RESOLUTION=19200x1080,AUDIO="audio"

What happens instead?
#EXT-X-STREAM-INF:BANDWIDTH=4150854,CODECS="avc1.64001f,mp4a.40.2",RESOLUTION=19200x1080,AUDIO="audio"

$Bandwidth$ however seems fine when generating segments:

video_1920_1080_4000000_68929200.ts

@vaage
Copy link
Contributor

vaage commented Apr 30, 2018

@kqyang What is the use case for giving bandwidth? What benefit is there giving an estimated bandwidth when we can calculate the actual bandwidth?

@synologic
Copy link
Author

I can give you at least a corner case there, while i was running some tests with ABR, i ended up having an estimated bandwidth on a 720p stream, higher than the one on an 1080p stream, and the player considered the 720p to be the better stream :)

Since this was done for DASH, i don't see why not have the same thing for HLS as an option

@kqyang
Copy link
Collaborator

kqyang commented Apr 30, 2018

@vaage There are a few problems with estimated bandwidth:

  • It is estimated from actual segments and the segment bitrate varies from segment to segment, thus the estimated bandwidth fluctuates from segment to segment. This may not be desirable sometimes.

  • A stable bandwidth is required when using $BANDWDITH$ template for media segments for DASH.

Given that users know the bitrate setting when doing transcoding, which is usually more accurate in long run than our estimates based on current available segments, we allow users to inject BANDWIDTH, which when provided, bandwidth estimation should be disabled.

@synologic For the corner case you given, it sounds more like a bug in the transcoder :) It should never happen that the 720p segments have a higher max bitrate than 1080p segments.

In any case, if BANDWIDTH is injected, bandwidth estimation should be disabled and user provided BANDWIDTH should be used.

@kqyang kqyang added type: bug Something isn't working correctly and removed needs triage labels Apr 30, 2018
@shaka-bot shaka-bot added this to the v2.1 milestone Apr 30, 2018
@vaage vaage self-assigned this Apr 30, 2018
@vaage
Copy link
Contributor

vaage commented Apr 30, 2018

@synologic Could you share with us the full command you ran? When we run it on our end it all works.

The bandwidth in #EXT-X-STREAM-INF:BANDWIDTH will be the combined audio and video bandwidths. So if you don't specify the audio bandwidth, it will get estimated and result in a variable bandwidth value for the variant.

The reason you are seeing the correct bandwidth for the video segment, is that the video segment only uses the video bandwidth and not a combined bandwidth.

shaka-bot pushed a commit that referenced this issue Apr 30, 2018
Created HLS and DASH tests that include overriding the
computed bandwidth value.

Issue #389

Change-Id: I6063fe780f6a68e2e7a7ad4440c9d76bacbbffe3
@synologic
Copy link
Author

synologic commented May 1, 2018

@kqyang possible a transcoder bug or not, it's ffmpeg which we all know it doesn't play very well with CBR :) however it happened, and I agree with your statement there.

@vaage Indeed by adding the audio bitrate for the audio segments in HLS the bitrates are correctly calculated (using the code compiled 2 days ago from git).

By not adding the audio bandwidth, still the bitrate calculation are off.

Here's the command i run
'in=udp://127.0.0.1:10005,stream=audio,segment_template=out/audio_eng_$Time$.ts,playlist_name=audio_eng.m3u8,hls_group_id=audio,hls_name=ENGLISH,language=eng'
'in=udp://127.0.0.1:10006,stream=audio,segment_template=out/audio_hun_$Time$.ts,playlist_name=audio_hun.m3u8,hls_group_id=audio,hls_name=HUNGARIAN,language=hun'
'in=udp://127.0.0.1:10007,stream=audio,segment_template=out/audio_rum_$Time$.ts,playlist_name=audio_rum.m3u8,hls_group_id=audio,hls_name=ROMANIAN,language=rum'
'in=udp://127.0.0.1:10001,stream=video,segment_template=out/video_1920_1080_$Bandwidth$$Time$.ts,playlist_name=1920_1080.m3u8,iframe_playlist_name=iframe_1920_1080.m3u8,bandwidth=6000000'
'in=udp://127.0.0.1:10002,stream=video,segment_template=out/video_1280_720
$Bandwidth$$Time$.ts,playlist_name=1280_720.m3u8,iframe_playlist_name=iframe_1280_720.m3u8,bandwidth=2500000'
'in=udp://127.0.0.1:10003,stream=video,segment_template=out/video_640_360
$Bandwidth$$Time$.ts,playlist_name=640_360.m3u8,iframe_playlist_name=iframe_640_360.m3u8,bandwidth=960000'
'in=udp://127.0.0.1:10004,stream=video,segment_template=out/video_384_216
$Bandwidth$_$Time$.ts,playlist_name=384_216.m3u8,iframe_playlist_name=iframe_384_216.m3u8,bandwidth=320000'
--segment_duration 2
--hls_playlist_type LIVE
--hls_master_playlist_output out/playlist.m3u8
--default_language "en"
--time_shift_buffer_depth 30

and the result i get

#EXT-X-MEDIA:TYPE=AUDIO,URI="audio_hun.m3u8",GROUP-ID="audio",LANGUAGE="hu",NAME="HUNGARIAN",AUTOSELECT=YES,CHANNELS="2"
#EXT-X-MEDIA:TYPE=AUDIO,URI="audio_eng.m3u8",GROUP-ID="audio",LANGUAGE="en",NAME="ENGLISH",DEFAULT=YES,AUTOSELECT=YES,CHANNELS="2"
#EXT-X-MEDIA:TYPE=AUDIO,URI="audio_rum.m3u8",GROUP-ID="audio",LANGUAGE="ro",NAME="ROMANIAN",AUTOSELECT=YES,CHANNELS="2"

#EXT-X-STREAM-INF:BANDWIDTH=2653750,CODECS="avc1.64001f,mp4a.40.2",RESOLUTION=1280x720,AUDIO="audio"
1280_720.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=6153750,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1920x1080,AUDIO="audio"
1920_1080.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=473750,CODECS="avc1.42c01f,mp4a.40.2",RESOLUTION=384x216,AUDIO="audio"
384_216.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1113750,CODECS="avc1.4d401f,mp4a.40.2",RESOLUTION=640x360,AUDIO="audio"
640_360.m3u8

#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=2500000,CODECS="avc1.64001f",RESOLUTION=1280x720,URI="iframe_1280_720.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=6000000,CODECS="avc1.640028",RESOLUTION=1920x1080,URI="iframe_1920_1080.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=320000,CODECS="avc1.42c01f",RESOLUTION=384x216,URI="iframe_384_216.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=960000,CODECS="avc1.4d401f",RESOLUTION=640x360,URI="iframe_640_360.m3u8"

somehow it estimates ~153k for audio where i asked ffmpeg to encode at 96k the audio tracks.

Still it's no deal breaker since it can be corrected by specifying bandwidth for both video and audio tracks.

Thanks for all the help

@vaage
Copy link
Contributor

vaage commented May 1, 2018

@synologic So it looks like setting the bandwidth tag is correct, so the part in question is the bandwidth estimation for streams. In our code it appears we use the max segment bitrate to determine the bitrate of the media playlist. @kqyang Do you remember why we chose to do it this way?

@kqyang
Copy link
Collaborator

kqyang commented May 1, 2018

That is required by HLS specification: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.2.

@synologic I assume you specified bitrate using -b: option in FFmpeg. That specifies the target bit rate, i.e. average bit rate for the encoder. You could also control maximum bitrate using -maxrate option in FFmpeg.

We also have a feature request to support AVERAGE-BANDWIDTH: #361. The value should more or less match the bandwidth specified in FFmpeg's -b: option.

@kqyang kqyang added status: working as intended The behavior is intended; this is not a bug and removed type: bug Something isn't working correctly labels May 1, 2018
@kqyang kqyang removed this from the v2.1 milestone May 1, 2018
@kqyang
Copy link
Collaborator

kqyang commented May 11, 2018

@synologic Do you have more questions? If not, we will close this issue.

@kqyang kqyang added the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 11, 2018
@synologic
Copy link
Author

synologic commented May 11, 2018 via email

@kqyang kqyang removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 11, 2018
@kqyang kqyang closed this as completed May 11, 2018
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Jul 10, 2018
@shaka-project shaka-project locked and limited conversation to collaborators Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated status: working as intended The behavior is intended; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants