Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.


Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Thread Tools Search this Thread Display Modes
Old 25th September 2013, 14:40   #1  |  Link
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
cretindesalpes's Avatar
Join Date: Feb 2009
Location: No support in PM
Posts: 712
trimx264opt A helper tool for x264 segmented encoding


Now we have the --stitchable option in x264, it becomes much easier to encode a video in multiple segments. There are multiple uses for this: mix different settings that cannot be set in --zones, redo only specific parts where global parameters or bitrate are unsatisfactory, make simultaneous encode to take a better advantage of a large number of cores, etc. Cutting (at GOP boundaries) and joining segments together can be achieved without much effort with ordinary muxing tools.

The problem is that x264 is not very handy when you need to encode just a part of a file. --seek and --frames could help but their behaviour with --qpfile, --zones and --tcfile-in is inconsistent. Plus, --seek often requires reading the source from the beginning. I looked for tools to overcome these problems but found nothing. Maybe I haven’t searched hard enough? Anyway, I finally came with my own (and modest) solution.

What is it?

trimx264opt is a Windows command line tool. It takes qpfile, zones and timecodes information and “shifts” a specified frame range to index 0. Therefore x264 can use directly these parameters to encode the source cut to this range, without the need of --seek or --frames. This can be done with Avisynth frameserving for example, with a Trim(beg, beg-end) after source loading.

As trimx264opt itself does only the basic things and is not very convenient, I added encode-part.bat which provides a template for encoding a segment (it requires to set some environment variables to locate trimx264opt, x264 and possibly avs2pipemod). Ideally we would need some kind of wrapper over x264 but at the moment this tool does the job and really helps.


r3: >>>> trimx264opt-r3.zip <<<<

Note: I’m pretty sure this kind of segmented encoding can break the VBV constraints on segment boundaries, and I’m not sure if there is a solution and how to make it work. If anybody knows something, shoot!
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding

Last edited by cretindesalpes; 15th December 2013 at 14:14. Reason: r3
cretindesalpes is offline   Reply With Quote
Old 26th December 2013, 08:26   #2  |  Link
Registered User
Join Date: Oct 2006
Posts: 26

Many thx!
Very usefull tool and perfect solution!

I'm using avs4x264mod to read stream directly thru DGDecodeNV.dll or like this.
trimx264opt and avs4x264mod working together without problem with involved AviSynth routine.

How is it possible to get working trimx264opt and another decode.dll?

set trimx264opt=trimx264opt.exe
set avs2pipemod=avs2pipemod.exe
set x264=avs4x264mod.exe
*- (--qpfile "qp.log", each frame sign)
C:\WINDOWS\system32\cmd.exe /c start /low /b encode-part.bat input.avs 8000 16000 "" "qp.log" "" 8 --x264-binary "x264.exe" 
--crf 18 --profile high422 --preset placebo --vbv-bufsize 40000 --vbv-maxrate 32500 --vbv-init 0.9 --slices 4 -I 24 -i 2 --ref 4 --mixed-refs 
--deblock -3:-3 --direct auto --bframes 3 --b-pyramid strict --weightb --weightp 2 --b-bias 0 --b-adapt 2 --me tesa --subme 11 --merange 16 
--scenecut 40 --8x8dct --partitions i4x4,i8x8,p8x8,b8x8 --aq-mode 3 --aq-strength 0.6 --trellis 2 --psy-rd 0.6:0.15 --level 4.1 --ratetol 1.00 
--cplxblur 20 --qblur 0.50 --nr 0 --rc-lookahead 24 --sync-lookahead 0 --qcomp 0.6 --qpmin 0 --qpmax 69 --qpstep 4 --ipratio 1.35 --chroma-qp-offset -2 
--deadzone-inter 6 --deadzone-intra 6 --aud --nal-hrd vbr --threads 6 --mvrange 511 --no-dct-decimate --no-fast-pskip --sar 1:1 --no-chroma-me 
--constrained-intra --chromaloc 0 --colorprim bt709 --transfer bt709 --colormatrix bt709 --non-deterministic --cqmfile "Movie.[AVC].Matrix.cfg" 
--log-file "encode.log" --output "C:\Temp\[crf]..movie.264" --no-mbtree --open-gop --input-range tv --range tv --fps 24000/1001 --index movie.index
I think makesimple option would be usefull too
Example: avisynth composed 2500 frames uniformly distributed of the video(25fps) pieces by 50 frames.
* - Maybe this help a little

I’m pretty sure this kind of segmented encoding can break the VBV constraints on segment boundaries

Last edited by sarmano; 27th December 2013 at 03:28.
sarmano is offline   Reply With Quote

qpfile, stitchable, timecodes, x264, zones

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 10:34.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.