I want to sync 2 video, but one has some blank/black frames in the middle for a pause, while the other just jumps to the next part of the episode.
I want to add solid black frames in to fill it in with silence to match up with the other source.
If this is possible, how would I do this with avisynth, whats the script command?
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 22 of 22
Thread
-
-
As a function:
Code:function InsertBlank(clip v, int position, int duration) { # position and duration are frame numbers blank = BlankClip(v, length=duration) # create black clip with same properties as existing clip v.Trim(0,position-1) ++ blank ++ v.Trim(position,0) }
Code:named_clip = WhateverSourceWithAudio() named_clip = InsertBlank(named_clip, 10000, 50) # insert 50 blank frames at frame 10000
-
This is easier to do visually in an NLE like Premiere.
I have a project in Premiere right now, with this issue, and a few others.Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS -
Thanks Jagabo!
Before I saw your reply, I also came up with the idea to copy black frames from other parts of the episode with trim and place them where I needed in the video. It seems to work for what I was looking for. -
-
Another way to insert a delay into a clip is to use Loop to repeat a frame (or a sequence of frames) multiple times. For example:
Code:Loop(51, 1000, 1000)
-
That's using an elephant gun on a mouse as it's a trivial exercise in AviSynth. VDub serves as the visual and script confirmation. jagabo has already shown several ways to do it. Me, I'd do it like so:
A=Trim(Last,0,1000)###1000=last frame before black frame insertion
B=BlankClip(Last,Length=10)###Insert 10 black frames with same characteristics (including silent audio) as rest of video
C=Trim(Last,1001,0)### resume video after insertion of black frames
A++B++C###AlignedSplice
Last edited by manono; 2nd Jun 2019 at 14:10.
-
Now, supposing I take that black frame, open it in paint, and add a title. How do I add this to the beginning of a clip, and make it last for a few seconds before the video begins?
-
Here's one way:
AssumeFPS(23.976)
Title=ImageSource("Title.bmp",End=99,fps=23.976).C onvertToYV12()
Title+Last
You might not need the AssumeFPS line, depending on your framerate, but you'll probably need to set one in the ImageSource line. The default is 24fps. Figure out how many frames for your length at your framerate. This adds 100 frames (Avisynth counting begins with zero) at 23.976fps or just over 4 seconds of title. This doesn't include the audio. If you need silent audio, read up on ImageSource on the AviSynth site. As they both have to be in the same colorspace to join, I added the ConvertTo command. -
Assuming the main video is already loaded as "last", YV12, no audio, and the image is already the right dimensions:
Code:title = ImageSource("filename.ext", start=0, end=int(last.framerate*3.00), fps=last.framerate).ConvertToYV12() # note: 3 seconds title+last
-
-
-
Just add a Subtitle() to the blank clip.
Code:function InsertBlank(clip v, int position, int duration) { # position and duration are frame numbers blank = BlankClip(v, length=duration) # create black clip with same properties as existing clip blank = blank.Subtitle("This is a subtitle.") # add font, size, x and y positions as desired v.Trim(0,position-1) ++ blank ++ v.Trim(position,0) }
-
Ahh, thanks! I'm totally new to this and just starting to experiment to see what is possible. I think I was making it more complicated than it needs to be since I wanted to add in front of video. So I think I would only need:
Code:video = Avisource("movie.avi") blank = BlankClip(video, length=200) # create black clip (200 frames) with same properties as existing clip blank = blank.Subtitle("This is a subtitle.") # add font, size, x and y positions as desired blank+video
Can you/how would you add FadeIn and FadeOut to both "blank" (so the subtitle would fade in and out) and "video"?
Also, how would you get multiple lines of subtitles using this format?
I'm trying to read through the Wiki articles but it's a lot to take in all at once
Ultimately I'm wondering if I can do simple titling and fading on my videos right in AviSynth (without being an actual "subtitle" that you can turn off). The title would have to be several lines to fit in what I want.. like what the event is, and the date, possibly the location, etc.
Other than fades and titles, I think the only other processing I would need in most cases is masking, QTGMC and conversion to x264 so if I can avoid using an external editor, that would be great. It's just a lot to wrap your head around when starting out, but so far I like it! -
subtitle() requires a video to refer to, otherwise which video are you referring to ? In this case the video being subtitled is "blank", but it could have been video1, video99, xyz, myvideo, etc...
If you did not use variable names, avisynth uses "implied last"
Code:BlankClip(length=200) Subtitle("This is a subtitle.")
Also, are these subtitles hardcoded into the video?
Can you/how would you add FadeIn and FadeOut to both "blank" (so the subtitle would fade in and out) and "video"?
http://avisynth.nl/index.php/Fade
eg. 10 frame fade in/out
Code:blank.fadeio(10)+video.fadeio(10)
Also, how would you get multiple lines of subtitles using this format?
eg.
Code:subtitle("first line \nsecond line", lsp=1)
-
!!!
Thank you! Worked perfectly. I get it now. I didn't know about "last" and I read those pages already that you linked but knowing the syntax and how it all goes together to do what you want it to do is tricky when you are just looking at basic isolated examples. Really appreciate both of your help here.
I'm so excited right now! -
Yes, that will work.
Most AviSynth filters take a clip as an input and produce a clip as an output. If you don't supply a name for those clips the name "last" is assumed. So a call like:
Code:Subtitle("This is a subtitle.")
Code:last = Subtitle(last, "This is a subtitle.")
Code:last = last.Subtitle("This is a subtitle.")
Use Fade filters: http://avisynth.nl/index.php/Fade
Code:blank = blank.Subtitle("This is a subtitle.").FadeIO0(10) # fade in (over 10 frames at the start) and out (over 10 frames at the end).
Code:blank = blank.Subtitle("This is a subtitle.\nThis is the second line.", lsp=10).FadeIO0(10) # fade in (over 10 frames at the start) and out (over 10 frames at the end).
See Overlay().
A pain get set up the first time because there are so many dependencies, versions, etc. But once you have everything it's pretty easy to use.
Use any encoder that supports AvISynth scripts as input. x264 cli, ffmpeg... -
Thank you!!! It's all starting to make a lot more sense now and I feel like the programmer I never was.
Here's what I have so far and it's working out great. I will easily be able to re-use this script and change the text for each video.
Code:video = Avisource("movie.avi") blank = BlankClip(video, length=200) # create black clip (200 frames) with same properties as existing clip blank = blank.Subtitle("Text line 1 \n" + \ "Text line 2 \n" + \ "Text line 3", \ lsp=10, font="georgia", size=48, text_color=$FFFFFF, x=-1, y=200) # add font, size, x and y positions as desired blank.fadeio(20)+video.fadeio(20)
For converting, the way I know how to do it so far is creating a .bat with the ffmpeg command inside and then executing the .bat. I haven't actually tried it with x264 yet though (only ProRes) so that is the next thing I need to look into with all the available parameters, and see what the best way is.
Thanks again. -
Here's an example batch file for ffmpeg:
Code:"G:\program files\ffmpeg64\bin\ffmpeg.exe" ^ -i %1 ^ -c:v libx264 -preset slow -crf 18 -g 50 ^ -profile:v high -level:v 4.2 -colorspace bt709 -color_range tv ^ -acodec ac3 ^ "%~dpn1.avc.mkv" pause
Code:start /b /low "x264" "g:\program files\x264\x264-64bit.exe" --preset=slow --crf=18 --keyint=50 --sar=1:1 --colormatrix=bt709 --stitchable --output "%~1.mkv" "%~1" pause
-
And is it as simple as changing avc.mkv to avc.mp4 for mp4 container?
That’s pretty cool. I didn’t know that either. Can you select multiple files and drag and drop them on the batch at the same time to do more than one?
Also I assume if I use my AVS script to create a intermediate file in say, ProRes format, that I could also just drag and drop the ProRes .mov onto the batch file as well and it would work just fine too?
Thanks. This helps a lot! -
Yes
Also I assume if I use my AVS script to create a intermediate file in say, ProRes format, that I could also just drag and drop the ProRes .mov onto the batch file as well and it would work just fine too?
But there is generation loss (albeit only a small amount if you're using HQ or 4444XQ) from using the prores file as the intermediate. Using the avs directly would result in less quality loss -
Yes.
Not as written. But you don't have to wait for one to finish before starting another so you can encode multiple files at once. You just have to drag/drop them individually.
Yes, as long as the programs have a ProRes decoder built in (most x264 and ffmpeg builds do).
Similar Threads
-
Replace random duplicate frames with black frames (AVISYNTH)
By benzio in forum EditingReplies: 7Last Post: 31st Jan 2018, 16:43 -
Avisynth total frames does not equal VirtualDub total frames
By EasyFeet in forum EditingReplies: 12Last Post: 14th May 2017, 00:20 -
Need help adding black frames to beginning and ending of mp4-no reencode
By Danfun64 in forum Newbie / General discussionsReplies: 28Last Post: 26th Jan 2016, 01:46 -
why I get the solid green using an avisynth script?
By marcorocchini in forum Newbie / General discussionsReplies: 1Last Post: 23rd Aug 2015, 07:56 -
Adding Black Bars
By wulf109 in forum Video ConversionReplies: 2Last Post: 15th May 2015, 20:42