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

OSMF: subclipping feature #9

Open
mangui opened this issue Jul 10, 2014 · 10 comments
Open

OSMF: subclipping feature #9

mangui opened this issue Jul 10, 2014 · 10 comments

Comments

@mangui
Copy link
Owner

mangui commented Jul 10, 2014

add API to support subclipping feature

in OSMF it should be done using clipStartTime,clipEndTime :
https://github.com/theturtle32/OSMF-AppleHLS/blob/master/OSMF/org/osmf/net/StreamingURLResource.as#L86-L87

@mahmutbayri
Copy link

Hi @mangui,
I'm interested this feature. How is going development? :) I have experience with OSMF but not Flashls API. Could you give me an entry point to implement it?

Thanks.

@mangui
Copy link
Owner Author

mangui commented Oct 21, 2014

Hi @kalimba
basically you need to retrieve clipStartTime and clipEndTime from StreamingURLResource (available here : https://github.com/mangui/flashls/blob/master/src/org/mangui/osmf/plugins/loader/HLSLoaderBase.as#L117)

then you would have to pass these values to HLS OSMF traits (all traits dealing with playlist duration / media position / buffer size, they are here : https://github.com/mangui/flashls/tree/master/src/org/mangui/osmf/plugins/traits) and take these clipping parameters into account.

having basic clipping working for VoD playlist should not be too complex, but handling live playlist (with sliding window) might be more difficult.

@mahmutbayri
Copy link

@mahmutbayri
Copy link

Hi @mangui ,
I have looked around. It is too complex for me. Do you have any schedule to add the feature?

Thanks.

@mangui
Copy link
Owner Author

mangui commented Oct 22, 2014

no schedule

@sathasivam11
Copy link

Hi @mangui ,
You have mentioned that clipStartTime and clipEndTime values need to be passed to HLS OSMF traits. Could you please elaborate when and how these values need to be handled in traits?

Thanks.

@mangui
Copy link
Owner Author

mangui commented Nov 18, 2014

Hi @sathasivam11
you need to handle conversion from flashls position/duration/buffer length (which are real position) to
subclip position/duration/buf length.

according to https://github.com/theturtle32/OSMF-AppleHLS/blob/master/OSMF/org/osmf/net/StreamingURLResource.as#L86-L87,

one way is to perform this conversion in the Traits (HLSNetStreamLoadTrait,HLSSeekTrait.as,HLSTimeTrait)
but there is still one issue : when reaching the end of the subclip, the playback should stop automatically. and a playback complete event should be triggered to OSMF.

the best solution would be to add this subclip functionality in flashls itself, and modify _hls.load() prototype (add 2 optional args, clipStartTime and clipEndTime).

@mangui
Copy link
Owner Author

mangui commented Jan 24, 2015

please note that subclipping has been implemented in FlashlsFlowplayer, refer to the last commits on https://github.com/mangui/flashls/commits/master/src/org/mangui/flowplayer/HLSStreamProvider.as
same logic could be easily adapted to FlashlsOSMF

@mahmutbayri
Copy link

Hi @mangui,
If this enhancement is easy for you, adding this would be great, please. I'm experience with OSMF, not Flowplayer or Flashls core.

Thanks

@mahmutbayri
Copy link

Hi @mangui

Should i focus there lines to implement it?

flashls/src/org/mangui/osmf/plugins/loader/HLSLoaderBase.as
->

private function _manifestHandler(event : HLSEvent) : void {
var resource : MediaResourceBase = URLResource(_loadTrait.resource);
// retrieve stream type
var streamType : String = (resource as StreamingURLResource).streamType;
if (streamType == null || streamType == StreamType.LIVE_OR_RECORDED) {
if (_hls.type == HLSTypes.LIVE) {
streamType = StreamType.LIVE;
} else {
streamType = StreamType.RECORDED;
}
}
var levels : Vector.<Level> = _hls.levels;
var nbLevel : int = levels.length;
var urlRes : URLResource = resource as URLResource;
var dynamicRes : DynamicStreamingResource = new DynamicStreamingResource(urlRes.url);
var streamItems : Vector.<DynamicStreamingItem> = new Vector.<DynamicStreamingItem>();
for (var i : int = 0; i < nbLevel; i++) {
if (levels[i].width) {
streamItems.push(new DynamicStreamingItem(level2label(levels[i]), levels[i].bitrate / 1024, levels[i].width, levels[i].height));
} else {
streamItems.push(new DynamicStreamingItem(level2label(levels[i]), levels[i].bitrate / 1024));
}
}
dynamicRes.streamItems = streamItems;
dynamicRes.initialIndex = _hls.startlevel;
resource = dynamicRes;
// set Stream Type
var streamUrlRes : StreamingURLResource = resource as StreamingURLResource;
streamUrlRes.streamType = streamType;
try {
var loadedElem : MediaElement = new HLSMediaElement(resource, _hls, event.levels[_hls.startlevel].duration);
LoadFromDocumentLoadTrait(_loadTrait).mediaElement = loadedElem;
updateLoadTrait(_loadTrait, LoadState.READY);
} catch(e : Error) {
updateLoadTrait(_loadTrait, LoadState.LOAD_ERROR);
_loadTrait.dispatchEvent(new MediaErrorEvent(MediaErrorEvent.MEDIA_ERROR, false, false, new MediaError(e.errorID, e.message)));
}
};

flashls/src/org/mangui/osmf/plugins/traits/HLSNetStreamLoadTrait.as
->

private function _mediaTimeHandler(event : HLSEvent) : void {
var time_total : Number = Math.round(10 * event.mediatime.duration) / 10;
var time_loaded : Number = Math.round(10 * (event.mediatime.position + event.mediatime.buffer)) / 10;
if (_time_total != time_total) {
if (time_total < _time_loaded || time_total < 0) {
time_total = NaN;
}
_time_total = time_total;
setBytesTotal(time_total);
}
if (_time_loaded != time_loaded && time_loaded <= time_total) {
_time_loaded = time_loaded;
setBytesLoaded(time_loaded);
}
};

Thanks

@mangui mangui changed the title subclipping feature OSMF: subclipping feature Jun 29, 2015
@mangui mangui added the OSMF label Jun 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants