Java – append video files with different widths and heights

I'm building an application where users can record screenshots An integral part of the application is that you can temporarily stop recording and resume it at any time later (the session is maintained on the server side)

Therefore, when the user starts recording the screen, the width and height are: 1024 * 768 Using xuggler (Java wrapper of ffmpeg), I can generate a video But then he said he was on a different system and wanted to restore screen projection, and then change the resolution to 1080 * 720 At this stage, I record it separately and then try to merge the two files However, because the width and height are different, I get the following exception:

What is the best way to solve this problem? Users can have different widths and heights on the screen How do I merge (or any other alternative, possibly attach) video files of different widths and heights?

Solution

I don't know xuggler, but with ffmpeg, I can connect video at different resolutions using the following command sequence

ffmpeg -i input(n).mp4 -c copy -vbsf h264_mp4toannexb -f mpegts -s 1280*720 out(n).ts

Generate all out After the TS file, I use the following command to connect all videos

ffmpeg -i "concat:out1.ts|out2.ts" -c:v libx264 -strict experimental -bsf:a aac_adtstoasc -ar 48000 -r 20 output.mp4
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>