I managed to do it thanks to wikipedia where it clearly explains the difference between SAR, DAR and PAR. https://en.wikipedia.org/wiki/Pixel_aspect_ratio
For the record, in case this can help others: SAR= 720/360 = 2 (calculated with the resolution) DAR=16/9 (how we want the image to be displayed) PAR=DAR/SAR = 16/18 (pixel aspect ratio is the "sample aspect") I had to adjust the sample aspect. profile.setWidth(width1) profile.setHeight(height1 + height2) profile.setSampleAspect(16,18) profile.setDisplayAspect(16,18) The result: https://i.imgur.com/upS5pjC.png El mié, 5 ene 2022 a las 22:13, José María García Pérez (< josemaria.alk...@gmail.com>) escribió: > Thanks Péter. > > I think my issue is more related with the "aspect ratio" and/or "display > ratio" of the profile, producer (the video itself) and the consumer. > > With this: > profile.setWidth(width1) > profile.setHeight(height1 + height2) > profile.setWidth(profile.width) > profile.setHeight(profile.height) > profile.setSampleAspect(1,1) > profile.setDisplayAspect(16,18) > > I am getting: https://i.imgur.com/UidhlNX.png > > I am using now a smaller video (720x360) with display aspect ratio 16:9 > and 25fps. > > > > El mié, 5 ene 2022 a las 21:02, Péter Hudoba (<hudi1...@gmail.com>) > escribió: > >> Hi! >> >> I am a noob, but I think the problem: if you use "hdv_720_50p" profile in >> your main function and create a consumer with that profile, you won't have >> a big enough consumer. >> https://www.mltframework.org/docs/profiles/ >> >> Best regards, >> Hudi >> >> José María García Pérez <josemaria.alk...@gmail.com> ezt írta (időpont: >> 2022. jan. 5., Sze, 20:54): >> >>> Honestly I don't understand that comment. >>> >>> The documentation is clearly insufficient. The framework design just >>> gives you a glimpse of the ideas; it doesn't even mention the word profile >>> https://mltframework.org/docs/framework/. The demos are more oriented >>> to the usage of melt. melt.c is not the best learning source either. >>> >>> So honestly I am bit confused, and this is the reason why I am asking >>> for help. I am not asking for the code solution, but for some direction >>> about the approach to follow. >>> >>> >>> El mié, 5 ene 2022 a las 20:43, Dan Dennedy (<d...@dennedy.org>) >>> escribió: >>> >>>> I am not going to help further. You need to learn more outside of the >>>> code. >>>> >>>> On Wed, Jan 5, 2022 at 11:06 AM José María García Pérez < >>>> josemaria.alk...@gmail.com> wrote: >>>> >>>>> Could you explain a bit further? >>>>> >>>>> I mean: >>>>> 1. Create profile: p >>>>> 2. Create producer: video1 (with profile p) >>>>> 3. Create producer: video2 (with profile p) >>>>> 4. Read the frame sizes >>>>> 5. Create a new profile with the size of both videos stacked vertically >>>>> 6. Create the consumer with that new profile >>>>> >>>>> So far I am getting funny sizes. >>>>> >>>>> I declared the following function: >>>>> 1. Creates a new profile >>>>> 2. Resize the profile with the size of both videos >>>>> 3. Creates a new tractor and adds the videos as two separated tracks. >>>>> 4. I use an affine filter and applies "oy=height1" to the second track. >>>>> 5. I apply the transition "addition" in order to make both videos >>>>> visible. >>>>> proc stackVertically( v1,v2:Producer ):tuple[tr:Tractor; p:Profile] = >>>>> # Get an appropriate profile >>>>> var profile = newProfile() >>>>> >>>>> var frame1 = v1.getFrame(0) >>>>> var (width1,height1) = frame1.getImage() >>>>> var frame2 = v2.getFrame(0) >>>>> var (width2,height2) = frame2.getImage() >>>>> profile.setWidth(width1 + width2) >>>>> profile.setHeight(height1 + height2) >>>>> >>>>> # Create the tractor >>>>> var tr = newTractor() >>>>> >>>>> tr.connect( v1, 0 ) # We use the playlist as track0 >>>>> tr.connect( v2, 1 ) >>>>> var aff = newFactoryFilter(profile, "affine") >>>>> aff["transition.oy"] = height1 >>>>> tr.plant(aff, 1) >>>>> >>>>> var compose = profile.newFactoryTransition("frei0r.addition") >>>>> tr.plant(compose, 0, 1) >>>>> return (tr, profile) >>>>> >>>>> >>>>> In order to use this function I do the following: >>>>> 1. Read two videos (in this case I use the same video) >>>>> 2. stack them vertically: the result is the tractor as a producer and >>>>> the new profile >>>>> 3. I create an SDL2 base on the new profile >>>>> 4. Connect the tractor to SDL >>>>> proc main = >>>>> var f = initFactory() >>>>> var p = newProfile("hdv_720_50p") >>>>> var v1 = p.newMedia("./resources/big_buck_bunny_720p_2mb.mp4") >>>>> var v2 = p.newMedia("./resources/big_buck_bunny_720p_2mb.mp4") >>>>> >>>>> var (newProducer, profile) = stackVertically( v1,v2 ) >>>>> >>>>> # Consumer >>>>> var sdl = profile.newFactoryConsumer( "sdl2" ) >>>>> sdl["terminate_on_pause"] = 1 >>>>> >>>>> # From tractor to SDL2 >>>>> #v1.attach(aff1) >>>>> newProducer > sdl >>>>> >>>>> # Start the consumer >>>>> sdl.run >>>>> >>>>> >>>>> The result is: https://i.imgur.com/eESDdJg.jpg >>>>> >>>>> >>>>> El mié, 5 ene 2022 a las 18:28, Dan Dennedy (<d...@dennedy.org>) >>>>> escribió: >>>>> >>>>>> >>>>>> On Wed, Jan 5, 2022 at 9:22 AM José María García Pérez < >>>>>> josemaria.alk...@gmail.com> wrote: >>>>>> >>>>>>> What is the proper way of stacking videos vertically? >>>>>>> >>>>>>> For example: >>>>>>> video1 >>>>>>> --------- >>>>>>> video2 >>>>>>> >>>>>>> so that I can later scale it and move it around in the profile. >>>>>>> >>>>>>> Right now I am using affine (scaling down and then positioning it >>>>>>> vertically). But the result is something like: >>>>>>> video1 | black >>>>>>> ------------------ >>>>>>> video2 | black >>>>>>> >>>>>>> Basically I am looking how to get a new video which is: (width) x >>>>>>> (2*height) >>>>>>> >>>>>>> You need to make a custom profile. >>>>>> >>>>> _______________________________________________ >>> Mlt-devel mailing list >>> Mlt-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/mlt-devel >>> >>
_______________________________________________ Mlt-devel mailing list Mlt-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mlt-devel