Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv::VideoCapture.open(RTSP URL string) crashes on Android and iOS. #11995

Closed
omatrot opened this issue Jul 17, 2018 · 7 comments
Closed

cv::VideoCapture.open(RTSP URL string) crashes on Android and iOS. #11995

omatrot opened this issue Jul 17, 2018 · 7 comments

Comments

@omatrot
Copy link

omatrot commented Jul 17, 2018

System information (version)
  • OpenCV => 3.4.1
  • Operating System / Platform => Android
  • Compiler => Android Studio
Detailed description

I'm using OpenCV native C++ code.
The following code:
cv::VideoCature.open("http://192.168.1.107/videostream.asf?user=admin&pwd=&resolution=32");

crashes and show the following variables (here in Android Studio):

cv::param_VIDEOCAPTURE_DEBUG = Cannot find the execution point
Signal = SIGBUS (signal SIGBUS: illegal alignment)
__cv_trace_location_extra_fn118 = {cv::utils::trace::details::Region::LocationExtraData * | 0x0} NULL
__cv_trace_location_fn118 = {const LocationStaticStorage}
this = {cv::VideoCapture * | 0x8bf893f0} 0x8bf893f0
filename = {const cv::String &}
__region_fn = {const cv::utils::trace::details::Region}

Please note that the URL is a RTSP stream. The same code works fine on Linux.

I'm sorry I can't find a way to copy the stack trace in Android Studio.
The last frame is:
cv::String::deallocate() 0x000000008b0829ce

Steps to reproduce

cv::VideoCapture cap;
cap.open("http://192.168.1.107/videostream.asf?user=admin&pwd=&resolution=32");

@omatrot
Copy link
Author

omatrot commented Jul 17, 2018

capture d ecran 2018-07-17 a 15 57 05

capture d ecran 2018-07-17 a 16 00 29

@alalek
Copy link
Member

alalek commented Jul 17, 2018

There is no support for RSTP streams in builds for Android platform.

Stack trace shows code from builtin OpenCV MJPEG codec. It is hard to say what is going wrong, but this codec definitely can't handle RSTP streams.

You need to rebuild OpenCV with FFmpeg / GStreamer for Android (they can handle RSTP streams).
Unfortunately, we can't provide complete actual recipes/steps how to do that - you can try to ask for help on Users Q/A forum: http://answers.opencv.org

@omatrot
Copy link
Author

omatrot commented Aug 22, 2018

We've solved the problem by aplying the following flags for compilation:
-fpack-struct=8 -mllvm -arm-promote-constant=0

The illegal alignment error lead us to use those options.

@takacsd
Copy link
Contributor

takacsd commented Aug 16, 2019

Have the same error with a simple mp4 file, but rebuilding opencv with the flags doesn't seem to help...
@omatrot can you explain exactly what was causing the error in your case?

@omatrot
Copy link
Author

omatrot commented Aug 19, 2019

@takacsd We had this problem on a 32 bits armeabi-v7a Android phone.
Low level c++ code and compilation options could be tricky.
If these options are not helping, then you're facing another problem that deserves its own issue.

@takacsd
Copy link
Contributor

takacsd commented Sep 19, 2019

Yes, it is also a 32 bits armeabi-v7a Android phone, with the same error at the same place.
Anyway I don't use VideoCapture anymore, seems like everything else is working fine.

@YasserMojahed
Copy link

YasserMojahed commented Apr 8, 2020

We've solved the problem by aplying the following flags for compilation:
-fpack-struct=8 -mllvm -arm-promote-constant=0

The illegal alignment error lead us to use those options.

Hi Omatrot,
I used to use VideoCapture for RTSP stream in Linux C++
Now, I am using VideoCapture in Java Android and it doesnt work. Open() method returns false.
I am going to Try Native C++ with NDK in AndroidStudio.
so seems u tried the same and that wont work.
Now I am confused. Where to add these flags?
-fpack-struct=8 -mllvm -arm-promote-constant=0
Thanks for help

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

No branches or pull requests

4 participants