I am building an app which allows users to upload videos from different devices including android and iOS then stream them from server with VideoView during playback. I end up with different video formats and get the inevitable "Cannot play this video" error on several occasions.
Some research says that videos with format .mp4 and codec H.264 can work on all devices, so I have a few things I am working on.
Convert all videos on server side to the above mentioned format and codec
Use ffmpeg to convert the videos in app during playback
Use VLC sdk which supports a wide range of video formats
I am not sure which if these is the best solution, I have not worked with videos a lot in the past on Android and I am not sure what the pros and cons maybe or if indeed these are viable solutions or if this problem already has a known solution.
Related
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
In my app I need to play videos from sdcard. Now it works fine on Galaxy S,Galaxy Tab2, But on some chinese tab Like "Giada" It is not working at all.
I have 4 different activities to play videos like. First activity plays a menu video which has navigation link to other activity. Problems I am facing.
First Video plays properly but looping failed and app closed.
If I navigate to other activity to play another video it says "Can't Play Video" and closed Some time it plays same video but not complete and closed app in between.
Video Extension: MP4
Resolution : 1024x600
Playing From : SDCard.
Target Tab Specification.
Resolution : 1024x600
Android :4.1
Tried with Video View and SurfaceView.
Help me out any help will be regreted.
The answer to this question will never be consistent across all devices or across all videos.
Whether a given video file will play in a given player depends on three things:
The video container format (file type).
The codecs the video (and potentially audio) streams are encoded with
Your player's support for that combination of container format and codec
The codec and player/device support for it is almost certainly the cause of the inconsistent results you've seen. (A codec, if you didn't know, is basically a repeatable mathematical formula that tells your system how to turn bits and bytes packed into a file into moving pictures(and back again, for that matter))
There are a large variety of video codecs in the video files floating around out there. Support for these codecs is wildly inconsistent just due to the history of video distribution. Many devices won't support streams encoded with certain codecs. There are a variety of reasons for this, but the most common are obscurity or licensing costs.
For example, up until a few years ago, almost everything was encoded in an .FLV container with an On2 VP6/VP7/VP8 codec. This is causing headaches today because while On2 owned these codecs, they kept a tight rein on the licenses. That didn't relax until .FLV had already begun to lose relevance, and so there is not a whole lot of (legitimate) software out there that can work with On2-encoded content.
What all of this means is that there is no silver bullet. All video will never run on all devices, at least not without the aid of video players that install and use their own codecs to decode the streams.
Needless to say, this does not include the libraries provided to you and your end users by the factory-installed Android libraries.
So, what do you do? Well, short of producing a video player that carries its own codecs, you can most effectively address the problem with a two-step approach:
Target specific devices that you want your application to work on
Encode your content to use use a video codec that works on all the devices you want to target. You may need to produce two copies of your video if you find that there is no codec that works across all devices you plan to support.
Today, the widest support is available with an MP4 container and a video stream encoded with the H.264 (AVC) codec. As I said, there is no silver bullet, and H.264 support is not universal by any means, but this one format will be playable more potential users than any other single choice you could make, due to its popularity and wide support in modern desktop and mobile environments.
Some tools you may find helpful:
MediaInfo will let you peek inside MPEG-flavored video containers to see what codecs are in use. This will be helpful in determining which devices are having trouble with which codecs.
FFmpeg is an encoding application that can convert your content to MP4/H.264
Android Supported media formats
List of supported media audio/video formats.
Good luck!
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.