Thanks Brian,
This is what I did in the first instance. And this is the approach that I
would follow if I needed to learn how to use a particular filter.

I will start from what I would like to achieve (globally speaking), so you
better understand my use case:

I really like a piece of software (now discontinued) named Photodex Proshow
(now Photopia I think). If you don't know it, you can see what it can do
here: https://www.youtube.com/watch?v=hF2s86G-KtM
Maybe shotcut/kdenlive, can do the same, but my feeling is that you have to
tell them explicitly what you want to do with your videos: compose, affine
transformation, fade in-out, ... On the other hand, in Photodex most of the
transitions are automatic with a very professional look. In the example,
you can see that handles properly videos shot in a mobile vertically that
are later shown in 16:9 final format.

In this particular case, I was trying to achieve the following transition:
https://i.imgur.com/SdPCx2i.png (as a proof of concept) where the two
videos are moving slowly (one to the right and the other to the left). As
you can appreciate, both videos have a reflection with a gradient, and one
is projecting a shadow over the other. I already managed to achieve that
effect: https://i.imgur.com/HbTOoHl.png with this code:
https://github.com/mantielero/mlt.nim/blob/1e082e07281c2e5601fee837bc14e8f511ba6861/examples/ex30_filter1.nim#L9

But my objective is not to achieve a particular effect for a one off video
(I could do that with kdenlive, shotcut or melt). I want to create
functions that I can easily compose. So I have a function that creates the
mirrored effect, other that stacks the videos vertically, another that
creates the shadow, another that moves the videos around in the final
profile, ... All this should be independent from the final profile that I
will use for the video generation.

So this is the rationale behind my weird use cases: I want to "compose"
tractors (with their own filters/transitions), so that I can create
"meta-transitions" or "meta-filters" as independent as I can from the
producer (size/aspect ratio) and the consumer final profile.

I also like the idea of using code in order to create videos. Nim supports
metaprogramming so you can create domain specific language that could be
even easier than XML to create the videos. You can see here (
https://github.com/juancarlospaco/nim-html-dsl) nim metaprogramming in
action in order to generate HTML code.

I hope this clarifies better the reason for the questions I am raising here.

Kind regards and thank you all for your support.



El vie, 7 ene 2022 a las 2:50, Brian Matherly (<brian.mathe...@yahoo.com>)
escribió:

> For this scenario (and any like it), I strongly recommend to not start
> with code. Even for my own coding projects I do not start with code. Start
> with Shotcut or Kdenlive and use the tool to visually achieve what you
> want. After you get the result that you are looking for in the graphical
> tool, examine the resulting MLT file to learn about how various properties
> interact.
>
> ~Brian
>
>
> On Wednesday, January 5, 2022, 04:44:33 PM CST, José María García Pérez <
> josemaria.alk...@gmail.com> wrote:
>
>
> 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
>
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to