Skip to content

update generate video for proper escaping#4975

Open
rnveach wants to merge 2 commits into
ZoneMinder:masterfrom
rnveach:issue_4970
Open

update generate video for proper escaping#4975
rnveach wants to merge 2 commits into
ZoneMinder:masterfrom
rnveach:issue_4970

Conversation

@rnveach

@rnveach rnveach commented Jul 7, 2026

Copy link
Copy Markdown

Issue #4970

This just fixes the log file creation. It doesn't resolve the issue.

I do know PHP, but it has been a while and because of the complexity of the command I asked AI to assist with the changes.

Feel free to review and recommend any updates.

Copilot AI review requested due to automatic review settings July 7, 2026 23:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Event::GenerateVideo() (ZoneMinder web UI backend) to improve shell escaping around the ffmpeg invocation so that ffmpeg’s output can be redirected into ffmpeg.log, addressing Issue #4970 where the UI references a log file that isn’t created.

Changes:

  • Switches to argument-level escaping (escapeshellarg) for ffmpeg input/output paths and filter arguments.
  • Stops wrapping the entire command with escapeshellcmd, allowing shell redirection (> ... 2>&1) to function.
  • Expands the error log message to include the captured exec() output and return code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/includes/Event.php Outdated
Comment thread web/includes/Event.php Outdated
Comment thread web/includes/Event.php Outdated
Comment thread web/includes/Event.php Outdated
@rnveach

rnveach commented Jul 7, 2026

Copy link
Copy Markdown
Author

Copilot recommended some fixes and it feels like all the ffmpeg errors are gone. However, I still get an internal server error (500 from the server) but I get no errors in the system logs. So there must be something else and I am not sure where to go from here.

@connortechnology

Copy link
Copy Markdown
Member

In system logs or in apache log? Typically with 500, there would be something in /var/log/apache2/error.log (or site-specific log). Maybe check journalctl -f ?

Changes look good to me.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread web/includes/Event.php
Comment on lines 865 to +868
$command = ZM_PATH_FFMPEG
." -y -r $frame_rate "
.ZM_FFMPEG_INPUT_OPTIONS
.' -i ' . $event_path.'/'.( $this->DefaultVideo() ? $this->DefaultVideo() : '%0'.ZM_EVENT_IMAGE_DIGITS .'d-capture.jpg' )
." -i ".escapeshellarg($event_path.'/'.( $this->DefaultVideo() ? $this->DefaultVideo() : '%0'.ZM_EVENT_IMAGE_DIGITS .'d-capture.jpg' ))
Comment thread web/includes/Event.php
Comment on lines +871 to +875
.implode(' ', array_map(function($t){ return ' -vf '.escapeshellarg($t); }, array_filter(explode(',', $transforms), 'strlen')))
." -s $video_size "

.ZM_FFMPEG_OUTPUT_OPTIONS
." '$event_path/$video_file' > $event_path/ffmpeg.log 2>&1"
." ".escapeshellarg($event_path.'/'.$video_file)." > ".escapeshellarg($event_path.'/ffmpeg.log')." 2>&1"
Comment thread web/includes/Event.php Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rnveach

rnveach commented Jul 8, 2026

Copy link
Copy Markdown
Author

In system logs or in apache log?

I checked system logs inside ZM. This is what I see from apache logs which seems like a PHP error:

PHP Fatal error: Uncaught Error: Call to undefined function findVideoEventFile() in /usr/share/zoneminder/www/includes/download_functions.php:118\nStack trace:\n#0 /usr/share/zoneminder/www/ajax/event.php(147): downloadEvents()\n#1 /usr/share/zoneminder/www/index.php(300): require_once('/usr/share/zone...')\n#2 {main}\n thrown in /usr/share/zoneminder/www/includes/download_functions.php on line 118, referer: https://mydomain/zm/?view=montagereview&filtering=&MonitorName=&Source=&MonitorId%5B%5D=1&filter%5BQuery%5D%5Bterms%5D%5B0%5D%5Battr%5D=DateTime&filter%5BQuery%5D%5Bterms%5D%5B0%5D%5Bop%5D=%3E%3D&filter%5BQuery%5D%5Bterms%5D%5B0%5D%5Bval%5D=2026-07-07+17%3A09%3A15&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Bcnj%5D=and&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Battr%5D=DateTime&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Bop%5D=%3C%3D&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Bval%5D=2026-07-07+17%3A16%3A00&filter%5BQuery%5D%5Bterms%5D%5B2%5D%5Bcnj%5D=and&filter%5BQuery%5D%5Bterms%5D%5B2%5D%5Battr%5D=MonitorId&filter%5BQuery%5D%5Bterms%5D%5B2%5D%5Bop%5D=IN&filter%5BQuery%5D%5Bterms%5D%5B2%5D%5Bval%5D=1&filter%5BQuery%5D%5Bterms%5D%5B3%5D%5Bcnj%5D=and&filter%5BQuery%5D%5Bterms%5D%5B3%5D%5Battr%5D=Archived&filter%5BQuery%5D%5Bterms%5D%5B3%5D%5Bop%5D=%3D&filter%5BQuery%5D%5Bterms%5D%5B3%5D%5Bval%5D=&filter%5BQuery%5D%5Bterms%5D%5B4%5D%5Bcnj%5D=and&filter%5BQuery%5D%5Bterms%5D%5B4%5D%5Battr%5D=Tags&filter%5BQuery%5D%5Bterms%5D%5B4%5D%5Bop%5D=%3D&filter%5BQuery%5D%5Bterms%5D%5B5%5D%5Bcnj%5D=and&filter%5BQuery%5D%5Bterms%5D%5B5%5D%5Battr%5D=Notes&filter%5BQuery%5D%5Bterms%5D%5B5%5D%5Bop%5D=LIKE&fit=1&live=0

This will be for a separate another PR.

Edit: I tried adding a require_once('functions.php'); but it still generated the same error.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants