View Full Version : At which step does AddBorders get applied?
Thunderbolt8
15th June 2020, 16:40
I want to crop parts of a movie, encode it and add black bars again afterwards because Intro and End are full frame and I cannot have different ARs within the same file.
so what I would like to be able to do is Crop -> encode -> Addborders all within the same encode. Is this possible?
E.g. with Crop(0, 92, 0, -92)
AddBorders(0, 92, 0, 92)
in the script. What I need for this to work is that crop gets applied before the encoding process, but Addborders only applied AFTER the frame has already been encoded as last step of the processing. Is this possible (the way I did or in general)?
Groucho2004
15th June 2020, 16:57
what I would like to be able to do is Crop -> encode -> Addborders all within the same encode. Is this possible?Nope. :(
StainlessS
15th June 2020, 17:01
If it can be done, then can crop in Avisynth, and addborders using eg ffmpeg during encode, no idea how to do that. [perhaps x264 can also add borders, dont know]
Avisynth only processes uncompressed video/audio, nothing whatever to do with encoded clip.
Simplest would be to just trim into 3 parts, intro, main, exit, and use crop/addborders on main,
however LetterBox is better option than crop/addborders, does it in single step, and faster.
And of course splice before encode eg Intro ++ Main ++ Exit.
qyot27
15th June 2020, 17:07
Encode as separate files with the desired cropping per section, use Matroska's linked chapters or ordered chapters feature to make it seamless on playback. No need to use AddBorders at all.
Groucho2004
15th June 2020, 17:08
I was referring to this:
Addborders only applied AFTER the frame has already been encoded as last step of the processing
I'm rather sure that this is impossible with any encoder. However, I'm certainly not the source of all knowledge...
StainlessS
15th June 2020, 17:16
impossible with any encoder
Maybe, but I think ffmpeg could possibly do it as an extra step after encode, but I'm just guessin'.
anyways, qyot27 seems to have it well sussed out.
EDIT: Crap, gotta run like hell to try catch shop open.
Thunderbolt8
15th June 2020, 18:26
Encode as separate files with the desired cropping per section, use Matroska's linked chapters or ordered chapters feature to make it seamless on playback. No need to use AddBorders at all.unfortunately my smart TVs cant deal with linked chapters or ordered chapters in matroska.
qyot27
15th June 2020, 18:40
The thing you're essentially asking for is either a variable resolution file (which arguably *might* be possible with MKV, but most probably not; MPEG-2 TS can get around it via streaming chunks, where each chunk can have its own resolutionı), or variable anamorphic flagging per-frame/GOP (which AFAIK, nothing supports). Capable software or hardware players will do auto-letterboxing/auto-pillarboxing if the AR of the video doesn't match the display AR, but to have resolution changes in a single file one of the segments has to be hard letterboxed/pillarboxed beforehand, and that cannot be done at playback, it has to be done before encoding.
ıyes, this is what happens when watching an online stream from TV broadcasters, at least in the US. The main program may be a constant resolution, so long as your internet connection is good, but the advertisements can vary wildly. If you're not careful, a stream downloader could bork your output file if you don't compensate for this.
So either you fix the sections of the video using Trim so you can keep the 4:3 content untouched while letterboxing the 16:9 parts (or Trim so you can pillarbox the 4:3 sections and leave the 16:9 ones alone) and Splice them back together at the end of the script before giving the script to the encoder, as StainlessS suggested, or you can have the segments as separate files with their own properties and attempt to do whatever is possible to make it seamless on playback (if being played off a USB stick, just having the files named sequentially might trick the TV enough to be passable, with a pause between the segments being more/less noticeable based on the TV...if the TV is set to just autoplay the next file and not go back to the file menu). If MKV won't work for the purpose, you're probably out of luck. A playlist file is a dumb measure that, again, a TV probably can't handle, and probably won't be seamless even on a computer.
qyot27
15th June 2020, 18:57
Example of a 640x480 video with 4:3 intro/outro and 16:9 hard-letterboxed main segment, switching it to a 16:9 848x480 video so the main segment looks correct on modern TVs, with the intro/outro pillarboxed:
v=FFMS2("input",atrack=-1)
v1=v.Trim(0,5000).AddBorders(104,0,104,0) #adds pillarboxing to sides of 640x480 video to make it 848x480
v2=v.Trim(5001,25000).Crop(0,64,0,-64).BilinearResize(848,480) #crops existing letterboxing from 16:9 segments, resizes to 848x480
v3=v.Trim(25000,0).AddBorders(104,0,104,0) #adds pillarboxing to sides of 640x480 video to make it 848x480
v1 ++ v2 ++ v3 #puts all three segments back together
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.