4

I want to split up a video into 2 equal parts.

The problem is that video could be any duration. E.g. 3 seconds, 3.5 seconds or more.

I could only find a solution to split up a video if you know exact duration.

Is it possible to achieve the same result for a video with variable duration?

With FFmpeg on Windows.

  • 1
    Windows or some kind of *nix? – Michael Harvey Mar 31 '19 at 19:36
  • @MichaelHarvey Windows. – SharpAffair Mar 31 '19 at 19:41
  • There are free products on Windows which can do video split into equal parts, other than FFmpeg. For example: Bandicut Video Splitter and SolveigMM Video Splitter. Let me know if you are interested in such an alternative solution. – harrymc Apr 15 '19 at 06:50
  • You can extract/calculate the whole video time then divide it by 2 and use the result with the correct format for the -ss and -to options (in the two ffmpeg invocations: extract the first half, extract the second one) . You can even use the number of frames...for example you can count it with ffmpeg -i input.mkv -map 0:v:0 -c copy -f null - then with grep and awk select the output...divide by 2 etc etc... – Hastur Apr 15 '19 at 22:06
  • Even more efficiently with the segment -f segment -segment_time then the time... you have only to extract it in advance. OS depending... – Hastur Apr 15 '19 at 22:15
  • Do you just need the ffmpeg commands to do this, or is this a two-in-one question and do you expect the answer to also include batch scripting? (I know the commands, but not the batch.) – llogan Apr 16 '19 at 17:32

1 Answers1

1

You can split up video files by this command :

ffmpeg -i largefile.mp4 -t 00:50:00 -c copy smallfile1.mp4 -ss 00:50:00 -c copy smallfile2.mp4

Find the current duration of the file with this:

ffmpeg -i inputfile 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,//

Now calculate the half of it and put the value in previous code.

I can Create a script in bash But you are using windows. however, you can use a bash script if you are using Windows 10.