150

If just need to crop Audio/Video from a longer track, what can I use? I tried OpenShot, but I find the export video slow, perhaps its compling all the "layers" into a new movie? Perhaps I just need a simple "crop" tool for audio/video will surfice?

20 Answers 20

159

I was going to mention commands like ffmpeg or avconv (The new one) which can OBVIOUSLY split files into groups. For example:

FFMPEG

ffmpeg -ss 00:00:00 -t 00:30:00 -i input.avi -vcodec copy -acodec copy output1.avi
ffmpeg -ss 00:30:00 -t 00:30:00 -i input.avi -vcodec copy -acodec copy output2.avi  
ffmpeg -ss 01:00:00 -t 00:30:00 -i input.avi -vcodec copy -acodec copy output3.avi

Or

ffmpeg -ss 0 -t 100 -i source.m4v -vcodec copy -acodec copy part1.m4v
ffmpeg -ss 100 -t 100 -i source.m4v -vcodec copy -acodec copy part2.m4v  
ffmpeg -ss 200 -t 100 -i source.m4v -vcodec copy -acodec copy part3.m4v  
ffmpeg -ss 300 -t 100 -i source.m4v -vcodec copy -acodec copy part4.m4v

AVCONV

avconv -i input.avi -vcodec copy -acodec copy -ss 00:00:00 -t 00:30:00 output1.avi
avconv -i input.avi -vcodec copy -acodec copy -ss 00:30:00 -t 00:30:00 output2.avi  
avconv -i input.avi -vcodec copy -acodec copy -ss 01:00:00 -t 00:30:00 output3.avi

Or

avconv -ss 0 -i source.m4v -t 100 -vcodec copy -acodec copy part1.m4v
avconv -ss 100 -i source.m4v -t 100 -vcodec copy -acodec copy part2.m4v
avconv -ss 200 -i source.m4v -t 100 -vcodec copy -acodec copy part3.m4v  
avconv -ss 300 -i source.m4v -t 100 -vcodec copy -acodec copy part4.m4v

Or do some script like here: http://icephoenix.us/notes-for-myself/auto-splitting-video-file-in-equal-chunks-with-ffmpeg-and-python/

  • 6
    Beware: According to the man page [ linux.die.net/man/1/ffmpeg ] this results in unnatural, overlapping cuts. For instance, the second command starts at 00:30:00 but goes on for an hour; i.e., up to 01:30:00, so the third command, which starts at 01:00:00, will yield an overlapping cut. It may be the goal, but it wouldn't be very natural. – ezequiel-garzon Sep 24 '12 at 22:12
  • 1
    I can vouch for what ezequiel mentions. When doing the tests with ffmpeg or avconv the overlapping effect appears if using the times as mentioned above. I will update to a more accurate effect although I should mention that the first second will also overlap. I will fix both and add avconv to the group. Thanks ezequiel. – Luis Alvarado Sep 25 '12 at 3:00
  • Thanks! But these ppa versions are out-of-date. Are the versions in Precise 12.04 good? Or can someone suggest better ones? – nealmcb Oct 14 '13 at 14:47
  • Thanks for notifying me. When I get back home I'll post an updated link. – Luis Alvarado Oct 14 '13 at 15:03
  • 1
    At least when using avconv you don't need to invoke the video and audio codec separately. You should just go with $ avcon -i input-file -codec copy [any option like -ss -t -fs ... just check on ubuntu.manpages.com for avconv] output-file – Antonio Jan 3 '16 at 0:20
31

With new version from ubuntu avconv

avconv -i srcFileName -c:a copy -c:v copy -ss 00:03:40 -t 00:01:12 targetFileName
  • First argument time is from time
  • Second argument is duration (not end time) duration may be either in seconds or in "hh:mm:ss[.xxx]" form.

To specify end time instead, use the option -to [end time].

Please refer to ffmpeg documentation for more informations

  • Thanks, an expert. Damn me not to read third-rated answer in the thread before doing anything. Without this examples Ī̲’d fail to turn off video recoding (“-vn” failed to produce this effect, for some reason) and would also have other problems. By the way, does “-c:s copy” make the same thing for subtitles? – Incnis Mrsi Aug 22 '15 at 11:24
  • Also, since my experience, when cutting out only the last part (i.e. when beginning of the new video coincides with beginning of the original video) “-ss 0” is potentially problematical and should be omitted. Ī̲ had a program (namely, Bombono DVD) crashed trying to read a file made with “-ss 0” substituted in place of the original file. – Incnis Mrsi Aug 22 '15 at 12:01
  • Thanks Philippe! This helped me a lot. can I ask what the args -c:a copy -c:v copy mean? – Alex Jan 3 '16 at 9:43
  • 2
    @Alex c=codec a=audio v=video – Philippe Gachoud Jan 3 '16 at 20:03
  • 1
    @Alex copy to copy the audio codec and video codec to the target stream. See more @ ffmpeg.org/ffmpeg.html#Main-options and refer to the ffmpeg documentation for more informations – Philippe Gachoud Jan 4 '16 at 10:51
30

kdenlive is (in my experience) the easiest software which will allow you to perform that task in a few steps and without problems. Even so, the OpenShot Video Editor project is also useful but it yet needs lots of hard work to get closer to the kdenlive.

Here are a screenshot of the kdenlive and openshot respectively:

enter image description here

enter image description here

Good luck!

  • Kdenlive is my favourite. All other linux editors crashed when using MOV files from my Kodak Zi8 camera. Easy to use and very powerful. – Ramon Suarez Jun 16 '12 at 6:52
  • 1
    Not sure what's going on with my edit. Looks fine in editing mode but here its messed up. – Insperatus Sep 5 '12 at 20:59
  • Sorry, I can't understand. Do you mind giving further details? If you think necessary please open a question about your issues. Thank you! – Geppettvs D'Constanzo Sep 5 '12 at 21:17
  • 3
    The easiest software Kdenlive asks a hell of irrelevant questions before even starting a project. But when about to do something, it spawns avconv and whenever it fails, Kdenlive won't offer help tp rectify situation and even doesn't report with which exactly parameters it ran avconv. Definitely a non-choice for one willing simply to trim a video file. – Incnis Mrsi Aug 22 '15 at 11:07
  • 2
    Personally, kdenlive seemed good, but the interface is very unintuitive and unnecessarily complex. Also, there seems to be some bug. After loading a clip, sometimes the clip plays. Sometimes it doesn't. Not recommended. – Nav Jul 23 '17 at 19:47
13

I like kdenlive for finishing up as well or clipping out small chunks...but if he wants to split a LARGE lecture into smaller pieces he could try:

ffmpeg -i input.mpg -ss 00:00:10 -t 00:00:30 out1.mpg -ss 00:00:35 -t 00:00:30 out2.mpg

discussion of the command is here: http://ubuntuforums.org/showthread.php?t=480343

  • you can use winff (GUI for ffmpeg) also – jahid65 Aug 6 '11 at 17:36
8

OpenShot Video Editor looks promising. Have you checked it?. Checkout the features: http://www.openshot.org/features/

The official installation method is via AppImage available at https://www.openshot.org/download/

To install it just open a terminal and run the following commands:

sudo add-apt-repository ppa:jonoomph/openshot-edge
sudo apt-get update
sudo apt-get install openshot openshot-doc

Just give a try. alt text

  • If he is using maverick it is in the repository – Sabacon Nov 11 '10 at 6:26
  • Openshot FTW! :) – OpenNingia Nov 11 '10 at 14:16
  • If the OP only wants to quickly crop video, then AVIDemux is far easier to use than OpenShot. I've just tried them both - OpenShot was surprisingly cumbers at just letting me define the in and out points for one video track. – Dan Dascalescu Jan 27 '16 at 22:40
  • OpenShot is definitely more user friendly than any of the other highly upvoted answers here. – Nav Jul 23 '17 at 20:10
  • OpenShot is mentioned in the question as program that failed but for me it was acceptable (export is slow but at least it had working preview of position where I cut and was not crashing - unlike other solutions that I tried). – Mateusz Konieczny Dec 20 '18 at 5:39
5

My preference for easy video clipping has always been avidemux. Avudemux logo

Just set the video and audio encoding to Copy and choose the container format you want, within reason.

Installation:

entry at apps.ubuntu.com Install avidemux

sudo apt-get install avidemux
3

Try Avidemux Install avidemux

sudo apt-get install avidemux

or LiVES Install lives

sudo apt-get install lives
  • Avidemux freezed several times for my under Ubuntu 13.10, even with a x4 CPU. – Lucio Mar 1 '14 at 19:01
2

For cutting, merging, scaling etc one can use … Blender (yes, this 3D editor, but it has also video editing part). You need workout some 20-min tutorial to survive the interface, but then it appears to be unexpectedly pleasant to use.

2

There is also WinFF that is avconv graphic interface. It works great. I installed it from Ubuntu Software Center.

Here is the screenshot: WinFF

2

I'm using ffmpeg CLI interface for that. It's very easy and fast:

  • to cut video:

    ffmpeg -i InputFile -vcodec copy -acodec copy -ss 00:00:00 -t 00:01:32 OutPutFile
    
  • to cut audio:

    ffmpeg -i InputFile  -vn -acodec copy -ss 00:00:00 -t 00:01:32 OutPutFile
    

In both of these -ss is the start point, while -t is the duration of the piece.

You can calculate duration e.g. using LibreOffice Calc or python's dateutil package, or you can use the -to option which accepts the end time directly.

1

I use Kdenlive, but I wouldn't be surprised if you could even slice video this way in PiTiVi:

  1. Create a new project with your full lecture.
  2. Set your start and end points for the first "manageable chunk" in the clip monitor.
  3. Drag from the video in the clip monitor down to your timeline. It will be just the chunk you chose.
  4. Set new start and end points in the clip monitor and repeat as needed.
  • 1
    I've looked around, and I can't find any way to divide a long clip into multiple shorter clips that I can easily manage. There is no "clip monitor"; PiTiVi is very simple (and I mean that in a good way!) Obviously, I could just cut up the video and reorganize the unnamed chunks in the timeline, but I'd like to know if there's a better way. – Evan Kroske Nov 11 '10 at 6:05
1

In PiTiVi 0.13.5 (Ubuntu 10.10) I was able to simply select a clip and go to Timeline > Split (or just press "S").

1

For quickly cutting I have used MythTV. I recorded some show, let it automatically search for the commercial breaks and fine-tuned the found markers. After this I started the Myth archiving function and burned all to DVD, without the commercials.

I have to admit, it worked gread from about 2006 or such. Somewhere in 2008 or 2009 some update ruined it all, my markers where somehow shifted.

Right now, I'm in the progress of re-installing this myth stuff, just to see if I can get the trimmer/editor and archiver working.

1

vidcutter is a very useful tool for cutting, trimming and merging videos in ubuntu:

Install vidcutter:

sudo add-apt-repository ppa:ozmartian/apps
sudo apt update
sudo apt install vidcutter

works in ubuntu 17.10

1

LosslessCut is focused entirely on clipping/cutting, is simple to use and does not re-encode, meaning saving to disk is pretty much instant.

enter image description here

To ensure audio remains synced with image, use the keyframe cut option.

1

Yesterday I just found that I can do it online, With a youtube account:) If you are in a hurry, and do not have enough time to try which ubuntu software works for you, then do it online.

Go to youtube account, upload your video, then select Video Manager, there is a Enhancement option, at the bottom right corner there lies Trim option

Watch this 1 minute tutorial if you still can not find it

Screen Capture of the Trim menu

0

If you want a GUI application you can use dmMediaConverter, a ffmpeg frontend, which has a split function, without reencoding, fast. Just add the split points and press Run. Also, it can do a lot of other stuff. http://dmsimpleapps.blogspot.ro/2014/04/dmmediaconverter.html Split function example

  • Sadly not open-source, though. – Martin R. Apr 28 '17 at 14:15
  • Yes, but it is free. – mdalacu May 1 '17 at 7:18
0

I wrote a helper for ffmpeg that mimics substr() syntax.

Usage

ffslice infile [start [duration [outfile [ffmpeg-args]]]]

Examples

# Get the last 5 minutes of an MP3
ffslice input.mp3 -5:00

# Get the first 30 seconds of a webm
ffslice input.webm 0 30

# Get 5 minutes of video starting at 2 minutes in
ffslice input.mp4 2:00 5:00

Code

#!/bin/bash
# substr() for MPEG-encoded files

infile="$1"; shift
start="$1"; shift
end="$1"; shift
outfile="$1"; shift
args=()

# Input file requred
if [ -z "$infile" ]; then
  echo "Usage: $(basename -- "$0") infile [start [duration [outfile [ffmpeg-args]]]]" >&2
  echo "Example: $(basename -- "$0") input.mp3 -5:00" >&2
  exit 1
fi

# Start
if [ "${start:0:1}" = "-" ]; then args+=('-sseof' "$start")
elif [ -n "$start" ]; then args+=('-ss' "$start")
fi

# Input
args+=('-i' "$infile")

# Duration
if [ "${end:0:1}" = "-" ]; then args+=('-sseof' "$end")
elif [ -n "$end" ]; then args+=('-to' "$end")
fi

# Default output filename
if [ -z "$outfile" ]; then
  filename=$(basename -- "$infile")
  extension="${filename##*.}"
  filename="${filename%.*}"
  outfile="${filename}-${start}-${end}.${extension}"

  # Cannot have colon in the filename with ffmpeg
  # https://unix.stackexchange.com/questions/412519/ffmpeg-protocol-not-found-for-normal-file-name
  outfile="$(printf "$outfile" | sed 's/:/./g')"
fi

ffmpeg "${args[@]}" -c copy "$@" "$outfile"

Caveat

Note that ffmpeg will only split on keyframes. This usually works well enough for most cases, but if you need precise video segments, see How to extract time-accurate video segments with ffmpeg?. You can force all the needed keyframes before segmenting.

-1

Pitivi too complex? Well... I suggest you learn how to use the mouse then lol

Anyway, I always use Kdenlive. Just import the video, drag it onto the timeline, click on the spot where you want to split it, right-click it, and choose cut. Then remove the part you don't need.

  • Thanks for the helpful suggestion, but for what I need they are too complex. Note that I didn't say too difficult to use, just unnecessarily bloated for my purposes. I ended up using openshot – jfoucher Aug 22 '11 at 23:06
  • 1
    @jfoucher: you should accept Geppettvs's answer then ;) – Takkat Aug 23 '11 at 7:31
-1

I've struggled with this same issue, having a large video file that I want to cut and save as separate scenes. After trying to do this in the usual suspects all listed by others here I ended up using Kino.

You will have to import the file as Kino needs it in dv format (whatever that is) and you can then specify start and end point for each clip on the Edit tab, then export each clip individually on the Export tab. Works great and is fast, the slowest part is the initial import of the video file. You can even add effects like titles to each clip.

I found that it is hard to find the exact spot to cut the scene in Kino and when I play the vid in the built in player there is no sound (there is when exported) and it plays too fast so I play the video in avidemux, find the time or frame number where I want to cut it, then use this info in Kino.

I do find it crashes a fair bit (I use Ubuntu 15.04 Kino v1.3.4) but it will recover where you were upon restart.


Update on the Kino webpage:

Kino is a dead project
( 05.08.2013 14:15 )
Kino has not been actively maintained since 2009. We encourage you to try other Linux video editors such as Shotcut, Kdenlive, Flowblade, OpenShot, PiTiVi, LiVES, and LightWorks.

protected by Community May 27 '17 at 22:06

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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