Search code examples
phpvideoffmpegmp4watermark

Zoneminder Watermarking on MP4 video from custom ZM branch


The ZM i have installed is the video branch. I followed these instructions to install it. https://github.com/ZoneMinder/ZoneMinder/tree/video https://github.com/ZoneMinder/ZoneMinder/issues/452

I am looking to watermark my recordings. I have successfully achieved what i want on regular ZM. I just need it on the MP4 branch version of ZM. I have used ASR to search for "ffmpeg" and "mp4" but i only found anything relevant to video creation in zmvideo.pl... but i think zmvideo.pl is only for generating videos from JPEG files. I simply want to have the watermark appear on the mp4 file when it is created.

So in short after a long explanation: Where should I be looking for the commands that create the MP4 files in ZM? or do i have to add them to jpeg frames somewhere or something? sorry for the noobiness... I have spent at least 3 hours looking for this and I'm actually sweating from frustration. ANY help at all would be appreciated :) Thanks in advance.


Solution

  • NEW ANSWER

    user Shinobi instead of zoneminder. It has it built in. http://shinobi.video

    OLD ANSWER

    Not sure why I've been down-voted. Either way I have solved my issue without editing the creation script directly. It watermarks , converts the video to webm and removes the MP4. I have been testing for some time now and it seems 200mb mp4 files will come down to 22mb or less when in WebM, same quality. This is a PHP Shell script that I have running on cron every hour.

    <?php
    echo'Watermarking and Converting to WEBM. Storage Preservation Addon.'."\n";
    require 'zcon.php';
    //VIDEO WATERMARK
        $nSql = "select M.*,M.Name As MName,E.* from Monitors as M inner join Events as E on (M.Id = E.MonitorId) where";
        $nSql .= " E.DefaultVideo LIKE '%.mp4' AND E.Name != '%New Event%'";
            $nResult = $conn->query($nSql);
    if ($nResult->num_rows > 0) {
        while($n = $nResult->fetch_assoc()) {
            shell_exec("avconv -i ".getEventDefaultVideoPath($n)." -qscale 0 -vf 'movie=/usr/share/zoneminder/images/watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]' ".goEventToDir($n).$n['Id']."-video.webm && rm -rf ".getEventDefaultVideoPath($n));
            $msql = "UPDATE Events SET DefaultVideo='".$n['Id']."-video.webm' where Id = '".$n['Id']."'";
            if ($conn->query($msql) === TRUE) {echo getEventDefaultVideoPath($n)." --> ".goEventToDir($n).$n['Id']."-video.webm"."\n";}
        }
    }else{echo 'No MP4 found'."\n";}
    $conn->close();
    ?>