Log in

View Full Version : Encode hazy/foggy/dark comes out pixelated/appears to "jump" to keyframes


stormy1777
10th November 2018, 13:46
Source video is MOV/quicktime from digital camera, mostly of "foggy" hazy/clouds and mostly dark, which is fine..

however, when trying to encode using X264, it becomes heavily pixelated, and every second or two scene appears to JUMP as if there is a "keyframe" or something..

Tried multi-pass using Virtualdub2/latest, but that still has this jumping/pixelation.. raised target bitrate to 10000, with not much of a difference.

noticed keyframes by default come every 15 frames, so ran 2-pass with "force keyframes every" 5, and every 2, and even every "1"!!

and I can't really tell the difference, other than filesizes do change , so it does do something different :)

ironically, the force-keyframe every "1" produced a SMALLER file-size than the every 2 or 5....

Are there any "presets" for such dark/foggy/cloudy scenes? or maybe a different codec? the original video is very smooth, size wise it is about ~2GB, and the compressed goes down to roughly 200MB.

Thanks.
S

LoRd_MuldeR
11th November 2018, 15:13
First of all, be sure you are using the latest version of x264, which is r2935 by now.

Also, I'd recommend to use CRF mode and set the CRF value to the highest value that still produces "good enough" quality; if quality is unsatisfactory, lower CRF value some more.

Set preset to the slowest one that you are willing to accept. And set the tune to "film" for real world footage; maybe give tune option "grain" a try.

Furthermore, x264 places key-frames (IDR frames) dynamically, which means at "scene changes". The default --keyint value is 250, and the default --min-keyint is equal to the frame-rate.

Keep in mind that those options just specify the minimum and maximum key-frame distance, not a fixed key-frame distance!

Last but not least, AQ mode “3” (aka "Auto-variance AQ with bias to dark scenes") may be worth a try, if you are seeing block artifacts specifically in "dark" areas/scenes.

(As a rule of thumb, I would recommend to not touch any options, unless you know exactly what you are doing and why it is needed; instead just rely on the preset and tune system)

SaurusX
12th November 2018, 15:45
AQ-strength plays a large part in detail retention in flat areas with subtle color changes, like fog or clouds. Make sure that value is at least 1 and then edge it higher (1.05, 1.1, etc) to your liking. It should go without saying, but the higher it goes the larger the resulting file.

benwaggoner
12th November 2018, 20:55
Good advice above. Adding on, using --open-gop can also reduce keyframe strobing. Lowering ipratio can also help. Having a keyframe ever 15 frames is really short. 2 seconds is about the minimum that gets used for IP delivery. 1 sec gets used for Blu-Ray at high bitrates. For making a standalone file, something between 4-10 seconds is good; higher values make for more efficiency but slower random access.

stormy1777
13th November 2018, 20:54
very interesting suggestions.. Still on the FIRST one though :) :)

Tried to find the right "x264" encoder:

1) Attempted to d/l from sourceforge: https://sourceforge.net/projects/x264vfw/files/
but latest there is from 2017....
https://sourceforge.net/projects/x264vfw/files/x264vfw/44_2851bm_44825/

it is ~2MB and installed OK, so now I'm on r2851 :)

2) Later found: http://download.videolan.org/x264/binaries/win32/x264-r2935-545de2f.exe

linked from here: https://www.videohelp.com/software/x264-Encoder#download

This is a ~20MB file...

Running it is just a CLI (black window starts and disappear :) how does one hook this into VD2?

3) Went to sourceforge again for "latest":

https://sourceforge.net/projects/x264vfw/files/latest/download

again that takes build 2851, not the newer one.... this appears to be the GUI installer...

same with other websites, they have the 20mb download: https://www.majorgeeks.com/files/details/x264_video_codec.html

any chance someone can post a link to the latest x264 bits that can hook up to VD2?

Will re-test once the newer build is found :)
Thanks much!!

LoRd_MuldeR
13th November 2018, 21:09
Just do yourself a favor and don't use x264 VfW encoder, which has been dropped by "official" x264 developers ages ago.

Simply download the latest x264 CLI encoder, e.g. from here:
https://www.mediafire.com/?bxvu1vvld31k1

If you don't like encoding from the command-line, then there is like a zillion of GUI front-ends available that you can choose from:
https://forum.doom9.org/forumdisplay.php?f=78

Even VirtualDub can use the x264 CLI encoder, as an "external encoder", if you really need to stick with VirtualDub:
* https://forum.videohelp.com/attachments/7183-1307132603/External%20Encoder.gif
* https://forum.videohelp.com/threads/367446-Virtualdub-External-Encoder-feature


Running it is just a CLI (black window starts and disappear :)

If you want to manually invoke the CLI encoder, you have to start it from a terminal (https://en.wikipedia.org/wiki/Cmd.exe). With a command-line like this:

x264.exe --crf 20 --preset slower --tune film --output "c:\some\path\your_output.mkv" "c:\some\path\your_input.{avs,mp4,mov}"


how does one hook this into VD2?

If you really want to go that route, as an "external encoder" (see above).

stormy1777
14th November 2018, 13:33
LoRd_MuldeR -

Thanks SO much for your time!!!


Not fixated on VirtualDub, been using it for years, but certainly open to new tools.

Since this video stuff is not my full-time, just a hobby, need basic (single tool) built-in editing abilities - just load video, clip front/end, and add audio (music/voice) and sync length of these two, more or less.

The link you sent seems mostly "encoders" (MeGUI, Handbrake, etc.) with a GUI front-end, so they help construct the CLI for user.

these tools don't really "handle" the video file in the sense that they allow basic trim/preview.

But that got me to re-visit and evaluate other options, while at it.

Tried: Blender.. boy.. that is an *overkill* for my needs, it seems like a huge learning curve, just the editor... need to learn keyboard shortcuts, etc. Maybe one day when i can block a week or two to really learn it.

Next tried: KDEnLIVE, not deterred by the known issues on Windows :)

https://userbase.kde.org/Kdenlive/Manual/Windows_Issues

SIDENOTE:

added a single MOV and MP3 into project, pulled both down so they are on timeline, took a while to get it to play (due to known issues), but the AUDIO started playing *after* all the video finished even though *visually* they are aligned..

Decided to render, got a 6 min video, first 3 min are the video, with no audio, and last 3 min are the audio with black screen :) :) :)

also, it was not clear how to 'decouple' audio/video compression, i.e. 'copy audio' as-is (with no compression).

Tried another rendering, changed Quality to 20, and audio to 160, got an identically long "video", all 6 minutes are BLACK, and last 3 minutes have the audio track :)

This is all using latest 18.08.2 on Windows 7....

Just funny.. decided to give a second try, deleted all tracks, added MOV and MP3 again, this time it went OK.. although Codec code came as AVC1 not sure if this is as 'compatible' as 'x264' (with virtualdub).

I may revisit this KDEnLive b/c it might work, although it does have way too many features for my needs :)


For old-time sake, tried: Avidemux, wow, that GUI is pretty dated and very hard to move around, so abandoned it pretty quickly.

LiVES is a Linux only.....


Decided that VD2 is not that bad after all :) :) few MB binary, lightweight, no learning curve :) :) :)


IMPORTED the VD external profiles, from here:

https://forum.videohelp.com/threads/367446-Virtualdub-External-Encoder-feature/page3#post2390309

They appear OK, however could not figure how to actually USE them.. ctrl-P (Compression) opens the built-in (plugins) encoders.. It's funny, anyways, after about an hour of battling with the virtualdub forums and the GUI, finally found the option to:

EXPORT -> USING EXTERNAL ENCODERS

Then chose the "ACV [Film] (10bit)", it ran for about 30 seconds, with projected filesize as 16GB (source file is roughly 1GB :), then crashed with:


---------------------------
VirtualDub Error
---------------------------
Write error occurred on file "<anonymous pipe>": Insufficient system resources exist to complete the requested service.
---------------------------
OK
---------------------------


Figure the 'projected size' is not known to VD so large value is normal, since it puts out the raw video for the external encoder to handle.. but not sure what "system resource" is missing :) Maybe more memory, not sure..

Decided to try the "ACV [Film] (8bit)" instead, and wow, it went through all the way, but, at the very end, probably when it "mixes" audio/video or something it crashed with this:


---------------------------
VirtualDub Error
---------------------------
CLI: The multiplexing process failed with error code 1 (00000001). Check the log for possible error messages.
---------------------------
OK
---------------------------


Found this post: https://forum.videohelp.com/threads/374404-External-encoder-in-Virtualdub-fails-at-multiplex

Tried without the .mp4 at the end, and still same failure...

I suspect that this is b/c the encoders in that "pack" are very old, also noticed the "bin/x265" has "x265-8bit" whereas the "bin/x264" has the "x264-10bit", shouldn't it be other way around?

anyways, need to find the right/recent/current External encoders then maybe that will be it, until then, using the plugins in VD2, they are at r2851 from OCT2017, so not that bad.

Sorry for the long post, I don't expect an "answer", let me do some homework and followup in the respective place :)

Stormy.

stormy1777
15th November 2018, 10:03
btw, got the VD2 working with the external encoder, it simply boils down to matching the actual called/underlying binaries, ffmpeg, etc. with the right command line flags.. tricky part is there are many "flavors" of these tools, with various "options" built into them.

Pressing F8 shows the Vdub LOG, then one can extract the cmd lines from there, running them separately produces the actual error, for example:

x264 [error]: not compiled with MP4 output support

VD2 does not capture this output, it just gets to show as a 'broken pipe' or some generic/random failures as posted earlier.

Once u got the right bits, with right flags, and sequence of tools, it works.. not trivial though :)

For the above 'not compiled with mp4' ended up switching to Multiplexing with MP4Box using such flags:

-add "%(tempvideofile)" -add "%(tempaudiofile)" -fps %(fps) "%(outputname)"

then can use the "official" x264 from:

http://download.videolan.org/pub/videolan/x264/binaries/

moving on to implement the suggestions of the original post :) made following changes:
- film in 60fps on source material
- latest X264, with preset Slower, Tuning Film, and CRF 15, and going down further..

so far looks better... I'm sure it'll improve with time,

thanks for the support/suggestions.
Stormy.

benwaggoner
16th November 2018, 19:59
I find MeGUI a great tool for using the open-source tools for both preprocessing and encoding with x264. It feels like an app while using it. The part that is easily missed is going to Tools > AVS Script creator, or control-R. That'll make the avs file to use as input for the encoder session. That should be a big button in the main UI!

If you use MeGUI from the Development server (Settings > Extra Configuration > Auto Update) you'll get the latest and greatest versions of the components pretty regularly.

Alas, the x265 GUI is still mostly theoretical.

hello_hello
17th November 2018, 01:28
The link you sent seems mostly "encoders" (MeGUI, Handbrake, etc.) with a GUI front-end, so they help construct the CLI for user.

these tools don't really "handle" the video file in the sense that they allow basic trim/preview.

MeGUI has an AVS Cutter under the Tools menu. After creating a script, you can open it with the AVS Cutter and select which sections of the video you wish to encode on a frame accurate basis. It can apply fades and dissolves. It has a preview and is much like cutting/editing with VirtualDub.
The AVS Cutter can save a "cuts file" for loading into the audio section so it's re-encoded to match the video, or the Audio Cutter under the Tools menu can load the cuts file to cut the audio losslessly.

https://i.postimg.cc/ThqZ0KqW/AVS-Cutter.jpg (https://postimg.cc/ThqZ0KqW)

stormy1777
18th November 2018, 18:46
Thanks... I did try MeGUI, but I'm not that keen on writing scripts to open/edit/process video files - unless in very special cases where there is no choice :) In VD, just drag-drop, cut, add audio, and save, that is quick and easy.. btw, MeGUI also did not open the MOV/Quicktime, and so i guess it too needs some plugins, but I just don't see myself writing scripts for each video file, so for now will stick with VD2 :)

hello_hello
19th November 2018, 02:16
If you're happy with VD2 that's fine, but MeGUI should have no problem opening MOV files (I'm fairly sure, I never work with them). You don't need to write scripts. MeGUI will do it for you.

Use the File/Open menu to open a file. MeGUI might ask how it should open it. If it does, choose the File-Indexer. Add the indexing job to the queue and run it. When it's done, the Script Creator should open with a preview. You can use the Script Creator to apply the usual stuff like cropping or resizing etc, but if you don't want to do that, just click the Save button, then you can open the script MeGUI created with the AVS Cutter.

Just thought I'd let you know, maybe for future reference. :)

stormy1777
19th November 2018, 09:08
Hello Hello, thanks...

Ineeded with this sequence of "open" it does open, but takes 20 sec to SEVERAL minutes (opening bunch of windows, for updates, jobs, etc.)!!! for 5-8min clips.. Also, opened several AVI, on the preview window the PLAY button only advanced ONE frame each time :)

anyways, good to know of other options.. time to leave this thread until/when i got more data on the actual encoding/fuzzy/clouds stuff which was the original post :)

Thanks!

Stormy.