Using VLC's MediaPlayer in my Android application - android

I've been struggling for days to build an application that, given a RTSP link, views the video to the screen.
It's a live video streaming coming from an IP camera in H264 format (it's not a file).
I couldn't get it done using the native MediaPlayer or VideoView (it starts showing the video and then freezes afrer 2-3 seconds), but since that when I view it in VLC player it's working fine, I've decided to use a VLC MedaPlayer in my application.
I've found some sources such as vlc-android and exoplayer_vlc, but I would like just to have a library jar, which I get import to my application and just use its classes. Is there such a jar somewhere? How can I make it work?
Thanks in advance

Related

ExoPlayer playing currently recording media files

Let me refraise my question, I wrote it in a hurry.
Current situation:
I have set up a digital video recorder to record broadcasts provided via DVB-C. It is running on a raspberry 3B using TVHeadend and jetty/cling to provide UPnP and other possibilities to access media files. For watching recordings, I wrote an android player app using IJKPlayer, which runs on smartphones, FireTV and AndroidTV.
One hassle when playing media files which are currently beeing recorded is, that IJKPlayer doesn not support timeshifting. Means, when I start playing a currently recording file, I can only watch the length which is known by the player at that moment. Anything which is recorded afterwards can not be played. I need to exit the player activity and start it again. I have resolved that issue by "simulating" a completed recoding using a custom servlet implementation. Since the complete length of the recording is already known, I can use ffmpeg to accomplish this.
Future situation:
I plan to move away from IJKPlayer to ExoPlayer, because it supports hardware playback and is much faster when playing h.264 media. I can of course use the same solution like above, but as far as I have found out yet, ExoPlayer can support media files which are currently being recorded by using the Timeline class. However, I don't seem to find neither a usefull documentation nor any good example. Hence, I would appreciate any help with the timeline object.
Regards
Harry
Looks like my approach won't work. At least, I didn't find a solution. Problem is, that the server returns the stream size as it is during player-start-time. I didn't find a method to update the media duration for "regular" files.
However, I can solve the problem by changing the server side. Instead of accessing a regular file, I convert the file to m3u8 in realtime, using ffmpeg. I then throw the m3u8 URI onto the player and it updates the duration of the stream (while playing) without the need to create any additional code on the client side.

Simple Qt Video streaming application and only sound, no video (white screen)

After an intense search on this site I found nothing which fits
my problem. I want to write a small video streaming client on
an Android 5.1 device. The following code is used:
QApplication a(argc, argv);
QWidget *widget=new QWidget;
widget->resize(320,200);
QMediaPlayer *player=new QMediaPlayer;
QVideoWidget *vw= new QVideoWidget;
QHBoxLayout *layout=new QHBoxLayout;
layout->addWidget(vw);
widget->setLayout(layout);
player->setVideoOutput(vw);
player->setMedia(QUrl("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"));
player->play();
widget->show();
The problem is, the sound works but I only get a white screen.
the sound is playing but no video.
The VLC player on the android device is playing the video
correctly. I also used a small player in android studio and
it plays the video (but with high latency, so it is not useful for me)
I ran out of options what I can change to make it run.
Qt is not media friendly, if you want to play specific format/codec like MOV or h.264/h.265 ect... in a crossplatform way I advise you to use external lib like QtAV (http://www.qtav.org/) or VLC Qt wrapper (https://github.com/RSATom/QmlVlcDemo)
I believe the problem is that Android devices do not support the QuickTime Format (MOV) by default.
VLC Media Player on the other side, is well-known to be able to correctly play MOV videos.
Try testing videos with another format such as MP4or WebM to see how the program behaves.
I once developed a desktop software for streaming audio/video in Qt and I had the pleasure to work with the GStreamer framework.
Among many functionalities, it allows you to convert MOV videos to other formats.
You may check the GStreamer for Android tutorials and QtGstreamer, a set of well-implemented GSstreamer bindings for Qt.

Android LibVlc integration and streaming issues (slow stream, stuttering, only audio play etc)

I want to integrate libvlc in my Android app to play live video stream that is in m3u8 format. To achieve that I have downloaded a sample source code from here that is a demo to play videos. It is mentioned that we have to first compile vlc for android to run this sample code. For that we must follow this process androidcompile and must be on linux. So instead of following that process i have found an sdk vlc-android-sdk in which vlc code is already compiled for armeabi-v7a and it contains already generated .so files.
Now i have successfully imported that sdk code into sample source code and it works but with following issues:
1) Very slow streaming. After some seconds 6-7 sec it get stuck and then play after very long time again.
2) Sometimes it play video stream for 5-6 seconds and then gets stuck and never play again.
3) Video stream does not play for very long interval of time like 20-30 minutes.
4) Video starts very late.
5) In some devices on start it show video for 2-3 seconds but then video stops and only audio keeps playing.
6) Some streams does not even play at some devices.
So is the above mentioned way (using vlc-android-sdk) to achieve vlc integration the right way? or we must compile the libvlc first on linux (doing that whole lengthy process). If yes then what could be the possible reasons of above mentioned issues. Any suggestions or solution?

Audio Crossfading in Android

I am develping a media player for my learning purpose and I want to have crossfading feature in media player app. But I don't have clue where to start from. i tried searching on inernet but no luck. I am using Android MediaPlayer class for all media player related operation. Anyone know any workaround to achieve the same.
thanks for your support
Try to use the AudioTrack instead of MediaPlayer. Generally, I'd suggest the following plan:
Learn some sources for an app that uses AudioTrack. A good player can be found here
This is an aac audio player that uses JNI for aac-audio decoding.
Find a MP3 decoding library. The library should be a Java one (look at this for example, or it is possible there are another libraries (I did not use such java libraries)) or a C/C++ library (in this case you also will use it through JNI).
When you will get simple working MP3 player, add manual crossfading (this should be easy, if you aware of basics of digital audio).
Try to use two objects of MediaPlayer one after another with crossfade, like in this class https://github.com/psaravan/JamsMusicPlayer/blob/f165057dd664727ed06b9fac2c27557e5fb7e7ee/jamsMusicPlayer/src/main/java/com/jams/music/player/Services/AudioPlaybackService.java
When second mediaPlayer stars first pauses for while (On some devices mostly on samsung )so transition is not smooth. MediaPlayer has this issue and its been reported to google since long ago but still not resolved(https://issuetracker.google.com/issues/36931073) so we can do nothing about it. So I used Exoplayer for playing audio and it works very smoothly without any pause.

Adding video codec to Android

Can someone please explain the steps I need to take in order to add a
new codec to Android?
Also, I would like the codec to be installed as part of an application
installation (or first launch) and NOT as part of a full Android OS
build.
The reason I want to do this is that I have an application that needs
to show a video of a non supported codec (HLS or TS), but I wouldn't
want to build a full blown video player - just integrate with the
existing, built-in, player.
Thanks,
Alik.
Can someone please explain the steps I need to take in order to add a new codec to Android?
Build your own firmware, or build your own media player (like VLC for Android).
Also, I would like the codec to be installed as part of an application installation (or first launch) and NOT as part of a full Android OS build.
That is not possible, unless you build your own media player.
The reason I want to do this is that I have an application that needs to show a video of a non supported codec (HLS or TS), but I wouldn't want to build a full blown video player - just integrate with the existing, built-in, player.
VLC for Android is due out (at least for some phones) shortly, so it may be able to play your format.
I think it maybe possible to add custom codec(though I have not tried) by referring to the android developer page Adding custom codec to android.
You can try out adding your codec through openMAX IL layer then call up the android media player to play it(I believe vlc has done in this way but uses its own player). The awesome player, the android default player, just fetch a list of codecs available through openMAX API and if there is a codec, it plays. So it is worth to try adding your codec during initialization of your app, and call up media player.

Categories

Resources