FFmpeg noob: Crop and stack video - ffmpeg

I am looking for a video solution for a 360 video that gives clips in panoramic strips.
I want to crop / split a video and stack it.
After a long morning, I managed to install Homebrew and FFmpeg successfully (although I don't know how I did it). I also managed to crop the video and stack it, but in 3 steps.
ffmpeg -i /Users/xx/desktop/Test360.mp4 -filter:v crop=1920:640:0:0 Out.mp4
ffmpeg -i /Users/xx/desktop/Test360.mp4 -filter:v crop=1920:640:1920:0 Out2.mp4
ffmpeg -i /Users/xx/desktop/Out.mp4 -i /Users/xx/desktop/Out2.mp4 -filter_complex vstack=inputs=2 Stacked.mp4
Can I collapse this into 1 command?

Use
ffmpeg -i Test360.mp4 -filter_complex \
"split=2[top][bottom];\
[top]crop=1920:640:0:0[top];\
[bottom]crop=1920:640:1920:0[bottom];\
[top][bottom]vstack=2" stacked.mp4

Related

ffmpeg: Is there a way to create video from images and overlay on image at same time?

I am trying to create a video from still images using ffmpeg. The command I use to do this is
ffmpeg -y -r 3 -i input_images%03d.png -c:v libx264 -vf fps=24 -pix_fmt yuv420p output.mp4
However, I would like to overlay this video on still image, without creating a video of the still image first. So, for example, if I have the following images
[still, frame1, frame2, frame3]
I'd like a command to create a video of frame1, frame2, and frame3 overlayed on still.
all with one command. Is there a way to do this?
I've looked at several answers to related problems (e.g., Add image overlay on video FFmpeg) but they don't answer my question, exactly.
Use
ffmpeg -framerate 24 -i still.png -framerate 3 -i input_images%03d.png -c:v libx264 -filter_complex "overlay=x='(W-w)/2':y='(H-h)/2'" -pix_fmt yuv420p -y output.mp4

Create Seamless Video and Crop Video in one command

I have a ffmpeg command that convert a video for seamless loop. But now i want to crop Video as well in same command.
is there any solution to do crop video 720x720 in same command
--Seamless Commmand--
ffmpeg -i video.mp4 -filter_complex [0:v]split[body][pre];[pre]trim=duration=1,format=yuva420p,fade=d=1:alpha=1,setpts=PTS+(28/TB)[jt];[body]trim=1,setpts=PTS-STARTPTS[main];[main][jt]overlay -c:v libx264 -strict experimental out.mp4
Change [0:v]split[body][pre] to [0:v]crop=720:720,split[body][pre]

Tile filter for libav/avconv

Is there some way to use libav/avconv to duplicate the effect of the tile filter in FFMPEG?
I'm trying to create a strip of images from left to right with one image for every ten seconds of video input.
My plan is to first generate the images and then create the image strip. Preferably I want to use libav over ffmpeg. So far I have created this:
avconv -i video.mp4 -vf scale=320:-1,fps=1/10 -q:v 6 img%03d.jpg
which creates the images. But then I only know how create the image with ffmpeg using:
ffmpeg -i img%03d.jpg -filter_complex tile=6x1 output.jpg
So if anyone has any tips on how to rewrite the just the second or both commands to use avconv I welcome any advise :)
As libav/avconv did not have any filters supporting my requirements in any easy way switching to a static build of ffmpeg was the simplest solution.
The commands then became:
ffmpeg -i video.mp4 -vf scale=320:-1,fps=1/10 -q:v 6 img%03d.jpg
and
ffmpeg -i img%03d.jpg -filter_complex tile=6x1 output.jpg

Ffmpeg video overlay

I am trying to create a video output from multiple video cameras.
Following the example given here Presenting more than 2 videos using FFmpeg
and other similar examples.
but Im getting the error
Output pad "default" for the filter "src" of type "buffer" not connected to any destination
when i run
ffmpeg -i /dev/video1 -i /dev/video0 -filter_complex "[0:0]pad=iw*2:ih[a];[a][1:0]overlay=w[b];[b][2:0]overlay=w:h" -shortest output.mp4
Im not really sure what this means or how to fix it.
Any help would be greatly appreciated!
Thanks.
When using the "padding" option, you have to specify which is the size of the output image and where you want to put the input image
[0:0]pad=iw*2:ih:0:0
tested under windows 7 with file of same size
ffmpeg -i out.avi -i out.avi -filter_complex "[0:0]pad=iw*2:ih:0:0[a];[a][1:0]overlay=w" -shortest output.mp4
and with WebCam Cap (vfwcap) and a still picture (as i have only o=1 WebCam). BTW you can see how to scale one the source to fit in the target (just in case your source have different resolution)
ffmpeg -y -f vfwcap -r 10 -i 0 -loop 1 -i photo.jpg -filter_complex "[0:0]pad=iw*2:ih:0:0[a];[1:0]scale=640:480[b];[a][b]overlay=w" -shortest output.mp4
under Linux:
ffmpeg -i /dev/video1 -i /dev/video0 -filter_complex "[0:0]pad=iw*2:ih:0:0[[a];a][1:0]overlay=w" -shortest output.mp4
if it doesn't work test a simple record of video 1 and after of video 0 and check their properties (type, resolution, fps).
ffmpeg -i /dev/video1 -shortest output1.mp4
ffmpeg -I output1.mp4
If you still have issue, update your question with ffmpeg console output (as text) for video and video 0 capture and also of the call with the overlay

Which filter should be used when i want to add watermark to a video?

Hi everyone,
I want to add a watermark to a video use a picture.
here is the problem
and this is my command:
c:\ffmpeg.exe -y -i c:\ffmpeg\input\walk.mp4 -acodec copy -b 300k -vf "movie=w1.jpg [watermark];[in][watermark] overlay=5:5 [out]" c:\ffmpeg\output\walk.mp4
What am I doing wrong?
You can use the overlay filter, but first you need to use a recent build because the version you are using is considered to be absolutely ancient due to how active the FFmpeg project is. You can get builds for Windows at Zeranoe FFmpeg builds.
Now that you are not using a graybeard ffmpeg here is the most basic example:
ffmpeg -i background.avi -i watermark.jpg -filter_complex overlay output.mp4
The overlay filter documentation will show how to position the watermark. This example will place the watermark 10 pixels from the bottom right corner of the main video and copy your audio as in your example:
ffmpeg -i background.avi -i watermark.jpg -filter_complex overlay=main_w-overlay_w-10:main_h-overlay_h-10 -codec:a copy output.mp4

Resources