Create Seamless Video and Crop Video in one command - ffmpeg

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]

Related

FFMPEG script to merge multiple videos and a background image

I have 30 clips which are different in aspect ratio(like some videos are 10801920(they are vertical) and some are 1280720(horizontal aspect ratio videos). I want to merge all of them but also have a static background image that is of 1920x1080 aspect ratio. The video would be such that all the clips are concatenated but they have a background image(just like those tiktok compilation videos on youtube). Can someone please help me with this program?
Example using 3 videos. It can easily be expanded to 30 videos. I broke the command into multiple lines so you can see the syntax better. Make it one line before executing.
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i image.png -filter_complex
"[0:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1,fps=25,format=yuv420p[v0];
[1:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1,fps=25,format=yuv420p[v1];
[2:v]scale=1280:720:force_original_aspect_ratio=increase,crop=1280:720,setsar=1,fps=25,format=yuv420p[v2];
[0:a]aformat=sample_rates=44100:channel_layouts=stereo[a0];
[1:a]aformat=sample_rates=44100:channel_layouts=stereo[a1];
[2:a]aformat=sample_rates=44100:channel_layouts=stereo[a2];
[v0][a0][v1][a1][v2][a2]concat=n=3:v=1:a=1[vid][a];
[3][vid]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[v]"
-map "[v]" -map "[a]" -c:v libx264 -c:a aac -movflags +faststart output.mp4
References:
How to concatenate videos in ffmpeg with different attributes?
How to center overlay in ffmpeg?
Resizing videos with ffmpeg to fit specific size

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

Make video from images with ffmpeg/imagemagic

I want to convert jpg images to mp4 video without resizing image(keep original images size and well formated video)
I have tried lot's of solutions of ffmpeg and imagemagic (links given below)but both crop images after converting in video format and i want a video from images with original image size.
Solution will be appreciated with ffmpeg or imagemagick. :)
slow ffmpeg's images per second when creating video from images
image to video ffmpegf
FFMPEG An Intermediate Guide/image sequence
How can I create a video file from a set of jpg images? [duplicate]
How to create a video from images with FFmpeg?
FFmpeg
Make video from still image sequence
Combining images with ImageMagick
Imagemagick.org
ffmpeg -framerate 1/5 -i na%03d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4
on large image(1600X1200) its execute successfully but not generate a smooth video.
on small image(300x168) its show error. i also try this command on small image
ffmpeg -framerate 1/5 -i abc%03d.jpg -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p output.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"
this work for me i use this in loop
ffmpeg -loop 1 -i na002.jpg -c:a copy -c:v libx264 -strict 1 -shortest -vf "scale='min(1280,iw)':min'(720,ih)':force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" test.mp4
ffmpeg -y -i video.mp4 -vf "scale='min(1280,iw)':min'(720,ih)':force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" out1.media
ffmpeg -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp0.mp4" -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp1.mp4" -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp2.mp4" -i "C:\xampp\htdocs\social_media\public\uploads\stories\temp_media\81/temp3.mp4" -filter_complex "[0]setdar=16/9[a];[1]setdar=16/9[b];[2]setdar=16/9[c];[3]setdar=16/9[d];[a][0:a][b][1:a][c][2:a][d][3:a] concat=n=4:v=1:a=1[v][a]" -map "[outv]" -map "[outa]"

Create muted video and black screen video with FFmpeg

I'm trying to use FFmpeg to generate the following from a local mp4 file:
A copy of the original video with no audio
A copy of the original video with audio but without visuals (a black screen instead). This file also needs to be in mp4 format.
After reading through the documentation I am struggling to get the terminal commands right. To remove the audio I have tried this command without any success:
ffmpeg -i file.mp4 -map 0:0 -map 0:2 -acodec copy -vcodec copy
Could anyone guide me towards how to accomplish this?
Create black video and silent audio
Use the color and anullsrc filters. Example to make 10 second output, 1280x720, 25 frame rate, stereo audio, 44100 sample rate:
ffmpeg -f lavfi -i color=size=1280x720:rate=25:color=black -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -t 10 output.mp4
Remove audio
Only keep video:
ffmpeg -i input.mp4 -map 0:v -c copy output.mp4
Keep everything except audio:
ffmpeg -i input.mp4 -map 0 -map -0:a -c copy output.mp4
See FFmpeg Wiki: Map for more info on -map.
Make video black but keep the audio
Using the drawbox filter.
ffmpeg -i input.mp4 -vf drawbox=color=black:t=fill -c:a copy output.mp4
Generate silent audio
See How to add a new audio (not mixing) into a video using ffmpeg? and refer to the anullsrc example.
To remove the audio you can use this:
ffmpeg -i file.mp4 -c copy -an file-nosound.mp4
notice the -an option
-an (output)
Disable audio recording.
To keep audio but "replace" the video with a black screen, you could do this:
ffmpeg -i file.mp4 -i image.png -filter_complex overlay out.mp4
image.png is a black wallpaper that is placed on top of the video, but there should be better ways of full removing the frames, you could either extract the audio and later create a new video with the audio as a background

animation between images using FFmpeg

Hi I am new in FFmpeg,
I have made video from slideshow of sequential images (img001.jpg, img002.jpg, img003.jpg....). Using following commands in Ubuntu 14.04
ffmpeg -framerate 1/5 -i img%03d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p -vf scale=320:240 out.mp4
But now I want to put animation like fade-in, fade-out between each sequential images, I want to generate video,
can anybody help me how to make it, i have searched lots of things but could not get....
The best way to do this is create intermediate mpeg's for each image and then concatenate them all into a video. For example, say you have 5 images; you would run this for each one of the images to create the intermediate mpeg's with a fade in at the beginning and a fade out at the end.
ffmpeg -y -loop 1 -i image -vf "fade=t=in:st=0:d=0.5,fade=t=out:st=4.5:d=0.5" -c:v mpeg2video -t 5 -q:v 1 image-1.mpeg
where t is the duration, or time, of each image. Once you have all of these mpeg's, you use ffmpeg's concat command to combine them all into an mp4.
ffmpeg -y -i image-1.mpeg -i image-2.mpeg -i image-3.mpeg -i image-4.mpeg -i image-5.mpeg -filter_complex '[0:v][1:v][2:v][3:v][4:v] concat=n=5:v=1 [v]' -map '[v]' -c:v libx264 -s 1280x720 -aspect 16:9 -q:v 1 -pix_fmt yuv420p output.mp4
This gives you the desired video and is the simplest and highest quality solution with ffmpeg. Let me know if you have any questions about how the above command works.

Resources