#

DGIndexNV 2053

What is DGIndexNV?
File Menu
Open
Open Disk
Load Project
Close
Output Trimmed TS
Save Project
Save BMP
Preview, Play, Stop, Pause/Resume
Exit
Stream Menu
Detect PIDs: PAT/PMT
Detect PIDs: Raw
Set PIDs
Video Menu
Enable PureVideo Deinterlacer
Zoom
HDR to SDR
Disable Display
Cropping Tool
Copy Frame to Clipboard
List GPU Devices
Demux Menu
Demux
Settings Menu
Loop Playback
Use Full Paths
Enable Info Log
Log Timestamps
Use D3D
Bare Demux
Disable Encrypted Audio Warning
Strict AVC
PGS Forced Subtitles Only
Do Not Split THD Audio
Optimize for HDD
Template Settings
Playback Speed
Response to Mismatched Audio
Force Zoom
AVC/HEVC/MPG/VC1 Extensions
CUDA Device
Default Save Project Path
Help
Help Menu
DGDecNV Quick Start Guide, DGIndexNV User Manual, and DGDecodeNV User Manual
Display Window
Navigation
Selection
Play/Preview
Frame Step Mode
Splash Screen
Window Resizing
Information Panel
Video Section [AVC]
Video Section [HEVC]
Video Section [MPG]
Video Section [VC1]
Audio Section
Status Section
Appendix A: DGI File Structure [AVC]
Appendix B: DGI File Structure [HEVC]
Appendix C: DGI File Structure [MPG]
Appendix D: DGI File Structure [VC1]
Appendix E: Command-Line Interface
Appendix F: Notes on Audio Delay Reporting

##

What is DGIndexNV? | Table of Contents

DGIndexNV, part of the DGDecNV package, is primarily designed to create an index of an AVC/HEVC/MPG/VC1 video stream, containing the location of each frame in the input stream, and some additional information about each frame. This index, or project file, is used by the companion Avisynth filter DGDecodeNV to provide frame-accurate serving of the video via an Avisynth script. DGDecNV can also be used with Vapoursynth because Vapoursynth can load and use Avisynth source filters. DGIndexNV can open AVC/HEVC/MPG/VC1 video in elementary streams, and in program, transport, Matroska, and MP4 containers.

The "NV" in the name "DGIndexNV" indicates that this version of the program is designed for use with the GPU decoder on Nvidia video cards. Consult the following table to determine which cards support DGDecNV. If the card shows VP2 or later for the PureVideo HD, then DGDecNV can be used with the card.

Table of Nvida GPUs

You can get the latest binaries of DGDecNV at http://rationalqm.us/dgdecnv/dgdecnv.html.

This document is a reference manual for DGIndexNV. Please refer to the accompanying documents for quick start information, frequently asked questions, and guidance on actual usage of DGIndexNV in typical scenarios.

##

File Menu | Table of Contents

###

Open | Table of Contents

Use this option to open the source media file(s) (elementary, program, transport, Matroska, and MP4 streams only). You can also open BluRay MPLS playlist files (see below).

Clicking on File\Open causes one of two things to happen:

1. If no files have yet been selected, the Open dialog will appear.
   Click "Open" to proceed to the File List dialog.

2. If a file has already been selected, the File List dialog will open.

Files can also be opened by dragging-and-dropping them onto the DGIndexNV window, and files can also be loaded by dragging-and-dropping them onto a desktop shortcut icon. Finally, files can also be opened by means of the most-recently-used list on the File menu.

Multiple files can be opened at once but they are expected to be fully compatible, e.g., a series of vob files, or a series of transport stream files. When opening multiple files, the File List dialog allows you to specify the order of appearance of the files in the resulting overall timeline.

You can also open BluRay MPLS playlist files. The decrypted BDMV folder must exist on your hard drive. Open an MPLS file in the BDMV/PLAYLIST directory. If multiple angles are present you are prompted for the angle. The required M2TS files are automatically loaded in order. You can use a tool such as BDInfo to help you to determine the correct MPLS file to open to get the main movie (or use Open Disk). In some cases where the playlist specifies many M2TS files audio/video sync can drift off due to the joints between files. DGIndexNV automatically corrects this in demuxed audio files.

Note that you can also open an MPLS playlist via the Open Disk option (see below).

###

Open Disk | Table of Contents

Use this option to open a BluRay disk. When you select this option you will be able to browse to and select a BluRay disk folder. The folder must be decrypted using an appropriate ripper application. After selecting the folder, a list of the playlists with details will be shown. You can then select a playlist and open it.

If multiple angles are present you are prompted for the angle. The required M2TS files are automatically loaded in order. In some cases where the playlist specifies many M2TS files audio/video sync can drift off due to the joints between files. DGIndexNV automatically corrects this in demuxed audio files.

###

Load Project | Table of Contents

Use this option to open existing DGIndexNV (dgi) project files.

When a project file is loaded, DGIndexNV opens the project's source file(s) and restores the following settings from the project file:

- Timeline selection points
- Demux dialog settings

###

Close | Table of Contents

Use this option to close all open input files.

###

Output Trimmed TS | Table of Contents

This option will output a transport stream file delimited by the project's range. Note that this is a rudimentary function intended for advanced users who understand its limitations. If you cut at an open GOP, or instance, then you will get macroblocking at the start. Any orphaned frames can be mitigated in your Avisynth script using FreezeFrame().

Here's a little tip for those lacking the creative juices to figure it out themselves. Suppose you want to cut two or more segments from a stream and have them appended together to make an edited stream (a common example is deleting commercials). Set the project range for the first segment (that you want to keep!) and save the output file. Now set the next project range and save that, but this time specify the same file and answer the dialog box with the append option. Continue this way until you have saved all your segments.

For best performance, output to a file on a physical disk different from the disk where the source files reside.

###

Save Project | Table of Contents

Use this option to generate a DGIndexNV project file (dgi file). The project file is used by DGDecodeNV to frame-serve the video via Avisynth.

DGIndexNV builds a project file containing the path to the source file, the video settings, and indexing information. For more information on the structure of dgi files, refer to Appendices A-C.

Generation of the project file can take several minutes depending on the size of the project and the speed of your computer.

For MPG streams, DGIndexNV performs a post-processing step on the dgi file after it is written. This step checks for repeat flag patterns that create changes of field order in the stream (field order transitions). Detected changes of field order are automatically corrected by modifying the flags. The dgi file without the changes is also saved with an extension ".bad". This post-processing guarantees that the video served by DGDecodeNV will have one consistent field order.

When a bluray MPLS file is loaded, upon subsequently performing Save Project, a chapters file will be created in the same directory as the dgi file.

###

Save BMP | Table of Contents

Use this option to save the current frame on display in the DGIndexNV window to a Windows BMP file. When this option is selected, a file dialog will open that allows you to specify the desired name and location for the BMP file.

Note that this option saves the frame in its original size, e.g., if the frame is reduced by two for display that will not be effective for the saved BMP.

###

Preview, Play, Stop, Pause/Resume | Table of Contents

Use these options to control video playback in the display window. Keyboard hotkeys are given in parentheses.

- Preview (F5) - Plays from the beginning to the end of the timeline.
- Play (F6) - Plays from the current position on the timeline.
- Stop (ESC) - Stops a running Play or Preview.
- Pause/Resume (SPACE) - Pauses/resumes a running Play or Preview.

When you are stopped on the timeline (not performing a Play or Preview operation), then you may use the < and > arrows to step by GOPs on the timeline. When you start a Play or Preview you enter a decoding mode that plays the video.

The Play/Preview commands decode and display all frames from the starting point, i.e., they do not suppress orphaned frames. if any, at the start of the GOP. So you may see macroblocking on the first few frames of a Play/Preview operation if your stream has open GOPs. Note that this is purely a display matter in DGIndexNV; it never occurs in the frame-served video or in demultiplexed video files. While such frames could have been suppressed, DGIndexNV is intended for analysis and not playback; it can be useful to operate this way because one can easily identify open GOPs in the stream. Note that when navigating on the timeline when stopped, orphaned frames are suppressed.

The video playback speed is controlled by the playback speed control options available via the Settings/Playback Speed setting.

Play and Preview automatically pop up the Information Panel.

###

Exit | Table of Contents

Use this option to close the source file(s) and terminate DGIndexNV.

##

Stream Menu | Table of Contents

###

Detect PIDs: PAT/PMT | Table of Contents

DGIndexNV can open transport streams. Transport streams can contain multiple programs, each of which contains audio and video streams. The Stream menu allows the user to list the programs and to select the desired program to be decoded. The stream menu is disabled if the input stream is not a transport stream. Transport streams periodically send data tables called the PAT/PMT tables that specify the programs and tags (PIDs) for the associated audio and video streams. By setting the PID for the desired video stream, you thereby select the desired program to decode. Note that only the video and PCR PIDs can be set in this menu. Use the Demux menu to setup audio PIDs.

Use the "Detect PIDs: PAT/PMT" option to list the programs and their associated streams, and to select the desired video stream to be decoded. DGIndexNV will parse the input file for the PAT/PMT tables and, if found, will display the programs and their PIDs in a list box. If PAT/PMT tables cannot be found, an error message will be shown instead, in which case the list box should be closed and the "Detect PIDs: Raw" option used instead.

To select the desired video stream, highlight it by selecting it with a mouse click. Then click on the "Set Video" button. To select the desired PCR stream, highlight it by selecting it with a mouse click. Then click on the "Set PCR" button. When you have selected your PIDs, click on the "Done" button to close the list box. The video should now be displayed in the DGIndexNV window.

The PIDs are stored in the DGIndexNV.ini file and so will be retained across DGIndexNV sessions.

Note that selecting an audio stream as video will produce undefined operation and may crash DGIndexNV. For that reason, the video PID comes up by default as 0x02, which is a reserved value. However, because the DGIndexNV.ini file retains PIDs from a previous session, you may run into this. If you get strange behavior or crashing, then manually set the video PID to 0x02 using the "Set PIDs" option before loading your input file, and then detect and set your video PID normally.

###

Detect PIDs: Raw | Table of Contents

Rarely, a transport stream may lack PAT/PMT tables. In such cases, the PIDs of the audio and video streams can be displayed and selected using the "Detect PIDs: Raw" option. Because raw PID detection does not show which audio and video streams go together, some trial and error may be required to find which audio and video PIDs belong together (commonly encountered pairs of associated video/audio PIDs are 11/14, 21/24, and 31/34). For that reason "Detect PIDs: PAT/PMT" should always be tried first.

The operation of the "Detect PIDs: Raw" list box is the same as described above for the "Detect PIDs: PAT/PMT" list box.

###

Set PIDs | Table of Contents

Use this option to manually specify the video and PCR PIDs using hexadecimal notation, or to query the selected PIDs. If you use this dialog to specify your PIDs, DGIndexNV will not detect PIDs and will simply use the specified PIDs to select the video and PCR streams. Note that only the video and PCR PIDs can be set in this menu. Use the Demux menu to set audio PIDs.

Note that selecting an audio stream as video will produce undefined operation and may crash DGIndexNV. For that reason, the video PID comes up by default as 0x02, which is a reserved value. However, because the DGIndexNV.ini file retains PIDs from a previous session, you may run into this. If you get strange behavior or crashing, then manually set the video PID to 0x02 using the "Set PIDs" option before loading your input file, and then detect and set your video PID normally.

##

Video Menu | Table of Contents

###

Enable PureVideo Deinterlacer | Table of Contents

Use this option to enable/disable the Nvidia PureVideo deinterlacer. If you have HD video, you will have to enable the Display HD Full Sized option to see the effects of the deinterlacer in DGIndexNV.

Check Single Rate to enable classical deinterlacing, where the number of output frames is the same as the number of input frames.

Check Double Rate to enable bobbing, where each field of an input frame generates a full frame in the output. Note 1: Double rate deinterlacing requires Windows XP Service Pack 3! Note 2: Double Rate deinterlacing here is intended only to show how the video will look when served with DGSource(deinterlace=2), so some of the Info dialog fields (such as frame rate and playback frame count) are not adjusted to reflect the double rate.

Check Use progressive_frame if you want the deinterlacing to honor NVCUVID's progressive_frame indication. If single or double rate deinterlacing is enabled and this option is checked, then only frames marked as interlaced by NVCUVID will be deinterlaced. If single or double rate deinterlacing is enabled and this option is not checked, then all frames will be deinterlaced.

The option is stored in the INI file.

###

Zoom | Table of Contents

Use this option to scale the video display as needed. You can display the video at full size, one-half size, one-quarter, and one-eighth size. For example you may want to set the zoom to one-quarter size when opening UHD video on a normal-sized monitor. Be aware however that interlacing can be seen only at full size.

The option is not stored in the INI file, however, there is a setting 'Force Zoom' to force a desired zoom on startup.

###

HDR to SDR | Table of Contents

Use this option to enable HDR to SDR conversion for video display in the DGIndexNV GUI. The conversion is controlled by parameter sliders on the HDR to SDR dialog. The displayed video is automatically refreshed after every slider movement. Note that HDR to SDR should be enabled only for HDR streams and that it has no effect for 8-bit streams.

Following are guidelines for using the HDR to SDR dialog:

Enable HD to SDR: This checkbox enables the conversion. When checked HDR is converted to SDR for display. When unchecked the conversion is disabled.

HLG: This checkbox selects Perceptual Quantizer (PQ) versus Hybrid Log Gamma (HLG). For PQ streams leave this checkbox unchecked. For HLG streams check this checkbox. Note that when this checkbox is changed the dialog is re-drawn with different scalings for the 'white' slider, and the slider is reset to its midpoint.

white: This slider determines the overall brightness of the output. It uses arbitrary units such that when the slider is moved to the right the brightness increases.

black: This slider determines the black level of the output. It uses arbitrary units such that when the slider is moved to the right the black level increases. Note that this slider is active only for HLG processing.

gamma: This slider sets the gamma for the output. For Rec.709 the standard value is 0.42.

r, g, b: These sliders allow you to tweak the saturation of the red, green, and blue components. A value of 1.0 for a component gives no change. Increase the value to increase saturation. Do not overdo it; 0.5 to 1.5 is probably the most you can get away with without ruining colors. The default value for blue (b) is 1.15 to perform a correction appropriate for the gamut mapping employed.

tm: This slider controls the strength of tonemapping. Reduce this towards 0.0 to smoothly transition to blowout (clipping) of highlights. This value controls a LERP between Reinhard tonemapping and no tonemapping.

roll: This slider controls the rolloff of the tonemapping. Decrease this to increase contrast and saturation. This parameter also affects overall brightness so you may have to adjust the light parameter as needed when changing the rolloff.

###

Disable Display | Table of Contents

This option is intended for getting an idea of the performance of the GPU's decoding engine. When this option is enabled, all display operations are disabled except for one: the FPS field of the Info dialog is updated. If you load your stream, select this option, and start a preview, the FPS field will show the raw decoding rate of the GPU decoder as implemented in DGIndexNV. Note that the conversion from YV12 to RGB24 used when display is enabled is very CPU intensive. So if you want to assess the frame rate and CPU utilization of the GPU decoder, it is necessary to disable the display.

###

Cropping Tool | Table of Contents

Use this tool to find and optionally export good cropping values. There are two ways to exit this dialog: if the X button on the top right of the window is clicked, then any changes will be discarded; if the OK button is clicked then the changes will be accepted and exported as described below. The Reset button clears all the cropping values back to 0.

If the Cropping Tool dialog is closed with the OK button, and at least one of the crop values is non-zero, then the configured cropping will be exported to the Avisynth script DGSource() ct/cb/cl/cr parameters. This requires that the __crop__ macro is included in the template for the DGSource invocation. Note that the __crop__ macro must NOT be preceded by a comma in the template, e.g., DGSource("__vid__"__crop__). If the Cropping Tool dialog is exited with the X button, or if the OK button is used but the crop values are all zero, then the __crop__ macro will expand to nothing.

The Auto Crop buttons can be used to automatically crop black bars (letterboxing and pillarboxing). Auto Crop mod 4/8/16 will enforce at least mod 4/8/16, respectively, for the resulting width and height. For best results, navigate to a frame with high contrast between the video and the black bars before entering the cropping dialog.

###

Copy Frame to Clipboard | Table of Contents

Use this option to copy the frame on display to the clipboard. It may then be pasted into suitable graphics applications.

Note that this option saves the frame in its original size, e.g., if the frame is reduced by two for display that will not be effective for the clipboard copy.

###

List GPU Devices | Table of Contents

This option allows you to display a list of the available CUDA-enabled GPU devices together with their ordinal numbers. The active GPU device is marked with '>'. You can force DGDecNV to use a specific GPU device by means of the setting 'CUDA Device'.

##

Demux Menu | Table of Contents

###

Demux | Table of Contents

DGIndexNV can open several container types. Containers can contain multiple programs, each of which contains associated audio, video, and subtitle streams. The Demux menu allows the user to select streams to be demultiplexed when a Save Project operation is performed. The Demux menu can also be used to trim elementary streams: set your project range, enter the Demux menu and enable the video stream, and then save your project. The demuxed output file will be an elementary stream limited to the defined project range.

For the video stream, the elementary stream file will be generated in the same directory as the project (dgi) file, and its name will be created depending on the type of the source file. If the source file is an elementary stream (ES), the base name of the project file is concatenated with ".demuxed.avc", ".demuxed.hevc", ".demuxed.m2v", or ".demuxed.vc1" (depending on the video type). For example, if the project file is named "movie.dgi", the elementary stream file will be named "movie.demuxed.avc" (for AVC video). If the source file is not an ES, then the "demuxed." is omitted. The inclusion of "demuxed." when the source file is an ES prevents possible overwriting of the source file.

In addition to the video stream, the following audio types are currently supported: MPEG audio, AAC ADTS audio, AAC LATM/LOAS, AC3 audio, DTS audio, and LPCM audio. Additional formats will be added as test streams are received. For MKV containers, some subtitle streams (SRT, SSA, ASS, PGS, and VOBSUB) and chapters are supported for demuxing. When a BluRay MPLS file is opened, PGS subtitle streams are supported for demuxing. Additional support will be added for other container types and formats as test streams are received.

The dialog lists the streams that can be demultiplexed. To select or deselect an item for demultiplexing, use its checkbox. Checked items will be demultiplexed. To select all items, right click. Right click again to deselect all items. When you have selected your items, click on the "Done" button to close the menu. Subsequently, when you perform a Save Project operation, the selected streams will be demultiplexed. Also, if you do a Preview or Play operation, the detected audio streams will be listed on the Info dialog (when demux processing is enabled).

Demultiplexed audio files will be named after the project name and additional parameters of the audio format. For example: "arte.hd PID 083 L2 2ch 48 128 DELAY -27ms.mp2".

For transport and program streams: The DELAY value reported is the required adjustment for the demuxed audio elementary stream to retain sync with the video. As it is not obvious why this delay exists and how to interpret the sign of the number, I offer the following explanation. The delay arises because demuxing elementary streams may not hit the same PTS (Presentation Time Stamp) values for the audio and video at the point in the stream where demuxing begins. (The PTS is a number that says when that audio or video access unit is to be displayed.) There is no guarantee in a stream that access units for audio and video with the same presentation times will be close together. So, for example, if we demux and find that the first video PTS is 7 and the first audio PTS is 3, then if we start playing both together immediately, we will have the video playing too early relative to the audio, so we need to move up the audio in time by -(7 - 3) = -4. So, a positive delay means you have to delay the audio, and a negative delay means you have to advance the audio.

You may occasionally encounter a DELAY value that is inaccurate. Refer to APPENDIX F for important information about this and what you can do to determine the correct delay.

When LPCM is demuxed from a transport stream, the raw PCM is written as W64 so that the file will be readable in other applications..

It is possible that audio streams are declared in the PAT/PMT tables but are not actually present in the source file, in which case demultiplexing them will fail to produce demultiplexed files. You can test for the actual presence of declared streams by doing a Preview operation. If the streams are actually present they will be listed on the Info dialog.

You can permanently disable stream detection (during play/preview) and demuxing by unchecking the "Enable demux processing" checkbox. If you want to temporarily disable demuxing while retaining detection, you can clear the "Streams to demux" list.

Only the "Enable demux processing" setting is stored in the DGIndexNV.ini file.

##

Settings Menu | Table of Contents

###

Loop Playback | Table of Contents

When this option is selected and playback during a Preview or Play operation reaches the end of the timeline, playback will automatically start again at the beginning of the timeline.

###

Use Full Paths | Table of Contents

DGI files and AVS/VPY script files created via an AVS/VPY template contain references to files. This option controls whether they should be stored as relative paths or full paths. When this option is disabled, the DGI file and generated scripts will suppress the full path information and provide just the relative paths; everything is relative to the location of the DGI file.

The option to continue using full paths was retained to provide backward compatibility to third-party applications.

This option setting is stored in the INI file and so is retained across DGIndexNV invocations.

###

Enable Info Log | Table of Contents

When the Enable Info Log option is checked and the Information Panel is closed, either manually or automatically by DGIndexNV, a log file is created that contains the information displayed in the Information Panel at the time of closure. The file name used is that of the output DGI file with the extension changed to "log". The log file is created in the same directory as the DGI file.

This option setting is stored in the INI file and so is retained across DGIndexNV invocations.

###

Log Timestamps | Table of Contents

This option allows you to dump a trace of the audio and video PTS/DTS timestamps encountered when a Save Project operation is performed. This is an advanced feature for expert users and so how to interpret this dump is not described here. For transport streams, the PCRs encountered on the configured PCR PID are also logged, and for program streams the SCRs are logged.

To dump the timestamps, enable this option and then perform a Save Project operation. A text file will be created that contains the timestamp trace. For example, if your index file is named "movie.dgi", the dump file will be named "movie.timestamps.txt".

The timestamps are presented in native syntax units, and in brackets divided by 90 (so the time unit is milliseconds). E.g.:

PCR 237636675 [2640407 ms]

Note that this option setting is not stored in the DGIndex INI file.

###

Use D3D | Table of Contents

If this option is checked, then CUDA will be initialized for dependence on Windows D3D. If not checked, then D3D-less operation is used. It is preferable to not check this option but some Nvidia mobile adapter drivers do not yet support this mode.

###

Bare Demux | Table of Contents

When DGIndexNV demuxes AVC video, it prepends the starting SPS/PPS NALUs to the start of the demuxed files. This can assist some streams that erroneously do not start with the appropriate SPS/PPS NALUs (due to bad editing). This can cause problems for some authoring suites. In such cases, if your authoring application does not accept files demuxed by DGIndexNV, check this option. When this option is checked, the starting SPS/PPS NALUs are not prepended to the start of the demuxed video file.

###

Disable Encrypted Audio Warning | Table of Contents

Normally, DGIndexNV pops up a dialog box to warn you when an audio stream appears to be encrypted. Sometimes, however, this warning is spurious. You can disable this warning by checking this option. When this option is checked, the encrypted stream is always ignored.

###

Strict AVC | Table of Contents

For AVC video, when this option is not checked, both IDR and I pictures are treated as seekable; when this option is checked, only IDR pictures are treated as seekable. Often, I pictures are seekable but this is not universally true. Checking this option when the I pictures are in fact seekable may reduce random access performance. Also, if a stream has only I frames and no IDR frames, decoding may fail. So check this option only when you encounter seek errors. New INI files are defaulted to Strict AVC unchecked.

###

PGS Forced Subtitles Only | Table of Contents

This option applies to PGS subtitles in BluRay M2TS files loaded via the playlist, or to MKV files. When this box is checked the demuxed .sup file will include only forced subtitles.

###

Do Not Split THD Audio | Table of Contents

This option demuxes THD with it's embedded AC3 as a single THD+AC3 stream. When this option is not checked, THD is demuxed into two separate streams, one THD without embedded AC3, and one AC3. Note that file gaps processing for the embedded AC3 can be done only when this option is not given, i.e., when the streams are split.

###

Optimize for HDD | Table of Contents

This option optimizes processing to improve performance when there is a mechanical HDD involved in the processing. Set this option if you have an HDD involved, and clear it otherwise. Currently, this option affects only MKV stream processing. Failing to set this when performing MKV demuxing with an HDD can lead to poor performance compared to setting it. Similarly, when there are only SSD drives involved (highly recommended) then setting it can lead to a small performance degradation compared to not setting it.

###

Template Settings | Table of Contents

DGIndexNV can automatically generate an Avisynth/Vapoursynth script for serving your project. It requires you to specify a template file, such as the following Avisynth one (operation is analogous for Vapoursynth):

`loadplugin("...\DGDecodeNV.dll")
loadplugin("...\Decomb.dll")
dgsource("__vid__")
fielddeinterlace()`

This is any normal AVS script, except that the DGI file name is replaced with __vid__ (that's two underscores before "vid" and two after). When DGIndexNV creates the AVS script, it replaces __vid__ with the correct DGI file name.

To select and enable a template, use the Settings/Template Settings button to open a dialog that allows you to set your template file as the active template file. After performing a Save Project operation, DGIndexNV uses this file as a template and inserts the right file name whenever it sees __vid__.

You may also use the __aud__ specifier to generate the audio file name. Note that if you are generating more than one audio file, this specifier will refer to the first audio file that is opened. Therefore, to be sure to get the desired audio file, process just one audio stream.

You may also use the __del__ specifier to generate the delay value for use in DelayAudio(__del__).

You may also use the __crop__ specifier to allow the Cropping Tool to export cropping values to the Avisynth script. Important note: for proper operation, the __crop__ macro must NOT be preceded by a comma in the template file, e.g., DGSource("__vid__"__crop__).

You may also use the __h2s__ specifier to generate parameters for HDR to SDR conversion as defined in the HDR to SDR dialog. This typically for DGHDRtoSDR() invocation.

DGIndexNV creates the script file only if it does not already exist or if the 'Overwrite existing script' box is checked. The script file is created in the same directory as the DGI file.

The Template Serttings dialog box displays the current active template folder and the current active template file.

If the 'Enable template' box is unchecked, the template file will not be created.

After a template directory is specified, the template file drop-down box will list all AVS/VPY files in that directory. You may select one of these listed files to specify that file as your active template file.

The option settings are stored in the INI file and so are retained across DGIndexNV invocations.

###

Playback Speed | Table of Contents

Specify the playback speed for play and preview operations.

- Super Slow 5 frames/sec.
- Slow 10 frames/sec.
- Normal The frame rate of the stream.
- Fast Double the frame rate of the stream (two times Normal).
- Maximum The fastest possible rate that your computer can perform.

###

Response to Mismatched Audio | Table of Contents

If DGIndexNV detects that the type of an audio stream as declared in the PAT/PMT differs from the type actually detected in the stream, then the desired behavior is determined by the state of this option.

This option setting is stored in the INI file and so is retained across DGIndexNV invocations.

- Prompt User is promped with a dialog box to pick one of the options below.
- Use PAT/PMT The audio type from the PAT/PMT tables is used.
- Use Detected The detected audio type is used.
- Ignore Stream The audio stream is disabled.

###

Force Zoom | Table of Contents

When set to 0, the zoom factor is automatically set based on the size of the loaded video. When set to 1, the zoom factor is set to 1; when set to 2, the zoom factor is set to 1/2; when set to 4, the zoom factor is set to 1/4. A change to this option takes effect the next time DGIndexNV is opened.

###

AVC/HEVC/MPG/VC1 Extensions | Table of Contents

Defines the extensions used on demultiplexed video files. For example, if VC1 Extension is set to "vc1" then demultiplexing will create a file such as "myfile.vc1".

###

CUDA Device | Table of Contents

If set to 255, then DGDecNV will use the first available CUDA-enabled device. If otherwise, the value selects the ordinal number of the CUDA device to be used. A change to this option takes effect the next time DGIndexNV is opened. To list available CUDA devices and their ordinal numbers, use "Video/List GPU Devices".

###

Default Save Project Path | Table of Contents

This field specifies the directory to be used for Save Project. It must contain a full path and must end with a backslash. If this field is empty the directory to be used is the one containing the stream that was opened. Note that when doing Save Project this driectory will be opened but you can still change that in the save dialog if you wish.

###

Settings Help | Table of Contents

The Help button invokes a browser on the DGIndexNV user manual. The file DGIndexNVManual.html must be present in the same directory as DGIndexNV.exe.

##

Help Menu | Table of Contents

###

DGDecNV Quick Start Guide, DGIndexNV User Manual, and DGDecodeNV User Manual | Table of Contents

These options open the respective documents in your browser. To work, the files "QuickStart.html", "DGIndexNVManual.html", "DGDecodeNVManual.html" that are included in the DGDecNV package must be in the same directory as the "DGIndexNV.exe" file. Do not rename these files.

##

Display Window | Table of Contents

###

Navigation | Table of Contents

Use the navigation slider, and these two timeline buttons for navigation by GOP:

Solid left-pointing arrow button - Seek to previous GOP.
Solid right-pointing arrow button - Seek to next GOP.

Currently, the display window displays only the first frame of a GOP in navigation mode (because they are possible selection points for cutting the video). This makes the video appear to jump when stepping, instead of moving smoothly. Of course, during play, preview, or frameserving, all frames are shown.

When "scrubbing" using the navigation slider, the movement of the cursor may seem curious. When you move the mouse and let go, or you click and drag and then pause without releasing the click, DGIndeNV starts decoding forward from that point, displays the first decodable frame (at the start of the next GOP), and then positions to that point. That may not be the place where you let go or paused, and this will be obvious when there are just a few GOPs on the timeline. This is by design. The idea is that the bar should be positioned at the start of the GOP on display.

The mouse scrollwheel is supported. When you are not in play/preview mode, the scrollwheel will act as do the right and left arrow keys, i.e., it will perform GOP stepping.

The video may in some cases appear stretched/squashed in the display window because DGIndexNV displays the video as is it stored in the video stream, which may not be the same as the final display size. For an explanation, read Doom9's article on Aspect Ratios.

When a video is displayed that has a frame size that will not fit on a 1024x768 desktop, the video is reduced in size by a factor of two. Thus, high-definition (HD) videos can be previewed without requiring scrolling.

###

Selection | Table of Contents

Starting and ending points for the project may also be optionally specified:
Left angle bracket button or HOME key - Mark selection start point.
Right angle bracket button or END key - Mark selection end point.

When doing Save Project or Preview, the operation will be applied only to the portion of the timeline between the selected start and end points.

By default, the entire timeline is automatically selected. Selection start/end point can be changed, but only one set of start/end point may be specified for a project (i.e.: multiple start/end points are not yet supported).

###

Play/Preview | Table of Contents

Preview and Play operations may be controlled using these buttons:
Open right-pointing arrow button - Play from the current timeline position.
Open right-pointing arrow with small o button - Preview from the start of the project.
Double bars button - Pause/resume the preview/play operation.
Solid square button - Stop the preview/play operation.

For the 32-bit executable, the conversion from YV12 to RGB for display is implemented with the following attributes: coefficients that are dynamically set based on the stream's colorimetry (usually Rec601 or Rec709), progressive scan, and TV scale. For the 64-bit executable, in order to provide a fast pure C language implementation, the conversion is implemented with the following attributes: fixed coefficients, progressive scan, and PC scale (this will be corrected in a future version). This affects only display in DGIndexNV; YV12 is served out of DGSource(). Conversions (if needed) for the served video are implemented in your Avisynth script.

###

Frame Step Mode | Table of Contents

You can enter a mode that allows you to step forward through the frames one-by-one.
Open right-pointing arrow with vertical bar button - Enter frame step mode.

The Frame Step Mode is a useful mode of operation that allows you to single step through the frames starting from the current timeline position. The Information Panel is updated as you step, providing useful stream and per-frame information.

The Frame Step Mode is controlled by the step button. Note that during a frame-stepping operation, you cannot navigate on the timeline. To exit the Frame Step Mode, use the stop button, use File/Stop, or hit ESC.

The mouse scrollwheel is supported. When you are in frame step mode, the scrollwheel will act as does the frame step button, i.e., it will single-step by frame.

To frame-step from a new location, first exit the operation, then reposition on the timeline in the normal way, and restart the frame-step operation. Finally, frame-stepping does not give you per-frame granularity for cuts and timeline positioning; it just allows you to pace the playback so that individual frames can be examined.

###

Splash Screen | Table of Contents

When no input file is loaded DGIndexNV can display a splash screen. To enable this feature, place an appropriately sized windows BMP file called "dgindexnv.bmp" in the same directory as DGIndexNV.exe. Several sample BMPs are available from the DGDecNV home page.

###

Window Resizing | Table of Contents

The main DGIndexNV window can be freely resized. Resizing is enabled only after a stream is loaded. The window proportions are automatically adjusted to maintain the aspect ratio of the loaded stream.

##

Information Panel | Table of Contents

The Information Panel displays important statistics about the loaded video stream. Information displayed in this panel is often essential for correctly processing DGIndexNV projects, especially when frameserving into third-party applications. The Information Panel is displayed when a project is saved or when using the Play/Preview commands. Note that when doing a Play/Preview operation, the information will apply only to the section actually played or previewed.

When the Enable Info Log option is checked and the Information Panel is closed, either manually or automatically by DGIndexNV, a log file is created that contains the information displayed in the Information Panel at the time of closure. The file name used is that of the input file with the extension changed to "log". The log file is created in the same directory as the input file. If this directory is not writable, then the log file is not created.

The Information panel can be docked to the main DGIndexNV window by placing the right edge of the main window close to the left edge of the Information panel. They will snap together. If you want to separate them, just move the Information panel away from the main window.

###

Video Section [AVC] | Table of Contents

Stream Type - Displays the stream type. Currently, DGIndexNV is limited to elementary streams, program streams, transport streams, Matroska streams, and MP4 streams.
Video Type - Displays the video type (AVC).
Profile - This field displays the AVC profile used to encode the currently loaded video.
Level - This field displays the AVC level used to encode the currently loaded video.
Coded Size - Displays the coded size of the frame in the currently displayed video. Note that this is the coded frame size, which may differ from the display frame size (see below).
PAR - Displays the pixel aspect ratio specified in the AVC stream.
Display Size - Displays the display frame size that results from applying the PAR to the coded frame size.
Frame Rate - Displays the encoded playback frame rate of the currently loaded video. Note that if the raw stream does not specify the frame rate (which is legal in AVC video), it defaults to 25fps. In such cases you can specify the frame rate by either editing the FPS line in the DGI file as needed, or by using AssumeFPS() in your script.
Colorimetry - Displays the colorimetry scheme (matrix coefficients) used by the stream. The actual value read from the stream is shown in brackets.
Frame Struct - Displays the encoded structure of the current frame: Frame, Fields (TFF), Fields (BFF), or MBAFF.
Field Order - Displays the field order of the defined project range. Because the field order can change depending on the starting point of the project when pulldown is present, this field is populated only when doing Save Project or Preview, and not when playing from an arbitrary point. Due to the design of AVC parsing in DGIndexNV, this field is populated only when the second GOP is encountered. Therefore, if the first GOP is very long, there may be a noticable delay when previewing before this field is populated. The field order is determined at the project starting point so that the correct order is communicated to DGDecodeNV for reporting to Avisynth. That makes PAFF streams problematic because the start of the project may be frame structure with no explicit specification of field order, in which case this field reports 'Progressive'. Later in the project a field structure picture may appear but the field order was already set. For PAFF streams, it is recommended to use preview and wait until a field structure picture is seen, in which case the Frame Structure field will state the field order.
Frame Type - Displays the type of the current frame: Intra (I), Predicted (P), or Bidirectional Predicted (B).
Frame Coding - Displays "Progressive" if the progressive_frame syntax element is set, otherwise "Interlaced" is displayed. Do not make the mistake of assuming that this tells you whether the video content itself is progressive or interlaced! What determines that is whether there is motion at the field rate. This Info dialog field tells you only how the video was encoded; it is quite common to encode progressive content as interlaced.
Coded # - Displays the total number of coded AVC frames encountered during the Save Project, Play, or Preview operation. If you Preview the stream from beginning to end, the coded count will be equal to the number of frames that libavcodec was able to decode, and it should match the frame count that DGDecodeNV reports via the Avisynth script. However, when you Save Project, the coded count may be a few frames higher, because all encoded frames are indexed, even if they are not decodable (frames are not decoded and displayed during a Save Project operation).
Playback # - Displays the total number of AVC frames displayed during the Save Project, Play, or Preview operation. This number can be greater than the Coded # if pulldown is present
Frame Rpts - Displays the total number of extra frames displayed due to frame repeat flags during the Save Project, Play, or Preview operation.
Field Rpts - Displays the total number of extra fields displayed due to field repeat flags encountered during the Save Project, Play, or Preview operation.
Film % - Displays the running percentage of film content (soft 3:2 pulldown).
Bitrate - Displays a windowed video bitrate averaged over the last 30 frames.
Bitrate (Avg) - Displays the video bitrate averaged over all the displayed frames.
Bitrate (Max) - Displays the maximum video bitrate encountered over all the displayed frames.

###

Video Section [HEVC] | Table of Contents

The HEVC information panel is the same as the AVC information panel with two exceptions: 1) a 'HDR' field is added that displays "PQ" for HDR10 streams, "HLG" for HLG streams, and is blank for SDR streams, and 2) the Frame Coding field is omitted.

###

Video Section [MPG] | Table of Contents

Stream Type - Displays the stream type. Currently, DGIndexNV is limited to elementary streams, program streams, transport streams, Matroska streams, and MP4 streams.
Video Type - Displays the video type (MPEG2).
Profile - This field displays the MPEG2 profile used to encode the currently loaded video.
Coded Size - Displays the coded size of the frame in the currently displayed video. Note that this reports the values of the horizontal_size and vertical_size fields in the MPEG syntax.
Display Size - Displays the display size of the frame in the currently displayed video. Note that this reports the values of the display_horizontal_size and display_vertical_size fields of the MPEG syntax if they are defined. If they are not defined, then this field is calculated from the PAR and the coded frame size.
PAR - Displays the pixel aspect ratio specified in the MPEG stream.
Frame Rate - Displays the encoded playback frame rate of the currently loaded video.
Colorimetry - Displays the colorimetry scheme (matrix coefficients) used by the stream. The actual value read from the stream is shown in brackets.
Sequence - Displays whether the current sequence is Frame Only or Frame/Field. Note that when the sequence is shown as "Frame Only", then all the frames of the sequence are coded progressively. If the sequence is shown as "Frame/Field", then some frames may be coded progressively, some coded interlaced, and some pulled down.
Frame Struct - Displays the encoded structure of the current frame: "Frame" or "Field". If "Frame" is shown, then the frame is encoded as one frame. If "Field" is shown, then the frame is encoded as two fields.
Field Order - Displays the field order of the defined project range. Because the field order can change depending on the starting point of the project when pulldown is present, this field is populated only when doing Save Project or Preview, and not when playing from an arbitrary point.
Frame Type - Displays the type of the current frame: Intra (I), Predicted (P), or Bidirectional Predicted (B).
Frame Coding - Displays "Progressive" if the progressive_frame syntax element is set, otherwise "Interlaced" is displayed. Do not make the mistake of assuming that this tells you whether the video content itself is progressive or interlaced! What determines that is whether there is motion at the field rate. This Info dialog field tells you only how the video was encoded; it is quite common to encode progressive content as interlaced.
Coded # - Displays the total number of coded MPEG2 frames encountered during the Save Project, Play, or Preview operation. If you Preview the stream from beginning to end, the coded count will be equal to the number of frames that the decoder was able to decode, and it should match the frame count that DGDecodeNV reports via the Avisynth script. However, when you Save Project, the coded count may be a few frames higher, because all encoded frames are indexed, even if they are not decodable (frames are not decoded and displayed during a Save Project operation).
Playback # - Displays the total number of MPEG2 frames displayed during the Save Project, Play, or Preview operation. This number can be greater than the Coded # if pulldown is present
Frame Rpts - Displays the total number of extra frames displayed due to frame repeat flags during the Save Project, Play, or Preview operation.
Field Rpts - Displays the total number of extra fields displayed due to field repeat flags encountered during the Save Project, Play, or Preview operation.
Film % - Displays the running percentage of film content (soft 3:2 pulldown).
Bitrate - Displays a windowed video bitrate averaged over the last 30 frames.
Bitrate (Avg) - Displays the video bitrate averaged over all the displayed frames.
Bitrate (Max) - Displays the maximum video bitrate encountered over all the displayed frames.

###

Video Section [VC1] | Table of Contents

Stream Type - Displays the stream type. Currently, DGIndexNV is limited to elementary streams, program streams, transport streams, Matroska streams, and MP4 streams.
Video Type - Displays the video type (VC1).
Profile - This field displays the VC1 profile used to encode the currently loaded video.
Level - This field displays the VC1 level used to encode the currently loaded video.
Coded Size - Displays the coded size of the frame in the currently displayed video. Note that this is the coded frame size, which may differ from the display size (see below).
Display Size - Displays the display frame size. DAR - Displays the display aspect ratio specified in the VC1 stream.
Frame Rate - Displays the encoded playback frame rate of the currently loaded video.
Colorimetry - Displays the colorimetry scheme (matrix coefficients) used by the stream. The actual value read from the stream is shown in brackets.
Sequence - Displays whether the current sequence is progressive or interlaced. Note that when the sequence is shown as "Progressive", then all the frames of the sequence are in fact progressive. If the sequence is shown as "Interlaced", then some frames may be prgressive, some interlaced, and some pulled down. Refer to the other Info dialog fields for furth information on the nature of individual fields.
Frame Struct - Displays the encoded structure of the current frame: Progressive, Frame Interlaced, or Field Interlaced.
Field Order - Displays the field order of the defined project range. Because the field order can change depending on the starting point of the project when pulldown is present, this field is populated only when doing Save Project or Preview, and not when playing from an arbitrary point.
Frame Type - Displays the type of the current frame: Intra (I), Predicted (P), Bidirectional Predicted (B), Bidirectional Intra (BI), or P Skipped (Pskip).
Coded # - Displays the total number of coded VC1 frames encountered during the Save Project, Play, or Preview operation. If you Preview the stream from beginning to end, the coded count will be equal to the number of frames that the decoder was able to decode, and it should match the frame count that DGDecodeNV reports via the Avisynth script. However, when you Save Project, the coded count may be a few frames higher, because all encoded frames are indexed, even if they are not decodable (frames are not decoded and displayed during a Save Project operation).
Playback # - Displays the total number of VC1 frames displayed during the Save Project, Play, or Preview operation. This number can be greater than the Coded # if pulldown is present
Frame Rpts - Displays the total number of extra frames displayed due to frame repeat flags during the Save Project, Play, or Preview operation.
Field Rpts - Displays the total number of extra fields displayed due to field repeat flags encountered during the Save Project, Play, or Preview operation.
Film % - Displays the running percentage of film content (soft 3:2 pulldown).
Bitrate - Displays a windowed video bitrate averaged over the last 30 frames.
Bitrate (Avg) - Displays the video bitrate averaged over all the displayed frames.
Bitrate (Max) - Displays the maximum video bitrate encountered over all the displayed frames.

###

Audio Section | Table of Contents

Displays the audio streams that were detected in the source stream.

###

Status Section | Table of Contents

Elapsed - Displays the time elapsed since starting the current Save Project, Play, or Preview operation.
Remain - Displays the time remaining for completion of the current Save Project, Play, or Preview operation.
FPS - Displays the frame rate achieved by DGIndexNV's play/preview process. Note that this may not match the video frame rate of the stream, because the user can configure the playback speed, and because DGIndexNV may not be able to decode the stream in real time.
Info - Displays video error information.

##

APPENDIX A: DGI File Structure [AVC] | Table of Contents

This Appendix documents the syntax and semantics of the DGI file format used when AVC video is indexed. Normal users need not concern themselves with this information, as it is intended for developers and power users.

There are three sections to all DGI files: 1) the header section, 2) the settings section, and 3) the data section. These sections are described below.

###

DGI Format - Header Section | Table of Contents

Following is a typical header section:

`DGAVCIndexFileNV22 DGIndexNV 2053.0.0.146 X64
Y:\DGDecNV\DGIndexNV\Release\

Y:\don1.264 8192000
Y:\don2.264 8192000

`

The first line always begins with the string "DGAVCIndexFileNV" immediately followed by a DGI file version number. This string is checked by DGDecodeNV and must match the version expected. This mechanism thus enforces the requirement that DGIndexNV and DGDecodeNV must be used in matched pairs. If DGDecodeNV rejects your DGI file as "obsolete", be sure that you are using the correct version of DGDecodeNV. Sometimes one forgets that one has an older version in the Avisynth plugins folder, or one forgets to upgrade DGDecodeNV when upgrading DGIndexNV.

The first line also contains the version number of DGIndexNV and X32 or X64 to indicate the 32-bit or 64-bit executable.

The second line specifies the path to the DGIndexNV executable. The third line is blank and the fourth line specifies the first input stream file. Additional input files are listed after the first. Each input file line also gives the size of the input file. The header section must then terminate with a blank line.

The source file reference consists of either a relative path and filename, if the Use Full Paths option is disabled; or the full absolute path of the referenced file, if the Use Full Paths option is enabled. If the Use Full Paths option is enabled and the referenced file is moved after creation of the DGI file, you must either edit the path to be correct, or you must regenerate your DGI file.

###

DGI Format - Settings Section | Table of Contents

The settings section consists of one-line specifiers. The following specifiers are defined:

`DEVICE 0
`

The number on this line specifies the ordinal number of the GPU device to be used by DGDecodeNV.

`DECODE_MODES 0,0,0,0,0
`

This is an obsolete parameter and is always 0,0,0,0,0.

`STREAM 1 0
`

The first number on this line is interpreted as follows: 0 = elementary stream, 1 = transport stream, 2 = Matroska stream, 3 = program stream, 4 = MP4 stream. The second number is 0 unless the first number is a 3, in which case it is 5 = MPEG1_PROGRAM_STREAM, or 6 = MPEG2_PROGRAM_STREAM.

`PKTSIZ 188
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the transport packet size in bytes.

`VPID 68
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the video PID that was selected in DGIndexNV.

`RANGE 0 0 200000 0
`

For elementary and transport streams, the first number on this line is the offset in the source file corresponding to the left selection range value. The third number is the offset in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used.

For Matroska streams, the first number on this line is the timecode in the source file corresponding to the left selection range value. The third number is the timecode in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used. Note that the right timecode value of 18446744073709551615 (0xffffffffffffffff) is special; it denotes that a right range is not set, or in other words, the right range is the end of the file.

`DEMUX 80,c0
`

The string on this line is the comma-separated list of audio id's to demux. This line will list no audio id's for elementary and Matroska streams.

`DEPTH 8
`

The number on this line is the bit depth of the video. Currently, only HEVC supports 10-bit and 12-bit video.

`ASPECT 1 1
`

The numbers on this line give the rational integers for the aspect ratio.

`COLORIMETRY 2 2 2
`

The numbers on this line give the coded values for matrix_coefficients, transfer_characteristics, and colour_primaries, in that order. For the meaning of the values, get the AVC spec:
https://www.itu.int/rec/T-REC-H.264-201704-I/en
and refer to tables E-3, E-4, and E-5. "2 2 2" means everything is unspecified. In practice for this case, if the video has HD resolution assume Rec709; if it has SD resolution assume Rec601.

###

DGI Format - Data Section | Table of Contents

The data section consists of one-line specifiers identified with an upper-case keyword. For example:

`SPS 552
PPS 581
SPS 552
PPS 581
IDR 591
0:FRM 7 0 0 5
1:FRM 5 1 0 5
2:FRM 6 2 0 5
3:FRM 6 3 0 5
4:FRM 5 4 0 5
5:FRM 6 5 0 5
6:FRM 6 6 0 5
7:FRM 5 7 0 5
8:FRM 6 8 0 5
9:FRM 6 9 0 5
10:FRM 5 10 0 5
11:FRM 6 11 0 5
12:FRM 5 12 0 5
13:FRM 5 13 0 5
14:FRM 5 14 0 5
15:FRM 5 15 0 5
16:FRM 5 16 0 5
SIZ 1920 x 1088
DISP 0,1920,0,1080
FPS 24000 / 1001
CODED 47
PLAYBACK 47
0.00% FILM
ORDER 1
`

The data section of a DGI file contains the indexing of the AVC video stream. The syntax for each keyword line is as follows:

- SPS n: A new Sequence Parameter Set (SPS) is located at offset n (decimal) in the source file. Note that repeated identical SPS's are not new and so are not indexed. For Matroska streams, SPS's are not indexed because they are stored in metadata in the Matroska file.
- PPS n: A new Picture Parameter Set (PPS) is located at offset n (decimal) in the source file. Note that repeated identical PPS's are not new and so are not indexed. For Matroska streams, PPS's are not indexed because they are stored in metadata in the Matroska file.
- IDR n: For elementary and transport streams, an Instantaneous Decoder Refresh (IDR) frame is located at offset n (decimal) in the source file. For Matroska streams, an IDR frame is located at timecode n (decimal) in the source file.
- I n: For elementary and transport streams, an I frame is located at offset n (decimal) in the source file. For Matroska streams, an I frame is located at timecode n (decimal) in the source file.
- n:FRM w x y: A frame of type w (refer to slice types in the AVC specification) with POC x and pic_structure y is present in the source file. FRM entries appear in display order. If pic_structure is -1, then there are no SEI's specifying the picture structure. The number n preceding FRM is the frame number (without honoring pulldown, if any).
- RPS x: A Recovery Point SEI (RPS) is located at offset n (decimal) in the source file.
- SIZ W x H: The video frames have a coded width of W and a coded height of H.
- DISP l,r,t,b: The video display area offsets for the left, right, top, and bottom.
- FPS N / D: The frame rate of the video is N/D.
- CODED n: The number of coded frames in the project.
- PLAYBACK n: The number of playback frames in the project.
- n% FILM: Specifies the percentage of flagged pure 3:2 content in the stream.
- ORDER n: Specifies the field order of the project: 0 = progressive, 1 = TFF, 2 = BFF.

##

APPENDIX B: DGI File Structure [HEVC] | Table of Contents

This Appendix documents the syntax and semantics of the DGI file format used when HEVC video is indexed. Normal users need not concern themselves with this information, as it is intended for developers and power users.

There are three sections to all DGI files: 1) the header section, 2) the settings section, and 3) the data section. These sections are described below.

###

DGI Format - Header Section | Table of Contents

Following is a typical header section:

`DGHEVCIndexFileNV22 DGIndexNV 2053.0.0.146 X64
Y:\DGDecNV\DGIndexNV\Release\

Y:\don1.hevc 8192000
Y:\don2.hevc 8192000

`

The first line always begins with the string "DGHEVCIndexFileNV" immediately followed by a DGI file version number. This string is checked by DGDecodeNV and must match the version expected. This mechanism thus enforces the requirement that DGIndexNV and DGDecodeNV must be used in matched pairs. If DGDecodeNV rejects your DGI file as "obsolete", be sure that you are using the correct version of DGDecodeNV. Sometimes one forgets that one has an older version in the Avisynth plugins folder, or one forgets to upgrade DGDecodeNV when upgrading DGIndexNV.

The first line also contains the version number of DGIndexNV and X32 or X64 to indicate the 32-bit or 64-bit executable.

The second line specifies the path to the DGIndexNV executable. The third line is blank and the fourth line specifies the first input stream file. Additional input files are listed after the first. Each input file line also gives the size of the input file. The header section must then terminate with a blank line.

The source file reference consists of either a relative path and filename, if the Use Full Paths option is disabled; or the full absolute path of the referenced file, if the Use Full Paths option is enabled. If the Use Full Paths option is enabled and the referenced file is moved after creation of the DGI file, you must either edit the path to be correct, or you must regenerate your DGI file.

###

DGI Format - Settings Section | Table of Contents

The settings section consists of one-line specifiers. The following specifiers are defined:

`DEVICE 0
`

The number on this line specifies the ordinal number of the GPU device to be used by DGDecodeNV.

`DECODE_MODES 0,0,0,0,0
`

This is an obsolete parameter and is always 0,0,0,0,0.

`STREAM 1 0
`

The first number on this line is interpreted as follows: 0 = elementary stream, 1 = transport stream, 2 = Matroska stream, 3 = program stream, 4 = MP4 stream. The second number is 0 unless the first number is a 3, in which case it is 5 = MPEG1_PROGRAM_STREAM, or 6 = MPEG2_PROGRAM_STREAM.

`PKTSIZ 188
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the transport packet size in bytes.

`VPID 68
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the video PID that was selected in DGIndexNV.

`RANGE 0 0 200000 0
`

For elementary and transport streams, the first number on this line is the offset in the source file corresponding to the left selection range value. The third number is the offset in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used.

For Matroska streams, the first number on this line is the timecode in the source file corresponding to the left selection range value. The third number is the timecode in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used. Note that the right timecode value of 18446744073709551615 (0xffffffffffffffff) is special; it denotes that a right range is not set, or in other words, the right range is the end of the file.

`DEMUX 80,c0
`

The string on this line is the comma-separated list of audio id's to demux. This line will list no audio id's for elementary and Matroska streams.

`DEPTH 8
`

The number on this line is the bit depth of the video. Currently, only HEVC supports 10-bit and 12-bit video.

`ASPECT 1 1
`

The numbers on this line give the rational integers for the aspect ratio.

`COLORIMETRY 2 2 2
`

The numbers on this line give the coded values for matrix_coefficients, transfer_characteristics, and colour_primaries, in that order. For the meaning of the values, get the AVC spec:
https://www.itu.int/rec/T-REC-H.264-201704-I/en
and refer to tables E-3, E-4, and E-5. "2 2 2" means everything is unspecified. In practice for this case, if the video has HD resolution assume Rec709; if it has SD resolution assume Rec601.

###

DGI Format - Data Section | Table of Contents

The data section consists of one-line specifiers identified with an upper-case keyword. For example:

`SPS 28
PPS 72
LIGHT 0 0
MASTERING 0 0 0 0 0 0 0 0 0 0
0:IDR 999 2 0
1:TRAIL 0 1
2:TRAIL 0 2
3:TRAIL 0 3
4:TRAIL 0 4
5:TRAIL 1 5
6:TRAIL 0 6
7:TRAIL 0 7
8:TRAIL 0 8
9:TRAIL 0 9
10:TRAIL 1 10
11:TRAIL 0 11
12:TRAIL 0 12
13:TRAIL 0 13
14:TRAIL 0 14
15:TRAIL 1 15
16:TRAIL 0 16
17:TRAIL 0 17
18:TRAIL 0 18
19:TRAIL 0 19
20:TRAIL 1 20
21:RASL 0 21
22:RASL 0 22
23:RASL 0 23
24:RASL 0 24
SIZ 1920 x 1088
DISP 0,1920,0,1080
FPS 2997 / 125
CODED 1024
ORDER 0
`

The data section of a DGI file contains the indexing of the HEVC video stream. The syntax for each keyword line is as follows:

- SPS n: A new Sequence Parameter Set (SPS) is located at offset n (decimal) in the source file. Note that repeated identical SPS's are not new and so are not indexed. For Matroska streams, SPS's are not indexed because they are stored in metadata in the Matroska file.
- PPS n: A new Picture Parameter Set (PPS) is located at offset n (decimal) in the source file. Note that repeated identical PPS's are not new and so are not indexed. For Matroska streams, PPS's are not indexed because they are stored in metadata in the Matroska file.
- n:IDR/CRA/BLA n w x: A key frame of type IDR/CRA/BLA (refer to slice types in the HEVC specification) with file offset n, frame type w (2 = I, 1 = P, 0 = B), and POC x is present in the source file. Data entries appear in display order. The number n is the frame number (without honoring pulldown, if any).
- n:TRAIL/RASL/RADL w x: A frame of type TRAIL/RASL/RADL (refer to slice types in the HEVC specification) with frame type w (2 = I, 1 = P, 0 = B), and POC x is present in the source file. Data entries appear in display order. The number n is the frame number (without honoring pulldown, if any).
- SIZ W x H: The video frames have a coded width of W and a coded height of H.
- DISP l,r,t,b: The video display area offsets for the left, right, top, and bottom.
- FPS N / D: The frame rate of the video is N/D.
- CODED n: The number of coded frames in the project.
- ORDER n: Specifies the field order of the project: 0 = progressive, 1 = TFF, 2 = BFF.
- LIGHT: Contains the content light level info SEI message. This consists of 2 short decimal integers as defined in the HEVC specification. It may be present for ST.2084 HDR streams.
- MASTERING: Contains the mastering display colour volume SEI message. This consists of 8 short decimal integers followed by 2 decimal integers as defined in the HEVC specification. It may be present for ST.2084 HDR streams.
- PREFERRED TRANSFER CHARACTERISTICS: Contains the preferred_transfer_characteristics SEI message. This consists of a decimal integer. It may be present for BBC Hybrid Log Gamma (HLG) HDR streams, in which case the decimal integer will have the value 18.
- X265_CL: When the stream is HDR PQ, DGIndexNV creates this list of parameters to be passed to the x265.exe encoder. It includes colorimetry, PQ mastering and cll, and the frame count. You may cut and paste this list of parameters when creating your x265 invocation line.

##

APPENDIX C: DGI File Structure [MPG] | Table of Contents

This Appendix documents the syntax and semantics of the DGI file format when MPG video is indexed. Normal users need not concern themselves with this information, as it is intended for developers and power users.

There are three sections to all DGI files: 1) the header section, 2) the settings section, and 3) the data section. These sections are described below.

###

DGI Format - Header Section | Table of Contents

Following is a typical header section:

`DGMPGIndexFileNV22 DGIndexNV 2053.0.0.146 X64
Y:\DGDecNV\DGIndexNV\Release\

Y:\don1.m2v 8192000
Y:\don2.m2v 8192000

`

The first line always begins with the string "DGMPGIndexFileNV" immediately followed by a DGI file version number. This string is checked by DGDecodeNV and must match the version expected. This mechanism thus enforces the requirement that DGIndexNV and DGDecodeNV must be used in matched pairs. If DGDecodeNV rejects your DGI file as "obsolete", be sure that you are using the correct version of DGDecodeNV. Sometimes one forgets that one has an older version in the Avisynth plugins folder, or one forgets to upgrade DGDecodeNV when upgrading DGIndexNV.

The first line also contains the version number of DGIndexNV and X32 or X64 to indicate the 32-bit or 64-bit executable.

The second line specifies the path to the DGIndexNV executable. The third line is blank and the fourth line specifies the first input stream file. Additional input files are listed after the first. Each input file line also gives the size of the input file. The header section must then terminate with a blank line.

The source file reference consists of either a relative path and filename, if the Use Full Paths option is disabled; or the full absolute path of the referenced file, if the Use Full Paths option is enabled. If the Use Full Paths option is enabled and the referenced file is moved after creation of the DGI file, you must either edit the path to be correct, or you must regenerate your DGI file.

###

DGI Format - Settings Section | Table of Contents

The settings section consists of one-line specifiers. The following specifiers are defined:

`DEVICE 0
`

The number on this line specifies the ordinal number of the GPU device to be used by DGDecodeNV.

`DECODE_MODES 0,0,0,0,0
`

This is an obsolete parameter and is always 0,0,0,0,0.

`STREAM 1 0
`

The first number on this line is interpreted as follows: 0 = elementary stream, 1 = transport stream, 2 = Matroska stream, 3 = program stream, 4 = MP4 stream. The second number is 0 unless the first number is a 3, in which case it is 5 = MPEG1_PROGRAM_STREAM, or 6 = MPEG2_PROGRAM_STREAM.

`PKTSIZ 188
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the transport packet size in bytes.

`VPID 68
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the video PID that was selected in DGMPGIndexNV.

`RANGE 0 0 7762712 0
`

For elementary, program, and transport streams, the first number on this line is the offset in the source file corresponding to the left selection range value. The third number is the offset in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used.

For Matroska streams, the first number on this line is the timecode in the source file corresponding to the left selection range value. The third number is the timecode in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used. Note that the right timecode value of 18446744073709551615 (0xffffffffffffffff) is special; it denotes that a right range is not set, or in other words, the right range is the end of the file.

`DEMUX 80,c0
`

The string on this line is the comma-separated list of audio id's to demux. This line will list no audio id's for elementary and Matroska streams.

`DEPTH 8
`

The number on this line is the bit depth of the video. Currently, only HEVC supports 10-bit and 12-bit video.

`ASPECT 1 1
`

The numbers on this line give the rational integers for the aspect ratio.

`COLORIMETRY 2 2 2
`

The numbers on this line give the coded values for matrix_coefficients, transfer_characteristics, and colour_primaries, in that order. For the meaning of the values, get the AVC spec:
https://www.itu.int/rec/T-REC-H.264-201704-I/en
and refer to tables E-3, E-4, and E-5. "2 2 2" means everything is unspecified. In practice for this case, if the video has HD resolution assume Rec709; if it has SD resolution assume Rec601.

###

DGI Format - Data Section | Table of Contents

The data section consists of one-line specifiers identified with an upper-case keyword. For example:

`SEQ 12321
SEQEXT 0
GOP 0 5
0:FRM B 3 1 0 0
1:FRM B 3 1 0 0
2:FRM I 3 1 0 0
3:FRM B 3 1 0 0
4:FRM B 3 1 0 0
5:FRM P 3 1 0 0
6:FRM B 3 1 0 0
7:FRM B 3 1 0 0
8:FRM P 3 1 0 0
9:FRM B 3 1 0 0
10:FRM B 3 1 0 0
11:FRM P 3 1 0 0
12:FRM B 3 1 0 0
13:FRM B 3 1 0 0
14:FRM P 3 1 0 0
...
SIZ 1920 x 1088
DISP 0,1920,0,1080
FPS 25000 / 1000
CODED 223
PLAYBACK 223
0.00% FILM
ORDER 1
`

The data section of a DGI file contains the indexing of the MPEG2 video stream. The syntax for each keyword line is as follows:

- SEQ n: For elementary and transport streams, a sequence header is located at offset n (decimal) in the source file. For Matroska streams, a sequence header is located at timecode n (decimal) in the source file.
- SEQEXT n: A sequence header extension is present for this sequence. If n is 1, then the sequence is a progressive sequence, otherwise it is not.
- GOP n: If n is -1 then this GOP does not contain a GOP header, otherwise a GOP header is present. If n is 1, the GOP is closed; if it is 0, the GOP is open.
- n:FRM a b c d e: A frame of coding type a (I/P/B) is present in the source file. The remaining fields signal the following MPEG2 syntax elements: b is picture_structure, c is top_field_first, d is repeat_first_field, e is progressive_frame. Note that the FRM lines appear in display order. The number n preceding FRM is the frame number (without honoring pulldown).
- SIZ W x H: The video frames have a coded width of W and a coded height of H.
- DISP l,r,t,b: The video display area offsets for the left, right, top, and bottom.
- FPS N / D: The frame rate of the video is N/D.
- CODED n: The number of coded frames in the project.
- PLAYBACK n: The number of playback frames in the project.
- n% FILM: Specifies the percentage of flagged pure 3:2 content in the stream.
- ORDER n: Specifies the field order of the project: 0 = progressive, 1 = TFF, 2 = BFF.

##

APPENDIX D: DGI File Structure [VC1] | Table of Contents

This Appendix documents the syntax and semantics of the DGI file format used when VC1 video is indexed. Normal users need not concern themselves with this information, as it is intended for developers and power users.

There are three sections to all DGI files: 1) the header section, 2) the settings section, and 3) the data section. These sections are described below.

###

DGI Format - Header Section | Table of Contents

Following is a typical header section:

`DGVC1IndexFileNV22 DGIndexNV 2053.0.0.146 X64
Y:\DGDecNV\DGIndexNV\Release\

Y:\don1.vc1 8192000
Y:\don2.vc1 8192000

`

The first line always begins with the string "DGVC1IndexFileNV" immediately followed by a DGI file version number. This string is checked by DGDecodeNV and must match the version expected. This mechanism thus enforces the requirement that DGIndexNV and DGDecodeNV must be used in matched pairs. If DGDecodeNV rejects your DGV file as "obsolete", be sure that you are using the correct version of DGDecodeNV. Sometimes one forgets that one has an older version in the Avisynth plugins folder, or one forgets to upgrade DGDecodeNV when upgrading DGIndexNV.

The first line also contains the version number of DGIndexNV and X32 or X64 to indicate the 32-bit or 64-bit executable.

The second line specifies the path to the DGIndexNV executable. The third line is blank and the fourth line specifies the first input stream file. Additional input files are listed after the first. Each input file line also gives the size of the input file. The header section must then terminate with a blank line.

The source file reference consists of either a relative path and filename, if the Use Full Paths option is disabled; or the full absolute path of the referenced file, if the Use Full Paths option is enabled. If the Use Full Paths option is enabled and the referenced file is moved after creation of the DGI file, you must either edit the path to be correct, or you must regenerate your DGI file.

###

DGI Format - Settings Section | Table of Contents

The settings section consists of one-line specifiers. The following specifiers are defined:

`DEVICE 0
`

The number on this line specifies the ordinal number of the GPU device to be used by DGDecodeNV.

`DECODE_MODES 0,0,0,0,0
`

This is an obsolete parameter and is always 0,0,0,0,0.

`STREAM 1 0
`

The first number on this line is interpreted as follows: 0 = elementary stream, 1 = transport stream, 2 = Matroska stream, 3 = program stream, 4 = MP4 stream. The second number is 0 unless the first number is a 3, in which case it is 5 = MPEG1_PROGRAM_STREAM, or 6 = MPEG2_PROGRAM_STREAM.

`PKTSIZ 188
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the transport packet size in bytes.

`VPID 68
`

This specifier appears only if the input file is a transport stream. The number on this line specifies the video PID that was selected in DGVC1IndexNV.

`RANGE 0 0 5000456 0
`

For elementary and transport streams, the first number on this line is the offset in the source file corresponding to the left selection range value. The third number is the offset in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used.

For Matroska streams, the first number on this line is the timecode in the source file corresponding to the left selection range value. The third number is the timecode in the source file corresponding to the right selection range value. The second and fourth numbers are reserved and not currently used. Note that the right timecode value of 18446744073709551615 (0xffffffffffffffff) is special; it denotes that a right range is not set, or in other words, the right range is the end of the file.

`DEMUX 80,c0
`

The string on this line is the comma-separated list of audio id's to demux. This line will list no audio id's for elementary and Matroska streams.

`DEPTH 8
`

The number on this line is the bit depth of the video. Currently, only HEVC supports 10-bit and 12-bit video.

`ASPECT 1 1
`

The numbers on this line give the rational integers for the aspect ratio.

`COLORIMETRY 2 2 2
`

The numbers on this line give the coded values for matrix_coefficients, transfer_characteristics, and colour_primaries, in that order. For the meaning of the values, get the AVC spec:
https://www.itu.int/rec/T-REC-H.264-201704-I/en
and refer to tables E-3, E-4, and E-5. "2 2 2" means everything is unspecified. In practice for this case, if the video has HD resolution assume Rec709; if it has SD resolution assume Rec601.

###

DGI Format - Data Section | Table of Contents

The data section consists of one-line specifiers identified with an upper-case keyword. For example:

`SEQ 0 0 1 0 5
ENTRY 22 0 0
0:FRM 3 0 0
1:FRM 0 0 0
2:FRM 3 0 0
3:FRM 1 0 0
4:FRM 3 0 0
5:FRM 1 0 0
6:FRM 3 0 0
7:FRM 1 0 0
8:FRM 3 0 0
9:FRM 1 0 0
10:FRM 3 0 0
11:FRM 1 0 0
12:FRM 3 0 0
13:FRM 1 0 0
14:FRM 3 0 0
15:FRM 1 0 0
16:FRM 3 0 0
17:FRM 1 0 0
18:FRM 3 0 0
19:FRM 1 0 0
20:FRM 3 0 0
21:FRM 1 0 0
22:FRM 3 0 0
23:FRM 1 0 0
SIZ 1920 x 1080
FPS 24000 / 1001
CODED 7870
PLAYBACK 7870
0.00% FILM
ORDER 1
`

The data section of a DGI file contains the indexing of the VC1 video stream. The syntax for each keyword line is as follows:

- SEQ n interlaced_flag pulldown_flag psf_flag: For elementary and transport streams, a Sequence Header is located at offset n (decimal) in the source file. For Matroska streams, a Sequence Header is located at timecode n (decimal) in the source file. The interlaced_flag field displays the value of the corresponding VC1 syntax element. The pulldown_flag field displays the value of the corresponding VC1 syntax element. The psf_flag field displays the value of the corresponding VC1 syntax element.
- ENTRY n broken_flag closed_flag: For elementary and transport streams, an entry point header is located at offset n (decimal) in the source file. For Matroska streams, an entry point header is located at timecode n (decimal) in the source file.The broken_flag field displays the value of the corresponding VC1 syntax element. The closed_flag field displays the value of the corresponding VC1 syntax element.
- n:FRM x y z: A frame of coding type x (I/P/B/BI/Pskip) with frame structure y (PROG/FRAME/FIELD) and repeat z is present in the source file. Note that the FRM lines appear in display order. The number n preceding FRM is the frame number (without honoring pulldown).
- SIZ W x H: The video frames have a coded width of W and a coded height of H.
- DISP l,r,t,b: The video display area offsets for the left, right, top, and bottom.
- FPS N / D: The frame rate of the video is N/D.
- CODED n: The number of coded frames in the project.
- PLAYBACK n: The number of playback frames in the project.
- n% FILM: Specifies the percentage of flagged pure 3:2 content in the stream.
- ORDER n: Specifies the field order of the project: 0 = progressive, 1 = TFF, 2 = BFF.

##

APPENDIX E: Command-Line Interface | Table of Contents

###

Parameters | Table of Contents

DGIndexNV can also be executed via a command-line interface. This feature is intended for use in automated scripts and batch files, and for use by third-party applications. Following is the syntax and semantics for the command line interface. Note that options not included are controlled by DGIndexNV defaults and the DGIndexNV settings. DGIndexNV writes the progress percentage during indexing to standard out to allow for third-party tools to display the progress of the indexing.

Table 1: Command-Line parameters supported by DGIndexNV
Parameter | Command-Line Flag | Definition/Comments
--- | --- | ---
Input File | -i filename -i file1,file2, ... | Specify input file(s). If the specified file cannot be found, it is ignored. Each filename should be double quoted if it contains spaces.
MPLS Angle | -ang number | Specify MPLS angle. If the specified angle is too large, this option is ignored and a dialog box will appear.
Video PID | -v videoPID | Transport stream video PID, hex notation (e.g., -v 11).
PCR PID | -p pcrPID | Transport stream PCR PID, hex notation (e.g., -p 11).
Output File | -o filename | Name of output index file, including the .dgi extension. The filename should be double quoted if it contains spaces.
Output File with Video Demux | -od filename | Name of output index file, including the .dgi extension. The filename should be double quoted if it contains spaces. Same as -o but the video elementary stream is demuxed.
Specify Avisynth/Vapoursynth Template | -at filename | Specify the filename of the template to be used. This can be just a filename (e.g., template.avs), in which case the template file will be looked for in the same directory as DGIndexNV.exe. It can also be a full path that fully specifies the path and filename (e.g., c:\templates\template.avs). Leave the filename null to specify no template (i.e., give -at alone with no argument). Also note that overwrite is disabled, so if the target script already exists, it will not be overwritten. Delete it first.
Demux All | -a | Demux all detected audio and subtitle streams. Note that demuxing occurs only during a save project operation so you must also include the -o/-od option.
Exit | -e | Exits DGIndexNV when project has been saved.
Hide | -h | Starts and runs DGIndexNV in the hidden state and exits when the project has been saved (forces -e option).
Version | -version | Prints the DGIndexNV version and exits.

###

Example | Table of Contents

This example:

    DGIndexNV -i d:\files\movie.avc -o d:\MyProject.dgi -e

will save a project file, specifying:

`Input File = d:\files\movie.avc
Output File = d:\MyProject.dgi
Exit on end
`

This example does the same but uses a file name with embedded spaces:

    DGIndexNV -i "d:\files\my wedding day.avc" -o "d:\my wedding day.dgi" -e

These examples do the same but multiple input files are opened:

    DGIndexNV -i file1.264,file2.264 -o file.dgi -e

    DGIndexNV -i "d:\files\my wedding day.264","d:\files\my divorce day.264" -o "d:\my wedding day.dgi" -e

Note that quoting is supported only for the -i and -o options.

##

APPENDIX F: Notes on Audio Delay Reporting | Table of Contents

When demuxing audio files, DGIndexNV includes a DELAY value in the demuxed filenames. The method to obtain these values is a heuristic (hack) deriving from the earliest days of DVD processing with DVD2AVI. While the heuristic works pretty well for that use case, it can occasionally fail dramatically for more modern containers and video/audio types. Here are just three ways things can go wrong for the delay heuristic (there may be more):

1. There can be (intentionally) missing audio. An instance of this is the case sometimes seen where there is some black video without audio at the start and then when the real content starts with both video and audio, we align the first audio PTS with the first video PTS (one of the black frames), which is wrong. Following is an example from one case I analyzed. Here is the beginning of the timestamp dump from the full M2TS (not a selected project range):

    PCR1001 289144383 [10709 ms]
      V1011 PTS 1048560 [11650 ms]
      V1011 DTS 1044806 [11608 ms]
    	[GOP started]
      V1011 PTS 1056067 [11734 ms]
      V1011 DTS 1048560 [11650 ms]
        A1100 PTS 1048560 [11650 ms]
        A1101 PTS 1048560 [11650 ms]
        A1102 PTS 1048560 [11650 ms]
        A1103 PTS 1048560 [11650 ms]
        A1104 PTS 1048560 [11650 ms]

As you can see, the first video and first audio PTSs are both 11650, so we would conclude that the delay is 0. Now here is a section later in the dump:

    V1011 PTS 1089851 [12109 ms]
      V1011 DTS 1078590 [11984 ms]
      V1011 PTS 1082343 [12026 ms]
    PCR1001 301292097 [11158 ms]
      V1011 PTS 1086097 [12067 ms]
      V1011 PTS 1101112 [12234 ms]
      V1011 DTS 1089851 [12109 ms]
    PCR1001 303722655 [11248 ms]
      V1011 PTS 1093605 [12151 ms]
      V1011 PTS 1097358 [12192 ms]
      V1011 PTS 1112373 [12359 ms]
      V1011 DTS 1101112 [12234 ms]
    PCR1001 306152367 [11338 ms]
      V1011 PTS 1104866 [12276 ms]
      V1011 PTS 1108620 [12318 ms]
    PCR1001 308582079 [11428 ms]
      V1011 PTS 1123635 [12484 ms]
      V1011 DTS 1112373 [12359 ms]
      V1011 PTS 1116127 [12401 ms]
    PCR1001 311012637 [11518 ms]
      V1011 PTS 1119881 [12443 ms]
      V1011 PTS 1134896 [12609 ms]
      V1011 DTS 1123635 [12484 ms]
    PCR1001 313443195 [11609 ms]
      V1011 PTS 1127388 [12526 ms]
        A1100 PTS 1077360 [11970 ms]

We are getting a bunch of video without any audio frames. This can happen because there really is no audio (as in the black frame case) or just because it is muxed without expected alignment (the audio is there but appears later in the stream; that's not a problem for a player due to buffering). Starting a project range around this point will be problematic.

2. The timestamps can arbitrarily reset anywhere in the stream. That means the sync calculation can change and if we only do it at the start of the stream it may not be valid later in the stream.

3. The stream may have interpolated timestamps, i.e., there is not a transmitted PTS for every video frame. That means that when we see an audio PTS, the last video PTS we saw may be from many frames previously, instead of the last one before our audio PTS.

Note that even when these issues are not present, the delay value may not be perfectly exact (due to the granularity of audio blocks) and in some cases it may require tweaking by (for example) up to 16ms (half an AC3 audio block), depending on how sensitive you are to small desyncs.

So what can we do when we get an obviously wrong DELAY value reported? We have to resort to an empirical process to get things right. For example, using MPC-HC you can set an audio delay and you can use that feature to determine the amount by which to tweak if necessary (NUM + [+] / [-] in 10ms steps). Then you adjust the DelayAudio() call appropriately and off you go with your encoding/muxing. Or you can just blindly try small adjustments until you are happy. Be aware that assessing audio sync by observation can be tricky. If the desync is small it's hard to even be sure whether the audio is late or early. There is an Avisynth plugin that overlays the audio waveform on the video that you can use to tweak things exactly by observing a frame with a sudden loud sound.

Following is an example process that uses MPC-HC to tweak and select the delay. The main thing to note is that the detection of the delay is done by human perception and not any kind of automated heuristic.

1. Using DGIndexNV demux the video and audio with the desired range. We'll ignore the reported delay in the audio file. If you need to re-encode the video, do so now and use that instead.

2. Using mkvtoolnix, mux the video and audio with delay 0 on both the video and audio tracks.

3. Load the MKV into MPC-HC media player. Repeat play through a good section for assessing sync while using the NUM + [+] / [-] to adjust the sync. When you have good sync, write down the value displayed. For my stream and the selected project range, I obtained a value of -1550.

4. Using mkvtoolnix, again mux the video and audio with delay -1550 on the audio track. The resulting MKV should play in good sync. When serving through an Avisynth script, DelayAudio(-1.550) gives good sync.

Note that VLC media player also can be used to tweak the delays, but its granularity is only 50ms, so MPC-HC is preferred.

Copyright (C) 2007-2021 Donald A. Graft, All Rights Reserved.