video export seems worse quality than watching footage?

Forum for questions and support relating to the 1.30.x releases only.
Locked
thoraxe
Posts: 14
Joined: Sun Jun 17, 2018 2:25 pm

video export seems worse quality than watching footage?

Post by thoraxe »

I noticed that when I exported a video, the quality seemed worse than watching it in the stream or looking at individual images.

Any idea why that might be?
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: video export seems worse quality than watching footage?

Post by alabamatoy »

I would like to know the answer to this as well. The exported video seems horrible quality compared to the streamed images. Are there ffmpeg options that can improve this?
mikb
Posts: 586
Joined: Mon Mar 25, 2013 12:34 pm

Re: video export seems worse quality than watching footage?

Post by mikb »

Are there options? Yes there are, sometimes when throwing video at FFMPEG (outside of ZoneMinder) it seems to pick the most horrid quality possible to remind you to read the manual and do something about it.

I use :-

-r 25 -q:v 1 -f avi -vtag XVID -g 30 -bf 2 -vf "hqdn3d,lutyuv=y=gammaval(1.4),unsharp"

Which sets a standard frame rate (25) when the underlying video is anything from 1 to 7 fps, the quality setting is "-q:v 1". The -vf magic is to reduce speckly noise at lower light levels, and to fix the general brightness curve of the picture, and enhance the sharpness.
jwarfin
Posts: 41
Joined: Mon Jul 23, 2018 4:36 am

Re: video export seems worse quality than watching footage?

Post by jwarfin »

My Ubuntu 18.04 ZM server (1.30.4) has a fairly low-end Nvidia GT-730 graphics card - but its gpu does support h264 encoding. The version of ffmpeg in the 18.04 repo supports h264_nvenc. So, I offload h264 video creation to the GT-730's gpu with this FFMPEG_OUTPUT_OPTIONS setting:

-threads 4 -c:v h264_nvenc -cq 18 -qp 28 -preset hq -b:v 1000k -minrate 500k -maxrate 3000k

I have the default format set as "mp4" in FFMPEG_FORMATS. So the above results in h264 mp4 video files being created. I have a 6 core, 12 thread cpu, so in the above I explicitly allocate just 4 threads to ffmpeg. I do this to limit cpu utilization during encoding as h264_nvenc still uses some cpu - mostly for i/o when streaming data to/from the gpu. Depending on your cpu, you probably will have to change the "-threads" option accordingly - or drop the option completely.

The cams I use are 1280x720 and I've configured them in ZM as B&W. Anyway, the quality of saved videos is quite good & the file sizes are quite small, considering the resolution & number of frames involved. Plus this keeps CPU load relatively low when the videos are generated.

If you have an Nvidia graphics card, you can see if it supports h264 encoding here:

https://developer.nvidia.com/video-enco ... ort-matrix

You can check if your version of ffmpeg supports hardware encoding with the command "ffmpeg -codecs | grep 264" and looking for the gpu related encoder options.
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: video export seems worse quality than watching footage?

Post by alabamatoy »

mikb wrote: Sat Jan 05, 2019 8:18 pm I use :-
Can these settings be implemented within ZM somehow? It would be nice to use the existing alarm interface to produce a useful high-res video when needed. O/W we gotta homebrew something to the same function.
mikb
Posts: 586
Joined: Mon Mar 25, 2013 12:34 pm

Re: video export seems worse quality than watching footage?

Post by mikb »

@alabamatoy -- those *are* the settings from ZoneMinder :) (Look under the FFMPEG_OPTIONS settings):

What I meant was that FFMPEG (inside OR outside of ZM) needs guiding as to what you expect it to do. If you don't, the defaults can be less than useful.
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: video export seems worse quality than watching footage?

Post by alabamatoy »

mikb wrote: Mon Jan 07, 2019 5:38 pm @alabamatoy -- those *are* the settings from ZoneMinder :) (Look under the FFMPEG_OPTIONS settings):
Thank you, I am starting to understand.

I tried that setting string, and the result is a huge video file (yeah, I know, better graphics means bigger file) but it is just a frame or two then half the frame is greenscreen, then a frame or two, then half greenscreen..... The video does seem far better resolution, though, what I am able to see of it.

The settings for ffmpeg are like the manual for the space station.
alabamatoy
Posts: 349
Joined: Sun Jun 05, 2016 2:53 pm

Re: video export seems worse quality than watching footage?

Post by alabamatoy »

The video flashes green in the default Windows media player on W10, but VLC plays it correctly! Go figure. Micro$oft strikes again.

Your solution works, I get a very nice high-res video. Thank you!!
mikb
Posts: 586
Joined: Mon Mar 25, 2013 12:34 pm

Re: video export seems worse quality than watching footage?

Post by mikb »

Glad you sorted it, you can turn the quality and file size down using -q:v 2 .... 9 (larger = worse quality) until you thing it looks bad. Should have said: My cameras are 640x480, so at higher resolutions -q:v 1 may be a lot bigger than I thought :)

No idea about Windows compatibility, I use VLC/Xine/Mplayer on Linux -- it wouldn't surprise me that they fail to play somehow under Windows :)

The other settings "-g 30 -bf 2" are to do with how often key frames are put in/group of picture size.

The FFMPEG manual is huge, and changes somewhat between versions too ... it is a bit of a swiss-army-chainsaw, but it usually gets a job done when you find the right settings.
Locked