medialement.js not working for my hls on iphone - http-live-streaming

Here is my m3u8 file:
cat 8.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:YES
#EXT-X-MEDIA-SEQUENCE:1131
#EXT-X-TARGETDURATION:5
#EXTINF:4.950, no desc
1545049888215.ts
#EXTINF:4.950, no desc
1545049893218.ts
I serve it at as static file at http://104.248.205.68:31339/8.m3u8
I use mediaelemnts.js to run this hls video: jsfiddle
html:
<video width="240" height="160"
id="player1" src="http://104.248.205.68:31339/8.m3u8"
controls="controls" autoplay preload="auto" muted ></video>
js:
$('video').mediaelementplayer({});
It works fine on chrome mac os desktop. But not working on iphone 8+ (safari and chrome). No errors in the console. Video just not played, black screen. In the fullscreen mode of video - the same.
At the same time, if I find a random m3u8 on the internet and use mediaelemnts.js to play it, it works well on the iPhone (at least in fullscreen mode) jsfiddle 2.
So I guess something wrong with my m3u8 file since other m3u8s are runnable on the iPhone.
If I open network tab while loading the problem page on Iphone, I see it's downloading the files but not showing video for some reason.
Update
I checked on android: galaxy s5 and galaxy s9+ in chrome: both works.
Update 2
Zip archive with ts files and m3u8: http://104.248.205.68:31339/8.m3u8.zip

When inspecting the media files [1] it can be found that the PMT (Program Map Table) signals that there is audio in the stream, but there are actually no TS packets for audio (i.e. no audio data) present.
It looks like the player waits for the audio TS packets in order to build a common buffer for both, audio and video, and only then start playback. Since the stream lacks audio data that never happens. To back that up, you can use ffmpeg to remove the audio track from the media segments using the below command and find that playback would work once you do this.
ffmpeg -i 1545049893218.ts -an -vcodec copy 1545049893218-v.ts
Further, the reason this problem only manifests in Safari and Chrome on iOS is that in those cases mediaelement.js is using the browser's native capabilities to play HLS, instead of a JavaScript player (like hls.js) which is used on other platforms (e.g. Chrome on desktop) and is more tolerant to such problem cases.
[1] E.g. using http://thumb.co.il/ or ffprobe
EDIT:
While the above may be sufficient to make it work on older Apple mobile devices - I tested on iPhone 6 iOS10 - newer devices seem to be more restrictive. The official HLS Authoring Spec states
8.11. You MUST provide at least 6 segments in a live/linear playlist.
which does not seem to be a hard requirement on some iOS versions. However, to ensure it to be working on all versions these requirements should be met.
I did a quick test on iPhone X with iOS12 and found it would play if at least 3 segments are provided in the playlist by just duplicating the last segment entry.

Related

How does one play higher resolution videos (4k and higher) in VLC (desktop app and Unity)?

I'm trying to get a 360 streamed video to play at its full (4k) resolution. I did do previous searching and found the below thread but it didn't answer my question.
How do I adjust the video resolution?
My end goal is to integrate this into vlc unity but I also don't see how to adjust the resolution up to 4k (or higher) for streamed videos even on the desktop app. As a test, I tried a 4k video from youtube in the VLC desktop app and couldn't see how to get it to play in 4k. The end goal is to stream from aws but I want to confirm that my stream can indeed play at 4k before continuing to try to figure out why it's playing at lower resolution within Unity. It resizes down to 1920x1080 instead of the intended 4096x2048 for my aws stream and resizes the youtube video down to 1280x720 from its 3840x2160.
I've tried messing with the advanced settings and looking at input/codecs and the best option for "preferred video resolution" is "best available" (below that is full hd). I've looked through other suggestions online and didn't see a lot to change but did change Settings-->Video-->Output to "DirectX (DirectDraw) video output. This one was just me fumbling through the desktop app, but I tried going through Media-->Open Network Stream, clicking the arrow next to play and selecting stream, choosing RTSP for destination, and then editing the resolution within the profile to be a specified width and height. None of the above changed the resolution of the video.
TL;DR - How can I play a streamed video at higher resolutions (4k and up) in the VLC desktop app and in VLC Unity?
Edit - adding requested code snippets. This just modifies the UseRenderingPlugin file from the VLC unity asset.
Also, similar to what was getting discussed in the comments, when I play the video locally instead of streaming, it plays at the full resolution of the video.
Within Awake() I set the material to the 4096x2048 one mentioned for the skybox
RenderSettings.skybox = material4k;
And then in Update here is the relevant segment
var texptr = _mediaPlayer.GetTexture(out bool updated);
            if (updated && texptr != IntPtr.Zero)
            {
                Debug.Log("Creating texture ");
                tex = Texture2D.CreateExternalTexture((int)width,
                    (int)height,
                    TextureFormat.RGBA32,
                    false,
                    true,
                    texptr);
                RenderSettings.skybox.mainTexture = tex;
                }

Size of video container in receiver

I know this is ridiculous, but I'm learning...
In a Chrome application I let my sender initiate and load a Custom receiver.
The receiver page includes a video element set to play one specific video, like this:
<video autoplay>
<source src="../media/someVideo.mp4" type="video/mp4">
</video>
The receiver page and the media file are hosted on a web server (SP)
I use no further communication between sender and receiver, so the receiver just loads and plays the video.
It works beautifully, but the video size on the device (TV) is too big. It fills the screen, but I don't see the full picture.
I try to downsize the video using CSS or by setting the width and height parameters on the video element, but the result is the same. Why doesn't ChromeCast respect these settings?
width/height for the video element should work. As a test, just set width and height in the element itself and test. On a tv screen, in general, there is a notion of overscan and most modern tv sets have a setting to adjust that, you might want to check to see if your tv offers that too or not.

Chrome extension, play sound in background script

I want to play a sound from a Chrome Extension, but I read that Content Scripts cannot play sounds. So I put this code in my background script:
var audio = new Audio("alert.ogg");
audio.play();
but still no sound. From the Console of the _generated_backgound_page.html I was able to inspect the Network tab and see that the sound file is loaded successfully, but I hear nothing.
Also, in another HTML page, I could load another Javascript, which has the above code, and it works (I can hear the sound.)
The fact that it is in the background script seems to have made it fail. Also, note that I do not have a background PAGE associated with the background SCRIPT. Does that matter?
edit: problem solved. The above code works but I forgot to listen to the right sound output channel.
You can generate the background page with javascript. I think the sound must be in a html page to be loaded and played.
This should work:
document.write('<audio id="player" src="data:audio/wav;base64,UklGRhwMAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAZGF0Ya4LAACAgICAgICAgICAgICAgICAgICAgICAgICAf3hxeH+AfXZ1eHx6dnR5fYGFgoOKi42aloubq6GOjI2Op7ythXJ0eYF5aV1AOFFib32HmZSHhpCalIiYi4SRkZaLfnhxaWptb21qaWBea2BRYmZTVmFgWFNXVVVhaGdbYGhZbXh1gXZ1goeIlot1k6yxtKaOkaWhq7KonKCZoaCjoKWuqqmurK6ztrO7tbTAvru/vb68vbW6vLGqsLOfm5yal5KKhoyBeHt2dXBnbmljVlJWUEBBPDw9Mi4zKRwhIBYaGRQcHBURGB0XFxwhGxocJSstMjg6PTc6PUxVV1lWV2JqaXN0coCHhIyPjpOenqWppK6xu72yxMu9us7Pw83W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fH18fXx8fHt8e3x7fHt8e3x7fHt8e3x7fHt8e3x7fHt8e3x7fHt8e3x8e3x7fHt8e3x7fHx8fXx9fH18fX5+fX59fn9+f35+f35/gH+Af4B/gICAgICAgICAgICAgYCBgIGAgIGAgYGBgoGCgYKBgoGCgYKBgoGCgoKDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KDgoOCg4KCgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGCgYKBgoGBgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCAgICBgIGAgYCBgIGAgYCBgIGAgYCBgExJU1RCAAAASU5GT0lDUkQMAAAAMjAwOC0wOS0yMQAASUVORwMAAAAgAAABSVNGVBYAAABTb255IFNvdW5kIEZvcmdlIDguMAAA" >');
document.getElementById('player').play();
I used a base64 audio file but you can use a normal file too.

Does ActionBar Sherlock cause problems with MediaRecorder?

I have a problem using MediaRecorder to record video with ActionBar Sherlock. I have a base app that sets up and records video files without any problem, but as soon as I add ABS, it stops working.
Right now I have a non-ABS app that can record video with no problems at all and the same app (in all other respects) with ABS that doesnt work.
Initialising the video recorder using the CAMCORDER settings gets through the MediaRecorder setup OK, but when I stop recording, I get a '-1' error in the logcat and the resulting .MP4 file has no audio or video track (although the file size looks OK).
If I try setting MediaRecorder with maunaul setups (i.e., format, frame rate, size etc), the setup keeps falling over at 'setVideoSource...CAMERA'.
Does anyone know if there's any reason why ABS would upset MediaRecorder this way?
Added 01/01/13:The application I'm working on is being upgraded from a photo-taking app to a video-recording app. The preview for the camera was previously done with a ImageView frame, which works OK for providing an image preview, but not for use as the video preview on MediaRecorder. For MediaRecorder, I needed to use a SurfaceView. Once I switched to a SurfaceView, all was good!

Best way to play wav files in the browser?

I have no choice but to play wav files directly in the browser (serverside encoding to mp3 isn't an option, unfortunately.)
What's the best way to do this? I'd really like to take advantage of the HTML 5 audio tag but my target audience includes many, many teens using IE6. As far as I'm aware flash isn't an option, but speedy playback really is critical.
Thanks.
Nowadays, the best way is probably just to use the HTML5 <audio> tag. In the past, you might have done it like this:
Background:
<embed src="bgsound.wav" hidden="true" autostart="true" loop="1">
On Click:
Play Sound
It's been a few years since the last answer. Embed tag was good but I had an issue trying to trigger it to play in JavaScript. New audio tag works well is most browsers.
<audio src="cat9.wav" preload></audio>
You can trigger it manually with audioElement.play()
<audio controls="controls"><source src="http://blablabla.com/hghghgh/my%20file.wav" type="audio/x-wav" /></audio>
Due to unfixed bug (issue from 2012 year?) sometimes Chromium-like browsers cannot play .wav from redirected URLs because they "think" that file size is zero. But .mp3 is OK.
Opera 12.14 and Firefox play from < audio >
tag normally in the same case (redirected URL).
I tried JPlayer's 2.9.* lib in Drupal 7 with 3 players, but not successful (was black inactive rectangle 300*14 pixels for each player).

Resources