Pjsip video call - python

I am looking for video call for my door intercom system. I followed the famous "pjproject" for audio calls. It is also mentioned that pjsip is video API supportable. I tried to make video call but couldn't figure out how to proceed with that. I tried to initiate video call in same "sample" file, that is used for audio call.
First I tried to switch auto transmission and auto start video on call but that didn't work. Then I tried to get the count and info of video device using commands vid_dev_count and vid_dev_get_info both didn't work.
ERROR AttributeError: Lib instance has no attribute 'vid_dev_count'
and same for other. Even I tried to access class "VideoDeviceInfo":
AttributeError: 'module' object has no attribute 'VideoDeviceInfo'
First of all whether pjsip API is supportable for Raspberry Pi or not? I read it is mostly supported on PC not portable devices(for video).

Did you follow the instructions for building PJSIP with video support like here, on the section video support? Because there is a big difference between the PJSIP build with and without video support. Further more i can't help you without any sourcecode.

Related

How to listen to audio output by application

Background
I'm working on a music player, and want any sort of audio visualizer to be part of it. I've already made a previous post specifically targeting python-vlc, but I guess not too many people know about it. Here is the post in question: How to get audio samples from python-VLC
What I need
I need a way to listen to audio output, preferably by application although it is not completely necessary. It must be a python module.
What I found
A bunch of tutorials regarding audio input from the microphone, which is NOT what I need
Two swhardware.com tutorials with audio visualizers
https://swharden.com/blog/2016-07-19-realtime-audio-visualization-in-python/
Another one from 2013 but I can't find the link
PyAudio tutorials also using the microphone
Listening audio output with python
terminatorX on Linux; it uses the microphone
squishyball on Linux; it doesn't support all audio files
livefft; uses pyqt4 so I couldn't even test it
Alternatives
Any python module or linux terminal that can provide a list of audio samples from any audio file. Similar to pydub.AudioSegement.get_array_of_samples()
What I don't need
More suggestions to use pydub's get_array_of_samples()
Pydub doesn't read the audio file correctly and quickly gets out of sync from already playing audio
More tutorials of how to get audio from the microphone
Answers on how to strip audio from a video file with ffmpeg

Trying to change the resolution of RTSP video streaming

I am currently working on a hobby project, which is video streaming from an IP camera (Giroptic 360) on RaspberryPi 3 board via RTSP.
I am particularly interested in its URL link used to connect to said camera:
rtsp://[IP address]:[Port]/PSIA/Streaming/channels/2?videoCodecType=H.264
I am wondering if there's such a thing as changing the streamed resolution directly from the URL link (by adding more parameters?) and if there's any more extra functionalities available through the URL link?
** I have tried changing the resolution via openCV's
cap.set(CAP_PROP_FRAME_WIDTH, 1000)
cap.set(CAP_PROP_FRAME_HEIGHT, 500)
But it still gave me the default 2048x1024 resolution.
No, you won't have anyway of commanding via the RSTP link using the opencv built in functions. These work at driver level and all the RTSP link provides is a place to pull frames from.
If you want to resize the images, you can do this after you grab the frame using OpenCV resize
If you want to size the stream itself, then you will need to recode the stream at the source i.e. go into the settings and change it. Although you may not have access to this if it is somebody elses stream, you dont have permissions etc.

How can I change webcam properties that OpenCV doesn't support but v4l2 API does?

I'm using OpenCV 3.1 and Python 2.7 to capture video frames from my webcam, Logitech C270. I'm also using video4linux2(v4l2) to set the properties of my camera but this led to a few problems. My OS is Ubuntu 15.04.
The specific property I'm trying to change is absolute_exposure.
I'm able to change it manually using v4l2 API via terminal, with the command v4l2-ctl --set-ctrl exposure_absolute=40, and it works nice but I need to write a script for this task.
Using OpenCV's set(cv2.CAP_PROP_EXPOSURE, 20) leads to "VIDEOIO ERROR: V4L: Property Exposure(15) not supported by device". I'm sure the webcam supports the change of this property since it's possible to do so using v4l2, then I assume the problem is with OpenCV's wrapper.
I also tried to use subprocess lib to send a terminal command and change the property using v4l2. The command is subprocess.call('v4l2-ctl --device=/dev/video0 --set-ctrl exposure_absolute=20', shell=True).
The result is that exposure_absolute changes but it isn't applied to my current video capture. Image 1 shows the result after setting the property via script. Image 2 shows the result after setting the same property via terminal, with the same video capture active.
Setting exposure_absolute via script (image 1)
Setting exposure_absolute via terminal (image 2)
Image 2 was taken right after image 1, the highlighted line is the same of image 1.
Am I doing something wrong on the subprocess call? Or how can I make the change of this property using a script?
Also, why cv2.VideoCapture(id) resets the camera properties, it's no use changing them before running the script, and is it possible to stop that?
__________________________________________________
Edit: I maybe found a workaround for this problem. The subprocess call is indeed right, I just had to use cv2.read() once before changing the properties, apparently the first cv2.read() is where the camera properties are reset. I still don't know how to stop it from automatically resetting webcam's properties though.
If you build opencv with GStreamer support (flag: -D WITH_GSTREAMER=ON) you can open a VideoCapture using a GStreamer pipeline where you can specify all kind of parameters for v4l2:
std::string cameraPipeline;
cameraPipeline ="v4l2src device=/dev/video0 extra-controls=\"c,exposure_auto=1,exposure_absolute=500\" ! ";
cameraPipeline+="video/x-raw, format=BGR, framerate=30/1, width=(int)1280,height=(int)720 ! ";
cameraPipeline+="appsink";
VideoCapture cap;
cap.open(cameraPipeline);
This is works in C++ and Python. You can get the full list of controls by typing this in a terminal :
v4l2-ctl --list-ctrls-menus

Saving Video to MJPEG Format Locking Up Application

I am using a RPi camera to capture video in a MJPEG format to file. However, when I attempt to do so, the application freezes up and requires me to manually kill it. I am not sure why it is freezing up, but any ideas to resolve this problem would appreciated.
This program entails the following code in accord to the documentation from the following website under the section "start_recording": https://picamera.readthedocs.org/en/release-1.10/api_camera.html#picamera.camera.PiCamera.start_recording
The actual program is as listed below:
start_recording('/home/pi/testVideo.mjpeg', format = 'mjpeg')
camera.wait_recording(5)
stop_recording()

Python Wifi Issue Connect to Mysterious Camera

I have been working with some drones and robotics projects using arduino and python. There was a kickstarter project for a neat little hex copter, that hasn't been managed well.
I was lucky, i got my copter and then some time later after some frustrated email exchanges, i finally recieved the camera as well. To this day, their forum has people still complaining. Their maker forum is now down and their wiki hasn't been updated with any specifics on the camera.
http://www.flexbot.cc/wiki/index.php?title=Main_Page#Hardware
Their app to accompany the drone still doesn't support the camera module. Not that it'd matter, as their code isn't very well documented or annotated.
https://github.com/HexAirbot
There are some tips on switching the camera on the comments page of their kickstarter campaign.
https://www.kickstarter.com/projects/1387330585/hex-a-copter-that-anyone-can-fly/posts/1093716
So, sob story over, i'm stuck with this neat little wifi camera that i am unsure on how to connect to. I know how to switch it on and it does have a micro-usb port on it.
What library in Python could i use to stream an image from this camera given that it is a wifi camera. If i wanted the video stream as a numpy matrix.
I need to interface with the camera, so i can connect and disconnect.
Then, be able to read images frame by frame with ffmpeg. I have some python modules that can detect and read from a camera, but how can my code ensure that the camera is connected?
Totally stuck. Any help would be appreciated.
Considering you are building for the android platform, you will more than likely need to use some sort of java/python driver/interface, unless you just use java.
Here is an article on java/python, and using python from within java.
Using Python from within Java

Categories

Resources