I'm kinda new to ffmpeg, but I found it quite useful to turn image sequences into sprite sheet, but I need to skip frames. I've tried this but it skip the 1st filter. How could I make both -vf work?
ffmpeg -start_number 0150 -i %04d.png -vf framestep=10 -vf "tile=12x30" -an -vsync 0 spritesheet.png
If you use the same option two times then only its last occurence counts. You need to use one -filter_complex instead of two -vf filters, for example:
-filter_complex "[0:v]framestep=10[a];[a]tile=12x30[out]" -map [out]:v
Related
I am using FFmpeg to speed up a video and add a watermark. The watermark is a percentage of the video size.
To speed up I am using
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4
And to add a watermark, I am using
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5" -c:a copy output.mp4
Both work well on their own. I am trying to combine them into a single command. There are many questions/answers regarding similar problems that I could find, however they seem to either be outdated or I just can't get them to work.
To combine filters I have read to just add a comma, but that doesn't seem to work:
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5,[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4
The command will run without errors, and add the watermark, but the audio/video filter is not being applied.
How can I do it?
Combined command:
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5,setpts=0.5*PTS;[0:a]atempo=2.0" output.mp4
Connect linear filters with a comma. Connect filterchains with a semicolon. See FFmpeg Filtering Intro.
I am cropping and adding subtitles to a video using the following:
ffmpeg -i inputfile.mov -lavfi "crop=720:720:280:360,subtitles=subs.srt:force_style='OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,MarginV=20,Fontsize=18'" -crf 1 -c:a copy output.mov
I have another video called credits.mp4 which has the same dimensions as the output.mov (after cropping). Can I do this during the above process, or would I have to use something like concat afterwards?
Using bash in Terminal on a Mac
Use the concat filter:
ffmpeg -i inputfile.mov -i credits.mp4 -lavfi "[0]crop=720:720:280:360,subtitles=subs.srt:force_style='OutlineColour=&H100000000,BorderStyle=3,Outline=1,Shadow=0,MarginV=20,Fontsize=18',setpts=PTS-STARTPTS[v0];[1]setpts=PTS-STARTPTS[v1];[v0][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" output.mp4
Because no info was provided about your inputs I made some assumptions:
The attributes of both input files are the same as they are fed to concat. If not then perform additional filtering to conform them to a common set of parameters.
credits.mp4 has audio. If not, then add an audio file or use the anullsrc filter as an input to create silent/dummy/filler audio for proper concatenation.
I want to use the scale filter and also add a delay in the first X seconds of a movie.
I tried to use this command:
ffmpeg -i new1.mp4 -filter_complex
"scale=720:-1[scale];tpad=start_duration=2;adelay=2s|2s" -map "[scale]"
scaled720.mp4
What I want is a video with a specific size (720:-1 - aspect ratio) that will also have a delay in the first 2 seconds.
ffmpeg -i new1.mp4 -filter_complex "[0:v]scale=720:-1,tpad=start_duration=2[v];[0:a]adelay=2s:all=true[a]" -map "[v]" -map "[a]" scaled720.mp4
The filter inputs and outputs should be properly labeled to avoid ambiguity. See filtering introduction and filtergraph syntax for more info.
I just started learning FFmpeg. I have code (like below), but it's doing nothing.
fmpeg -i videoplayback.mp4 -filter_complex "[1:v]trim=start=0:end=1,setpts=PTS-STARTPTS,scale=480x360,setsar=sar=16/9[intro1];
[1:v]trim=start=1:end=123.39,setpts=PTS-STARTPTS,scale=480x360,setsar=sar=16/9[main1];
[1:v]trim=start=123.39:end=124.39,setpts=PTS-STARTPTS,scale=480x360,setsar=sar=16/9[end1];
[intro1]format=pix_fmts=yuva420p, fade=t=in:st=0:d=1:alpha=1[intro1];
[end1]format=pix_fmts=yuva420p, fade=t=in:st=0:d=1:alpha=1[end1];
[intro1][main1][end1][output];
[a:1][audio]; -vcodec libx264 -map "[output]" -map"[audio]" "output.mp4"
fmpeg should be ffmpeg.
You only have one input so [1:v] should be [0:v] (it starts counting from 0).
No need for alpha for fading because you are not overlapping or blending frames.
Ending fade needs to be a fade out (not fade in).
You can't re-use filter output labels within the filtergraph.
Some of your filterchains can be combined.
Some of your labels are not associated with a filter (it appears you forgot to use the concat filter).
You can add scale and setsar at the end instead of using them for each segment.
Replace the last ; with ".
You didn't map the audio properly.
Stream copy (re-mux) the audio.
Example:
ffmpeg -i videoplayback.mp4 -filter_complex "[0:v]trim=end=1,setpts=PTS-STARTPTS,fade=t=in:d=1[intro];[0:v]trim=start=1:end=123.39,setpts=PTS-STARTPTS[main];[0:v]trim=start=123.39,setpts=PTS-STARTPTS,fade=t=out:d=1[end];[intro][main][end]concat=n=3:v=1:a=0,scale=480x360,setsar=16/9[v]" -map "[v]" -map 0:a -c:a copy output.mp4
I have the need to apply fadein and overlay filters to a video. Is it possible to apply 2 filters at once?
I got:
ffmpeg -i input.mpg -vf "movie=watermark.png [logo]; [in][logo] overlay=W-w-10:H-h-10 [out]" output.mpg
I'm trying to add fade=in:0:20, but if I add a new -vf parameter, it will overwrite the preceding one, and if I add:
-vf "fade=in:0:20; movie=......"
it won't work.
Is this possible or do I have to run FFmpeg twice?
Okay, someone helped me somewhere.
I had to separate filters with commas:
ffmpeg -i input.mpg -vf "movie=watermark.png [logo]; [in][logo] overlay=W-w-10:H-h-10, fade=in:0:20 [out]" output.mpg
This will apply fadein to both the watermark and the video.
Yes it is possible .
ffmpeg.exe -i yourvideo.avi -vf "[in] scale=iw/2:ih/2, pad=iw+40:ih+40:10:10 [top]; movie=yourLogoOrVideo.pngOraviEtc, scale=iw/2:ih/2 , fade=out:400:40:alpha=1 [bottom]; [top][bottom] overlay=PaddingFromTop:PaddingFromLeft [out]" -f flv ff.flv