how should one compress a MPG file made with small P&S Digital Camera?
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
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.
how should one compress a MPG file made with small P&S Digital Camera?
I've made a 15-minute film, but its 99MB in size. What's a good CLI method to compress it down? I hear ffmpeg is good at this, but I don't know exactly what flags/options to include/exclude, which codecs to employ, etc. I don't want to shrink the video dimensions down, they are already as 3xx-by-4xx
Click here to see the post LQ members have rated as the most helpful post in this thread.
Making the dimensions of the video smaller is the easiest way to make the file size smaller, but since you don't want to do that you are going to need to increase the compression on the video. Depending on your target file size, the final video quality may become an issue.
Thank you for your reply. The video quality is not really that much of an issue. It was MEDIUM quality setting on a $150 sony digital cam. It won't win an Oscar
The size is pretty small already, largest dimension 4xx pixels (I don't have the file with me now, it's on my Desktop machine half way around the world).
What I'd like to do, is post it on the web, for others to view (download). I don't really know what file sizes are possible. I would like something less-than 20MB. If it helps a great deal, I guess I could live with shrinking the dimensions down a bit, maybe 10% (15%??).
There are a few basic ways to reduce file size. Most of them rely on reducing quality in some way. A) Reduce the frame size. B) Reduce the framerate. C) Reduce the bitrate. and/or D) Use a more efficient codec. (There may also be some intra-codec tweaks you can use, like setting the gop size or number of b-frames, but I'm not completely clear about how to use those advanced settings myself.)
We'll probably need to know what the original is set to before we can come up with proper settings to use. Also, can you give use some more details about how you will post it? Will it be used in a youtube-like player, or just as a raw file or something?
I don't think we need to see the video itself, just get the metadata for it. Can you run "ffmpeg -i filename", and post the output here?
I think I may have been wrong about the video's original dimensions, it appears that it is 640 x 480. Shrinking it could be possible. Yes --- I was thinking of having the video be made ideal for sharing on a youtube-like site.
Besides `man ffmpeg' and doom9's forums, and linuxquestions.org, are there any recommended places to learn about video (and audio) encoding processes, optimisations, types of codecs and containers, etc, etc?
There are things that I know so very little about, and wish to learn more - in as short a span of time as possible. I find the discussion of video/audio codecs, bitrates, frame-rates, I-frames, B-frames, sample rates, et al., to be so alien/foreign to me, and I'd really like to learn more.
Thanks for the above ffmpeg line. I shrunk the video down from 100M to 46M, but I haven't downloaded it yet (only getting 2.0KBytes/s download ATM) so I can't speak for the quality
Last edited by felipe1982; 02-14-2010 at 07:42 AM.
Wikipedia is a good resource to learn about container formats and protocols. An article will have references in the bottom. For the esoteric options, usually someone active in this area has a blog where they post articles, with sample configurations. There also is an ffmpeg users mailing list where you can ask particular questions.
Download a sample from youtube or use their recommendations.
Use the mediainfo program to analyze that video and adopt them for your output video.
Often a variation of the input video will point out an addition option or setting you need. For example the line above doesn't provide a -pix_fmt option for the colorization model. It may be carried over from the input (yuv420p) or be implied by the output codec. When you try to transcode a different input you my learn you need to add another option. The options after the -i <input video> pertain to the output video. Once these options are complete enough, you usually don't need to change them for the same target. Ffmpeg handles changes in the input video.
By using MPEG-4 video type, as I have done above, what is the 'container' format? Would AVI or MVK or any other be a suitable container type? How does one know that this is in fact mp4 (aside from the extension, of course)? Why is it better to select mpeg-4 versus mpeg-2? Does one produced smaller file sizes? I'm trying to get a better grasp of these things. Thanks for all the inputs. The wiki articles are helpful, but leave me with a thousand more questions than I began.
AIUI, mpeg4 generally uses it's own container format, specifically designed for it. It's possible to put mpeg4 in an avi container, but with some limitations. I've heard that avi doesn't support mpeg4's b-frames correctly, for example.
mpeg2 is the format used in the dvd standard. It has two container formats of it's own, mpeg-ps and mpeg-ts. ps is designed to support the same parameters (bitrate, framerate, framesize) as dvd video (which uses yet another container, vob) and is often used as a stepping stone in dvd authoring, while ts is more flexible and designed for general usage.
mpeg4, being a newer codec (or set of codecs) is, in general, more efficient, providing higher quality at lower bitrates than mpeg2, but at the cost of requiring more processing power to encode and decode. There are several different codec levels defined, for various purposes from internet streaming to blu-ray discs.
Note also that mpeg4 is not yet universally supported, and is also heavily patent-encumbered, meaning that all Free versions of the codecs fall inside a legal grey area.
I'm not too familiar with the matroska container, but I believe it's often used for dv digital video streams. Then there's the ogg container, which goes well with the theora codec.
The only way to tell for sure what's inside a container is to run it through a program that can read the streams inside, like ffmpeg or mplayer or something. Don't forget that they can also often hold multiple audio and subtitle streams as well.
Again, Wikipedia and Google will tell you much more about each different format.
mkv is a very good container format and supports many codecs. On the site there is a set of tools that can easily extract and combine streams, which makes things really easy to work with. It also supports many advanced features.
Oh, and one more thing, I don't think you will do well to choose patent unencumbered codecs just because it's a great thing to be free of patents. In general, I've found them to be rather crappy. One exception is vorbis, but in terms of size, it's still a bit large.
Here are my recommendations:
Xvid/Divx using libxvid
x264/H264 using libx264
AAC using libfaac/libfaad
mp3 using lame