Umamio
19th August 2008, 17:36
Is there a way to output variables to screen without using subtitle? I am trying to debug my script and I am clearly making some logical errors that I can't find.
I have been asked to add an intro-logo animation to a collection of different videos
The videos come in a variety of frame sizes and aspect ratios
They can have stereo or 5.1 audio
The colourspace is either YV12 or RGB32
They can be short (requiring a trim of the intro logo) or feature length
They can be NTSC, PAL, Film, Super8 framerate
I am trying to create a single function that will take these variables into account and output the correctly scaled and cropped or bordered logo animation.
My script gives memory errors for certain source aspect ratios (<1.8 approximately) and appears to work above this (in Bordering Vs Cropping) but I think that is just dumb luck rather than correctness.
My code is a complete mess but any help at all would be much appreciated. I feel like I am making some massively basic mistake that I haven't noticed.
I also assume the script is called more than is strictly necessary. If there is a way to "flow" my code to optimise it in this way I would be grateful for any such information.
Function Logoise (clip c, int TruePixel, int SourcePixel)
{
# Source Logo Intro Animation Audio & Video
LogoV = DirectShowSource("C:\Compressionism\_Video\Source\Logos\Raindance TV Logo").ConvertToRGB32
AudioStereo = WavSource("C:\Compressionism\_Video\Source\Logos\RDTV-Logo-Feature-Stereo.wav")
Audio51 = DirectShowSource ("C:\Compressionism\_Video\Source\Logos\RDTV-Logo-Feature-51.ac3")
# Frame duration before which film is classified as "Short"
MaxShortFilmFrames = 53946
# Trim Intro Logo frame constants for short Film
TrimStart=124
TrimeEnd=201
# True Source Aspect Ratio, taking into account pixel shape
# e.g Anamorphic Wide: (720/576)*(1024/720)
# e.g Square Pixels: (720/404)*(1/1)
SourceAR = (c.width/c.height)*(TruePixel/SourcePixel)
LogoAR = (LogoV.width/LogoV.height)
Logo = (c.Audiochannels == 6) ? AudioDub(LogoV,Audio51) : AudioDub(LogoV,AudioStereo)
Logo = (c.Framecount<MaxShortFilmFrames) ? Logo.Trim(TrimStart,TrimeEnd) : Logo
Logo = (c.Framerate > 25)||(c.Framerate < 23) ? Logo.ChangeFPS(c.FramerateNumerator , c.FramerateDenominator, true).ResampleAudio(c.Audiorate) : Logo.AssumeFPS(c.FramerateNumerator , c.FramerateDenominator, true).ResampleAudio(c.Audiorate)
LogoCrop = Round(((Logo.Width)-((Logo.Height)*SourceAR))/2)
LogoBord = Round((((Logo.Height)*SourceAR)-(Logo.Width))/2)
Logo = (SourceAR < LogoAR) ? Logo.Crop(LogoCrop,0,-LogoCrop,0) : Logo.AddBorders(LogoBord,0,LogoBord,0)
Logo = Logo.Spline36Resize(c.width, c.height)
Logo = (c.IsYV12 ) ? Logo.ConvertToYV12 : Logo
return (Logo+c)
}
function SharedResize (clip v1)
{return v1.Spline36Resize(1024,472)}
v = DGDecode_mpeg2source("BonneAnnee.d2v",info=3).ColorMatrix(hints=true)
a = DirectShowSource("BonneAnnee T80 2_0ch 192Kbps DELAY 0ms.ac3")
Main = AudioDub(v,a).Crop(0,52,-2,-52).Trim(1,14666).SharedResize
Main.Logoise(1,1)
:thanks:
I have been asked to add an intro-logo animation to a collection of different videos
The videos come in a variety of frame sizes and aspect ratios
They can have stereo or 5.1 audio
The colourspace is either YV12 or RGB32
They can be short (requiring a trim of the intro logo) or feature length
They can be NTSC, PAL, Film, Super8 framerate
I am trying to create a single function that will take these variables into account and output the correctly scaled and cropped or bordered logo animation.
My script gives memory errors for certain source aspect ratios (<1.8 approximately) and appears to work above this (in Bordering Vs Cropping) but I think that is just dumb luck rather than correctness.
My code is a complete mess but any help at all would be much appreciated. I feel like I am making some massively basic mistake that I haven't noticed.
I also assume the script is called more than is strictly necessary. If there is a way to "flow" my code to optimise it in this way I would be grateful for any such information.
Function Logoise (clip c, int TruePixel, int SourcePixel)
{
# Source Logo Intro Animation Audio & Video
LogoV = DirectShowSource("C:\Compressionism\_Video\Source\Logos\Raindance TV Logo").ConvertToRGB32
AudioStereo = WavSource("C:\Compressionism\_Video\Source\Logos\RDTV-Logo-Feature-Stereo.wav")
Audio51 = DirectShowSource ("C:\Compressionism\_Video\Source\Logos\RDTV-Logo-Feature-51.ac3")
# Frame duration before which film is classified as "Short"
MaxShortFilmFrames = 53946
# Trim Intro Logo frame constants for short Film
TrimStart=124
TrimeEnd=201
# True Source Aspect Ratio, taking into account pixel shape
# e.g Anamorphic Wide: (720/576)*(1024/720)
# e.g Square Pixels: (720/404)*(1/1)
SourceAR = (c.width/c.height)*(TruePixel/SourcePixel)
LogoAR = (LogoV.width/LogoV.height)
Logo = (c.Audiochannels == 6) ? AudioDub(LogoV,Audio51) : AudioDub(LogoV,AudioStereo)
Logo = (c.Framecount<MaxShortFilmFrames) ? Logo.Trim(TrimStart,TrimeEnd) : Logo
Logo = (c.Framerate > 25)||(c.Framerate < 23) ? Logo.ChangeFPS(c.FramerateNumerator , c.FramerateDenominator, true).ResampleAudio(c.Audiorate) : Logo.AssumeFPS(c.FramerateNumerator , c.FramerateDenominator, true).ResampleAudio(c.Audiorate)
LogoCrop = Round(((Logo.Width)-((Logo.Height)*SourceAR))/2)
LogoBord = Round((((Logo.Height)*SourceAR)-(Logo.Width))/2)
Logo = (SourceAR < LogoAR) ? Logo.Crop(LogoCrop,0,-LogoCrop,0) : Logo.AddBorders(LogoBord,0,LogoBord,0)
Logo = Logo.Spline36Resize(c.width, c.height)
Logo = (c.IsYV12 ) ? Logo.ConvertToYV12 : Logo
return (Logo+c)
}
function SharedResize (clip v1)
{return v1.Spline36Resize(1024,472)}
v = DGDecode_mpeg2source("BonneAnnee.d2v",info=3).ColorMatrix(hints=true)
a = DirectShowSource("BonneAnnee T80 2_0ch 192Kbps DELAY 0ms.ac3")
Main = AudioDub(v,a).Crop(0,52,-2,-52).Trim(1,14666).SharedResize
Main.Logoise(1,1)
:thanks: