I am going to concat multiple videos so I can get one video file with FFmpeg.
I've found several ways to implement this but all ways I found can't concat with specific duration of each video.
It means they only concat whole videos.
Exactly, what I wanted is to insert video1 into video2 with specific time. While searching several articles related with this, I checked many articles say "It is impossible with ffmpeg".
So I am trying to split video2 into two videos( like video2-1,video2-2) and concat video1, video2-1, video2-2.
what you can do is using trim and atrim in filter complex.
example
ffmpeg -i vid1.mp4 -i vid2.mp4 -filter_complex "[0:v]trim=0:2,setpts=PTS-STARTPTS[v1];[1:v]trim=3:6,setpts=PTS-STARTPTS[v2];[0:a]atrim=0:2,asetpts=PTS-STARTPTS[a1];[1:a]atrim=3:6,asetpts=PTS-STARTPTS[a2];[v1][a1][v2][a2]concat=n=2:v=1:a=1" out.mp4
this will cut vid1 from 0 to 2 and vid2 from 3 tot 6 and combine those together.
Related
I am a newer user to ffmpeg, but I have a slightly complicated use case for it. I need to be able to cut multiple sections out of a video and/or multiple sections out of the audio, with the actual length of the video and audio files remaining intact (e.g. the audio would cut out but the video continues, or the video continues but the audio cuts out). I have been slowly learning about complex filtergraphs, but a little help would be VERY much appreciated.
this is currently my super basic "test script" to see if I can get it to work (in it's actual use case, the timestamps will be variables in a python program)
ffmpeg -i bdt.mkv -filter_complex
[0:v]trim=start=10.0:end=15.0,setpts=PTS-STARTPTS[0v];
[0:a]atrim=start=10.0:end=15.0,asetpts=PTS-STARTPTS[0a];
[0:v]trim=start=65.0:end=70.0,setpts=PTS-STARTPTS[1v];
[0:a]atrim=start=65.0:end=70.0,asetpts=PTS-STARTPTS[1a];[0v][0a][1v]
[1a]concat=n=2:v=1:a=1[outv][outa] -map [outv] -map [outa] out.mp4
Use timeline option enable with the between expression. For video, you can use the overlay filter.
-vf color=black[b_];
[b_][0:v]scale2ref[b][in];
[in][b]overlay=shortest=1:enable='between(t,1,2)'
For audio, use the volume filter:
-af volume=0:enable='between(t,1,2)'
You'll need to escape 's. If you want to do more complex on/off's build up enable option using additional expressions (see the link above).
These aren't the only way to achieve the effect, but the easiest I could think of atm.
I am having an image sequence input of webp-s concatenated (for various reasons) in a single file. I have a full control over the single file format and can potentially reformat it as a container (IVF etc.) if a proper exists.
I would like ffmpeg to consume this input and time properly each individual frame (consider first displayed for 5 seconds, next 3 seconds, 7, 12 etc.) and output a video (mp4).
My current approach is using image2pipe or webp_pipe followed by a list of loop filters, but I am curious if there are any solid alternatives potentially a simple format/container I could use in order to reduce or completely avoid ffmpeg filter instructions as there might be hundreds or more in total.
ffmpeg -filter_complex "...movie=input.webps:f=webp_pipe,loop=10:1:20,loop=10:1:10..." -y out.mp4
I am aware of concat demuxer but having a separate file for each input image is not an option in my case.
I have tried IVF format which works ok for vp8 frames, but doesnt seem to accept webp. An alternative would be welcomed, but way too many exists for me to study each single one and help would be appreciated.
i'm quite new to ffmpeg and i've been learning how to make a 5 hour videos which loops for 5 hours and also add a intro video in the start of the video and at a outro/endscreen video at the end. I would like to know how i could do it more efficiently since i feel it's really taking a long time and too much work. My process and command's are as follows:
video specs: 3840x2160 , 60fps , 18M bitrate, hevc265
First i create a video of intro and outro/endscreen and save them as .mp4 format(both are 10secs long) using adobe premier.
i create a audio using adobe audition for the x amount of duration i want it to play, in this case 5 hours
I create the main video(which is 10 secs long) which i want to make it loop for 5 hours or any amount of time i want(this takes alot of time and is a huge file size and also adding name of the videos in the loop.txt etc video1.mp4, video2.mp4 till i reach to 5 hours), i use the command:
ffmpeg -f concat -i loop.txt -c copy main5hours.mp4
Than i concat the intro,main,outro/endscreen videos together using:
ffmpeg -f concat -i files.txt -c copy videowithoutaudio.mp4
Than merge video and audio using:
ffmpeg -i videowithoutaudio.mp4 -i audio.flac -c:v copy -c:a copy finalvideo.mp4
So this process takes a lot of time and file size and want some advice how i could do this more efficiently saving myself both time and file size and less work.
I read that i could also overlay the intro and endscreen videos but not sure how to do them and will it make any difference?
p.s: i'll be using the same intro and endscreen videos for all other videos i'll be making. Thanks in advance for any advice and help.
I've decided for some reason to upscale an entire 90-minute movie using AI. Problem is, I have several demo scenes that have already been upscaled, and I want to keep those frames rather than upscaling them again. Basically I want to export frames starting at a specific number, like ffmpeg -i scene1.mp4 scene1/%10d+[starting number].jpg. If the specified number were 1550, for example, the first frame it would export would be 0000001550.jpg. I still want it to start at the first frame of the input video, though; the only things I want to change are the names of the output files. Is there a way to do this?
Use the -start_number option for image2 muxer.
Use
ffmpeg -i scene1.mp4 -start_number 1550 scene1/%10d.jpg
I have two videos, one 640x480 and one 480x640 and I want to use ffmpeg to concatenate them together, but I want the resulting video to be 640x640 with both of the videos letterboxed. Is there a way to do this?
How To create mosaic with live stream with ffmpeg ( or with xuggle )
see above for concat
then read the docs on ffmpeg options for 'pad' and 'crop' paying attention to values that must divide by 2 or some such.
you should be able to do what you want but u may have to do separate experiments on the concat and on the padding/cropping to get all the frame sizes correct.