I want to get a frame from video to combine with other image
using two ffmpeg commands as:
command 1:
ffmpeg -ss 3 -i video.mp4 -vf \"select=gt(scene\,0.4)\"
-frames:v 5 -vsync vfr -vf fps=fps=1/100
-vf scale=150:150 output.jpeg
command 2:
ffmpeg -i output.jpeg -i other.png -filter_complex "[0:v][1:v]
overlay=(W-w)/2:(H-h)/2:enable='between(t,0,20)'"
-pix_fmt yuv420p -c:a copy output2.jpg
how to combine two commands in one, or
how to get frame from video and combine other image in one?
You can combine the two commands using the and && after the first command which allows you to execute the second command based on whether the first command completed successfully:
ffmpeg -ss 3 -i video.mp4 -vf "select=eq(n\,4)"
-frames:v 5 -vsync vfr -vf fps=fps=1/100
-vf scale=150:150 output.jpeg
&&
ffmpeg -i output.jpeg -i other.png -filter_complex "[0:v][1:v]
overlay=(W-w)/2:(H-h)/2:enable='between(t,0,20)'"
-pix_fmt yuv420p -c:a copy output2.jpg
Now if you want to combine multiple images onto one, Take a look at this solution
Related
I edit the video with the command
ffmpeg -i video.mp4 -y -vf eq=saturation={rand_saturation},fade=in:st=0:d={rand_fade},hflip,noise=alls={rand_noise}:allf=t -c:a copy output.mp4
then the resulting video
ffmpeg -i output.mp4 -i logo.png -filter_complex "[0:v][1:v]overlay=x='if(lt(mod(t,10),5),1,W-w-10)':y='if(lt(mod(t,10),5),5,H-h-200)'" -c:a copy output_1.mp4
I tried to combine all this together so that I didn't have to spend time processing the video twice, but I couldn't do it because you can't use the -vf and -filter_complex commands together. How can this problem be solved?
First apply the video specific filters before using the result as overlay input.
ffmpeg -i video.mp4 -i logo.png -filter_complex "[0:v]eq=saturation={rand_saturation},fade=in:st=0:d={rand_fade},hflip,noise=alls={rand_noise}:allf=t[vid];[vid][1:v]overlay=x='if(lt(mod(t,10),5),1,W-w-10)':y='if(lt(mod(t,10),5),5,H-h-200)'" -c:a copy output_1.mp4
Justing wondering how to combine below commands into one, I have searched how to combine simple filters with comma and complex filter with colon, but I'm not sure how to do this.
Basically I want the output of the first command to be the input of the second.
Command 1: concatenate multiple clips into one with different xfade transitions.
Command 2: add a fade in for a video
ffmpeg -i input0.mp4 -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -filter_complex "[0:v][1:v]xfade=transition=fade:duration=0.500:offset=27.486[v01];[v01][2:v]xfade=transition=fadeblack:duration=1.000:offset=31.531[v02];[v02][3:v]xfade=transition=fadeblack:duration=1.000:offset=42.972[v03];[v03][4:v]xfade=transition=fade:duration=0.500:offset=94.149,format=yuv420p[video];[0:a][1:a]acrossfade=d=0.500:c1=tri:c2=tri[a01];[a01][2:a]acrossfade=d=1.000:c1=tri:c2=tri[a02];[a02][3:a]acrossfade=d=1.000:c1=tri:c2=tri[a03];[a03][4:a]acrossfade=d=0.500:c1=tri:c2=tri[audio]" -map [video] -map [audio] -movflags +faststart output.mp4
ffmpeg -i input.mp4 -vf "fade=t=in:st=0.000:d=1.000:color=black" -c:a copy output.mp4
Combined command:
ffmpeg -i input0.mp4 -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -filter_complex "[0:v][1:v]xfade=transition=fade:duration=0.500:offset=27.486[v01];[v01][2:v]xfade=transition=fadeblack:duration=1.000:offset=31.531[v02];[v02][3:v]xfade=transition=fadeblack:duration=1.000:offset=42.972[v03];[v03][4:v]xfade=transition=fade:duration=0.500:offset=94.149,format=yuv420p,fade=t=in:st=0.000:d=1.000:color=black[video];[0:a][1:a]acrossfade=d=0.500:c1=tri:c2=tri[a01];[a01][2:a]acrossfade=d=1.000:c1=tri:c2=tri[a02];[a02][3:a]acrossfade=d=1.000:c1=tri:c2=tri[a03];[a03][4:a]acrossfade=d=0.500:c1=tri:c2=tri[audio]" -map [video] -map [audio] -movflags +faststart output.mp4
I have 300 images and i wants to generate video from these images.
i am new to FFMPEG so now i am using two commands to generate video from images.
Command to generate video from images which also add Logo on video
ffmpeg -framerate 24 -i img_%d.jpg -i logo.png -filter_complex \
"[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
-vcodec libx264 -crf 25 -pix_fmt yuv420p test_video.mp4
After using above command i am getting the video to add audio to this video i am using below command
ffmpeg -i test_video.mp4 -i inputfile.mp3 -c:v libx264 -c:a libvorbis -shortest final_video.mp4
which generates video and i am getting below message
MPEG-4 AAC decoder is required to play the file
Help to combine this both command. if possible can we add sound without any decoder required
Log for command 1 https://drive.google.com/file/d/1zS7gvrPy69VK_MkyE4127FpX2kEziJHq/view?usp=sharing
and Log command 2 https://drive.google.com/file/d/1rHqVGzj7f003aWP6eISiyUjsES8_EWuw/view?usp=sharing
Try next command:
ffmpeg -framerate 24 -i img_%d.jpg -i logo.png -i inputfile.mp3 -filter_complex \
"[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
-vcodec libx264 -crf 25 -map 2:a -c:a copy -pix_fmt yuv420p -shortest test_video.mp4
-map 2:a is needed to skip image in case if there is cover image in track.
With -c:a copy track will not be re-encoded, so you will have mp3 inside of your video file.
I need your help. I stream to Twitch with this Command:
ffmpeg -i input.mp4 -i image.jpg -filter_complex 'overlay=x=10:x=10' -s \
1920x1200 -framerate 15 -c:v libx264 -preset ultrafast -pix_fmt yuv420p \
-threads 0 -f flv 'rtmp://'
How is it possible to change the image.jpg picture to another picture on a variable time? I will don't restart the FFMPEG Command.
Add the -f image2 -loop 1 input options for the image input, then atomically replace image.jpg when desired such as by using mv.
Basic example:
ffmpeg -i input.mp4 -f image2 -loop 1 -i image.jpg -filter_complex overlay output.mp4
Streaming example:
ffmpeg -re -i input.mp4 -f image2 -loop 1 -i image.jpg -filter_complex "overlay,format=yuv420p" -c:v libx264 -preset fast -g 50 -b:v 4000k -maxrate 4000k -bufsize 8000k -f flv 'rtmp://'
To answer the "variable time" part of your question use a cron job to run scripts that update the overlay image at a specified time i.e. every 5 mins. For example you can create a folder of various overlays and select one randomly every 5 minutes and copy it to image.jpg. FFMPEG will then render the new image to your stream.
It is important to use -f image 2 -loop 1 -thread_queue_size 512 -i image.jpg especially when rendering other image formats.
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.