I am using VideoJS to play videos served up from a fileserver. The files are in mp4 format, and work fine (using Flash fallback) on any desktop browser. However they do not work at all on mobile devices. For reference, feel free to check out:
http://74.203.203.93/content/aacfc5e7-fbeb-4785-ad04-023856a54a3d
I've tried to work the code around every which way I can think of to get it to work, but apparently I'm missing something somewhere. Does anyone have any ideas/suggestions?
More information:
Constants:
Video is in mp4 format (H.264 according to MediaInfo showing video codec being AVC).
Multiple formats are not possible (there will be no more than 1 (one) "source" tag).
Video file is hosted in a file server without a filename. Browser gets the location, and gets a source type tag.
Server is IIS.
Server supports byte-range requests.
Attempts so far:
Per http://help.videojs.com/discussions/problems/539-playing-mp4-on-android-using-videojs
Removed "type='video/mp4'" from tag.
Checked MIME types on server, video/mp4 is showing.
Per https://github.com/zencoder/video-js/blob/master/docs/api.md
Added javascript to call play() on ready.
Extension of above: tried javascript to call play() on click.
Tried adding '.mp4' to the end of the guid in the src location.
Swapped position of "type" and "src" elements of "source" tag.
I have changed the https:// in the source to http:// per several locations saying mobile doesn't do https well.
I changed the relative url in the src to an absolute url.
I will update with more information as I continue...
In the great media wars flash has been eliminated from androids, thats why the webm file is a key component in videojs.The mp4 file must be converted into a webm file and both sources used. You can just upload the webm vid to fileserver as well and link both sources in the player. The filenames in the link to the server must end in .mp4 and .webm to be recognized.
2 must reads -
http://www.zdnet.com/androids-flash-player-is-dead-live-with-it-7000002668/
http://www.pcadvisor.co.uk/how-to/google-android/3417930/how-get-flash-in-android-jelly-bean/
The quickest way to convert a mp4 to webm without software is to upload it to youtube, once the video is there copy the link and go to keepvid.com, then download the webm. Remember the highest quality webm file is not always optimal do to the size of mobile devices and slow internet connections planetwide. The video quality toggle on videojs is on the way though.
Related
I have been searching all around the web to try to understand how to stream videos to my android app.
I learned:
That the videos must be in the HLS or MPEG-DASH format to be adaptive for streaming .
What I mean by adaptive streaming:
The kind of streaming that allows the user to change the quality while video is streaming.
What could help me do this:
The first thing should be to encode my videos into an HLS or MPEG-DASH, for that I found a service that could do this which is Bitmovin.
The second thing is to play the adaptive video, I found two ways exoplayer and Bitmovin-player.
The problem:
I made an account on bitmovin and tried to test an mp4 video to encode, but there are too many stuff there like input, output and manifest and I don't know what URL I should use to pass to the bitmovin player to play. I encoded the video but I don't know where the reference to the enocoded video is.
My question:
1) Is my approach of streaming videos correct?
2) Can someone explain which url I must pass to the player or where I can find the video that was encoded in Bitmovin cloud?
1) Is my approach of streaming videos correct?
Short answer: Yes :) Adaptive streaming is used by almost every major VoD platform out there, and a proper way to do that. Further it allows you and your viewers to either
let the player decide on its own to select the optimal quality for the given connection and device of the viewer to provide continuous playback
and the viewer can select a specific quality on their own as well, if they want to.
When creating adaptive streaming content using MPEG-DASH and/or HLS as streaming format, your output would typically consist of the following:
Video/Audio Segments
MPD Manifest, and/or HLS playlists
1) Your input file (e.g. an mp4 file) will be downloaded and splitted into segments, which are being processed by the Bitmovin encoding. Out of these, it creates the different qualities the player or your viewer can choose from later.
2) This segmented output is then transferred back to your own storage, e.g. a cloud storage like AWS Simple Storage, or Google Cloud Storage. Other output types like (S)FTP and many others can be used as well.
3) In order to play your created MPEG-DASH or HLS content, a MPD manifest and/or HLS playlist needs to be created. Those are basically an index for the player, which tells it which qualities are available and where to find them to start the playback.
2) Can someone explain which url I must pass to the player or where I can find the video that was encoded in Bitmovin cloud?
The URL you would have to provide to the player, has to point the MPD and/or HLS master playlist, that gets transferred to your storage. Bitmovin doesn't offer a hosting service for your encoded content, which is why you didn't find an URL to the manifest that is used. So you would need a storage first, where the encoding could be transferred to.
Give the getting started guide a try. Select your preferred API client. Then you will be guided step by step on how to integrate this encoding service. I hope this helps :)
To test the playback of the player you can also have a look at https://bitmovin.com/demos/stream-test and select "Use our defaults" which provide URL's to sample content for testing the player and playback.
I am working on a project which requires a player to play iptv which comes in .ts links
I used vitamio player but it loads the link as entities and close after only 23 second
So my approach is to playvthe link again in onCompleteListener, it works fine but after complete it takes a long time to load the next entity of the link and play it and so on.
The question is what is best free player sdk to run ts and iptv links for android?
Usually, the TS segments for a stream will be indexed in a manifest file as part of HLS or MPEG-DASH steaming protocols, although DASH typically uses fragmented mp4 rather than TS.
You can see examples of this with the example HLS manifests that apple provides in the HLS documentation online (https://developer.apple.com/library/content/technotes/tn2288/_index.html):
#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
http://example.com/movie1/fileSequenceA.ts
#EXTINF:10.0,
http://example.com/movie1/fileSequenceB.ts
#EXTINF:10.0,
http://example.com/movie1/fileSequenceC.ts
#EXTINF:9.0,
http://example.com/movie1/fileSequenceD.ts
#EXT-X-ENDLIST
ExoPlayer (https://github.com/google/ExoPlayer) will play this type of stream - you provide it the manifest file (e.g. myStream.m3u8) file as the source, rather than the individual TS segments.
If you look in the demo app 'media.exolist.json' in the assets folder you will see it includes a HLS example.
You can see how it parses the HLS manifest in the 'HlsPlaylistParser' class.
I have created an Android application which is capable of playing movies, which are protected with DRM (Widevine Modular). Video are in MPEG-DASH standard. In case, that device is online, everything works fine.
Now I need to add feature for playing video in offline mode. The problem is that I do not know how can I download some file(s) for offline playback. Everything what I have is .mpd file, which contains structured data.
How can I get some file(s) for download from this manifest .mpd file? There are no direct links to some video. I see some chunk, which looks like this:
media="chunk_ctvideo_cfm4s_rid$RepresentationID$_cs$Time$_w1003607280_qaWQ9QVBsSUxIMUpaRnVfdfdfkstMDImYXdsgdreaW9pbmRleD0w_mpd.m4s
I do not know if it is useful for me, but there is nothing more "noticeable" in the manifest file.
For an example of code that processes a manifest and downloads the media chunks have a look here: https://github.com/axiomatic-systems/Bento4/blob/master/Source/Python/utils/mp4-dash-clone.py
Of particular interest you may find the ProcessUrlTemplate which shows how to pass the media elements to get a URL for a chunk
Is it somehow possible, you can load the movie trailers from imdb to videoView or the native android player.
so far, what i've tried.
Iframe approach which let me load trailer in webview, which is exactly i don't want.
Here i found a link which is something a direct link to stream.
I want this to play in video view or native android control.
thanks in advance.
The link you have above is not a direct link to the video - it is actually a link to a web page which contains an embedded player, which in turn has a link to the actual trailer video itself.
You can see the link the to the video if you use the network timeline tab in a browser inspector to look at the network requests. For your example above the client (the browser running the HTML5 page you have downloaded) is requesting the video m3u8 file with the following request:
http://imdb-video.media-imdb.com/vi1225109529/1421100405014-mxwp62-1434643350557.m3u8
This is the 'index' file for a HLS format video file - it tells the client where to request the video streams. The client then downloads the video chunk by chunk which you can see as requests for TS segments - e.g. for you example above:
http://imdb-video.media-imdb.com/vi1225109529/1421100405014-mxwp62-143464335055700002.ts
If the IMDB site does not protect or restrict the video in some way (for example only allowing it play from their embedded web page) then in theory Android should be able to play a HLS file if you point the Media Player towards the m3u8 file. In practice however Android has well know issues with HLS playback so you may find it problematic - see this summary: http://www.jwplayer.com/blog/the-pain-of-live-streaming-on-android/
How can I compress a video file in Android before uploading to a remote server? I'm not looking to zip up the file, because I don't think that will help much. I want to compress the video and re-encode it with a lower bit-rate or resolution. The idea is to get a standard 360х480, 30 FPS video file from every device. This way I can avoid users with better cameras being forced to upload huge video files.
I know iOS makes it fairly simple to force video file resolutions. 10 second video recorded on iPhone 4:
high (1280х720) = ~14MB = ~11Mbit/s
640 (640х480) = ~4MB = ~3.2Mbit/s
medium (360х480) = ~1MB = ~820Kbit/s
low (144х192) = ~208KB = ~170Kbit/s
Is there any easy way to do this in Android? Do I need to find some external library that will let me re-encode the video file, then save it to the SD card (or overwrite the old video file), then upload that file? Mainly looking for general direction here and not code to copy and paste, although anything is helpful.
I got a similar problem. Where I had to upload video in server having size within 5.4mb. But due to different camera resolutions of different phones, there was a problem. These are the solutions which I have opted
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setVideoEncodingBitRate(690000 );
Hope these will help you
One of the app that I worked on earlier has this requirement of sending the video file after compressing it. Here are the steps I followed which worked:
Compress the file using a Silicompressor library in android. Run the compression task on a background thread.
The output file format will have the mime type "video/raw". You can check that in logcat. So, you need to add this mime type in your server so that the compressed file format is uploaded successfully.
After this is done, trying sending the compressed file and it should work.
Make sure the mime type of the file you are uploading to server is accepted by the server.
Read About this Library, its the best for new mobile which has a Full HD cameras
Compress Video with high quality for Java and Kotlin
We decided to save this functionality for another iteration of the project. We opted to warn the users of the large data payload (especially if they are not on Wi-Fi). I'm confident this can be done, and the link provided by tabbykitten is the best related SO post I've found on this topic to this date.
From API level 18 onwards you have direct android API to do Video Encoding but if you are targeting Less than API level 18 it not straight forward
the below link does the encoding
https://github.com/google/grafika/blob/master/src/com/android/grafika/VideoEncoderCore.java