LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2007, 02:29 PM   #1
Maverick1182
Member
 
Registered: Aug 2004
Location: London
Distribution: Gentoo
Posts: 277

Rep: Reputation: 30
Breaking avi file into 3 via the commandline?


Hi there,

I am currently trying to break a large .avi file into three equal chunks. I want it to be done slick in commandline as I dont want to go through the bother of a GUI to select points I want etc. Recommendations have pointed me to the avidemux command line interface. Unfortunately, it seems to miss frames when it breaks the file into fixed sizes... this means that when I try to patch them together there is a noticable skip where the cut has occurred. I was wondering if there are any other simple commandline utilities I could try to simple break one large avi file into 3 files of identical size without loss of frames?
 
Old 11-05-2007, 04:17 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

You could have a look at the split command. And use cat to put them back together again (cat a b c d > abcd).

Hope this helps.
 
Old 11-05-2007, 05:08 PM   #3
Maverick1182
Member
 
Registered: Aug 2004
Location: London
Distribution: Gentoo
Posts: 277

Original Poster
Rep: Reputation: 30
can this be done to an avi? I dont know how its encoded but I will see if this can be done...
 
Old 11-05-2007, 05:11 PM   #4
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
I don't think split is appropriate as it has no idea where to break the file - it uses criteria like number of bytes, lines and so on. I assume that splitting an avi file would require the addition of some sort of headers to each file, and probably choosing a split point at a key frame, or adding a new one at the start of the second and third chunk.

Maverick, what is the format of the video? As I understand it, AVI is just a container, and may contain one of a large number of codecs. Many codecs are supported by Linux programs, but a few are less commonly or less well supported.

Assuming the codec in one which can be handled, you could use one of the various transcoding tools to extract and re-encode a segment of the original file. This is not ideal because you would lose quality and it will take a lot of CPU power.

What would be ideal would be a way to do the edits without having to re-encode everything. I don't know how to do this with video, sorry. With audio (ogg or mp3) you can use mp3splt. I'm guessing you want that sort of thing but for video.
 
Old 11-06-2007, 03:44 AM   #5
Maverick1182
Member
 
Registered: Aug 2004
Location: London
Distribution: Gentoo
Posts: 277

Original Poster
Rep: Reputation: 30
The video I need to split is coded in DivX. Any ideas/experiences on a program which could do this? I need to spilt it using the commandline so which ever program it is , there needs to be a commandline interface. Hoping someone can help...
 
Old 11-06-2007, 04:15 AM   #6
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
I just found that there is a program called avisplit on my system which seems to work on DivX files. This program is part of the transcode package (at least it is on Ubuntu).

You can specify to split by maximum size of output file, or by time.

e.g.
Code:
avisplit -s 20 -i big_file.divx -o splitted
This will split big_file.divx into 20 Mb chunks.
 
Old 11-06-2007, 04:38 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
Do you want to split the avi file to produce 3 separate playable avi files, or do you want to split the file just due to the size; Such as posting on usenet or sending slices via email, or not exceeding the filesize limit? If it is the latter, then you can use the split command to split the file up into slices. I've done this to store a backup of my home directory before an upgrade. The external drive I had handy used the FAT32 filesystem.
I think that avisplit will break up a video into shorter videos.
 
Old 11-06-2007, 07:33 AM   #8
Maverick1182
Member
 
Registered: Aug 2004
Location: London
Distribution: Gentoo
Posts: 277

Original Poster
Rep: Reputation: 30
I will have a try with avisplit. I actually need the 3 smaller files to be seperate playable files so, as you say, I think avisplit is probably best. matthewg42, when you split the files and play them sequencially (say in vlc playlist), is there a noticable jump when it changes from one file to the other? This is what I have experienced in avidemux. I dont know if it is intelligent enough (or what it does) when you ask it for files a certain size, whether it creates one file of say 20MB and then starts at exactly the next frame to generate the next file etc...

Any input/information would be helpful but in the meanwhile I will try out avisplit when I get home and post back. Thanks for the help so far.
 
Old 11-06-2007, 07:48 AM   #9
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
I just tried it, and I see what you mean - looks like there are jumps and overlaps. I have no idea how to remedy that.
 
Old 11-06-2007, 08:02 AM   #10
Maverick1182
Member
 
Registered: Aug 2004
Location: London
Distribution: Gentoo
Posts: 277

Original Poster
Rep: Reputation: 30
Bummer, (thanks for testing it Matthew) would anyone know of software which cuts the file according to the frame number? At least then I can have control over how the three smaller files are created and avoid this clipping problem?
 
Old 11-06-2007, 05:14 PM   #11
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

You could take a look at mencoder. This does means that you to need to add headers to the individual parts.

Very roughly you can do something like this:

mencoder INFILE -ss 00:00:00 -endpos 00:00:00 -ovc lavc -oac copy -forceidx -o OUTFILE.avi

Although it's wise to take a look at the other options used (are divx options needed??) and to check the manpage (man mplayer), the options that concern your question are:

-ss 00:00:00 (Seek to given time position).
and
-endpos (Stop at given time or byte position).

-ss 00:01:30 -endpos 00:00:30 will start playing one minute and thirty seconds into the movie and will play for 30 seconds. The actual start and stop point are chosen by mencoder, there's no hard cut-off. I never tried using the byte position (-endpos 100mb), and don't know if this is or is not a hard cut-off.

Anyways, Hope I gave a better answer then the previous one

Last edited by druuna; 11-06-2007 at 05:15 PM.
 
Old 11-07-2007, 03:36 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681Reputation: 681
If you simply split the file, you could play it with "mplayer <(cat /path/to/file/name.avi.*)"
 
Old 11-09-2007, 03:27 AM   #13
Maverick1182
Member
 
Registered: Aug 2004
Location: London
Distribution: Gentoo
Posts: 277

Original Poster
Rep: Reputation: 30
Okay, I've tried all the solutions and played the broken files back... The best at breaking the file into 3 without loss of frames seems to be mencoder using precise time stamps rather than file size. It's a little slower but seems to get the job done. I hope this helps anyone else who wants to do what I wanted to do....

Thanks everyone for posting suggestions (please do , if anyone has a better/faster option)

mencoder INFILE -ss 00:00:00 -endpos 00:00:00 -ovc lavc -oac copy -forceidx -o OUTFILE.avi
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mount .iso (image) file and read *.avi file smartdragonfly Linux - Software 2 12-21-2006 04:48 AM
My player cant play rmvb file while avi file is ok......what's going on??!!! shuvernce Linux - General 6 03-28-2006 09:45 PM
How to convert the MPEG file to AVI file? stiphon General 3 06-08-2004 07:22 PM
Breaking up a file into blocks otnaicus Programming 9 05-19-2004 11:13 PM
Help with AVI FIle Risc91 Linux - General 2 01-11-2002 11:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration