I'm scaling a video and applying a watermark like so:
ffmpeg -ss 0:0:0.000 -i video.mp4 -y -an -t 0:0:10.000
-vf \"[in]scale=400:316[middle]\" -b:v 2000k -r 20
-vf 'movie=watermark.png,pad=400:316:0:0:0x00000000 [watermark];[middle] [watermark]overlay=0:0[out]'
out.flv
However, the applied watermark seems to be scaled to the original video size rather than the smaller scaled video size.
This command line worked on ffmpeg version 0.8.6.git and now behaves differently after an upgrade to version N-52381-g2288c77.
How do I get it to work again?
Update 2013-04-26:
I now have tried to use the overlay filter's X and Y parameters instead of padding without success.
Answered by ubitux on the FFmpeg IRC:
Use scale and overlay in a single -filter_complex chain, like so:
ffmpeg -y -ss 0 -t 0:0:30.0 -i 'video.mp4' -i '/watermark.png'
-filter_complex "[0:0] scale=400:225 [wm]; [wm][1:0] overlay=305:0 [out]"
-map "[out]" -b:v 896k -r 20 -an
'out.flv'
Also load the watermark via -i rather than the movie filter.
Related
I want to take the input, blend N frames, decimate the other frames and use those for the output with the fps of my choice.
I used this line:
ffmpeg -y -i input.mp4 -vf tmix=frames=15:weights="1",select='not(mod(n\,15))' -vsync vfr frames/output-%05d.tif
That generated images, which I combined into the video. So far, so good.
But I'd like to skip the image output and go straight to video, so I tried this:
ffmpeg -y -i input.mp4 -vf tmix=frames=15:weights="1",select='not(mod(n\,15))' -vsync vfr -r 30 -c:v prores_ks -profile:v 3 -vendor apl0 -bits_per_mb 8000 -pix_fmt yuv422p10le output.mov
That produces 1.62 fps video, instead of 30 fps.
I'm at a loss on how to get it to output 30fps without the intermediate step of outputting images.
Thanks
I think the simplest way to achieve this is to feed the input at the 15-times the desired rate and drop all intermediate frames with -r 30:
ffmpeg -y -r 450 -i input.mp4 \
-vf tmix=frames=15:weights="1" \
-r 30 sandbox/out.mp4
However, a tmix solution is somewhat inefficient for your use case because it's mixing for all frames, including those dropped. If you don't mind a longer expression, you can try:
ffmpeg -i in.mp4 \
-vf
setpts=\'floor(N/15)/(30*TB)\',select=\'mod(n,15)+1\':n=15[v0][v1][v2][v3][v4][v5][v6][v7][v8][v9][v10][v11][v12][v13][v14];\
[v0][v1][v2][v3][v4][v5][v6][v7][v8][v9][v10][v11][v12][v13][v14]mix=inputs=15:weights=1 \
-r 30 sandbox/out.mp4
[edit] setpts expression should be floor(N/15)/(30*TB) not mod(n,15)+1 for 15 successive frames to have the same pts.
I'm trying to display a transparent keyboard like this one (he is using OBS studio):
https://www.youtube.com/watch?v=6RCXyh2aICY
So I'm setting all "NohBoard v1.2.2" colors to green (0x00FF00), except the letters, then:
ffmpeg -y -f gdigrab -framerate 30 -draw_mouse 0 -i title="NohBoard v1.2.2" keyboard.mp4
ffmpeg -y -i keyboard.mp4 -c: png -vf "chromakey=0x00FF00:similarity=.200" keyboard1.mp4
ffmpeg -y -i gameplay.avi -i keyboard1.mp4 -filter_complex "[1:v] scale=560x180 [kb]; [0:v][kb] overlay=x=W-w-520:y=H-h-0 [done]" -shortest -map [done] test.mkv
Everything works great so far, but can I use 1 command for this ?
Simply use the gdi cap as the first input and run colorkey* before scaling.
ffmpeg -y -i gameplay.avi -f gdigrab -framerate 30 -draw_mouse 0 -i title="NohBoard v1.2.2" -filter_complex "[1:v]colorkey=0x00FF00:similarity=.200,scale=560x180 [kb]; [0:v][kb] overlay=x=W-w-520:y=H-h-0 [done]" -shortest -map [done] test.mkv
gdigrab sends RGB frames, so colorkey will be quicker than chromakey which will require conversion to YUV pixels before keying.
I want to add one or multiple resized images anywhere over the video using ffmpeg. It works well for some position. However, it does not add images to the exact position I want. I have tested it on console and its embedded in php with dynamic variables.
ffmpeg -y -i vid_1561454052.mp4 -i Penguins.jpg -filter_complex
"[0:v][1:v] overlay=221:127:enable='between(t,0,5)'" -pix_fmt yuv420p
-aspect 16:9 -c:a copy vid_1562740969.mp4
Please Help me out...
use loop option
ffmpeg -y -i vid_1561454052.mp4 -loop 1 -i Penguins.jpg \
-filter_complex "[0:v][1:v] overlay=221:127:enable='between(t,0,5)'" \
-pix_fmt yuv420p -aspect 16:9 -c:a copy vid_1562740969.mp4
I am looking to overlay a video on top of another video and then also add a fade in and fade out PNG.
I have the current command which works perfectly in merging two video files one on top of the other.
ffmpeg -y -i output.mp4 -i transparent.mp4 -filter_complex "[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=.7[u];[b][u]overlay=eof_action=pass[v]" -map [v] awsome.mp4
I need to now add a PNG on it as well that fades in at 1s and fades out at 9.5s.
Appreciate any and all advice.
Use
ffmpeg -y -i output.mp4 -i transparent.mp4 -loop 1 -t 10 -i image.png -filter_complex "[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=.7[u];[b][u]overlay=eof_action=pass[v];[2]fade=in:st=0:d=1:alpha=1,fade=out:st=8.5:d=1:alpha=1[i];[v][i]overlay[v]" -map [v] awsome.mp4
If the PNG needs to be scaled to video size, use scale2ref for the image as well.
ffmpeg -y -i output.mp4 -i transparent.mp4 -loop 1 -t 10 -i image.png -filter_complex "[1:v][0:v]scale2ref[ua][b];[ua]setsar=1,format=yuva444p,colorchannelmixer=aa=.7[u];[b][u]overlay=eof_action=pass[v];[2][v]scale2ref[i][v];[i]fade=in:st=0:d=1:alpha=1,fade=out:st=8.5:d=1:alpha=1[i];[v][i]overlay[v]" -map [v] awsome.mp4
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.