ffmpeg, dramatic decrease in size from camera videos.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
ffmpeg, dramatic decrease in size from camera videos.
Am I using ffmpeg correctly? I noticed an insane decrease in file size when passing videos through ffmpeg.
I passed a video through with the command
ffmpeg -i mvi_0130.avi -r 30 mvi_0131.avi
'-r' changes the frame rate, and the movie was originally 30 fps anyway. The result, however, gave me a 4MB file from a 75.7MB file. Of course, the video quality is a lot worse, the music is the same, from what I can tell. The only differences from the properties window are as follows:
So is this natural behavior for ffmpeg? Is there a way I can control to what degree ffmpeg degrades the quality of the movie? Is there a way I can just slightly reduce the frame rate, but keep each individual frame the same quality as it was recorded? Is it just because I am using an .avi file? (it is going from .avi to .avi)
when I say reduce the frame rate I'm not talking about stretching the video, a reduction from 30 to 15 would mean that it removes half the frames. And here I didn't even do anything, it just automatically reduced the quality without my input. Is there something I can do to stop this? So that if I did tell it to reduce the framerate to 15, that it would take half the frames out and that's all?
I think I just need an explaination of what exactly ffmpeg does. I don't think I quite understand.
Disclaimer: Bear in mind what I'm about to say is without looking at the docs, man pages, etc.
Looking at the transcoding output I'm seeing a rather extreme reduction in both rates, but especially the video: if I'm reading this right, you've taken a 12 megabit/second video stream and knocked it down to just 200 kilobits/second, which is pretty extreme--that explains your video quality loss. It says it's using MPEG4, which is a container--I'm assuming it's actually using x.264 as a codec, but I can't tell from the output. Also, any noise in the original video (analog to digital conversion in particular) will make compression worse.
Depending on the actual codec in use, there probably exist options to make it not compress as hard so your video looks better; the caveat being your resulting file will be larger. I also know there exists a codec, but I can't remember the name, that does for video what FLAC does for audio: lossless compression. (All other codecs will reduce video quality by removing information that can't be recovered, but that's the trade-off for much higher compression ratios.)
There exists a program made for just what you're doing called "transcode", which is also the name for what you're doing (transcoding from one digital format to another). I believe it can call ffmpeg along with a host of other codec packages. You should really consider it rather than trying to feed it through ffmpeg raw.
Disclaimer #2: Despite how this may sound, I'm not an expert. I just learned all this while I was in my "downloading anime torrents" phase, which the MPAA/RIAA/FBI/DMCA snoops reading this message can know I don't do anymore.
200kbs is the default bitrate ffmpeg falls back to if it doesn't know what value to use. In my experience its default behavior has been inconsistent. Sometimes it will use the settings from the input video and sometimes it won't. I haven't been able to figure out in which situations it does it, so I make sure to always manually set the bitrate now. Same goes with audio, as 64kbs is a rather low default there too.
I'm not sure how framerate conversion works exactly, but I believe it usually involves taking only the required frames from the input video. This is easy if the new framerate is an even multiple of the input (e.g. just take every other frame), but involves some interpolation if it's an odd number conversion, such as converting NTSC to PAL framerates. Of course, changing the bitrate, video size, and especially codec definitely means having to reencode the video.
I've always found ffmpeg to be rather tricky when it comes to framerate conversions. I generally use transcode or the gui program avidemux when I have to do something like that, since they both have specially-designed filters for conversion.
So when you use ffmpeg, it's usually best to set your -b and -ab manually. You can also use the 'copy' codec option to keep the original audio stream, say. But use another program if you want to change framerates.
when I say reduce the frame rate I'm not talking about stretching the video, a reduction from 30 to 15 would mean that it removes half the frames.
Are you absolutely sure that MJPEG stores full frames and allows to remove some of them without recompression? It's not uncompressed video! I don't know details about mjpeg, but (as far as I know) other compressed formats don't store all frames, they store differences between frames(motion vectors, color changes, etc). In this case reducing framerate would require recompression of entire video. If MJPEG allows just to throw out every second frame, then you should look for some mjpeg-specific tool.