I am assigned with a task to play a video in Android. Also, they mentioned if I use HLS it would be nicer. I tried playing video in VideoView, works good. I don't know anything about HLS. So I request, if I get some valuable resources on how to play video using HLS in android, it would be great.
Any leads are appreciated.
Thanks
The Android VideoView has limited steaming support (HLS, DASH, Smooth Stream, etc.) especially on older API versions. The best option would be to use the ExoPlayer library from google (or a wrapper around it like ExoMedia).
As an note, the streaming protocols are only supported on API 15+
Related
I need to play a video in M3U8 format.
I used the following example but does not play the video (.m3u8), someone could help me?
Researched elsewhere and there are distorted information. Some say that the androids can not play, others say that only some versions reproduce and there are those who say to use VitamioBundle. Prem say is not guaranteed and increases the size of apk around 20mb.
Android supports HLS starting with version 4.0+. Most bugs were fixed on 4.4 so newer versions should work without issues.
Apart from the HLS protocol compatibility you need to make sure the stream you're trying to play is also supported. Older Android devices can only play Baseline Profile H.264/AVC with AAC in MPEG-TS. The supported media formats page lists HD 720p - 30 fps # 2 Mbit/s as the maximum level supported on the majority of devices.
Newer Android devices are able to play High Profile, Level 4.2, 60 fps.
There are a couple of 3rd party libraries available but discussing them here is off-topic as it attracts opinion based answers. You'll need to do a bit of research depending on your required target/specs.
Try to use ExoPlayer.
ExoPlayer is an application level media player for Android. It
provides an alternative to Android’s MediaPlayer API for playing audio
and video both locally and over the Internet. ExoPlayer supports
features not currently supported by Android’s MediaPlayer API,
including DASH and SmoothStreaming adaptive playbacks. Unlike the
MediaPlayer API, ExoPlayer is easy to customize and extend, and can be
updated through Play Store application updates.
I am trying to achieve HLS streaming in Android.
I have setup the HLS streaming server (apache2) in Ubuntu desktop and able to play the stream using the VLC player on Desktop.
But when i try to play the stream using VLC player in Android, I am not play the video, nor I am getting any error.
If anyone has tried similar streaming, please provide your inputs.
Thanks
Following some further investigation, I've found the following information that can hopefully help other people get HLS streaming on Android working.
Encoding - The video encoding, and the segmentation setup can have a large impact on the Android versions that the video supports. I ended up creating a video using HandBrake, with the following settings:
MP4 File
H.264; Baseline Profile; Level 3
AAC Audio; 44.1k; 128bit (Note: I found that JellyBean was a lot more picky about the audio than ICS/Honeycomb. Some audio bitrates would create videos that Jellybean would not play at all. In general Mono and low bitrate audio seemed to work better on Jellybean).
Segmentation - Using the Apple MediaFileSegmenter, I found adding the "-no-floating-point-duration" and "-z none" flags allowed me to create a video that worked across Android 3.0->4.2
Gingerbread - I was unable to get Android 2.3 to work with HLS out of the box, but I did find that using the Vitamio library worked pretty well (see this question for further info)
Is it possible to invoke(deploy) HTTP Live Streaming (HLS) on Android(4.x)?
https://developer.apple.com/streaming/
Obviously iOS devices can both capture/play, and I know android can at least play, but how about capturing? I wonder interoperability.
Thanks.
The best answer I found so far is
Creating a HLS video stream with FFmpeg
12 May 2013
http://walterebert.com/blog/creating-on-hls-video-stream-with-ffmpeg/
For video conversion I use FFmpeg. Creation of HLS is possible with FFmpeg, but not really well documented. So I had to figure out how to create the video streams. After a lot of research and experimentation I created my FFmpeg HLS reference implementation that is available on Bitbucket.
On iOS the created video plays without problems on new devices. Older iOS devices with a maximum resolution of 480×320 pixels seem to select the best quality stream available, even if they cannot play it. For Android you have to create a MP4 video and before converting it into a MPEG stream. Doing this in a single command creates a choppy stream on Android. Flash playback has still some issues if you change the bitrate. So I still have some work to do.
These are the writings of Walter Ebert on web development, web design and free, open source software
Yes. HLS is widely used on Android 4.x.
I am trying to play a video in android native code using new API mediacodec. I dont want to go mediaPlayer way due to unavoidable reasons. can anybody share some code snippet as to how to go about it? Thanks in advance.
Your original question is too generic. And to be honest, create a new media player in native code is a huge task for your own.
If you are only seeking for some media player solution which has better supporting for variety of formats/codecs like VLC player, you can either try VLC lib which is open source but still in beta release. I have tried VLC, but it really has some crash issues or ANR issues, which is inside the whole framework.
Or you can try with Vitamio SDK which is a library without souce code. Check it out at this link: https://github.com/yixia/VitamioBundle Below is the feature list of it:
I have tried this solution, it is very stable, also some minor issue on 4.3, but still acceptable. So I am not posting any spam here, just copying from the official document:
Vitamio is an open multimedia framework or library for Android and iOS, with full and real hardware accelerated decoder and renderer. It's the simple, clean and powerful API of Vitamio that makes it famous and popular in multimedia apps development for Android and iOS.
According to the developers' feedback, Vitamio has been used by more than 1000 apps and 100 million users around the world.
Vitamio can play 720p/1080p HD mp4,mkv,m4v,mov,flv,avi,rmvb,rm,ts,tp and many other video formats in Android and iOS. Almost all popular streaming protocols are supported by Vitamio, including HLS(m3u8), MMS, RTSP, RTMP, and HTTP.
Network Protocols
The following streaming protocols are supported for audio and video playback:
MMS
RTSP (RTP, SDP), RTMP
HTTP progressive streaming
HLS - HTTP live streaming (M3U8)
And yes, Vitamio can handle on demand and live videos in all above protocols.
Media formats
Vitamio used FFmpeg as the demuxers and main decoders, many audio and video codecs are packed into Vitamio beside the default media format built in Android platform, some of them are listed below.
DivX/Xvid
WMV
FLV
TS/TP
RMVB
MKV
MOV
M4V
AVI
MP4
3GP
Subtitles
Vitamio support the display of many external and embedded subtitle formats.
SubRip(.srt)
Sub Station Alpha(.ssa) / Advanced Sub Station Alpha(.ass)
SAMI(.smi/.sami)
MicroDVD(.sub/.txt)
SubViewer2.0(.sub)
MPL2(.mpl/.txt)
Matroska (.mkv) Subtitle Track
More features
More wonderful features
Support wide range screens from small phone to large tablet
Multiple audio tracks support
Mutitiple subtitles support, including external and embedded ones
Processor optimization for many platforms
Buffering when streaming
Adjustable aspect ratio
Automatically text encoding detection
I want to play in .mov file in android. But videoview or mediaplayer doesn't support this meida format. How can i add the support to it?
In general Android doesn't support any other media formats than the one listed here. That being said, there are quite a few 3rd party players that enable playback of more exotic formats, most of which are probably based around ffmpeg. You might want to take a look at the open source Dolpin Player (actual player also available in the Play store) for Android for some more pointers - not sure if mov playback is supported by default though.
However, since most mov files are actually H.264 encoded these days, why not remultiplex (or re-encode, depending on the source) into an something that Android plays nice with, e.g. an mp4 container? In terms of video support on Android, H.264 is definitely the way, as also pointed out by the 'Video Encoding Recommendations' section in the earlier link.
I know this is an old question, but times changin'
Now we can use the ExoPlayer as a custom Video Player (like VideoView), it supports more formats than the VideoView on android.
It's really simple to use, just to play videos, but has the powerfull of customization if you needed.
https://google.github.io/ExoPlayer/
Give it a try and please respond if this helped you.
Just try to play it anyway. The Quicktime .mov specification is the predecessor of the MP4 spec. There are only differences in a few atoms/boxes. You will be able to play an MP4 as .mov and a .mov as MP4 in most cases.
I found that even the big named players such as MX Player, BS Player and VLC for Android would not play .mov files correctly, especially those that had been recoreded on my wifes iphone 4s.
The playback was very choppy on my Nexus 7 and Nexus 10 and totally unwatchable on my HTC One (M7).
The player I found and installed that will play old and new iphone movie clips (.mov) flawlessly was found freely available from the Google Play Store.
Here is the best player I have found and believe me I have tried lots:
Playing .MOV files on an Android Device
Hope this helps some of those people with an Android device wishing to view iphone .mov files.