View Full Version : how 4/3 -> 16/9 in x264 ?
lutinor
15th April 2011, 09:56
hi all,
i have some 4/3 media and i want to see them in 16/9 full screen. The movie will be 'enlarged' but i don't care, i want full screen ^^ The target output must be in 1280x720 aka 720p blueray compliant media
At http://sites.google.com/site/x264bluray/home
You can see :
--sar 1:1 for 720p
Question : When i use the 1:1 i have a 4/3 movie :( is it a --resize option ? or a --sar option which can make me happy?
Question 2 : If we mod sar, will it keep the compliant bd rule?
Thx in adv,
Max
smok3
15th April 2011, 12:31
you have two options:
a. to resize to center of 16:9 frame (pillarbox)
http://resizecalc.sourceforge.net/index.php?ssmw=720&sar=1.06667&sar2=&ssmh=576&CT=&CL=0&CR=0&CB=&mplayCrop=&trw=960&dar=1&dar2=&modw=&modh=&padw=1280&padh=720&css=&doit=true
LanczosResize(960,720) # (modw16,modh16)
AddBorders(160,0,160,0) # pad width 1280
b. to resize to fill
http://resizecalc.sourceforge.net/index.php?ssmw=720&sar=1.06667&sar2=&ssmh=576&CT=72&CL=0&CR=0&CB=72&mplayCrop=&trw=1280&dar=1&dar2=&modw=&modh=&padw=1280&padh=720&css=&doit=true
Crop(0,72,-0,-72) # 720x432
LanczosResize(1280,720) # (modw16,modh16)
i'd go with a.
p.s.
--sar option other than 1 will not make you happy
lutinor
15th April 2011, 14:09
you have two options:
a. to resize to center of 16:9 frame (pillarbox)
http://resizecalc.sourceforge.net/index.php?ssmw=720&sar=1.06667&sar2=&ssmh=576&CT=&CL=0&CR=0&CB=&mplayCrop=&trw=960&dar=1&dar2=&modw=&modh=&padw=1280&padh=720&css=&doit=true
LanczosResize(960,720) # (modw16,modh16)
AddBorders(160,0,160,0) # pad width 1280
b. to resize to fill
http://resizecalc.sourceforge.net/index.php?ssmw=720&sar=1.06667&sar2=&ssmh=576&CT=72&CL=0&CR=0&CB=72&mplayCrop=&trw=1280&dar=1&dar2=&modw=&modh=&padw=1280&padh=720&css=&doit=true
Crop(0,72,-0,-72) # 720x432
LanczosResize(1280,720) # (modw16,modh16)
i'd go with a.
p.s.
--sar option other than 1 will not make you happy
I'm new in x264 and i guess what you said is an avysynth script pass ? Can you tell me more about that ? Unless it's a cli x264 line (which i doubt) i need some help plz
Last thing : what do you mean by 'other than 1 will not make you happy' ?
Thx in adv for your help,
Max.
ps: what about bd compliant ? The sar is important or not ?
LoRd_MuldeR
15th April 2011, 14:58
I'm new in x264 and i guess what you said is an avysynth script pass ? Can you tell me more about that ?
Yes, it's Avisynth script!
If you are new to Avisynth, look at the Avisynth Wiki, as suggested before:
http://avisynth.org/mediawiki/Main_Page
For specific questions, you can ask in the Avisynth forum:
http://forum.doom9.org/forumdisplay.php?f=33
Last thing : what do you mean by 'other than 1 will not make you happy' ?
SAR == Sample Aspecr Ratio (sometimes referred to as "PAR" == "Pixel Aspect Ratio")
Commonly a SAR of 1:1 is referred to as "square pixels" whereas a SAR different from 1:1 would be referred to as "anamorphic video".
http://en.wikipedia.org/wiki/Anamorphic_format
(I think BluRay doesn't use "anamorphic" video anymore, i.e. SAR should be 1:1. It was used heavily on Video-DVD though)
lutinor
15th April 2011, 15:25
Yes, it's Avisynth script!
If you are new to Avisynth, look at the Avisynth Wiki, as suggested before:
http://avisynth.org/mediawiki/Main_Page
For specific questions, you can ask in the Avisynth forum:
http://forum.doom9.org/forumdisplay.php?f=33
SAR == Sample Aspecr Ratio (sometimes referred to as "PAR" == "Pixel Aspect Ratio")
Commonly a SAR of 1:1 is referred to as "square pixels" whereas a SAR different from 1:1 would be referred to as "anamorphic video".
http://en.wikipedia.org/wiki/Anamorphic_format
(I think BluRay doesn't use "anamorphic" video anymore, i.e. SAR should be 1:1. It was used heavily on Video-DVD though)
Ok will check this tonight but i have a question :
If i use another tool (aka tmpg) to make it 16/9 and after that i use the x264 cli with the 1:1 will i get a compliant file blueray file?
poisondeathray
15th April 2011, 15:37
i would avoid tmpg, you will incur YV12=>RGB=>YV12 losses
lutinor
15th April 2011, 16:39
i would avoid tmpg, you will incur YV12=>RGB=>YV12 losses
Ok but with this i can resize to 16/9 and after that i can encode with cli x264 with the SAR 1:1, am i wrong ? Have i miss something ?
poisondeathray
15th April 2011, 16:54
Ok but with this i can resize to 16/9 and after that i can encode with cli x264 with the SAR 1:1, am i wrong ? Have i miss something ?
I'm referring to any filtering.
If you do filtering in avisynth, you can stay in YV12 and avoid quality loss. Filtering in TMPG causes RGB conversion
IMO pillarboxing is the best option
smok3
15th April 2011, 17:56
lutinor, can you 'mediainfo' your source file and post some data?
http://mediainfo.sourceforge.net
lutinor
16th April 2011, 19:19
lutinor, can you 'mediainfo' your source file and post some data?
http://mediainfo.sourceforge.net
here's my source file :
Vidéo
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Profil du format : High@L5.1
Paramètres du format, CABAC : Oui
Paramètres du format, RefFrames : 16 images
Identifiant du codec : V_MPEG4/ISO/AVC
Durée : 24mn 21s
Débit nominal : 900 Kbps
Largeur : 720 pixels
Hauteur : 544 pixels
Format à l'écran : 4/3
Images par seconde : 23,976 Im/s
Espace de couleurs : YUV
Sous-échantillonnage de la chrom : 4:2:0
Profondeur des couleurs : 8 bits
Type d'image : Progressif
Bits/(Pixel*Image) : 0.096
Bibliothèque utilisée : x264 core 54 svn-618
Paramètres d'encodage : cabac=1 / ref=16 / deblock=1:2:2 / analyse=0x3:0x133 / me=umh / subme=6 / brdo=1 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / chroma_qp_offset=0 / threads=1 / nr=0 / decimate=1 / mbaff=0 / bframes=2 / b_pyramid=1 / b_adapt=1 / b_bias=0 / direct=2 / wpredb=1 / bime=1 / keyint=300 / keyint_min=25 / scenecut=30 / rc=2pass / bitrate=900 / ratetol=1.0 / rceq='blurCplx^(1-qComp)' / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.20 / pb_ratio=1.30
Langue : Japonais
Edit : i think i will have some hard time with avisynth, i will try it this night (gl to me)
smok3
16th April 2011, 21:11
i would try something like this (since being in pal land), i did overlook the possibility of standard res in my previous post:
LoadPlugin("t:\avisynth\plugins\FFMS2.dll")
# http://code.google.com/p/ffmpegsource/
a=ffaudiosource("z:\file.mp4")
v=ffvideosource("z:\file.mp4")
audiodub(v,a)
#some sort of frame rate conversion here to get 24 or 25 fps ?
AssumeFPS(25, 1, true)
SSRC(48000)
LanczosResize(720,576) # (modw16,modh16)
# then i would feed this into:
# http://sites.google.com/site/x264bluray/home/576p-pal
# or i guess if you'd want to keep the original fps, then this (with different upsizing)
# http://sites.google.com/site/x264bluray/home/720p-encoding
# edit: not sure if you really need to specify --sar at this point in time? Anyway, use a small sample to test the entire path, you can add:
# trim(100,2000)
p.s. Also i guess you can do all of that with a proper x264 command line this days, completely eliminating avisynth?
poisondeathray
16th April 2011, 21:39
p.s. Also i guess you can do all of that with a proper x264 command line this days, completely eliminating avisynth?
If you are using x264 built with the filtering patch (or is it in the main build now?), you can crop and resize , or fittobox, but I don't think you can add borders
If he's upscaling to 720p25(with double pulldown, sar 1:1) , then your option "A" still works if the 720x544 source has no borders.
I wouldn't bother upscaling in this case. The source stats look miserable
smok3
16th April 2011, 21:45
then your option "A" still works if the 720x544 source has no borders
what do you mean? (i assumed this is PAR=1)
from x264 --longhelp:
resize:[width,height][,sar][,fittobox][,csp][,method]
resizes frames based on the given criteria:
- resolution only: resizes and adapts sar to avoid stretching
- sar only: sets the sar and resizes to avoid stretching
- resolution and sar: resizes to given resolution and sets the sar
- fittobox: resizes the video based on the desired contraints
- width, height, both
- fittobox and sar: same as above except with specified sar
- csp: convert to the given csp. syntax: [name][:depth]
- valid csp names [keep current]: i420, yv12, nv12, i422, i444, bgr, bgra, rgb
- depth: 8 or 16 bits per pixel [keep current]
note: not all depths are supported by all csps.
- method: use resizer method ["bicubic"]
- fastbilinear, bilinear, bicubic, experimental, point,
- area, bicublin, gauss, sinc, lanczos, spline
select_every:step,offset1[,...]
apply a selection pattern to input frames
step: the number of frames in the pattern
offsets: the offset into the step to select a frame
see: http://avisynth.org/mediawiki/Select#SelectEvery
shrug.
poisondeathray
16th April 2011, 21:46
yes that's it
I don't see borders option ? crop is an option too if you scroll a bit higher
I was referring to the 720p pillarbox option with 4:3 content (your original "a" option above in post #2)
smok3
16th April 2011, 21:46
yes that's it
I don't see borders option ?
fittobox ?
I was referring to the 720p pillarbox option with 4:3 content (your original "a" option above in post #2)
yeah, still appears as if that the "only" way to keep original fps.
poisondeathray
16th April 2011, 21:51
fittobox ?
never tried that one :)
does it work ?
where does it say he's doing 23.976 => 25p ?
smok3
16th April 2011, 22:00
where does it say he's doing 23.976 => 25p ?
it doesn't, thats why i specifically wrote: "i would..." :)
sneaker_ger
17th April 2011, 00:12
never tried that one :)
does it work ?
IIRC it does not do what smok3 thinks it does. It doesn't add borders nor does it apply any cropping.
smok3
17th April 2011, 09:16
IIRC it does not do what smok3 thinks it does. It doesn't add borders nor does it apply any cropping.
:), why i'am always so misunderstood, all i did was make a (slightly hidden) request/wish for people to share their knowhow with x264 filters (which i honestly don't have a clue about..) . :thanks:
lutinor
17th April 2011, 13:54
I was a bit busy yesterday but , i'm not sure :
It is possible to avoid avisynth? It sounds very hard for me :(
The 720*544 has left and right border, it's a square + 2 ugly black band, one on the left , one on the right
Maybe a resize option in x264 can save my day ?
J_Darnley
17th April 2011, 14:10
If you want to use a resize option in x264, use the resize option in x264! There is also cropping and, if you use my patch, padding.
lutinor
17th April 2011, 14:19
If you want to use a resize option in x264, use the resize option in x264! There is also cropping and, if you use my patch, padding.
Atm i use this :
--vf resize:width=720,height=576,method=spline
How can i mod it ? Help plz :(
J_Darnley
17th April 2011, 14:24
To do what? Aren't the named options fairly clear?
kemuri-_9
17th April 2011, 14:24
:), why i'am always so misunderstood, all i did was make a (slightly hidden) request/wish for people to share their knowhow with x264 filters (which i honestly don't have a clue about..) . :thanks:
resize's fittobox is to resize the video to fit within the provided box, but it does not necessarily fill in the box completely, e.g.
16:9 video with fittobox of 640x480 will cause it to resize 640x360
if the destination video must absolutely have a 1:1 SAR, then currently doing all filtering within standard x264 builds with that requirement will only lead to distortion.
if 1:1 SAR must be the result, then the filtering chain would be
1) crop off unwanted video (if any)
2) resize (without changing SAR)
3) pad to add borders to the side to fit the 4:3 video within 16:9
but there is no pad in standard builds, I think JEEB's builds are still including the pad filter though...
lutinor
17th April 2011, 21:13
To do what? Aren't the named options fairly clear?
well, :
--vf resize:width=720,height=576,method=spline
I adapt to :
--vf resize:width=720,height=576,method=spline,fittobox
result ? : Ordered option given after named -> HELP :'(
J_Darnley
17th April 2011, 21:19
fittobox is the name of another option, it needs an argument. You need to say whether you want it to fit the width, height or both.
sneaker_ger
17th April 2011, 21:20
fittobox=width
or height or both
lutinor
17th April 2011, 22:35
fittobox is the name of another option, it needs an argument. You need to say whether you want it to fit the width, height or both.
That's official : i"m stupid
x264 --preset ultrafast --vf resize:width=1280,height=720,method=spline,fittobox:width=1280,height=720 -o outputbox.264 ep1.mkv
Where is my mistake ? :confused:
Ok i have done the job ^^ :
x264 --preset ultrafast --vf resize:width=1280,height=720,method=spline,fittobox=both -o outputbox.264 ep1.mkv
but it encode to a different resolution than what i want , in this case (argument: both) it make 952*720 file :s
sneaker_ger
17th April 2011, 22:53
So, what do you want? I see that you want to fit 4:3 in 16:9, but you didn't state whether you want to remove a part of the picture at the top and bottom or if you want to just scale, so that the aspect ratio changes (i.e.: heads and other round objects will look like eggs).
If you just want to resize (heads = eggs):
--vf resize:width=1280,height=720,sar=1:1,method=spline
If you want black bars (needs patched x264 build (http://x264.fushizen.eu/files/1936/x264_1936_32.7z)):
--vf resize:width=1280,height=720,method=spline,fittobox=both/pad:width=1280,height=720
Haven't tested the last line, but it should work.
lutinor
17th April 2011, 23:01
So, what do you want? I see that you want to fit 4:3 in 16:9, but you didn't state whether you want to remove a part of the picture at the top and bottom or if you want to just scale, so that the aspect ratio changes (i.e.: heads and other round objects will look like eggs).
If you just want to resize (heads = eggs):
--vf resize:width=1280,height=720,method=spline
If you want black bars (needs patched x264 build (http://x264.fushizen.eu/files/1936/x264_1936_32.7z)):
--vf resize:width=1280,height=720,method=spline,fittobox=both/pad:width=1280,height=720
Haven't tested the last line, but it should work.
I want a fullscreen 1280x720 image without black line.
The 'pad' is not valid : x264 error 'pad' is not a valid filter :(
Edit:oups i need to dwl your link before, brb with the result
sneaker_ger
17th April 2011, 23:06
I want a fullscreen 1280x720 image without black line.
Don't bother downloading the patched build then, you don't need it.
But do you want to have "egg heads" or do you want to crop a part of the bottom and top?
lutinor
17th April 2011, 23:17
Don't bother downloading the patched build then, you don't need it.
But do you want to have "egg heads" or do you want to crop a part of the bottom and top?
egg heads plz :) but if you wanna put the both code it will be helpful for some people like me :)
sneaker_ger
17th April 2011, 23:21
egg heads:
--vf resize:width=1280,height=720,sar=1:1,method=spline
I can't give you any universally applicable crop method - it has to be recalculated for each source resoultion.
poisondeathray
17th April 2011, 23:32
Won't that will give you "melon heads", not egg heads ? :D
Everything is horizontally stretched - everyone will look "fat"
sneaker_ger
17th April 2011, 23:33
Yes, you are correct. I wasn't aware that eggheads only referred to "standing" eggs.
lutinor
17th April 2011, 23:40
It works perfectly , you guys are priceless :thanks:
kypec
18th April 2011, 08:38
It works perfectly
Looks to me like your meaning of the word perfection is distortion. Why would you want to have distorted picture is beyond my comprehension but if it makes you happy then who am I to question, right?
lutinor
18th April 2011, 09:00
Looks to me like your meaning of the word perfection is distortion. Why would you want to have distorted picture is beyond my comprehension but if it makes you happy then who am I to question, right?
No no it's a good question ^^
My own project to rip my saint seya collection, i have all dvd box but they are in 4/3 and the heroes from the original picture are lean like skeletor lol when they are enlarged they seem better to -> me ^^ maybe it's not but it's only for me, so it's doesn't matter.
About croping, it's about removing a part of the up and down to keep a valid aspect ratio in 16/9, right ?
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.