I have 2 videos: v1.mp4 and v2.mp4. I want to make a output video that is a copied-v2.mp4 video but has the same width, height, SAR with v1.mp4.
How could i do that by ffmpeg command?
I think about the command:
ffmpeg -i v1.mp4 -i v2.mp4 -filter_complex [1:v]scale={width_of_v1}:{height_of_v1},setsar={sar_of_v1}[out] out.mp4
but i do not know how to get those values: {width_of_v1}, {height_of_v1}, {sar_of_v1}
解决方案
There is probably a way to get the values in one line, but I would just first get the values from video 1, and then plug in the numbers / strings into video 2. This can be done programatically with ffprobe, for example, by this command:
ffprobe -print_format json -show_format -show_streams v1.mp4
The output of ffprobe can be parsed as JSON or just read to get the width, height, and screen_aspect_ratio of video 1.