View Single Post
Old 30th October 2011, 22:05   #1  |  Link
vampiredom
Registered User
 
Join Date: Aug 2008
Posts: 233
MpegAutoIndex | utility & function for loading MPEG2/MPEG4/VC1 + audio [2012/01/05]

Code:
# MPEGAutoIndex
# 2012/01/05 -> Fixed issue with DGIndex and paths with / instead of \
# 2012/01/04 -> Documentation correction
#               New version of DGIndexNV.exe and DGDecodeNV.dll
# 2011/12/30 -> Added CALL_25_Helper.exe to allow ' in filenames (and the possibility of other escape sequences)
#               Various cleanups
# 2011/11/02 -> AAC->WAV and FLAC->WAV is disabled by default, prefers BassAudioSource (see below)
#               Added global MpegAutoIndex_disable_WAV_conversion (default: true)
#               Included FLAC for optional WAV conversion
#               Added FLAC support and fallback for other demuxed audio formats with BassAudio
#               Defer loading of NicAudio and BassAudio
#               Included BassAudio
#               Checks for existence of license.txt files when NV=true or DI=true
# 2011/11/01 -> Updated to latest mp4box.exe
#               Added support for h264 .mkv files [NV=true is required]
#               Allows FFMS2 or FFMS as fallback for audio (with higher priority than DSS)
# 2011/10/31 -> Updated to latest NicAudio.dll, now prefers RaWavSource() to DSS for all .WAV files
#               Changed AAC downmix to 32-bit float
#               Removed unnecessary files from distribution
#               Changed DiAVC project extension from .dgi to .dgv to allow easier switching between NV and DI
#               Added support for VC1 streams in .wmv containers by demuxing via ASF2VC1.exe
#               Added Tebasuna51's downmixing scripts as fallbacks for when Downmix=true
# 2011/10/30 -> First public release
Download Latest Version Here

All requirements are included. It can also use FFMS or FFMS2 as fallbacks for audio (this can be useful for .mkv containers and some .mov files) but these are neither required nor included.

MpegAutoIndexSource()

This function loads MPEG2, MPEG4, and VC1 sources - and automatically indexes them (creating .dga or .d2v or .dgi 'project' files as needed). Indexing is skipped (by default) when the project file exists. [NOTE: VC1 functionality and interlaced MPEG4 sources require a license for Donald Graft's decoders -> http://neuron2.net]

The goal is to be a sort of "Swiss Army Knife" for MPEG2 and MPEG4 sources (with audio) – allowing users to get their video (with audio) into AviSynth quickly, reliably with the least amount of hassle. The distribution includes all required .exe and .dll files.

Audio tracks are demuxed and automatically dubbed via a generated and imported script snippet (e.g: myproject.d2v -> myproject.DemuxedAudioSource). The .DemuxedAudioSource file will reference all demuxed tracks. It will attempt to choose the "best" option when multiple tracks are found, but this can be changed by modifying the .DemuxedAudioSource file after it is generated.

You can also use Donald Graft's NV CUDA-enhanced indexer/decoder (set NV=true). If you have registered DG's tools, copy and paste your "license.txt" file into the "/plugins/MPEGAutoIndex/DGIndexNV/" folder. It also has the ability to use Donald Graft's DiAVC indexer/decoder (set DI=true]). Likewise, copy your "license.txt" into the "/plugins/MPEGAutoIndex/DGAVCIndexDi/" folder.

Note that although AVC/MPEG-4 video can be handled without an NV license (via DGAVCIndex), it is fairly limited and does not support interlaced video (among other formats). Therefore, using the NV option is recommended for AVCHD and other MPEG-4 formats.

MPEGAutoIndexSource also has options for downmixing, normalizing, and outputting audio separately to AC3 or WAV format, which can be useful for DVD authoring or when further audio processing is needed.

MPEGAutoIndexSource uses faad.exe for decoding AAC audio. It also incorporates mp4box for demuxing .mp4 and H.264 Quicktime .mov files as needed, allowing them to be indexed properly in most cases.

Installation:
  1. Unzip the files into your AviSynth 2.5/plugins folder, so that MpegAutoIndex_loader.avsi is loaded automatically.
  2. Copy your "license.txt" file for Donald Graft's tools into the "DGIndexNV" and "DGAvcIndexDi" subfolders

Updating to latest version from an existing installation:
  1. Delete the plugins/MpegAutoIndex folder entirely and replace with it with the MpegAutoIndex folder in the .zip file
  2. Copy your "license.txt" file for Donald Graft's tools into the "DGIndexNV" and "DGAvcIndexDi" subfolders

Usage:
Code:
# MPEGAutoIndexSource(filename [, options])

# Open an MPEG4 file
MpegAutoIndexSource("foo.mp4")

# Open an AVC stream using DGIndexNV and hardware double-rate deinterlacing
MpegAutoIndexSource("foo.mts", NV=true, args="deinterlacing=2")

# Open an AVC stream using DiAVC and hardware double-rate deinterlacing
MpegAutoIndexSource("foo.mts", DI=true, args="deinterlacing=2")

# Open an NTSC MPEG2 DVD stream using DGIndex, force it to 24P (film)
# Downmix the multichannel audio to stereo, Normalize the audio to 99%
MpegAutoIndexSource("VTS_01_1.VOB", FieldOperation=1, Downmix=true, PeakAudioLevel=0.99)

# Open an AVC stream from BluRay using DGIndexNV, forcing 24p
# Downmix the multichannel audio to stereo, normalize it to 100%
# Output the audio as a 256kbps AC3 file
MpegAutoIndexSource(
\     "12345.m2ts",
\     NV=true,
\     args="fieldop=1",
\     Downmix=true,
\     PeakAudioLevel=1.00,
\     AC3Out=true, AC3Bitrate=256
\ )

# Open an VC-1 .wmv file
MpegAutoIndexSource("vc1.wmv", NV=true)

# Open a .mkv container with h264 video
MpegAutoIndexSource("h264.mkv", NV=true)
Detailed information and parameters are listed at the top of the MpegAutoIndex/MpegAutoIndex.avsi file.

Note that this function tends to work rather well with MT() - at least in the "normal" and NV=true modes. There seem to be some issues and crashes with MT + DiAVC, however, but this has not been tested extensively.

Code:
# So, you should be able to:
SetMTMode(2)
MPEGAutoIndexSource("VTS_01_1.VOB")

# ... or:
SetMTMode(2)
MPEGAutoIndexSource("12345.m2ts", NV=true)
Supported extensions and input formats:

MPEG2 ... (.vob, .m2v, .mpv, .mpeg, .mpg, .m2t)
MPEG4 ... (.avc, .264, .h264, .m4v, .m2ts, .mts, .mov, .mkv)
VC1 ..... (.vc1, .wmv, .m2ts)

Audio Formats: PCM, AC3, AAC, DTS, MP3, MP2, MPA, FLAC [+ FFMS & DirectShow support as fallback]

NOTE: .mkv containers and VC1 video require setting NV=true (and a license for neuron2's tools)



Enjoy!

Last edited by vampiredom; 6th January 2012 at 05:31.
vampiredom is offline   Reply With Quote