Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #--------------- How to manage DVD-ISO file transcoding to the h264 format (mp4) with optimized quality ------------------
- #
- # Save this file as "MyProject.avs". Below the long description, there is a usable template script.
- #
- # This is an Avisynth project to be used with a corresponding AviDemux settings/preset package.
- # Source material should stem from DVD/ISO in NTSC format, 30 fps interlaced or non-interlaced (switch on/off yadif).
- # Adjust to other formats at your need.
- # Instructions below are valid for Windows OS, plz use the corresponding install procedures in case of LINUX.
- #
- # Its special features are:
- # customized convolutional processing, together with a smart filtering chain, and upsampling technique.
- #
- # Results in many cases will look remarkably better than what the regular video players in a computer will deliver from the DVD directly.
- # Players on current consumer hardware in realtime operation can hardly make use of sophisticated upsampling filters, they would become slow.
- # Further, with certain types of DVDs, typical attempts with one-click-default transcoding procedures will look quite poor and blurred,
- # thus we seek something better. Also, the upsampling makes the resulting videos more independent from the quality of the player.
- #
- # The purpose is to make the video look sharp, smooth, and calm, while not losing any texture e.g. of the skin or a rocky landscape.
- # Naturally, this depends on your decision to allow sufficient bitrates.
- # Experience shows good quality with space consumption from 10 to 30 MB's per minute of video length, according to the type and
- # style of the video. Interlaced sources will result in 60fps, but can take 20-30% more space than 30fps. Much more pleasant to view.
- # Encoding time is fair for the quality, depending on the computer and CPU. You may make 5 to 20 frames per second.
- # (5 fps speed was checked out with a cheap Windows tablet, sitting in the corner all night chewing..)
- #
- # ------------------------------------------------------------------------------
- # Prerequisites
- # ------------------------------------------------------------------------------
- #
- # A.1. Install Avisynth+ 64 bit
- # (Standard avisynth may be usable, but you need to check out for yourself. If your OS is 64bit, then stick to that in all of these tools here.)
- # http://avisynth.nl/index.php/Main_Page; then search the Plus-versions download.
- #
- # Avisynth works with avs-scripts that define input, a chain of processings, and output.
- # This text here serves as a template, and already can be used as an Avisynth project script,
- # but for actual work you need to enter the particular input file specifications, *************
- # and sometimes tailor a couple of settings to certain properties of the video.
- #
- # A.2. Find the yadif.dll deinterlacer - it not there, it is easy to download. See the avisynth filter listings for deinterlacing.
- # It should be found in a directory like C:\programs\AviSynth+\plugins\yadif.dll.
- # This is the deinterlacer that we use for creating 60fps videos (double framerate).
- # You may experiment with any other deinterlacers, but this one is fairly fast, and serves video with good sharpness.
- # The known yadif artifacts are being mitigated somewhat, by some particular filtering processes within this project.
- # Caution! Some DVDs are _not_ interlaced, then switch off deinterlacing with putting # comment tags, before the yadif lines in the script below.
- #
- # A.3. DGIndex and DGDecode - (tested version is 1.4.8.)
- # You also need the mpeg2 decoding tool for Avisynth -- dgdecode.dll
- # It should be found in a directory like C:\programs\AviSynth+\dgdecode.dll, or put it there.
- # It is part of a package together with the DGIndex.exe utility.
- # These tools must come from the same version number. DGIndex and DGDecode from different update versions are incompatible.
- # Hint: There are load commands in the script below, for yadif.dll and dgdecode.dll.
- # Thus, the dll files have to be found in the corresponding directories. Edit the path specifications in the load() commands.
- #
- # DGIndex.exe is the first program to use, it has to prepare the ISO file to be understood by the actual decoder,
- # by creating an additional d2v file.
- #
- #
- # B.1. Install Avidemux 64 bit -- www.avidemux.org - (tested version is 2.6.8)
- # This is the actual transcoding program that reads the Avisynth video data, applies more filtering, and invokes the in-built x264 encoder.
- # It has a nice user interface that lets you select and test filter processing like color corrections, resizing, sharpening etc..
- # Below at the bottom, you will find a customized MyProject.py script file that has been tuned to the generic properties of this project.
- # You'll have to save away that file and later load it in Avidemux as a project script.
- #
- # B.2. Install AVSProxy and AVSProxy-Gui - (tested version is 2.20)
- # AVSProxy is a helper utility for the AviDemux transcoding program, to be used together with Avisynth.
- # It may come packaged already with Avidemux.
- # In this type of project, AviDemux will not open a file but rather a virtual channel created by AVSProxy.
- # Thus, AVSProxy connects the Avidemux program with Avisynth, that serves the decoded and preprocessed video raw data from the ISO file.
- # ------------------------------------------------------------------------------
- # Operational Instructions
- # ------------------------------------------------------------------------------
- #
- # 0. Short version
- #
- # ("MyProject" always means the actual name of your ISO file, and of corresponding work scripts that you make for it.)
- #
- # Index MyProject.ISO with DGindex. Make it decode and write the audio wav also!
- # You may have to select beforehand the actual video segment with [ and ] buttons.
- # The resulting files are "MyProject.d2v" and "MyProject...kHz.WAV".
- #
- # Create a copy of this template you are reading right now, and name it "MyProject.avs".
- # Edit the "MyProject.avs" file, to have the read command in MPEG2Source() point to the d2v file.
- # Caution: When the video is not interlaced, remove the yadif() from the avs, else only every other frame will move and you waste file space and CPU.
- # Open resulting avs with avsproxy_gui.exe, [Custom] tab.
- #
- # Start Avidemux and connect it to the Avisynth channel, that was created with the steps mentioned above.
- # Open the "MyProject.py" settings file from the Menu - Tinypy - RunProject dialog. (Only after connecting w/proxy, else crash.)
- # Check that all audio is deactivated.
- # Adjust Video - Filters (optionally), and encoder compression rate (22-24 are the most useful compression values for this type of conversion).
- # From the filters, Contrast and Avisynth color filters are both optional and can be removed if the result is ok without. The Presets yield nice depth.
- # Remove the final sharpening filter, when results look oversharpened.
- # Check container type, normally use mp4.
- # Check start and end of the video. The copied py template file does not serve a correct video length, but this won't stop the show.
- # Set desired encoding time interval with the A and B buttons, or encode the whole. Without editing the WAV, [A] can start only with 0:00.
- # (Probably leave out the menu stuff already in DGIndex, as it spoils audio timing.)
- # Save the py settings file again, for your particular project.
- #
- # In the File menu, save the file "MyProject.mp4" and wait some hours for the encoding to complete. Encoding with audio included would run even slower.
- #
- # Audio: Open the resulting file with Avidemux, and set video to [copy].
- # Select your "MyProject...WAV" in the [audio] menu. Set audio compression to mp3.
- # Save the file again as "MyProject-audio.mp4". It will take some minutes.
- # Check that the audio sync is ok, else you may repeat the last step with setting an audio delay, often 250ms.
- # or you may even edit the WAV with an audio editor to correct sync problems.
- #
- # *ready* - below, there is the verbose full description.
- # ------------------------------------------------------------------------------------
- #
- #
- # 1. Index and audio preparation
- #
- # 1.1. Locate your target ISO file, that contains the video DVD data.
- # In our example, it is named "MyProject.ISO".
- # Run DGIndex.exe and drag the ISO file on it.
- # After a second, you should see the add files window and your file, just click OK.
- # The video preview will show up. (Often starts with black frames).
- #
- # 1.2. Use the time slider and the <,>,[,] Buttons to move the selection pointers. This is because some videos
- # require you to select the valid time intervals to transcode, while other parts will return unusable data, like menus
- # with incompatible timing information etc. that ruin the audio sync, or contain ad segments.
- # With [ and ] you can set the start and end of your selection that will now be indexed.
- # The indexing process will create a file with the name "MyProject.d2v". Takes some minutes.
- # You may want to create distinct segments to merge later, e.g. an intro, a main movie, a footage/making movie, and teaser sequences.
- #
- # 1.3. Make sure that DGIndex must write a WAV audio file while indexing.
- # In the [Audio] menu, select Output Method = Decode AC3 to WAV. Also, select conversion [48->44.1kHz] to [high].
- # The WAV file is the safest in that it does not carry tricky timing information, that can disturb the transcoding or playback processes.
- # The resulting audio file will have a complex name like "MyProject..........44.1kHz.WAV". You later need to feed this to AviDemux.
- #
- # (If you want to transcode the DVD menus, you may have to locate their audios yourself, that may be anywhere,
- # and cut out the relevant parts with an audio editor.
- # You may even have to decompile the ISO and search for menu audio in the VOB raw files.
- # DGIndex cannot properly process the menu sequences of certain DVDs, audio may come out wrong.)
- #
- # 1.4. Start the indexing with the menu [File] [Save Project].
- # For the save file name use "MyProject.d2v" in your transcodings directory, e.g. "F:\transcodings\MyProject.d2v"
- # This will take a while, perhaps 15 minutes, depending on your CPU. There is a progress indicator, anyway. When complete, it says "FINISHED".
- #
- #
- # 2. AVS Proxy preparation
- #
- # 2.1. Edit the script file. (A copy of this one you are reading right now. It should be named "MyProject.avs")
- # You need to enter the actual d2v full file path below, in the MPEG2Source(..) command.
- #
- # 2.2. You can select different convolution matrices.
- # Remove the # sign from _one_ of the GeneralConvolution() lines to activate it.
- #
- # The best choice of matrix may depend on the impact by postprocessing filters in the original DVD production,
- # and perhaps even on the physical camera lense and array.
- # The supplied matrices thus are estimates of a deconvolutional process that can optimize sharpness of the video,
- # corresponding to the typical errors and artifacts, like ringing and halo,
- # that were caused by e.g. the post production filtering (that takes into account the behavior of typical DVD players),
- # and by the lenses and cam pixel arrays.
- # You are free to experiment with the parameters. There is a whole universe of Math about convolution, z-transformation and digital filtering.
- # With some experience, the operator can learn to guess how to adjust parameters for particular details, e.g. radius of halo and of ringing.
- # Asymmetric matrices need a border preset, as they will create a shift of the whole video area. Such border is specified in the script already.
- #
- # 2.3. (optional) You may want to experiment with different color space conversions, as a few videos will come out with tainted colors.
- # This must correspond with the color correction settings in Avidemux.
- #
- # 2.4. (optional) You may tune the border preset and removal, but also the Avidemux project that follows with its filtering, has its
- # own preprocessing-borders and removal/crop, so the final size and aspect correction has to be done there.
- #
- # 2.5. (optional) Create a single-picture gallery display with the Loop command.
- # Below, you will find a template for creating an intro video that shows pictures from the menus, and other pictures that the DVD might serve.
- # The idea is to create a loop for each picture, that shows it for half a second.
- # You will need to find out the starting frames in the raw video, where the pictures are.
- # This method should be used with an extra project segment, as it is not compatible with the DVD audio,
- # and you will need to hack a customized audio file, or a silent one of the correct length.
- #
- # 2.6. (optional) There is a testing-template below, to create a sequence of many convolution-settings and view them directly one after the other.
- # Enter starting time and duration of the video test segment, that will repeat with the different settings.
- #
- # Please note that the result can only be judged after encoding the test sequence and watching it in the player. ###
- # This is because also the x264 encoder is set to have deliberate influence in the final result.
- #
- #
- # 2.7. *** When you are ready with the avs file editing, open AVSProxy-GUI.exe. ***
- # Select the [Custom] tab.
- # Pull the MyProject.avs file into the GUI, in the frame below the Custom tab.
- # Click [Show Details]. You may have to deactivate the [Automatically start Avidemus] option.
- # You should see the message "Waiting for client to connect.."
- # Now we can proceed to the actual encoding suite Avidemux.
- #
- #
- #
- # 3. Setting up Avidemux and starting the actual encoding
- #
- # It is recommended to process the audio only after successful video encoding, because audio will slow down the task.
- #
- # 3.1. Start Avidemux
- #
- # 3.2. In the [File] menu, "Connect to avsproxy".
- # The video should show up, and Avsproxy Detail frame should show the message "Client connected".
- #
- # 3.3. In the [File] menu, open the project file "MyProject.py". You will have to copy it from the project template given below at the end.
- # This is done with [Tinypy Project] [Run Project] and select the .py file.
- #
- # There may be situations where you need to edit that file before opening, e.g. because Avidemux would crash.
- # Invalid audio can make Avidemux crash. The py file should at that stage contain no information about an audio track, but set it disabled.
- #
- # Now we have one caveat. The py does not have the correct video duration because it was just copied from a template.
- # At least, it should specify a duration that is higher than any DVD length expected. This will make things easier.
- # (But py-template copying saves us a lot of time setting up the filters plus encoder, though we can also
- # load and save a filtering bench, and save particular encoder settings.)
- #
- # 3.4 To get to the correct basic duration, use the rightmost of the little round blue transport buttons.
- # The time pointer should jump to the actual end of the video. Encoding would stop at that time stamp, anyway.
- # Now we must decide whether we encode the whole video, or want to select a main video with its start
- # and end time points (otherwise, result may come surrounded with menus and gimmicks). Better, exclude menus with DGIndex already.
- # Use the red [A][B] buttons to set the start and end frames, after finding the correct positions.
- # Audio timing expects that [A] is set to 0:00 else you have to precisely edit out the start-offset with an audio editor.
- # For testing, of course A can be set to any interesting starting point.
- #
- # 3.5. Check and tune the filters. (Click [Filters] button) ***
- # The predefined filters for this project should show up.
- # You can use the [Preview] only after selecting which stage you want to preview, e.g. you click the filter before "swsResize",
- # to see the video in its biggest upsampling dimension. Or you click the last filter, and then [Preview].
- # (optional) Tuning:
- # 3.5.1 ChromaShift.
- # There are two chroma shifts, horizontal and vertical, and the vertical is done with rotating the video before and after.
- # Check, if the color is sitting at the center of the luminance. Else there is some sort of "rainbow".
- # The Filter lets you shift color left or right, up or down (with the rotation-embedded shifter);
- # normally we set the shift to a value among (0, 1, 2, -1, -2). The preset is already valid for most videos.
- # There may be videos that need a different _scaling_ of the chroma shift correction, which means you seem
- # to get it wrong for a half pixel in any direction.
- # In this case, that ChromaShift filter needs to be moved around in the list of filters, e.g. to another location in the _resized_ domains,
- # i.e. to be placed within the 720 or the 1600 or the 960 resolution.
- # For the up-down shift, of course, move it together with the two rotation filters before and after.
- # Be aware that chroma shifting will destroy a couple of lines or rows, which needs to be addressed with the preprocessing border width.
- # Incorrect chroma position will increase file size and look less sharp, or become really ugly.
- # 3.5.2 FluxSmooth.
- # This is the temporal cleaner, that helps to smoothen out artifacts. Settings higher than 30 will
- # probably create echoes, e.g. in moving landscapes. Default is 15.
- # Don't use the spatial parameter, unless the video is really noisy, else it will destroy textures (of the skin, the wall, the carpet etc.)
- # Resulting file size will be influenced by the wise usage of this filter. Echoes will increase file size.
- # 3.5.3. Add Borders / Crop, means preprocessing-borders.
- # Adding and removing borders will depend on details in the original video size, and on the chroma shift settings.
- # This needs quite some nudging and checking, if you want a precise result without bordering artifacts or losing width or height.
- # Be aware that the resizing needs to account for the pixels of the border width also, thus only after border removal we should result in the 960x640 size.
- # Some videos have a width slightly smaller than 720, then we must cut off the black bars at the right and left,
- # and adjust resizing-width in a way that preserves the aspect ratio (i.e. people should not look thinner or fatter).
- # 3.5.4 swsResize
- # You need to disable the [Lock Aspect Ratio]. Also, opening the parameter dialog does not preserve values because of this glitch.
- # Memorize dimensions before opening the parameter edit.
- # Enter the pixel width of the dimensions. The final resizing should yield a 960x640 video,
- # though you may of course experiment with any target size. The 4/3 factor benefits also in adding some subtle,
- # nice texture that makes hair, water, etc. sparkle.
- # The idea is to make an upsampled video, with a certain factor that will make artifacts look smoother, and for preventing the
- # video player that you use to watch, from adding its own non-ideal filtering impact.
- # The intermediate resizing in the chain is a tuning method for the chroma shift and the sharpening filter, and further smoothens some artifacts.
- # Intermediate size of 1600 is a compromise between useful color shift plus tight horizontal sharpening radius, with processing speed.
- # 3.5.4 Contrast
- # You may use this setting according to your taste, or remove it. Many DVDs look a bit pale after the conversion.
- # This filter is meant to be used with ChromaU only, and stepping up "U" contrast for one increment, or ChromaV only, with stepping down.
- # The effect is making the color red more intense.
- # 3.5.5 Avisynth color filter. (In Avidemux here; the same function is available in avisynth, but without the user interface)
- # This is a subtle correction for the notorious colorspace problems. You may remove it, if the result is ok without.
- # [Y] is used to enhance the black-and-white contrast to the full computer screen range. Useful values go from 10 to 20.
- # Gamma value could be used from 0.2 to 1.5 (zero seems to switch it off), and deals with the dark parts of the picture.
- # Often, the video has its black parts not dark enough.
- # So, we can adjust the contrast for the bright parts (boost but stop it before any details disappear, that are almost white already.)
- # Then we can correct the dark parts with the gamma.
- # [U] and [V] don't allow different settings. Set both the U and V contrast around 8-12 to achieve slightly more intense colors.
- # You may check the video without the color filters, to see if it is similar enough to the original.
- # But still, this can be judged only after encoding, and is a matter of taste.
- # 3.5.6 Sharpen convolution
- # This is a built-in preset sharpener in Avidemux, that is used for its linearity and precision.
- # If the video turns out oversharpened, you may as a first measure remove the last instance of this filter at the bottom of the filter manager.
- # In the upsampled section, this sharpener is included twice. The second instance is used only for tweaking the color information.
- # The extra color sharpening is up to the taste and will depend on the particular original video color encoding.
- # The problem behind this comes from the fact that color is encoded only with half of the luminance resolution, and this will add up at re-encoding.
- # So we have to choose between a setting with colors bleeding out (overflowing) of some structures, or leaving a pale border around
- # other structures (which might look a bit sharper then but also quite artificial).
- # Optional choices for the pale halos are: a) remove final sharpener; b) remove extra color sharpener.
- #
- # 3.6. Check the Encoder [Video Output] [x264] [Configure]
- # The preset is doing a nice job, still you may want to tweak the compression parameter. Default is 22 for high quality.
- # For ***** 4:3 ***** videos, the Output section tab needs to be adjusted to NTSC 4:3. (PAL was never tested with this project.)
- #
- # 3.7. [File][Save] - Save the MyProject.mp4 file and wait some hours for its completion.
- #
- # 3.8. How to add the audio.
- # Open the "MyProject.mp4" with Avidemux once again. For this, start another empty instance of Avidemux.
- # Set [Video Output] to [copy].
- # In the Audio menu, select the WAV file made by DGIndex as an audio track.
- # Set [Audio Output] to mp3 compression. Set audio delay to 220ms as a trial. You may have to repeat the process until you found the correct delay.
- # Set [Output Format] to mp4.
- # Save the video as "Myproject-audio.mp4".
- #
- # ------------------- ready -------------------
- # ------------------------------------------------------------------------------
- # Technical remarks
- # ------------------------------------------------------------------------------
- # The benefit in the packaged process concept lies in the synergy of all the filtering steps, together with the behavior of the x264 encoder.
- # One particular trick is the upsampling. It is done by resizing the 720x480px to 1600x960,
- # and then to a final 960x640 (add border values here also, then crop for remaining borders, down to the target size).
- # Upsampling allows to apply filters with a higher quality in the higher resolution domain,
- # it will deliberately influence the built-in sharpening filters of Avidemux,
- # also the bandwith-filtering of the resizers will make the pixels "rounder" and mitigate interlacing artifacts,
- # and the particular choice of a 4/3 from original size
- # will also create a minimal texture in the video, that looks nice in the eye, and adds up to beautify the deinterlacing.
- # There is an optional color shift correction, and while the available filter can only shift the color information for
- # the length of a whole pixel, then when we do this in the upsampled domain, we end up with fractional pixel shifts in
- # the color, and this is exactly what is required, due to the color coding methods in the MPEG2 formats, when we convert that to h264.
- # One of the most important features of the 960x640 format is that the video players will influence quality no more,
- # as player filterings are set to the 960 density for that matter, but there is no data beyond the 720 density, to be touched by this.
- # The encoder will optimize this situation quite well, und use only slightly higher bitrates than with encoding at 720px directly.
- # The convolution can make the video almost pixel-sharp (judged in the 720 domain), given that the original has detailed data in that range at all.
- # Other "diagonal" matrix parameters have been added to further soften the interlacing artifacts. You may further experiment with this.
- # One quite smart feature is that the convolutional sharpening, the temporal smoothener, and the motion detection in the encoder,
- # all work together very well.
- # The encoder will recognize structures in the moving blocks, and use a softening algorithm that slows down the changes from one block to the next.
- # The worst unwanted changes among any two adjacent frames will come from the deinterlacer's "bobbing" function,
- # and they will be softened, especially when the camera moves.
- # Another change comes from the natural math-rounding errors around pixel size. They would kind of flicker.
- # The convolution takes into account not just one pixel but a surrounding area, that holds still information about the pixel,
- # from the blurring halo.
- # As a result, the encoder will recognize easier those moving structures and blocks among a sequence of frames, and therefor,
- # small scale structures in the picture will be recognized and improved by using and averaging all data that
- # describes that structure over a number of frames.
- # In short, little structures close to pixel size will be translated more precisely, and look sharper and at the same time smoother.
- # Further, the encoder preset has turned off certain optimizations so to preserve all texture.
- # OTOH, another setting has been changed to allow some minimal distortion in moves, to save an amount of file size.
- # The video will look often more calm and natural than the original DVD, in the computer's DVD player. Some hardware standalone players may still perform better.
- # ---------------------------------------------------------------
- # AVISYNTH SCRIPT TO BE RUN BY AVSPROXY starts here:
- # ---------------------------------------------------------------
- #--- optionally to load old MPEG2:
- # LoadPlugin("C:\programs\AviSynth+\plugins+\mpeg2dec3.dll")
- # see the help files if you need this.
- # --- load command for the indexed video:
- # Caveat - MyProject.d2v will point also to the original MyProject.ISO,
- # that you cannot remove from its directory until the project has finished.
- LoadPlugin("F:\programs\AviSynth+\dgdecode.dll")
- MPEG2Source ("F:\transcodings\MyProject.d2v",cpu=0,info=2) # ****************************************************** edit input file here
- # (usage)
- # MPEG2Source (string d2v, int "idct", int "cpu", bool "iPP", int "moderate_h", int "moderate_v", string "cpu2", int "upConv", bool "iCC",
- # bool "i420", int "info", bool "showQ", bool "fastMC")
- # cpu=0..7 - post processing
- # iPP=false - force progressive postprocessing
- # cpu2="ooooxx" deringing only (LH LV CH CV LR CR)
- # upConv= 0=no upsample, 1=YUY2/4:2:2, 2=RGB24
- # iCC=false - force progressive upsample
- # info=1 add debug to video, 2=debug to textchannel
- #-- Deinterlace Yadif
- Load_Stdcall_plugin("F:\programs\AviSynth+\plugins\yadif.dll")
- Yadif(mode=1)
- # check whether the DVD is interlaced at all, else hide above lines with the # comment sign.
- /*
- # Loop some Frames -- if there is a picture gallery
- tx = 69.234 # enter in seconds, position of first frame of picture gallery
- f = 59.9 # frame rate after deinterlacing!
- n = int(tx * f) + 3 # you may simply correct this offset (default = +3), if it does not hit
- n1 = 30 # enter here: how many double-frames to create per picture
- # if still more pics, add to the looping from top, in reverse! order
- Loop(n1,n+32,n+33)
- Loop(n1,n+30,n+31)
- Loop(n1,n+28,n+29)
- Loop(n1,n+26,n+27)
- Loop(n1,n+24,n+25)
- Loop(n1,n+22,n+23)
- Loop(n1,n+20,n+21)
- Loop(n1,n+18,n+19)
- Loop(n1,n+16,n+17)
- Loop(n1,n+14,n+15)
- Loop(n1,n+12,n+13)
- Loop(n1,n+10,n+11)
- Loop(n1,n+8,n+9)
- Loop(n1,n+6,n+7)
- Loop(30,n+4,n+5)
- Loop(n1,n+2,n+3)
- Loop(n1,n,n+1)
- */
- # ----------------------------- the asymmetric convolution needs a run-in border to compensate for the pixel shift:
- AddBorders(4,0,2,4,$AAAAAA)
- #AddBorders(clip clip, int left, int top, int right, int bottom [, int color])
- # - the border is grey, and for best results, its brightness should be adapted to the average brightness of the video.
- # switch this off for symmetric matrix, then also the crop() at the end.
- # ----------------------------- the data format for convolution has to be RGB:
- #ConvertToRGB(clip [, string matrix] [, bool interlaced] [, string ChromaInPlacement] [, string chromaresample])
- ConvertToRGB32(matrix="PC.709",interlaced=false,chromaresample="lanczos4")
- # -- default for this preset package: PC.709 = HDTV full range
- # Rec.709 should be used when your source is DVD or HDTV
- # -- alternative DVD color space:
- # "Rec601" : Use 601 coefficients, scaled to TV range [16,235].
- # "PC.601" : Use 601 coefficients, keep full range [0,255].
- # chromaresample= ("point", "bilinear", "bicubic", "lanczos", "lanczos4", "blackman", "spline16", "spline36", "spline64", "gauss" and "sinc")
- # default is "bicubic".
- # ------------------------------ These are the customized convolutional matrices, collected from projects:
- # try those marked with *** first!
- #
- # --- symmetric matrices:
- # increase the central value to make the filter softer
- #GeneralConvolution(0, "-2 0 3 0 -2 0 -1 -3 -1 0 2 -6 56 -6 2 0 -1 -3 -1 0 -1 0 3 0 -1") # C2 crystal clear entry level
- #GeneralConvolution(0, "-1 0 3 0 -1 0 -1 -3 -1 0 3 -5 56 -5 3 0 -1 -3 -1 0 -1 0 3 0 -1") # Crystal Outline used on a 4:3 video *** ***
- # needs good source and is very crispy
- #GeneralConvolution(0, "-2 0 7 0 -2 0 -2 -6 -2 0 6 -10 112 -10 6 0 -2 -6 -2 0 -2 0 8 0 -2") # Crystal Outline B, softer
- #GeneralConvolution(0, "-2 0 7 0 -2 0 -2 -6 -2 0 5 -8 112 -8 5 0 -2 -6 -2 0 -2 0 6 0 -2") # Crystal Outline C, softer
- #GeneralConvolution(0, "-1 0 3 0 -1 0 -1 -3 -1 0 3 -5 48 -5 3 0 -1 -3 -1 0 -1 0 3 0 -1") # if it is blurred more
- #GeneralConvolution(0, "-1 0 3 0 -1 0 -1 -3 -1 0 3 -6 48 -6 3 0 -1 -3 -1 0 -1 0 3 0 -1") # was used for a blurred noninterlaced video
- #GeneralConvolution(0, "0 0 3 0 -0 0 -1 -3 -1 0 4 -4 44 -4 4 0 -1 -3 -1 0 0 0 3 0 0") # C3 level crystal clear, different halo *** ***
- #GeneralConvolution(0, "-3 0 4 0 -3 0 -1 -3 -1 0 12 -12 56 -12 12 0 -1 -3 -1 0 -3 0 4 0 -3") #test 11
- #GeneralConvolution(0, "-2 0 3 0 -2 0 -1 -3 -1 0 11 -12 56 -12 11 0 -1 -3 -1 0 -1 0 3 0 -1") #test 12
- # ----------------------------------------------------------------
- # --- asymmetric matrices (finer compensation of ringing):
- # increase the 5th value to make the filter softer, 4th (<0) for horizontal sharpness,
- # nudge the first two values for "ringing" that has a 3-4 px distance from the original edge
- # good choice helps the encoder a lot, to preserve detail while not inflating file size
- GeneralConvolution(0, "2 -5 12 -20 112 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0") # crystal clear with good compensation ***
- #GeneralConvolution(0, "3 -4 8 -10 112 0 0 -0 -4 -15 0 0 -6 -0 15 0 0 0 0 -5 0 0 0 0 0") # crystal soft for non-interlaced DVD
- # - this is for newer videos that have very fine detail and lot of sharpener was used in the production *** *** ***
- #GeneralConvolution(0, "3 -3 9 -13 112 0 0 -0 -4 -15 0 0 -6 -0 15 0 0 0 0 -5 0 0 0 0 0") # crystal non-interlaced; sharper
- #GeneralConvolution(0, "2 -6 15 -20 96 0 0 -0 -4 -12 0 0 -6 -0 15 0 0 0 0 -4 0 0 0 0 0") # X8 *** *** ***
- # - this one turns out quite generic and is very good for many blurred videos!
- #GeneralConvolution(0, "5 -13 15 -20 120 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0") # a3
- # - recommended for videos with less of detail resolution
- #GeneralConvolution(0, "5 -13 17 -21 100 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0") # a2
- #GeneralConvolution(0, "2 -6 13 -16 96 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0") # a1
- #GeneralConvolution(0, "2 -7 11 -12 28 0 0 0 2 -3 0 0 -1 0 3 0 0 0 0 -1 0 0 0 0 0") # C1 asymmetric
- #GeneralConvolution(0, "1 -2 4 -5 24 0 0 -0 -2 -3 0 0 -2 -0 3 0 0 0 0 -1 0 0 0 0 0") # X5
- #GeneralConvolution(0, "2 -4 12 -20 96 0 0 -0 -8 -12 0 0 -8 -0 12 0 0 0 0 -4 0 0 0 0 0") # X6
- #GeneralConvolution(0, "2 -5 15 -20 96 0 0 -0 -6 -12 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0") # X7 - very sharp with compensation ***
- # - differs from X8 mainly in the treatment of the deinterlacing artifacts
- #-------------- convolution tuning test bed -------------
- # use this template to insert a number of test matrices,
- # and repeat the same short video segment multiple times, with changing the matrix and printing the specimen number/tag on it.
- #---test start time = minutes*60 + ss.ddd #(seconds)
- tpos=0*60+56 # start time
- rff=29.97*2 # frame rate
- fpos=int(tpos*rff)
- #--test slice length:
- tsl=int(40*rff)
- #Trim(fpos, -tsl) + blankclip(last,15) \
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -5 12 -20 112 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("cc") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "3 -4 8 -10 112 0 0 -0 -4 -15 0 0 -6 -0 15 0 0 0 0 -5 0 0 0 0 0").subtitle("cn") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -6 15 -20 96 0 0 -0 -4 -12 0 0 -6 -0 15 0 0 0 0 -4 0 0 0 0 0").subtitle("x8") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "5 -13 15 -20 120 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("a3") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "5 -13 17 -21 100 0 0 -0 -4 -10 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("a2") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -4 12 -20 128 0 0 -0 -8 -12 0 0 -8 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("3") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -4 12 -20 148 0 0 -0 -8 -12 0 0 -8 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("4") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -5 14 -20 96 0 0 -0 -6 -12 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("5") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -5 10 -20 96 0 0 -0 -6 -12 0 0 -4 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("6") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -5 15 -20 96 0 0 -0 -6 -12 0 0 -6 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("7") + blankclip(last,15)\
- # + Trim(fpos, -tsl).GeneralConvolution(0, "2 -5 16 -20 96 0 0 -0 -6 -12 0 0 -4 -0 12 0 0 0 0 -4 0 0 0 0 0").subtitle("8") + blankclip(last,15)
- # -- remove the border (if AddBorders() was used)
- #Crop(clip clip, int left, int top, int -right, int -bottom, bool align)
- Crop(0,2,-2,-2)
- # -- back to standard format for avsproxy:
- ConvertToYV12(matrix="PC.709",interlaced=false,chromaresample="lanczos4")
- #---------------------------------------------------------------------------------------------------------------------
- # we are done with the script here.
- #---------------------------------------------------------------------------------------------------------------------
- #---------------------------------------------------------------------------------------------------------------------
- #---------------------------------------------------------------------------------------------------------------------
- # ------------------------------------------------------------------------------
- # Project template for *Avidemux*
- # ------------------------------------------------------------------------------
- # Copy away this section starting with "#PY" into another file, and name it "MyProject.py"
- #
- # Don't copy the start and end comment markers below, /* and */
- # This file is hidden from avisynth with the comment markers.
- # After creating the py file, you may remove this whole section from this avs file.
- #
- # Use the MyProject.py with Avidemux to load the whole package of settings at once.
- # Open it with "Run Project" from the Tinypy menu, but only after you have already connected to Avisynth.
- # After setting-up and tweaking for your particular video is complete, save the py project as <name of the video>.py
- #
- # Tweaks:
- # Check start and end markers (A,B) of the video. Default audio procedure works only with A = 0:00.
- # Check for the color shifts, both vertical and horizontal. Sometimes shifts may be obsolete, sometimes needs more.
- # You can move around the color shift between the resizing operations, to tune that on subpixel level.
- # Leave out the final sharpener, if result looks oversharpened.
- # Switch off the color contrast filter if skin looks too brown, or even reverse its direction.
- # Nudge gamma and contrast when black or white areas are pale or overloading.
- #
- /*
- #PY <- Needed to identify #
- #--automatically built--
- adm = Avidemux()
- adm.loadVideo("::ADM_AVS_PROXY::")
- adm.clearSegments()
- adm.addSegment(0, 0, 10000000000)
- adm.markerA = 0
- adm.markerB = 0
- adm.videoCodec("x264", "useAdvancedConfiguration=True", "general.params=AQ=22", "general.threads=0", "general.preset=ultrafast", "general.tuning=film"
- , "general.profile=baseline", "general.fast_decode=False", "general.zero_latency=False"
- , "general.fast_first_pass=True", "level=-1", "vui.sar_height=27", "vui.sar_width=32", "MaxRefFrames=5", "MinIdr=25", "MaxIdr=250", "i_scenecut_threshold=40"
- , "intra_refresh=False", "MaxBFrame=5", "i_bframe_adaptive=2"
- , "i_bframe_bias=0", "i_bframe_pyramid=2", "b_deblocking_filter=True", "i_deblocking_filter_alphac0=-1", "i_deblocking_filter_beta=0", "cabac=True", "interlaced=False"
- , "constrained_intra=False", "tff=True"
- , "fake_interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=True", "analyze.b_i8x8=True", "analyze.b_p8x8=False", "analyze.b_p16x16=True", "analyze.b_b16x16=True"
- , "analyze.weighted_pred=2", "analyze.weighted_bipred=True"
- , "analyze.direct_mv_pred=3", "analyze.chroma_offset=1", "analyze.me_method=2", "analyze.me_range=17", "analyze.mv_range=-1", "analyze.mv_range_thread=-1"
- , "analyze.subpel_refine=9", "analyze.chroma_me=True"
- , "analyze.mixed_references=True", "analyze.trellis=2", "analyze.psy_rd=1.100000", "analyze.psy_trellis=0.000000", "analyze.fast_pskip=True", "analyze.dct_decimate=True"
- , "analyze.noise_reduction=0", "analyze.psy=True"
- , "analyze.intra_luma=0", "analyze.inter_luma=0", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=4", "ratecontrol.qp_max=58"
- , "ratecontrol.qp_step=8", "ratecontrol.bitrate=0"
- , "ratecontrol.rate_tolerance=1.000000", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0"
- , "ratecontrol.ip_factor=1.400000", "ratecontrol.pb_factor=1.400000"
- , "ratecontrol.aq_mode=1", "ratecontrol.aq_strength=1.400000", "ratecontrol.mb_tree=True", "ratecontrol.lookahead=40")
- adm.addVideoFilter("fluxsmooth", "temporal_threshold=15", "spatial_threshold=0")
- adm.addVideoFilter("addBorder", "left=0", "right=2", "top=2", "bottom=2")
- adm.addVideoFilter("swscale", "width=1600", "height=968", "algo=2", "sourceAR=2", "targetAR=2")
- adm.addVideoFilter("chromashift", "u=-1", "v=-1")
- adm.addVideoFilter("Sharpen", "luma=True", "chroma=True")
- adm.addVideoFilter("contrast", "coef=0.900000", "offset=40", "doLuma=False", "doChromaU=False", "doChromaV=True")
- adm.addVideoFilter("colorYuv", "y_gain=0.000000", "y_bright=0.000000", "y_gamma=1.900000", "y_contrast=15.000000", "u_gain=0.000000"
- , "u_bright=0.000000", "u_gamma=0.000000", "u_contrast=12.000000", "v_gain=0.000000", "v_bright=0.000000"
- , "v_gamma=0.000000", "v_contrast=0.000000", "matrix=0", "levels=0", "opt=False", "colorbars=0", "analyze=1", "autowhite=False", "autogain=False")
- adm.addVideoFilter("rotate", "angle=90")
- adm.addVideoFilter("chromashift", "u=-1", "v=-1")
- adm.addVideoFilter("rotate", "angle=270")
- adm.addVideoFilter("Sharpen", "luma=False", "chroma=True")
- adm.addVideoFilter("swscale", "width=968", "height=646", "algo=2", "sourceAR=1", "targetAR=1")
- adm.addVideoFilter("crop", "top=4", "bottom=2", "left=4", "right=8")
- adm.addVideoFilter("Sharpen", "luma=True", "chroma=True")
- adm.audioClearTracks()
- adm.audioCodec(0, "Lame", "bitrate=128", "preset=0", "quality=1", "disableBitReservoir=False");
- adm.audioSetDrc(0, 0)
- adm.audioSetShift(0, 0,0)
- adm.setContainer("MP4V2", "optimize=0", "add_itunes_metadata=1")
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement