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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
|
04-02-2007, 06:30 AM
|
#1
|
|
LQ Newbie
Registered: Apr 2007
Posts: 7
Rep:
|
How do you split mpg files using a ffmpeg command?
thanks to anyone that can help me  i want to split a mpg file so that i can burn it onto a cd because the one i have now is too big to fit on a cd... i want to be able to use a ffmpeg command because its easier for me, but if there is another easy way i would like to know  iv'e been searching google for ages but i havent found anything.. so i thought i could find out how to here  soooooooooooooooooooo... if anyone could help me i will be very happy 
|
|
|
|
04-02-2007, 07:07 AM
|
#2
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,577
|
Did you try the man page? ffmpeg has two options, '-ss' (seek to position), and '-t' (recording duration). Basically, you set up a stream copy, use -ss to go to the point where you want to start the segment, then use -t to set the length of the recording from that position. You'll have to do it once for each segment you want to create.
An easier way would be to get mpgtx, which includes a variety of mpg tools including a splitter, and can do splits in a variety of ways.
|
|
|
|
04-03-2007, 05:31 AM
|
#3
|
|
LQ Newbie
Registered: Apr 2007
Posts: 7
Original Poster
Rep:
|
Quote:
|
Originally Posted by David the H.
Did you try the man page? ffmpeg has two options, '-ss' (seek to position), and '-t' (recording duration). Basically, you set up a stream copy, use -ss to go to the point where you want to start the segment, then use -t to set the length of the recording from that position. You'll have to do it once for each segment you want to create.
An easier way would be to get mpgtx, which includes a variety of mpg tools including a splitter, and can do splits in a variety of ways.
|
how do you use mpgtx though?
|
|
|
|
04-03-2007, 07:03 AM
|
#4
|
|
Senior Member
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,601
Rep:
|
you go there and read
http://mpgtx.sourceforge.net/#Usage
It is a usage to make your own homework before asking question, or lets put it that way, you are expected to do some homework/reading first
Welcome to LQ anyway, not everybody will be as stern as me :-)
|
|
|
|
04-03-2007, 08:25 AM
|
#5
|
|
LQ Newbie
Registered: Apr 2007
Posts: 7
Original Poster
Rep:
|
Quote:
|
Originally Posted by Emmanuel_uk
you go there and read
http://mpgtx.sourceforge.net/#Usage
It is a usage to make your own homework before asking question, or lets put it that way, you are expected to do some homework/reading first
Welcome to LQ anyway, not everybody will be as stern as me :-)
|
thanks  ill make that a mental note, but how do you know if i looked it up or not?  your magic 
|
|
|
|
04-03-2007, 01:12 PM
|
#6
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,577
|
You'll find that the *nix community is very big on encouraging people to 'RTFM' before they ask for help.
And people who have made the attempt usually indicate it in some way. Something like "I read the instructions, but I still don't understand what to do", followed by some detailed questions on use, would tell us that you at least gave it the effort first.
FYI, your first stop should always be the man page. In a terminal/console, simply type "man <command>" and you'll (usually) get a general how-to-use manual page for it. The mpgtx man page, in this case, is fairly detailed and should give you enough info on how to use it. If it's still unclear to you, then you can come back and ask about it. Be sure to make it clear what you do understand, as well as what you don't.
|
|
|
|
04-04-2007, 12:19 AM
|
#7
|
|
LQ Newbie
Registered: Apr 2007
Posts: 7
Original Poster
Rep:
|
Quote:
|
Originally Posted by David the H.
You'll find that the *nix community is very big on encouraging people to 'RTFM' before they ask for help.
And people who have made the attempt usually indicate it in some way. Something like "I read the instructions, but I still don't understand what to do", followed by some detailed questions on use, would tell us that you at least gave it the effort first.
FYI, your first stop should always be the man page. In a terminal/console, simply type "man <command>" and you'll (usually) get a general how-to-use manual page for it. The mpgtx man page, in this case, is fairly detailed and should give you enough info on how to use it. If it's still unclear to you, then you can come back and ask about it. Be sure to make it clear what you do understand, as well as what you don't.
|
ok thanks 
|
|
|
|
12-04-2008, 01:54 PM
|
#8
|
|
LQ Newbie
Registered: Dec 2008
Posts: 3
Rep:
|
Try the:
-vcodec copy
option to copy as well as the -ss and -t options mentioned above.
Example: ffmpeg -vcodec copy -ss 00:01:00 -t 00:03:00 -i infile.mpg outfile.mpg
the -vcodec option chooses the video codec to use, more options are:
-vcodec <string> : Force video codec.
copy : Copy raw codec data as is.
dvvideo : DV Video (for video editing, I've heard)
ffv1 : FFV1 lossless video codec
h264 : H.264 (best mpeg-4 codec, I've heard)
mpeg2video : MPEG-2 Video
rawvideo : RAW Video
xvid : XviD ( MPEG-4 Part 2 )
(-vcodec options from http forum dot videohelp dot com slash topic338564 dot html ) I can not post proper url's yet.
|
|
|
|
10-10-2009, 06:21 PM
|
#9
|
|
Member
Registered: Aug 2005
Distribution: Ubuntu Intrepid and Meerkat, formerly used Debian 3.1 (Sarge) with Gnome Desktop
Posts: 353
Rep:
|
I know this is an old thread, however for the benefit of those who stumble upon this thread from googling...
This is also useful use of ffmpeg.
ffmpeg -i inputfilename.mpg -sameq -ss 00:01:00 -t 00:03:00 outfile.mpg
The above will extract 3 minutes of mpg file from the 1 minute mark using same quality as the source file. This is useful for Variable Bit Rate (VBR) encoded files.
The -sameq parameter tells ffmpeg to use same quality as input file.
|
|
|
|
10-11-2009, 04:39 AM
|
#10
|
|
Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,612
|
If we're talking about a regular mpeg2 file, then you can just use split or dd to split it.
|
|
|
|
01-08-2010, 02:36 PM
|
#11
|
|
LQ Newbie
Registered: Jan 2010
Posts: 1
Rep:
|
Hi!
I'm trying to split my 50 minutes video file into 30 seconds long chunks. How could I achieve this with FFMPEG? I wrote a simple C# application that would start a process in a loop but it seems it's taking ages to split my file.
My code looks something like this:
Code:
class Program
{
private static TimeSpan ts = new TimeSpan(0, 0, 0, 00);
private static TimeSpan tsAdd = new TimeSpan(0, 0, 0, 30);
private static string timeSpan = "00:00:30";
static void Main(string[] args)
{
for (int i = 0; i <= 108; i++)
{
string fileName = string.Format("{0:00}{1:00}{2:00}.flv", ts.Hours, ts.Minutes, ts.Seconds);
string startTime = string.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds);
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = @"C:\ffmpeg";
info.Arguments = string.Format("-i C:\\Movie.flv -sameq -ss " + startTime + " -t " + timeSpan + " C:\\OutputFolder\\" + fileName);
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process process = Process.Start(info);
process.WaitForExit();
if (process.ExitCode != 0)
{
//Whatever goes here
}
process.Close();
process.Dispose();
ts = ts.Add(tsAdd);
}
}
}
Does anyone have any better idea?
|
|
|
|
08-29-2010, 07:58 AM
|
#12
|
|
LQ Newbie
Registered: Aug 2010
Posts: 1
Rep:
|
Effect of "-sameq"
Hi! I am new to ffmpeg. Actually, I am using it on a Mac but this thread has been useful to me so I thought I would add what I have learned by testing ffmpeg to split mpg files.
I tried greengrocer's suggestion and used "-sameq" as recommended to split part of an mpeg2video file. The video quality was, indeed, unchanged as far as I could see but when I checked it by typing in
ffmpeg -i resulting_file.mpg
and hitting return I saw that it had been changed from a mpeg2video to a mpeg1video. When I used space_age's command, that is
ffmpeg -vcodec copy -ss 00:01:00 -t 00:03:00 -i infile.mpg outfile.mpg
I found that the resulting file remained mpeg2video. Moreover, it was considerably smaller. I also used the -vcodec copy command to copy the entire file and found that it was just slightly smaller than the original. I'm not sure what was lost but after experimenting with the two I would say that "-vcodec copy" is what fits my needs.
I apologize for posting this so long after discussion has died down. However, as I found this discussion through a search engine, I thought I would post my experience for those who might also be Googling for this kind of information.
|
|
|
|
09-05-2010, 08:04 AM
|
#13
|
|
Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,612
|
'-sameq' is used when re-encoding a video, so I would also recommend using '-vcodec copy' instead.
|
|
|
|
09-25-2010, 11:00 PM
|
#14
|
|
LQ Newbie
Registered: Sep 2010
Posts: 1
Rep:
|
Quote:
Originally Posted by KMCheese
I apologize for posting this so long after discussion has died down. However, as I found this discussion through a search engine, I thought I would post my experience for those who might also be Googling for this kind of information.
|
No need to apologize! Even though this thread started early 2007, I too found all this info invaluable.
After searching for days and downloading various video converting programs, wasting lots of time in trying them out, none could directly stream copy or split videos. I was just about to give up, but stumbled upon this thread. After downloading FFMPEG and trying out the options listed here, it finally worked for me. I am very, very pleased with this "powerful" program.
At first, I also had problems with the -sameq option. I can't remember exactly. When running it, errors came up at the command prompt. I think it also changed the video format.
BTW, no one mentions stream coping and splitting the audio part with the option -acodec copy. Here are the options that worked for me with both video and audio:
ffmpeg -i some_video.flv -vcodec copy -acodec copy -ss 00:00:00 -t 00:02:24 cut_video.flv
The cut_video.flv was a carbon copy of the original except shorter; same resolution, codecs, aspect ratio and bit rates.
Hope this thread helps others like it did me.
|
|
|
|
03-06-2011, 02:52 PM
|
#15
|
|
LQ Newbie
Registered: Aug 2003
Posts: 2
Rep:
|
I'll second the last post. I've wasted time trying to do the seemingly simple operation of cutting a big mpeg file in two, getting nowhere, and just finding a hoard of windows shareware programs.
Thanks to this thread my problem is solved, with a similar ffmpeg invocation to that in the previous post 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:23 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|