Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append video files of different width, height

I am building an application where user can record a screencast. Integral part of application is that, one can pause recording and resume it later any time (the session is maintained on server side).

So say when user starts recording the screen, the width and height is :1024*768. Using xuggler (java wrapper for ffmpeg), I am able to generate a video. But say later he is on a different system and wishes to resume screen cast, then resolution changes to 1080 * 720. At this stage, I record it seperately and then try merging two files. But because the width & height are not same, I get the below exception:

16:38:03.916 [main] WARN com.xuggle.xuggler - Got error: picture is not of the same width as this Coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1430) Exception in thread "main" java.lang.RuntimeException: failed to encode video

What is the best way to solve this Issue. The user can be on screen with different width and height. How do I merge (or any other alternatives, probably append) video files of different width and height?

like image 491
Jatin Avatar asked Oct 04 '13 11:10

Jatin


1 Answers

I don't know about the xuggler, but using the FFMpeg I was able to concat the videos with different resolution using the following command sequence. For each video I use following command

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

And after generation of all out.ts files I use the following command to concat all videos

ffmpeg -i "concat:out1.ts|out2.ts" -c:v libx264 -strict experimental -bsf:a aac_adtstoasc -ar 48000 -r 20 output.mp4
like image 61
Akhil Avatar answered Nov 18 '22 14:11

Akhil