Giter Site home page Giter Site logo

Comments (10)

faithoflifedev avatar faithoflifedev commented on August 14, 2024

Hi @bubblesdev,

The simplest way to troubleshoot these issues is by using the included onvif cli command that is included in the package. You can find the install and quick start for these in the README. Once you have the cli application installed and authorized you can run commands like the following to get a full debug of the request/response for your device.

# list profile tokens for your device with debug
onvif media1 get-profiles --log-level all

#just list the tokens (no debug)
onvif media1 get-profiles | jq -r '.[]."@token"'

#get the stream uri (wuth debug)
onvif media1 get-stream-uri --profile-token Profile_1 --log-level all

If you add the output to the issue, I can make suggestions or resolve any bugs.

Overall, the error that your getting means that the http connection has timed out in its attempt to connect to your device. So it's likely that the IP address and port combination you're using to connect is incorrect.

Also the above commands are primarily targetted at macos and linux users. The jq utility can probably be installed on windows with chocolatey.

from easy_onvif.

bubblesdev avatar bubblesdev commented on August 14, 2024
Screen Shot 2024-01-23 at 12 36 07

I'm able to use the cli commands to fetch both snapshot and streamuri but doesn't work on the app as connections are refused and same errors above

from easy_onvif.

faithoflifedev avatar faithoflifedev commented on August 14, 2024

Hi @bubblesdev,

I assume by "app", you mean a Flutter app? Since the cli command is running properly this means that the easy_onvif package works properly with your device. The likely issue in this case is the Flutter code you're using to connect to the device. Since I haven't seen the code, there's not a lot I can suggest.

from easy_onvif.

bubblesdev avatar bubblesdev commented on August 14, 2024

Here's the code below:

String? rtspUri;
VideoPlayerController? _controller;
bool connecting = true;
late Onvif onvif;
late final List profiles;
String? snapshotUri;
String url = '';

@OverRide
void initState() {
initialize();
super.initState();
// Initialize ONVIF connection (replace with your camera details)
}

Future initialize() async {
onvif = await Onvif.connect(
host: 'ipaddress',
// Replace with camera IP address
username: 'admin',
password: 'password!');

setState(() {
  connecting = false;
});

}

Future _fetchStreamUri() async {
if (!connecting) {
try {
profiles = await onvif.media.getProfiles();
initializeVideoPlayer();
try {
if (profiles.isNotEmpty) {
snapshotUri = await onvif.media.getSnapshotUri(profiles[0].token);
print('Snapshot: $snapshotUri');
}
} catch (err) {
loggy.error(err.toString());
}
var media = await onvif.media.getProfiles();
var profileToken = media.first.token;
print('Profile: $profileToken');
try {
setState(() {
url = OnvifUtil.authenticatingUri(snapshotUri!, "admin", "password");
print('Snapshot URL: $url');
});
} catch (e) {
print('Error constructing snapshot URL: $e');
}

    rtspUri = await onvif.media.getStreamUri(profileToken);
    print('RTSP URI: $rtspUri');
     // Start video playback
  } catch (e) {
    print('Error fetching stream URI: $e');
    if (e is DioException) {
      print('DioError details: ${e.type}, ${e.message}, ${e.error}');
    }
  }
}else{
  print('Not connected!');
}

}
Screen Shot 2024-01-23 at 18 46 58

void initializeVideoPlayer() async {
if (rtspUri != null) {
_controller = VideoPlayerController.networkUrl(rtspUri! as Uri);
await _controller?.initialize();
await _controller?.play();
setState(() {
}); // Update UI to display video
}
}

Thank you for help!

from easy_onvif.

faithoflifedev avatar faithoflifedev commented on August 14, 2024

Flutter can be pretty tricky with it's use of Futures. In your case your initialize() method is returning before it's completed execution, due to it being an async method.

Have a look at the Flutter example that I've provided with the package. It might help you out - example.

from easy_onvif.

bubblesdev avatar bubblesdev commented on August 14, 2024

Thanks but I am still surprised that the getStreamUri still don't work after implementing your example and also the snapshotUri is fetched but doen't load as connection is refused, seems the uri is not in the right format:
I also tried futurebuilder and it is still same error :/

Here's a log report
` 21:45:48.468250 DEBUG - getStreamUri
[UI Loggy - LoggingInterceptors] 🐛 21:45:48.473820 DEBUG - URI: http://ipaddress:1091/Media2
[UI Loggy - LoggingInterceptors] 🐛 21:45:48.474655 DEBUG - REQUEST:

admin2aP4Za4Vkugw1n81hutfqcfwuhs=422l5F32DOFNSVOOnIg6Sw==2018-01-01T20:24:08.272919ZRTSPMainStream

E/flutter ( 7892): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: DioException [unknown]: null
E/flutter ( 7892): Error: HttpException: Connection closed before full header was received, uri = http://ipaddress:1091/Media2
E/flutter ( 7892): #0 Transport.sendRequest (package:easy_onvif/src/soap/transport.dart:51:7)
E/flutter ( 7892):
E/flutter ( 7892): #1 Media2.getStreamUri (package:easy_onvif/src/media2.dart:173:22)
E/flutter ( 7892):
E/flutter ( 7892): #2 Media.getStreamUri (package:easy_onvif/src/media.dart:256:11)
E/flutter ( 7892):
E/flutter ( 7892): #3 _MyHomePageState._initialize (package:onivf_app/stream_screen.dart:90:17)
E/flutter ( 7892):
E/flutter ( 7892):
[UI Loggy - LoggingInterceptors] ‼️ 21:45:49.019338 ERROR - ERROR:
DioException [unknown]: null
Error: HttpException: Connection closed before full header was received, uri = http://ipaddress:1091/Media2`

from easy_onvif.

bubblesdev avatar bubblesdev commented on August 14, 2024

After updating to the recent version 2.2.0. The streamUri was fetched succesfully, but the rtsp can't be opened:
ibvlc demux: Failed to connect with rtsp://ipaddress:554/stream0?username=admin&password=password
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: Failed to connect to RTSP server ipaddress:554
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: cannot connect to ipaddress:554
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: Connection failed
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: VLC could not connect to "ipaddress:554".
E/VLC (20644): [b400007219740290/5675] libvlc input: Your input can't be opened
E/VLC (20644): [b400007219740290/5675] libvlc input: VLC is unable to open the MRL 'rtsp://ipaddress:554/stream0?username=admin&password=password'. Check the log for details.

Pls which video player can open the link

from easy_onvif.

faithoflifedev avatar faithoflifedev commented on August 14, 2024

Hi @bubblesdev ,

Did you manually update the log message to remove the IP address from the log?

rtsp://ipaddress:554/stream0?username=admin&password=password

This package will return the rtsp uri from your device, anything after that is out of scope for thid project. For questions about errors from the VLC package should be asked there.

from easy_onvif.

bubblesdev avatar bubblesdev commented on August 14, 2024

Nah, i edited the ipaddress before commenting

from easy_onvif.

muyiwexy avatar muyiwexy commented on August 14, 2024

@faithoflifedev I on the other hand is getting DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.

from easy_onvif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.