Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 28th October 2017, 10:31   #1  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
How to add blackbars to mkv files on bottom and top?

Hello!

Don't know if this is the right place to post this request...?

I have some mkv files I would like to add blackbars on bottom and top.
The files are 1920x960 and I would like to make them 1920x1080.
That should be 60 extra on top and bottom.
Is there an fairly easy way to do this? Without losing any quality?
If the files get larger it's not a problem.
I don't mind if it's timeconsuming as I guess there have to be some kind of reencode of the mkv's.
A batch mode would be great then I can run the reencodes overnight.

I found a solution where converting the mkv's to other format is needed, then use Vegas Pro and in there add blackbars.
But that reqires two extra software and at least Vegas is not for free.
I'm thinking there have to be an easier way? With free software, maybe Avisynth?
If someone knows what settings/script Avisynth requires please let me know!

Thanks...
varekai is offline   Reply With Quote
Old 28th October 2017, 10:51   #2  |  Link
Yanak
Registered User
 
Join Date: Oct 2011
Posts: 275
Try with aviynth :
AddBorders(0, 60, 0, 60, color_black)
or
AddBorders(0, 60, 0, 60, $000000)

But you will have to reencode to get them on your video, i see not other solution, unless just playing the .avs script adding the black borders in a player like MPC-HC for example ( and this might not be very fluid, will depend of your PC performances i guess) , maybe others will have more ideas.

Last edited by Yanak; 28th October 2017 at 11:01.
Yanak is offline   Reply With Quote
Old 28th October 2017, 14:39   #3  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
OK, thanks, will do some testing.
Have to find a good video file converter first.
varekai is offline   Reply With Quote
Old 28th October 2017, 16:33   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
A lot of people here use MeGUI, or for less experienced perhaps Handbrake, both in MPEG-4 Encoder GUI's forum.

EDIT: There are many additional alternatives in same forum.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 28th October 2017 at 16:35.
StainlessS is offline   Reply With Quote
Old 28th October 2017, 20:16   #5  |  Link
Yanak
Registered User
 
Join Date: Oct 2011
Posts: 275
For the encoder GUI maybe Staxrip is a good option as it can do batch encodings.
http://staxrip.readthedocs.io/intro.html#download

You will just need to edit the filter list and add the "AddBorders(0, 60, 0, 60, color_black)"

Maybe using a x264 profile with a very low CRF will do the trick for the no loss of quality needed, not sure what will be the exact parameters for getting something very close to lossless tho.

Audio can be set to be just remuxed into the output container, not touched or re-encoded in Staxrip too, audio is extracted from the source and copied into the output container.

Or something like ProRes codec for output maybe since size is not a problem ? ( also possible in Staxrip, via FFMPEG if i make no errors ) ?

This will need others users with more knowledge to bring more infos to know the best output to choose to get something lossless or close to it for the video re-encoded.

Last edited by Yanak; 28th October 2017 at 20:26.
Yanak is offline   Reply With Quote
Old 28th October 2017, 20:24   #6  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
Using MeGUI adding the script throws an error:
https://s1.postimg.org/3fsk2ick7z/error.png
What am I doing wrong?

I'll try StaxRip!

Thanks for your help Yanak and StainlessS, appreciate it!

Best regards
varekai is offline   Reply With Quote
Old 28th October 2017, 20:53   #7  |  Link
Yanak
Registered User
 
Join Date: Oct 2011
Posts: 275
Long time i have not used MEGUI but if i recall correctly :

- Go to tools > Avs Script Creator
- Next to Avisynth profile click the "config" button and add this at the end and validate:
AddBorders(0, 60, 0, 60, color_black)
- Still on this popup window select the video input ( browse it ) , it will open preview.
- close preview and on the main window click on " reopen video preview" to see if the black borders have been added.

As for the output codec and parameters needed ... same as before hard to say what will be close to lossless...
Hard to say more on the error seeing the screenshot tho.


In Staxrip once you just started it create the filter for the borders :
- Right click on the "AVS filters list" then on the contextual menu select " Profiles"
- At the very top of the new popup copy and paste this, then save :
Quote:
[My Filters]
Add Blackbars = AddBorders(0, 60, 0, 60, color_black)


- Then right click again on the filters list , on the contextual menu " +Add > My Filers > Add BlackBorders"

-You can then save this as template going to "Project > Save as Template " ( and set staxrip to start like this with this filter set already too )

Then click on "source" or at the bottom to select your source using "Single File" , (select "File Batch" and put a few of your videos once you will have all ready and set to your needs )

- Press F5 or click preview to see if all went well with the balckbars added.
- for the audio select copy/mux ( click on the default "opus 250 kpbs" to change it)

Then next step is finding a nice preset and setting for a lossless as possible output ( clicking on x264 on the UI ), a low crf of 16-18 instead of 20 like it have by default should bring good results i think.

Again this will need someone else help for the best encoding codec and settings, the rest i could provide help again if needed to set this once parameters are known, here or on the Staxrip thread ^^ ( same about MEGUI, best will probably to ask help on the dedicated threads or dedicated forum section for the most lossless possible settings you need for the encodings )

Good Luck.

Edit : maybe RipBot could be a solution too, have not used it since years and can't even remember how to add a simple avisynth filter on it or if it is even possible
but it's maybe a solution for batch encoding, you will need to ask on the dedicated thread ^^

Last edited by Yanak; 22nd January 2018 at 23:45.
Yanak is offline   Reply With Quote
Old 29th October 2017, 00:37   #8  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,406
UncropMKV was designed for what you want. Since it uses AviSynth, it'll reencode.
manono is offline   Reply With Quote
Old 29th October 2017, 10:13   #9  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
Quote:
Originally Posted by manono View Post
UncropMKV was designed for what you want. Since it uses AviSynth, it'll reencode.
ESET Internet Security Scan Log
Version of detection engine: 16321 (20171029)
Date: 2017-10-29 Time: 09:58:18
Scanned disks, folders and files: *:\***\uncropMKV 1.55\uncropMKV_1.55.exe
*:\***\uncropMKV 1.55\uncropMKV_1.55.exe NSIS AcPro.exe INNO {app}\AutocompletePro.dll - a variant of Win32/Complitly.
A potentially unwanted application - action selection postponed until scan completion.
Number of scanned objects: 43
Number of threats found: 1
Number of cleaned objects: 1
Time of completion: 09:59:05 Total scanning time: 47 sec (00:00:47)

Cut from videohelp:
WARNING
uncropMKV 1.55 installed AutoCompletePro without asking.
To remove this malware see https://malwaretips.com/blogs/remove-autocomplete-pro/

Not cool at all!!

----------------------------------------------

Edit:
Well it seems Mr. Dean have a clean version on his site, no adware warning from ESET!
multiavchd.deanbg.com/uncropMKV/
Mr. Dean is a very clever man, I wish he would continue working on his smart tools, I use quite a few of them.

Last edited by varekai; 29th October 2017 at 11:03. Reason: More info...
varekai is offline   Reply With Quote
Old 29th October 2017, 10:21   #10  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
@Yanak
Got StaxRip to do what I wanted, good thing is it works directly on mkv so no need for converting.
Bad thing is it takes forever... so now it's time to confer with two of my best colleagues, trial & error...
varekai is offline   Reply With Quote
Old 29th October 2017, 11:05   #11  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Funny that everyone suggest some "GUI". ffmpeg can do this easily using the "pad" option with a simple command line.
For example:
Code:
ffmpeg -i "input.mkv" -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -preset slow -crf 21 -c:a copy "output.mkv"
Also in batch mode:
Code:
if not exist output md output
for %%i in (*.mkv) do (
  start/b/wait/low ffmpeg -i "%%i" -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -preset slow -crf 21 -c:a copy "output\%%~ni.mkv"
  echo.
)
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 29th October 2017, 11:28   #12  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Funny that everyone suggest some "GUI"
I guess that we were all waitin' for the wisdom of G2K4, thanx ol' wise one for those 'simple command line's
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 29th October 2017, 11:30   #13  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
Quote:
Originally Posted by Groucho2004 View Post
Funny that everyone suggest some "GUI". ffmpeg can do this easily using the "pad" option with a simple command line.
Probably because it's a steep learning curve for users who are unfamiliar with this type of interface.
I will look into this:
https://www.ffmpeg.org/ffmpeg.html
Maybe I could learn how to use it.
varekai is offline   Reply With Quote
Old 29th October 2017, 11:38   #14  |  Link
Yanak
Registered User
 
Join Date: Oct 2011
Posts: 275
Yup i'm too used to gui tools, only using cmd line and things like ffmpeg for very specific needs, not having the reflex to look into this first, forgot it had the possibility to add the bars too, at the same time this tool have so many options...

For the -crf 21 isn't this value a bit too high for the re-compression since he wanted to not loose any quality at all ? Maybe 16-18 will be better for this purpose and a small loss of quality, maybe combined with -ssim parameter too? maybe, i'm not sure.

I noted this command for a possible use of it one of those days too , thanks

Last edited by Yanak; 29th October 2017 at 11:43.
Yanak is offline   Reply With Quote
Old 29th October 2017, 11:41   #15  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by Yanak View Post
For the -crf 21 isn't this value a bit too high for the re-compression since he wanted to not loose any quality at all ? Maybe 16-18 will be better for this purpose and a small loss of quality
Yes, encoding parameters as needed. It was just an example to demonstrate the use of "pad".
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Old 29th October 2017, 11:46   #16  |  Link
Yanak
Registered User
 
Join Date: Oct 2011
Posts: 275
Got it, for this part he will need external help, i know only one real way to do lossless it's with x265 --lossless but the output file sizes are so big that it becomes crazy unless you do this on very short videos for very specific needs.

Now needs to find out what re encoding parameters will bring the minimal loss possible ^^

Thank you.
Yanak is offline   Reply With Quote
Old 29th October 2017, 12:31   #17  |  Link
Sharc
Registered User
 
Join Date: May 2006
Posts: 3,997
Quote:
Originally Posted by varekai View Post
Probably because it's a steep learning curve for users who are unfamiliar with this type of interface.
I will look into this:
https://www.ffmpeg.org/ffmpeg.html
Maybe I could learn how to use it.
Or import your file with BD-Rebuilder and select a BD (or AVCHD) compliant output. It will add the borders automatically for you.
Sharc is offline   Reply With Quote
Old 29th October 2017, 13:57   #18  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
Quote:
Originally Posted by Groucho2004 View Post
Funny that everyone suggest some "GUI". ffmpeg can do this easily using the "pad" option with a simple command line.
I learnt how to set up ffmpeg and it's working.
Is the correct way to add -crf 0 for keeping files "untuched"?
The results I get is very close to original size, sligthly larger but that would be expected.
Thanks for your help, learned a lot, lots of fun!

Edit:
How would the batch script look when having these mkv files in lets say drive X:
But I want to have another output drive like Y:


Code:
if not exist output md output
for %%i in (*.mkv) do (
  start/b/wait/low ffmpeg -i "%%i" -vf "pad=1920:1080:(ow-iw)/2:(oh-ih)/2" -c:v libx264 -preset slow -crf 21 -c:a copy "output\%%~ni.mkv"
  echo.
)

Regards

Last edited by varekai; 29th October 2017 at 14:29. Reason: .
varekai is offline   Reply With Quote
Old 29th October 2017, 13:58   #19  |  Link
varekai
Registered User
 
varekai's Avatar
 
Join Date: Jul 2006
Posts: 530
Quote:
Originally Posted by Sharc View Post
Or import your file with BD-Rebuilder and select a BD (or AVCHD) compliant output. It will add the borders automatically for you.
I will try this as I used BD-RB before.
Thanks.
varekai is offline   Reply With Quote
Old 29th October 2017, 14:17   #20  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by varekai View Post
Is the correct way to add -crf 0 for keeping files "untuched"?
The results I get is very close to original size, sligthly larger but that would be expected.
CRF 0 is lossless but the resulting file size would be very large compared to the source. So, I'm quite puzzled that you get a size close to the source.
__________________
Groucho's Avisynth Stuff
Groucho2004 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:36.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.