3

I have several large videos that I want to split into parts. The only way to do that I know is to split one part at a time with OpenShot. I have to split, wait a long time, delete the part, split the next part, ...

Is there a better way? I tried to google but it seems all the methods also require splitting one part at a time. This is really inconvenient as I need each video to be split into 20-30 parts. I want to be able to just mark all the split point and come back later and find it all done. Does anyone know a way?

UPDATE: Now I'm working on a command line solution. I tried this command but the only problem is that there are few seconds of where the video freezes in the beginning (and end) of each output split.

avconv -i x.mp4 -ss 00:00:00 -t 00:01:00 -c:v copy -c:a copy out.mp4  -ss 00:01:00 -t 00:01:00 -c:v copy -c:a copy out1.mp4  -ss 00:02:00 -t 00:01:00 -c:v copy -c:a copy out2.mp4  -ss 00:03:00 -t 00:04:00 -c:v copy -c:a copy out3.mp4
  • 1
    You can use command line --- ffmpeg -i input.mpg -ss 00:00:10 -t 00:00:30 out1.mpg -ss is the start point in hh:mm:ss from the beginning of your video file --- superuser.com/questions/31135/… – Tasos Mar 28 '14 at 9:00
  • I tried that. the quality of the output is really poor – fadiak Mar 28 '14 at 13:03
  • If you want to just split the video without re-ecoding it, use the copy codec for audio and video. Try this: ----- ffmpeg -ss 00:00:00 -t 00:50:00 -i largefile.mp4 -acodec copy \ -vcodec copy smallfile.mp4 – Tasos Mar 28 '14 at 15:16
  • I got an error but it worked when I removed the '\' before -vcodec. Except, it didn't split the file. the smallfile is the same length as the largefile and not 50 seconds. – fadiak Mar 28 '14 at 16:16
  • 2
    well you can try this --- ffmpeg -i in.mp4 -ss [start] -t [duration] -c:v copy -c:a copy out.mp4 --- source superuser.com/questions/377343/… – Tasos Mar 28 '14 at 16:49
3

Here is a solution that worked for me.

For example:

avconv -ss 0 -i x.mp4 -t 180  -vcodec copy -acodec copy -metadata track="1" "Part I.mp4"              
avconv -ss 180 -i x.mp4 -t 164  -vcodec copy -acodec copy -metadata track="2" "Part II.mp4"              
avconv -ss 344 -i x.mp4 -t 185  -vcodec copy -acodec copy -metadata track="3" "Part III.mp4"   

I had 50 entries and I put them in a script together. I first put skeletons like

avconv -ss  -i x.mp4 -t   -vcodec copy -acodec copy -metadata track="  " ".mp4"  

Then I filled out the -ss and put the titles. After that, I used libreoffice Calc with space as a delimiter. I got the values for -t and track with a formula and dragging.

1

If you do this often you can try to create a bash script. Start with something like this:

#!/bin/bash

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

FILES=$(ls *.mp4|sort)

let START=0

for FILE in $FILES
do
    echo Processing $FILE
    mkdir "${FILE}-chop"
    for COUNT in {1..59}
    do
        exec avconv -i "${FILE}" -ss $START -t 60 -c:v copy -c:a copy "./${FILE}-chop/${COUNT} - ${FILE}"
        let START=$START+60
    done
done

IFS=$SAVEIFS

Keep in mind that it's a very ugly code, and it will probably produce many errors and empty files, and won't work properly if the input file is more than an hour long, but it'll get you started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.