I have 2 same videos. One of the videos doesn't have audio and I want to concat them.
video1 = 1 video stream + 1 audio stream.
video2 = 1 video stream.
the result should be 1(concatenated) video stream, 1 audio stream
I have tried
ffmpeg -i videoonly.mov -i video+audio.mov -filter_complex "[0:v][0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" out.mov
but it doesn't work and prints the error message
Stream specifier ':a' in filtergraph description [0:v][0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a] matches no streams.
I except this kind of error message because the second video doesn't have the audio and I sepcifyed the audio but the question is how to make it work or is it possible?
Thanks in advance.
The concat filter expects matching pairs in each segment, so if one of the segment does not have audio, you should supply a dummy stream. Below, I use the anullsrc filter to generate one.
ffmpeg -i videoonly.mov -i video+audio.mov -f lavfi -t 1 -i anullsrc -filter_complex "[0:v][2:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" out.mov
Related
I was able to reverse with:
ffmpeg -i input.mp4 -vf reverse output_reversed.mp4
And I can concat with:
ffmpeg -i input.mp4 -i input.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4
But can I concat with a reverse version of the video, with a single command?
What I am trying to achieve is a ping pong effect, where the video plays once, then plays backwards right after.
Thanks!
Technically, you can do it using
ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][0:a][r] [0:a]concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4
But the reverse filter will use a lot of memory for large videos. I've added a fifo filter to avoid frame drops. But test and see. (I haven't reversed the audio)
If your clip has no audio, the above command will throw an error – instead, use:
ffmpeg -i input.mp4 -filter_complex "[0:v]reverse,fifo[r];[0:v][r] concat=n=2:v=1 [v]" -map "[v]" output.mp4
I want to combine some videos with some specific features like(video Speed, volume increase, resolution, rotation, framerate) of the final output of the video
We can do this process in 2 steps like
Combine video
ffmpeg -i test1.mp4 -i test2.mp4 -filter_complex [0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa] -map [outv] -map [outa] output.mp4
Then apply filters
ffmpeg -i output.mp4 -filter:a volume=1.0,atempo=1.0 -vf transpose=2,setpts=1/1.0*PTS,scale=3840X2160,fps=30 final.mp4
I can do it this way but is there any way to do it in 1 step
thank you
You have to apply the filters after concat.
ffmpeg -i test1.mp4 -i test2.mp4 -filter_complex [0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[v][a];[v]transpose=2,setpts=1/1.0*PTS,scale=3840X2160,fps=30[outv];[a]volume=1.0,atempo=1.0[outa] -map [outv] -map [outa] output.mp4
I try concat two videos (1.mkv has 640:360 image size, 2.mkv has 1280:720 image size), both videos have 2 video tracks and 0 audio tracks. I tried this code:
ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[0:v:1]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[v0][1:v:0][1:v:1]concat=n=2:v=2:a=0[v]" -map "[v]" -c:v "libvpx" 1+2.mkv
But I have wrong:
Filter pad has an unconnected output
Your filter labels need to be adjusted, and you need to change v=2 to v=1 in concat filter:
ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[1:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v1];[v0][v1]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libvpx 1+2.mkv
Since 2.mkv is already 1280x720 you can avoid processing that input:
ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[v0][1:v]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libvpx 1+2.mkv
Hey i newbie in FFMPEG and i'm trying to merge two videos and i get that error - No such filter: ''
How i can fix that ? Here is my code:
ffmpeg -i videoplayback.mp4 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];
[1:v]trim=end=1,setpts=PTS-STARTPTS,fade=t=in:d=1[intro1];
[1:v]trim=start=1:end=123.39,setpts=PTS-STARTPTS[main1];
[1:v]trim=start=123.39,setpts=PTS-STARTPTS,fade=t=out:d=1[end1];
[0:a][1:a][a];
[intro][main][end][intro1][main1][end1]concat=n=6:v=1:a=1,scale=480x360,setsar=16/9[v]" -map "[v]" -map "[a]" -c:a copy output.mp4
Looks like you meant to concat the audio in [0:a][1:a][a]; but since no filter has been specified here, ffmpeg sees the three pads as inputs to a filter with a null string as its name.
Use [0:a][1:a]concat=n=2:v=0:a=1[a];
However, there are other errors in the command, and the whole command can be simplified to
ffmpeg -i videoplayback.mp4 -i videoplayback.mp4 -filter_complex
"[0:v]setpts=PTS-STARTPTS,fade=t=in:st=0:d=1,fade=t=out:st=123.39:d=1[v0];
[1:v]setpts=PTS-STARTPTS,fade=t=in:st=0:d=1,fade=t=out:st=123.39:d=1[v1];
[v0][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a];[v]scale=480x360,setsar=16/9[v]" -map "[v]" -map "[a]" output.mp4
I have 2 working code's but can't combine them (they both work separately).
ffmpeg -i video.mp4 -i audio.mp3 -shortest -t 8 -vf "lutrgb=r=1.5, crop:500:500" output.mp4
ffmpeg -i video.mp4 -f lavfi -i "color=Red:s=1280x720"
-filter_complex "[0:v]setsar=sar=1/1[s];
[s][1:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]"
-map [out] -map 0:a output.mp4
the lutrgb will be replaced but the color overlay so we can remove that.
endresult will take video, audio, color overlay, crop it to 1:1 and duration length of video.
Thanks
Felix
ffmpeg -i video.mp4 -i audio.mp3 -f lavfi -i "color=Red:s=500x500" \
-filter_complex "[0:v]lutrgb=r=1.5,crop=500:500,setsar=sar=1/1[crop];\
[crop][2:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]" \
-map [out] -map 1:a -shortest output.mp4
Use three inputs:
video.mp4 --> 0
audio.mp3 --> 1
lavfi --> 2
Chain the filters:
crop, setsar etc. the video stream in the first input and name it [crop]
[0:v]lutrgb=r=1.5,crop=320:240,setsar=sar=1/1[crop]
blend the video stream of the third input with the crop as [out]
[crop][2:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]
finally map the outputs using out as the video stream and the mp3 track as audio
-map [out] -map 1:a