Source stream cropping strikes back

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
sabretoothedhamster
Posts: 23
Joined: Fri Mar 22, 2019 1:21 pm

Source stream cropping strikes back

Post by sabretoothedhamster » Mon Jun 01, 2020 10:56 am

Hello everyone!

May I draw your attention to a topic from the past: viewtopic.php?p=101031 ? My attempt to google the theme resulted in a conclusion that it raised several times but had not been solved. Yet I feel that with wider availability of cheap highres cameras (without variable zoom optics) such an option could be really helpful.

My own attempts also totally failed. The ffmpeg binary itself takes option like '-filter:v crop=1000:740:640:480' perfectly. However, any attempt to put into zm camera setup -> Source -> Options anything like that ('filter:v crop=1000:740:640:480' or 'filter:v=crop=1000:740:640:480' 'filter:v,crop=1000:740:640:480', or 'fv="crop=1000:740:640:480"' ) results in errors like 'Option filter:v crop not recognized by ffmpeg'.

I even tried to put my custom script into Options->Images->PATH_FFMPEG to dump real option strings passed to ffmpeg by zm, and run snoopy in background to trace every process run in the system, but found that zoneminder ignores that PATH_FFMPEG options and does not run ffmpeg process at all(!).

Could anyone give me a hint how can i crop the source video stream (before processing by zm)?

Thanks for any suggestions!

P.S. I do have zm 1.34.15 running on Ubuntu 18.04.4 LTS
5M RTSP camera configured as ffmpeg/modect source using rtsp:// URL, TCP stream and x264 Encode video writer.

User avatar
iconnor
Posts: 1186
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Source stream cropping strikes back

Post by iconnor » Mon Jun 01, 2020 12:44 pm

ZM doesn't support that at this time.

mikb
Posts: 456
Joined: Mon Mar 25, 2013 12:34 pm

Re: Source stream cropping strikes back

Post by mikb » Mon Jun 01, 2020 2:52 pm

sabretoothedhamster wrote:
Mon Jun 01, 2020 10:56 am
'-filter:v crop=1000:740:640:480' perfectly

Could anyone give me a hint how can i crop the source video stream (before processing by zm)?
Two things :-

Your command line seems to cut a 1000x740 box out of the source video, positioned 640 along and 480 down. Is that really what you meant? It's an unusual video size and aspect ratio, hence my question.

Or did you intend to cut a 640x480 box out of the source video, positioned 1000 across and 740 down.

Parameters are width:height:xoffs:yoffs ...

If you want another way to force parameters into ffmpeg, you could try creating a shell script, called "myffmpeg" which exists only to call the real ffmpeg, forcing in your parameters, and then passing on "everything else" from ZM -- then tell ZM the path to your fake ffmpeg.

I don't know if that would help your situation or not, but I recall having to do something similar before when something wouldn't play nice :)

Alternatively, maybe you could look at using something like ffserver to create a second virtual camera from your real camera, so: taking the stream from the camera into ffmpeg yourself, processing it, then making the output available via ffserver so that ZM can see it. ZM would unaware that you had tampered with the stream.

sabretoothedhamster
Posts: 23
Joined: Fri Mar 22, 2019 1:21 pm

Re: Source stream cropping strikes back

Post by sabretoothedhamster » Mon Jun 01, 2020 8:11 pm

iconnor wrote:
Mon Jun 01, 2020 12:44 pm
ZM doesn't support that at this time.
Hello Isaac!

Thank you for the prompt answer... Would you please elaborate also a little bit on PATH_FFMPEG? Do I understand correctly that zoneminder does not use ffmpeg binary at all? What if I build my own instance of ffmpeg (e.g. with additional hw accelerations enabled) - how could I use it then with zm?
Last edited by sabretoothedhamster on Mon Jun 01, 2020 8:17 pm, edited 1 time in total.

sabretoothedhamster
Posts: 23
Joined: Fri Mar 22, 2019 1:21 pm

Re: Source stream cropping strikes back

Post by sabretoothedhamster » Mon Jun 01, 2020 8:16 pm

Hello mikb!
mikb wrote:
Mon Jun 01, 2020 2:52 pm
Parameters are width:height:xoffs:yoffs ...
I know that. I have just used some temporary sample... It will not work this way in any case :(

As you may guess from my question I tried to substitute "default" zoneminder's ffmpeg with my own script but also without success.
mikb wrote:
Mon Jun 01, 2020 2:52 pm
Alternatively, maybe you could look at using something like ffserver to create a second virtual camera from your real camera, so: taking the stream from the camera into ffmpeg yourself, processing it, then making the output available via ffserver so that ZM can see it. ZM would unaware that you had tampered with the stream.
It seems that this approach with ffserver is the only remaining option. Thank you for the idea!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests