Splitting a video into multiple parts
Solution 1
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.
Solution 2
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.
Related videos on Youtube
![Péter Kertész](https://lh5.googleusercontent.com/-4yX2dKyifmM/AAAAAAAAAAI/AAAAAAAAABw/bcHWcWYl96U/photo.jpg?sz=256)
Péter Kertész
Updated on September 18, 2022Comments
-
Péter Kertész almost 2 years
I try to install a software for a thermal camera, but it gives the error message:
pi@raspberrypi:~ $ sudo dpkg -i /media/pi/PETI/libirimager-1.1.7-i386.deb Selecting previously unselected package libirimager. (Reading database ... 112361 files and directories currently installed.) Preparing to unpack .../libirimager-1.1.7-i386.deb ... Unpacking libirimager (1.1.7) ... dpkg: dependency problems prevent configuration of libirimager: libirimager depends on libudev-dev (>= 1.0). libirimager depends on gcc (>= 4.6). libirimager depends on build-essential (>= 1.14.18). libirimager depends on cmake (>= 2.6). dpkg: error processing package libirimager (--install): dependency problems - leaving unconfigured Errors were encountered while processing: libirimager
I tried the
dpkg --configure -a
, but did not solve the problem. The linux is totaly new for me, so I am unfamiliar with these orders. (Raspbian Jessie, i386)-
Tasos about 10 yearsYou 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 about 10 yearsIf 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 about 10 yearscan you check this solution, if you are familiar with scripts there is a nice script down the bottom yo can try --- stackoverflow.com/questions/5651654/…
-
romanbird about 10 yearsYes, I know about it. I need to split a video of an opera into scenes/acts, etc.
-
Tasos about 10 yearswell 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/…
-
romanbird about 10 yearsThis is better. Thanks. When I chain two outputs together the second one is frozen for the first few seconds.
-
Tasos about 10 yearsi believe i read somewhere but im not sure were, that you could also do multiple cuts in one command rather than doing it once every time. Cant remember though
-
romanbird about 10 yearsya, thats what I did but the second one freezes for a few seconds: ffmpeg -i x.mp4 -ss 00:00:00 -t 00:00:50 -c:v copy -c:a copy out.mp4 -ss 00:00:49 -t 00:02:00 -c:v copy -c:a copy out1.mp4
-
Barafu Albino about 10 yearsI believe that using
copy
codec one can only split videos on i-frames, which can be as rare as once per scene. -
romanbird about 10 yearswhat should I use then?
-
-
Péter Kertész about 7 yearsThank you for the fast answer. Now it is better, but I have still a message: 'This package is uninstallable' 'Dependency is not satisfiable: libudev-dev (>= 1.0)
-
Péter Kertész about 7 yearsHow can I install all dependencies? Are they independent files? I'm sorry for the silly questions...
-
tso about 7 years
apt install libudev-dev gcc build-essential cmake
-
Knud Larsen about 7 yearsPlease edit your question to include OS name, version, architecture. This command will reply with i686 or x86_64 :
uname -m
-
Toby Speight about 7 yearsThe question is not on-topic for Stack Overflow as defined in the help center. Please don't answer such questions; instead, you should flag them for attention and they will be closed or migrated appropriately.
-
Knud Larsen about 7 years
libudev-dev
, Jessie : libudev-dev_215-17 ... seems to be "later than 1.0". packages.debian.org/jessie/libudev-dev >>> arm64 packages.debian.org/jessie/arm64/libudev-dev/download