RSATom / QmlVlc

[ABANDONED] libvlc wrapper for Qt Quick 2/Qml
Other
139 stars 56 forks source link

QmlVlc on Android framerate #29

Open mzafers opened 9 years ago

mzafers commented 9 years ago

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 commented 9 years ago

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

RSATom commented 9 years ago

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

mzafers commented 9 years ago

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

RSATom commented 9 years ago

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

mzafers commented 9 years ago

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 commented 9 years ago

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

mzafers commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

mzafers commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

RSATom commented 9 years ago

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

Mikelgate commented 9 years ago

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:

Anyone can help me?

Thank you.

RSATom commented 9 years ago

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

Mikelgate commented 9 years ago

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

RSATom commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@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 commented 9 years ago

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 commented 9 years ago

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

mzafers commented 9 years ago

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 commented 9 years ago

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

mzafers commented 9 years ago

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

RSATom commented 9 years ago

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

mzafers commented 9 years ago

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

RSATom commented 9 years ago

It was predictable... Thank you for info.

sk2212 commented 9 years ago

@mzafers mzafers

Can you please tell what you have done?

mzafers commented 9 years ago

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 commented 9 years ago

[removed]

mzafers commented 9 years ago

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

mzafers commented 9 years ago

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 commented 9 years ago

Amazing! Will check it right now.

mzafers commented 9 years ago

Please comment after you tried.

sk2212 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@mzafers

Something new regarding Android 5?

mzafers commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

@mzafers

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

sk2212 commented 9 years ago

@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 commented 9 years ago

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

sk2212 commented 9 years ago

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 commented 9 years ago

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

sk2212 commented 9 years ago

Amazing!

trungnthut commented 8 years ago

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?