While we wait for Frank, maybe meanwhile just try ffmpeg in a cmd executor:
"%s_ffmpeg%" -i "%s_source%" -vf format=yuva444p16le,alphaextract,format=yuv420p "%s_source%_alpha.mov"
Note that we seem to have to trick ffmpeg to assume another pixel format in order to be able to retrieve alpha only.
Alpha Video to Luma Key
Re: Alpha Video to Luma Key
emcodem, wrapping since 2009 you got the rhyme?
Re: Alpha Video to Luma Key
Thanks for the insight, now I know exactly what you mean: you wanna color the image with green using the transparency layer.
I came up with the right script for you:
Code: Select all
#Indexing
FFMpegSource2("Wvd3_clean.mov", atrack=-1)
#Getting rid of evil frame properties
propClearAll()
#Keeping the alpha channel
ConverttoRGB32()
#Collecting data
my_width=Width()
my_height=Height()
my_framerate=FrameRate()
my_frames=FrameCount()
#Substituting the alpha channel with a custom image
mk=ExtractA().ConverttoRGB32()
bg=ImageSource("\\mibctvan000.avid.mi.bc.sky.it\Ingest\MEDIA\temp\green_screen_sample.png", fps=my_framerate, start=0, end=my_frames, pixel_type="RGB32").Spline64Resize(my_width, my_height)
top=last.Mask(mk)
Layer(bg, top)
#Going to 4:2:2 planar
Converttoyv16()
in FFAStrans, this would be:
Code: Select all
#Keeping the alpha channel
ConverttoRGB32(m_clip)
#Getting rid of evil frame properties
propClearAll()
#Collecting data
my_width=Width()
my_height=Height()
my_framerate=FrameRate()
my_frames=FrameCount()
#Substituting the alpha channel with a custom image
mk=ExtractA().ConverttoRGB32()
bg=ImageSource("\\mibctvan000.avid.mi.bc.sky.it\Ingest\MEDIA\temp\green_screen_sample.png", fps=my_framerate, start=0, end=my_frames, pixel_type="RGB32").Spline64Resize(my_width, my_height)
top=last.Mask(mk)
Layer(bg, top)
#Going to 4:2:2 planar
m_clip=Converttoyv16()
return m_clip
and this will achieve the right result, so from this:
to this:
and as I always say: anything is possible with Avisynth eheheheheeh
if you want to keep audio, you need:
Code: Select all
#Keeping the alpha channel
ConverttoRGB32(m_clip)
#Getting rid of evil frame properties
propClearAll()
#Collecting data
my_width=Width()
my_height=Height()
my_framerate=FrameRate()
my_frames=FrameCount()
my_audio_channels=AudioChannels()
my_audio=GetChannels(my_audio_channels)
#Substituting the alpha channel with a custom image
mk=ExtractA().ConverttoRGB32()
bg=ImageSource("\\mibctvan000.avid.mi.bc.sky.it\Ingest\MEDIA\temp\green_screen_sample.png", fps=my_framerate, start=0, end=my_frames, pixel_type="RGB32").Spline64Resize(my_width, my_height)
top=last.Mask(mk)
video=Layer(bg, top)
audio=my_audio
AudioDub(video, audio)
#Going to 4:2:2 planar
m_clip=Converttoyv16()
return m_clip
if you're using an Avisynth version prior to 3.7.1, you can toss "propClearAll()", so:
Code: Select all
#Keeping the alpha channel
ConverttoRGB32(m_clip)
#Collecting data
my_width=Width()
my_height=Height()
my_framerate=FrameRate()
my_frames=FrameCount()
my_audio_channels=AudioChannels()
my_audio=GetChannels(my_audio_channels)
#Substituting the alpha channel with a custom image
mk=ExtractA().ConverttoRGB32()
bg=ImageSource("\\mibctvan000.avid.mi.bc.sky.it\Ingest\MEDIA\temp\green_screen_sample.png", fps=my_framerate, start=0, end=my_frames, pixel_type="RGB32").Spline64Resize(my_width, my_height)
top=last.Mask(mk)
video=Layer(bg, top)
audio=my_audio
AudioDub(video, audio)
#Going to 4:2:2 planar
m_clip=Converttoyv16()
return m_clip
Re: Alpha Video to Luma Key
As a side note, since emcodem says that I have no love for ffmpeg and algie said that we should provide an alternative way to Avisynth to do it for educational purposes, he (algie) created the command line to do the same thing in FFMpeg:
Cheers,
Frank (FranceBB) and Livio (algie)
Code: Select all
ffmpeg.exe -i "source_with_alpha.mov" -i "fill.mxf" -filter_complex "[0]alphaextract[a];[1][a]alphamerge[mask];[mask][0]overlay[v]" -map [v] -y "out.mp4"
Frank (FranceBB) and Livio (algie)
Re: Alpha Video to Luma Key
Thank you!!
but if i use the script than get i the error: "there is no function named 'ImageSource"
When i add: LoadPlugin("%s_ffastrans_dir%\processors\ffmpeg\x64\plugins+\ImageSeq.dll") to the script then is the key black and not green.
but if i use the script than get i the error: "there is no function named 'ImageSource"
When i add: LoadPlugin("%s_ffastrans_dir%\processors\ffmpeg\x64\plugins+\ImageSeq.dll") to the script then is the key black and not green.
Re: Alpha Video to Luma Key
Yeah loadplugin was implied.
About the key, make sure that AV Decoder is set to no decode, same as source for both video and audio
Re: Alpha Video to Luma Key
i make the mistake with AV Decoder NICE THIS WORK!!!! THANK you