I am looking for a way to automatically remove all frames in my video that match a particular mask.
In the upper right hand corner of the video, the frames I want to keep are white. The frames I want to automatically strip out have a black box in this region.
I am not concerned about audio. I'm just looking to create a new video file that would only contain frames that had the upper right hand corner white.
There are lots of frames to strip out, so the solution has to be automatic.
+ Reply to Thread
Results 1 to 10 of 10
-
-
This could be done with Avisynth using my DeleteFrames function from
http://forum.doom9.org/showthread.php?t=163107
In outline, you would use it like this:
... # load source video, eg AviSource("myvid.avi")
global mask = ... # load corner mask, eg using ImageSource()
w = mask.width() # corner width
h = mask.height() # corner height
global corner = Crop(width()-w, 0, w, h)
DeleteFrames("LumaDifference(corner, mask) < 0.1") # delete frames matching mask in corner -
Thank you for your suggestion Gavino. This definitely seems to be what I am looking for, and I feel like I am very close to getting this to work. Unfortunately, I have one problem I can't seem to get around.
I receive the error: "Plane Difference: Only planar images (as YV12) supported!"
I tried to save my video from Premiere Elements with a variety of different formats and codecs that were available, but nothing worked.
I then converted my video to MPEG4 using Any Video Converter. I tried both the x264 and xvid codecs because the AviSynth FAQ indicated that these codecs store the video in YV12. Unfortunately none of these worked either.
Lastly, I tried to use the ConverToYV12 function, but that didn't work either.
If anyone has any suggestions as to how I might resolve my YV12 issue, or if there is another AviSynth function which doesn't require YV12 and could do a similar inspection of the upper right hand corner for black pixels, that would be very appreciated. -
Where did you place ConvertToYV12()? It should be right after AVISource()
What new error message did you get? -
-
Hi,
With AVISource() the video wasn't looking right, and with LumaDifference() in the script I was getting messages that said the cropping values had to be an even number.
The good news is that when I used DirectShowSource to load it, the video looked correct. And when I added ConvertToRGB32() and replaced LumaDifference() with RGBDifference(), IT WORKED!!
Thanks for the help. -
Hi,
I think I spoke too soon. I had this working for a brief moment with a simple file, but haven't been able to get it to work with any of the real files I'm working with.
All of the frames I want to remove have a black box in the upper right hand corner. Frames I want to keep are white in the upper right hand corner.
I've included the script I'm using and I also uploaded the script, a sample mpeg file and the bitmap I'm using as the mask.
As you will be able to see, some bad frames (with a black box in the upper right hand corner) are not being deleted.
As well, some good frames (with white in the upper right hand corner) are being deleted even though they wouldn't match the mask.
I've tried a lot of different variations including using YV12/LumaDifference() and varying the threshold value. Nothing I try seems to work.
If anyone can point out what I'm missing, that would be appreciated.
Loadplugin ("GScript.dll")
DirectShowSource("samplempg.mpg").ConvertToRGB32()
global mask = ImageSource("black.bmp")
w = mask.width() # corner width
h = mask.height() # corner height
global corner = Crop(width()-w, 0, w, h)
DeleteFrames("RGBDifference(corner, mask) <10") # delete frames matching mask in corner
Thanks in advance. -
DirectShowSource() isn't frame accurate. Use DgIndex and Mpeg2Source() instead. Build an index file (.D2V) with DgIndex, then use Mpeg2Source("filename.d2v") instead of DirectShowSource("filename.mpg") to open that file. Don't delete or move the MPG source file. And your MPG source is interlaced so add "interlaced=true" to your ConvertToRGB32(), ie, ConvertToRGB32(interlaced=true).
-
Thank you for the quick reply.
DirectShowSource() was definitely part of the problem. I had a copy of my sample video in AVI format as well. When I used AVISource() with that file, everything was perfect right down to the last frame.
Then I went on to use DgIndex and Mpeg2Source() as you suggested. Again, it worked perfectly with the samplempg.mpg file I had uploaded.
So then I moved on to one of my actual videos with no luck. I feel I am very close so I will try some more before posting again and uploading another sample. -
Looks like this is working now (I hope I'm not speaking too soon again). In my actual video, the black rectangle must not be perfectly in the upper right hand corner. I moved the co-ordinates of the corner I was cropping 10 pixels down and 10 to the left. This seems to have done the trick.
Thanks for your help!
Similar Threads
-
Possible to select audio and automatically turn off subtitles?
By kpic in forum Authoring (DVD)Replies: 5Last Post: 21st Feb 2011, 06:59 -
Select subtitles automatically in a DVD
By dexter30 in forum Newbie / General discussionsReplies: 0Last Post: 7th Nov 2010, 09:38 -
How to select or delete options in xserver-xorg?
By A Traveller in forum LinuxReplies: 1Last Post: 14th Sep 2009, 23:48 -
How can I automatically capture still frames of a video?
By SamScaff in forum Capturing and VCRReplies: 1Last Post: 13th Sep 2007, 19:28