Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

QmlVlc on Android framerate #29

Open
mzafers opened this issue Nov 12, 2014 · 48 comments
Open

QmlVlc on Android framerate #29

mzafers opened this issue Nov 12, 2014 · 48 comments

Comments

@mzafers
Copy link

mzafers commented Nov 12, 2014

Hello RSATom. I try to use QmlVlc on Android. I have a dual core 1Ghz tablet. VLC.apk can play fullHD video. But QmlVlc cannot. I think hardware acceleration mode is not enabled. I search VLC parameters, I found that:

const char _argv[] = {"-I", "dummy", "-vvv", "--no-drop-late-frames", "--codec", "iomx,all"};
size_t argc = sizeof(argv) / sizeof(_argv);
return libvlc_new(argc, argv);

If I set that parameters in QmlVlcConfig.cpp file, tablet can play fullHD video low fps and some freeze. Do you know how to play a fullHD video on QmlVlc like VLC.apk? What are the best parameters? Any idea?

@RSATom
Copy link
Owner

RSATom commented Nov 12, 2014

Sorry, I didn't test it on android. I even don't have any android device to try.

@RSATom
Copy link
Owner

RSATom commented Nov 12, 2014

btw, do you use VlcPlayer or VlcMmPlayer? if you use VlcPlayer, then try VlcMmPlayer, it could help, but I don't sure.

@mzafers
Copy link
Author

mzafers commented Nov 12, 2014

I've tried both of them. But I'm gonna try again VlcMmPlayer.

@RSATom
Copy link
Owner

RSATom commented Nov 12, 2014

btw, don't use "-vvv" option - it enables debug mode, and could affect performance.

@mzafers
Copy link
Author

mzafers commented Nov 12, 2014

I just tried VlcMmPlayer. Same result. Yes you're right, "-vvv" enables debug mode. I removed it. The parames are now:
const char *argv[] = {"-I", "dummy", "--no-drop-late-frames", "--codec", "iomx,all"};

@RSATom
Copy link
Owner

RSATom commented Nov 12, 2014

It seems QmlVlc needs some optimizations for android platform...

@mzafers
Copy link
Author

mzafers commented Dec 16, 2014

Hello again RSATom. I spend too much time to solve this issue. But I couldnt yet.
void QmlVlcVideoOutput::video_display_cb function is triggered well on android device. So, libvlc can decode all frames. But the render mechanism is too slow maybe and seems frame lost on the screen. What is the difference between desktop opengl and android opengl, do you know? Must I modify opengl code section for android? What function must be modified? Do you have any idea?
Thank you.

@RSATom
Copy link
Owner

RSATom commented Dec 16, 2014

Android devices just much less powerful than any desktop platform, and if on desktop decoding frame to memory and after that transfer to video memory is fast enough for smooth playback, on android device it could be much worse.
One possible solution, I think, could be decoding video frame directly to opengl framebuffer and use it as texture, but don't know haw good my guess is. Maybe it will be better look to vlc for android sourses to find way it uses, and use something similar...

@RSATom
Copy link
Owner

RSATom commented Dec 17, 2014

btw, did you try to use QtMultimedia (i.e. without QmlVlc at all)? Does it has acceptable performance?

@mzafers
Copy link
Author

mzafers commented Dec 17, 2014

Yes, I tried 1080p videos on QtMultimedia QML Video element. It plays perfect on tablet. I checked vlc android sources, but it seems simple. It uses libvlc's display methods. I didnt find any opengl code section. I checked QtMultimedia sources also, it's too complicated. I checked opengl shaders code section. It's too hard to find the reason.

@RSATom
Copy link
Owner

RSATom commented Dec 17, 2014

Sorry, don't know how to help you... I even don't have any android device to test it on...

Do you really need QmlVlc if QtMultimedia work good?

@mzafers
Copy link
Author

mzafers commented Dec 17, 2014

QtMultimedia cannot play http and rtsp streams, some video formats. If I rebuild QtMultimedia gstreamer with streaming feature, I can use that.

@RSATom
Copy link
Owner

RSATom commented Dec 17, 2014

Understand... I'm afraid I can't help you, at least this time, maybe later but don't know when exactly... Sorry.

@Mikelgate
Copy link

Hello, I've been trying to configure qmlvlc demo to compile to android devices with QT5.4 with no luck.
I want to play a video stream from the raspberry pi in tablet. The problem with qtmultimedia is that it uses the android native player and this player don't support h264 high profile. At this time android player only support h264 baseline profile and raspberry pi can not stream it. The transcoding option is discarded due the power of the raspberry.

I'm new in android development. I followed these steps:

  • https://wiki.videolan.org/AndroidCompile/:
  • Download / Install Android SDK
  • Download / Install Android NDK
  • Exported the paths
  • Exported the abi (export ANDROID_ABI=armeabi-v7a)
  • Download VLC (git clone git://git.videolan.org/vlc-ports/android.git)
  • Compile VLC (sh compile.sh release)
  • Create SDK (make .sdk ) => Fail. I have to build it manually copying the folders manually
  • In QT Creator:
  • I copied the generated sdk to the project folder.
    At this point, how can I link the android vlc sdk to QT Creator?
    I tried something like:
    X86{
    LIBS += -lvlc
    }
    else{
    LIBS += -Landroid/vlc-sdk/src/org/videolan/libvlc/libVLC.java
    }
    but doesn't work.
    There are a los of errors like:
    QmlVlcConfig.o:QmlVlcConfig.cpp:function QmlVlcConfig::createLibvlcInstance(): error: undefined reference to 'libvlc_new'

Anyone can help me?

Thank you.

@RSATom
Copy link
Owner

RSATom commented Jan 11, 2015

Are you really need QmlVlc? It needs to be optimized for android before.

@Mikelgate
Copy link

I would like to try and help its development if I can.

@RSATom
Copy link
Owner

RSATom commented Jan 11, 2015

I will be glad if you will try. But, unfortunately, I couldn't help you with any android related questions - Maybe somebody else will... Please keep me informed about progress. Thanks!

@mzafers
Copy link
Author

mzafers commented Apr 3, 2015

Hi friends. I follow different way on Android and it's done. I've integrated LibVLC into QtMultimedia source, modified original java files, compiled it. I created a hybrid system. After compiling, I just copy modified jar files into my "C:\Qt\5.4\android_armv7\jar" directory. It means I can use original QML elements in my QML project on Android. I can use original MediaPlayer or modified MediaPlayer. It's too easy. If I add ":VLC" suffix to MediaPlayer.source it uses QtMultimediaWithLibVLC at backend, otherwise it uses original QtMultimedia. So, QtMultimedia on Android is powerful now. I want to share it with Qt friends, but I have no time. I will. And dear Tom, I worked LibVLC QML project on desktop. It's a small project and uncompleted yet. It uses widget hwnd to display. Can I create a different repo for this?

@RSATom
Copy link
Owner

RSATom commented Apr 3, 2015

@mzafers, it's great! And I would like to see how you did it.

Can I create a different repo for this?

I don't understand. Why do you ask me? You free to do anything you like :)

@mzafers
Copy link
Author

mzafers commented Apr 3, 2015

Ok :) I will do some cosmetics (clean some output logs) for QtMultimediaVLC on Android and share it. Maybe name is "QtMultimediaVLC". In fact, I did try Vitamio integration before. I did it, but I faced an issue about hardware acceleration modules releasing. It can play first attempt fine, but if I release mediaPlayer and create again it cannot play with hardware acceleration mode. And then I decided to work on LibVLC.

And my second job is LibVLC QML for desktop. I couldn't find a name for it. It's tiny and uncompleted yet.

@RSATom
Copy link
Owner

RSATom commented Apr 3, 2015

Btw, on what hardware did you test it? And how smooth was playback?

@mzafers
Copy link
Author

mzafers commented Apr 3, 2015

I've Samsung 7" T230 tablet and LG G2 Mini mobile phone. I tested bigbuckbunny 1080p 30fps video. It plays fine. If VLC application can play then QtMultimediaVLC can play. Same result.

@RSATom
Copy link
Owner

RSATom commented Apr 3, 2015

How do you think, is it possible achieve same result with QmlVlc? Do you know what exactly wrong with it?

@mzafers
Copy link
Author

mzafers commented Apr 3, 2015

I think, EGLImage method can do that. It's hard to implement it.

@RSATom
Copy link
Owner

RSATom commented Apr 3, 2015

So the bottleneck in QmlVlc is copy decoded frame from memory to video memory?

@mzafers
Copy link
Author

mzafers commented Apr 3, 2015

Yes it is. I see that, glTexImage2D / glTexSubImage2D functions work slow.

@RSATom
Copy link
Owner

RSATom commented Apr 3, 2015

It was predictable... Thank you for info.

@sk2212
Copy link

sk2212 commented Jun 16, 2015

@mzafers mzafers

Can you please tell what you have done?

@mzafers
Copy link
Author

mzafers commented Jun 16, 2015

Hi. I've downloaded VLC Android and QtMultimedia source, copied VLC java files into QtMultimedia dirs, added them to jar project, modified QtMultimedia's own java files and compiled jar.pro only. It generates 2 jar files. (QtMultimedia.jar and QtMultimedia-bundled.jar) I copied them into C:\Qt\5.4\android_armv7\jar dir. I cannot create my own repo yet about this project.

@sk2212
Copy link

sk2212 commented Jun 16, 2015

[removed]

@mzafers
Copy link
Author

mzafers commented Jun 17, 2015

I'm creating new repo for this. What is your Android version?

@mzafers
Copy link
Author

mzafers commented Jun 17, 2015

I've created. You can check my repos. But I couldn't format readme.md file in my QtVlcMediaPlayerSample repo, sorry. Maybe I modify the file later. I tested it on Android 4.4.2 and 4.1.2.

@sk2212
Copy link

sk2212 commented Jun 17, 2015

Amazing! Will check it right now.

@mzafers
Copy link
Author

mzafers commented Jun 17, 2015

Please comment after you tried.

@sk2212
Copy link

sk2212 commented Jun 17, 2015

You are my hero!!! This works simply perfect. Tested on my Android lowspeed 4.2.2 Android Tablet device. Will try it also on my Nexus 4 with Android 5.1.1.

I also try QtAv project from wang-bin but it was hard to compile and furthermore content was als a little bit stuttering and asynchronous.

I think you (or we) MUST publish your work. Can you also provide the merged source code from QtMediaPlayer and VLC?

@mzafers
Copy link
Author

mzafers commented Jun 17, 2015

Did it work :) Thanks. I send it Qt Forum. Qt friends should use it. Actually I try QtAV before. But it was slow and unstable. I spend tooooo much time to play high res videos, streams on Qt Android. But I cannot find any solution. And then I started to read LibVLC java files and modify QtMultimedia java files. In fact I developt this 3 months ago. I dont have time for github. I saw your comment yesterday and I shared it. I will publish the codes when I free.

@sk2212
Copy link

sk2212 commented Jun 17, 2015

Really really good! Currently I play hd content from a Upnp Device over wireless network on my tablet with your MediaPlayer implementation.

I try also differnt solutions but no one works perfect...until your implementation.

On my Nexus 4 with Android 5.1.1 I got following error:

E/art (19564): dlopen("/data/app/org.qtproject.example.QtQmlMediaPlayer-2/lib/arm/libiomx.14.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "_ZN7android12MemoryDealerC1EjPKc" referenced by "libiomx.14.so"...

I seems that libiomx.14.so must be build against different Android version, right? Can you do it?

@mzafers
Copy link
Author

mzafers commented Jun 17, 2015

I don't have an Android 5 device. Right, maybe LibVLC files don't support Android Lollipop. I will try it on Android 5 emulator.

@sk2212
Copy link

sk2212 commented Jun 18, 2015

@mzafers

Something new regarding Android 5?

@mzafers
Copy link
Author

mzafers commented Jun 18, 2015

In fact, I couldn't build my sample project today. I'll try again later. Do you need to use this on Android 5?

@sk2212
Copy link

sk2212 commented Jun 18, 2015

Well, it would be really nice because more and more Android devices will be updated to latest Android versions. So when you be able to build it you project can become even more useful :-)!

@sk2212
Copy link

sk2212 commented Jun 19, 2015

@mzafers

Can you provide source code? Maybe I can help you with development.

@sk2212
Copy link

sk2212 commented Jun 19, 2015

@mzafers

I found the problem :-)!

To run the project on Android 5 devices simply not include "libiomx.14.so". So I removed the include path for this library and it works.

I studied code from "http://maci.satgnu.net/rpmbuild/BUILD/xbmc-12.2/xbmc/android/activity/AndroidFeatures.cpp" while searching for "libiomx.14.so" and see that they do not use this library for Android versions bigger than IceCreamSandwich (Version 4.2).

Playback is working like a charm!

@mzafers
Copy link
Author

mzafers commented Jun 22, 2015

Then we need 2 apk file. It's not good.

@sk2212
Copy link

sk2212 commented Jun 22, 2015

Well...than we have to patch the line where libVLC tries to load "libiomx.14.so". However maybe we can continue discussing this issue at your repo? Please can you also push the source code?

@mzafers
Copy link
Author

mzafers commented Jun 22, 2015

I pushed. You can see the trick at QtAndroidMediaPlayer.java file.

@sk2212
Copy link

sk2212 commented Jun 23, 2015

Amazing!

@trungnthut
Copy link

hi @mzafers I've just tried QmlVlc on Neo Minix X5 Mini 4.2.2 to play some mp4 file and the framerate is very slow. I've tried the QmlVlcDemo and got the same issue.
Official VLC app run well.

Do you got any idea or can you tell me who to see the trick for that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants