Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

05 June, 2024

FFmpeg stack two videos and merge audios




FFmpeg -i rtmp://192.168.137.1:1935/live/xyz -i rtmp://192.168.137.1:1935/live/abc -filter_complex "[0:v][1:v]vstack=inputs=2[v];[0:a][1:a]amerge=inputs=2[a]" -map "[v]" -map "[a]" -an -f flv rtmp://192.168.137.1:1935/live/qwe


The above command stacks video from two streams and merges audios into one.


I tried following commands before I came up with above. 


ffmpeg -i rtmp://192.168.137.1:1935/live/xyz -i rtmp://192.168.137.1:1935/live/abc -filter_complex "[0:a][1:a]amix[a]" -map 0:v -map "[a]" -c:v copy -f flv rtmp://192.168.137.1:1935/live/qwe


ffmpeg -i rtmp://192.168.137.1:1935/live/xyz -i rtmp://192.168.137.1:1935/live/abc -filter_complex "[0v][1v]xstack=inputs=2:layout=0_0|1920_0[stacked]" -map "[stacked]" -preset ultrafast -vcodec libx264 -tune zerolatency -an -f flv rtmp://192.168.137.1:1935/live/qwe


ffmpeg -i rtmp://192.168.137.1:1935/live/xyz -i rtmp://192.168.137.1:1935/live/abc -filter_complex "[0v][1v]xstack=inputs=2:layout=0_0|1920_0[stacked];[0:a][1:a]amix[a]" -map "[stacked]" -map 0:v -map "[a]" -preset ultrafast -vcodec libx264 -tune zerolatency -an -f flv rtmp://192.168.137.1:1935/live/qwe


How to test?


Use Node Media ServerNode Media Server to start a local server that takes in rtmp streams and publishes.

Create two rtmp streams using OBS StudioOBS Studio stream them to Node Media Server and use the rtmp streams url in the FFmpeg command above to create a third rtmp stream which you can use anywhere you want.



16 December, 2021

How to drag and drop item in Unity3D

 




For dragging and dropping to work we will need to first grab the Game Object and ensure while the Game Object remains grabbed it's position reciprocates the mouse position. This will work fine for not only PC bug mobile devices as well.


First define GameObject which we will be dragging.


public GameObject selectedPiece;



Now inside Update method we will give reference to touched/clicked object and while there is a reference available to an game object(selectedPiece;) we will move that object to mouse position.

When the reference is remove, object won't move therefore dropped.


void Update(){


RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

if (Input.GetMouseButtonDown(0)){


if(hit.transform != null)

            {

                if (hit.transform.CompareTag("PIECE"))

                {

                    selectedPiece = hit.transform.gameObject;

                }

            }

}


if (Input.GetMouseButtonUp(0))

        {

            selectedPiece = null;

        }


        if (selectedPiece != null)

        {

            Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);


            selectedPiece.transform.position = new Vector3(mousePosition.x, mousePosition.y, 0);


        }


}








Featured Post

Content Writing VS Content Marketing: How are Both Different From Each Other?

Regardless of how long the businesses have been introduced to digital marketing, it is often seen that they confuse the terms of marketing. ...