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.
Related
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'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 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.
Looking at the docs, it is not apparent to me whether ffmpeg would allow me to convert an image sequence to a video in reverse order, for example using this sequence:
frame-1000.jpg
frame-999.jpg
frame-998.jpg
...
frame-1.jpg
Is it possible to give a "step direction" for the frame indices?
There is a reverse video filter, so something like
ffmpeg -i frame-%d.jpg -vf reverse reversed.mp4
would work also.
Due to happenstance of your naming scheme, you're in luck.
FFmpeg's image sequence demuxer has a start number option and I've confirmed that it accepts negative values.
So,
ffmpeg -start_number -1000 -i frame%d.jpg reversed.mp4
Here the '-' has to be interpreted as part of the number series, so it's frame%d and not frame-%d.
I am starting with a high res video file and I would like to create 3 variants, low quality, mid quality, and high quality for mobile streaming. I want these mid/low/high variants to be segmented into ts pieces that the m3u8 file will be pointing that. Is there a way to do this in one line in ffmpeg?
I have successfully generated an m3u8 file and ts segments with ffmpeg, do I need to do this 3x and set specs for low/mid/high? If so, how do I get the singular m3u8 file to point to all variants as opposed to one for each variant?
This is the command I used to generate the m3u8 file along with the ts segments.
ffmpeg -i C:\Users\george\Desktop\video\hos.mp4 -strict -2 -acodec aac -vcodec libx264 -crf 25 C:\Users\user\Desktop\video\hos_Phone.m3u8
Yes, you need to encode all variants and generate the media playlists first (the playlists containing the segments).
If you want you can do it in one command since ffmepg supports multiple inputs/outputs. Eg:
ffmpeg -i input \
... [encoding parameters 1] ... output1 \
... [encoding parameters 2] ... output2 \
....[encoding parameters 3] ... output3
You must provide the variants in multiple qualities/bitrates but the aspect ratio should remain the same. Keeping the aspect ratio was initially mandatory but in the latest HLS authoring guide it's downgraded to a recommendation.
All variant streams must be keyframe aligned so set a GOP size using the -g option, disable scene-cut detection and use a segment duration hls_time which is a multiple of your keyframe interval.
Once you have all 3x m3u8 media playlist you can manually create the master playlist which points to each media playlist.
Example from the Apple HLS documentation, you must change the bandwidth, codecs, resolution and playlist filenames according to your own encoding options:
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2855600,CODECS="avc1.4d001f,mp4a.40.2",RESOLUTION=960x540
medium.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5605600,CODECS="avc1.640028,mp4a.40.2",RESOLUTION=1280x720
high.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1755600,CODECS="avc1.42001f,mp4a.40.2",RESOLUTION=640x360
low.m3u8
The Aspect ratio Does not have to be the same, that makes no sense.
How could you know what the client can play?
Aspect ratios are 4:3 for non-HD, 16:9 for a HD variants.
You don't want to do all your variants in one ffmpeg command if you
need segment times to be consistent.
Also watch transcoding downward, if you go from 1080 to 360, there
might be issues. One that I often get is that the audio degrades and
sounds weird. I try to go down no more than half, if I want high
quality.
#DavidC That hex is the codec version number.