-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Supported dynamic resolution change by DV timings & ioctl() timeout #164
Conversation
input_uvc had two problems: 1) It hangs if you disconnect the camera cable (or HDMI cable from capture board) while mjpg-streamer was running on ioctl(VIDIOC_DQBUF). I added select() befure this syscall and now mjpg streamer closes after timeout (5 sec. by default). It can be changed by option -timeout. 2) When using video capture devices, it is possible to change the resolution spontaneously when changing the source. I added support of DV timings events and now mjpg-streamer don't hang on changing source disconnecting/connecting cable - it changes resolution automatically and and continues streaming. Both these changes are necessary for work Auvidea B101 board: https://auvidea.com/b101-hdmi-to-csi-2-bridge-15-pin-fpc/ This is a very promising device for video processing. It's officially supports by Raspberry Pi team: https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=120702
Also my patch fixes segfault on IN_CMD_RESOLUTION. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, resolution switching is something I've wanted for a while and I'm sure people will find the timeout useful.
However, I'm hoping you can disable the timeout by default, because some people might not want mjpg streamer to quit or may want it to wait a really long time.
@@ -74,6 +74,8 @@ static unsigned int every = 1; | |||
static int wantTimestamp = 0; | |||
static struct timeval timestamp; | |||
static int softfps = -1; | |||
static unsigned int timeout = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can timeout be disabled by default? To keep current behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current behaviour is totally broken. You don't have any way to know that something went wrong while the program is running. If the connection to device is broken it will never be restored and the fd will be "dead". Mjpg-streamer will hang forever and you do not know why. If you have a timeout, at least you can restart the program.
For example, if mjpg-streamer works inside the camera firmware, the self-monitoring will restart stream in case of a problem if you have this timeout. With old behavior this is impossible, mjpg-streamer will remain frozen and broken.
Do you really want to keep this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenCV uses the same logic for V4L: https://github.com/opencv/opencv/blob/b39cd06249213220e802bb64260727711d9fc98c/modules/videoio/src/cap_libv4l.cpp#L1170
pthread_mutex_unlock(&pglobal->in[pcontext->id].db); | ||
} | ||
|
||
other_select_handlers: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not crazy about the multiple gotos, but I guess this code not very well structured to start with and I can't see an quick way to fix it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an old problem of this function. I didn't want to modify the existing code too much to get a giant patch because I saw that you are working on something in this function. I plan to investigate the automatic resolution change and continue to implement the best support for B101 and maybe I will have to refactor. It seems to me that it is better to make other PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this code and moved events processing into a separate function.
BTW I started my own streamer project. Now it supports multi-threaded compression, hardware compression on Raspberry Pi using OpenMAX and dynamic resolution change. I managed to get a much larger FPS than in mjpg-streamer. Perhaps you will find it useful for yourself :) |
Thanks again! |
input_uvc had two problems:
It hangs if you disconnect the camera cable (or HDMI cable from capture board) while mjpg-streamer was running on ioctl(VIDIOC_DQBUF). I added select() befure this syscall and now mjpg streamer closes after timeout (5 sec. by default). It can be changed by option -timeout.
When using video capture devices, it is possible to change the resolution spontaneously when changing the source. I added support of DV timings events and now mjpg-streamer don't hang on changing source disconnecting/connecting cable - it changes resolution automatically and and continues streaming. This behavior may be enabled by -dv_timings.
Both these changes are necessary for work Auvidea B101 board:
https://auvidea.com/b101-hdmi-to-csi-2-bridge-15-pin-fpc/
This is a very promising device for video processing. It's officially supports by Raspberry Pi team:
https://www.raspberrypi.org/forums/viewtopic.php?f=38&t=120702
May I ask you to take this patch as soon as possible? It is necessary for the open-source IP-KVM project that I develop. In addition, it will be very useful to everyone who uses devices that are disconnected from the PC.
Example for B101:
PS: Sorry for my English.