H265 playing in browser [Hack]

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
justanotherguy
Posts: 18
Joined: Wed Aug 03, 2022 12:48 am

H265 playing in browser [Hack]

Post by justanotherguy »

So finally did some more digging and found out that my RLC 811a will always send H265 stream no matter the URL I used for the main stream.

Both these url's:

rtsp://admin:password@192.168.1.167/h264Preview_01_main
rtsp://admin:password@192.168.1.167/h265Preview_01_main

did output in h265.

Changing the codec to MJPEG didn't help either for viewing. The only thing I could see was the first and last second of the recording, nothing in between. On the other hand, the sub stream recordings were coming as h264 and played properly in the browser. So I decided to come up with this hack where I convert the h265 recordings to h264 via a cron job and then they seem to work fine in the browser via the ZM console.

The shell script for the cron is as follows:

Code: Select all

#!/bin/bash
cd /var/cache/zoneminder/events/2
find -cmin -10 -cmin +2 -name '*.mp4' -print0 | while IFS= read -r -d '' file; 
do
DIR=$(dirname "$file")
echo "$DIR"
CODEC=$(ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$file")
if [ "$CODEC" == "hevc" ] 
then
        ffmpeg -i "$file" -map 0 -c:v libx264 -crf 18 -c:a copy "$DIR/output.mp4" < /dev/null
        rm "$file"
        mv "$DIR/output.mp4" "$file"
        chown "www-data" "$file"
        chgrp "www-data" "$file"
fi
done
I execute the cron job every 2 minutes. This does the job for me and I can finally view the recordings in the browser (zm console) and zmninja app.

This is on Ubuntu 22.04. Hope it can be of use to someone.

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

Re: H265 playing in browser [Hack]

Post by iconnor »

Just select mjpeg for codec in top right corner of event view.

Edit monitor->misc->Default Method For Event View = MJPEG to make it the default
justanotherguy
Posts: 18
Joined: Wed Aug 03, 2022 12:48 am

Re: H265 playing in browser [Hack]

Post by justanotherguy »

>Just select mjpeg for codec in top right corner of event view.

Changing the codec to MJPEG didn't help either for viewing. The only thing I could see was the first and last second of the recording, nothing in between.
Post Reply