| 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. |
|
|
By Steel_J at 2006-05-03 00:09
|
|
A lot of users have TV shows captured as MPEG files on their systems or personal video recorder.
I built a PVR that record's the satellite with an hardware MPEG2 encoder PCI card. It's all fine when I want to watch the shows within the week but for those shows I want to keep for later I convert them to high quality AVI files and transfer them elsewhere. Otherwise MPEG files take a lot of disk space.
Here is a little script I wrote to batch convert all MPEG files within a folder to quality AVI videos.
The only requirement for the script is mplayer. You can modify the "vbitrate" variable yourselves. I set it to 1100 because it produces a 500-550MB files from a one hour tv show. I find this to be a reasonable ratio between size and quality.
Copy and paste this code to a text file and name it "mpg2avi". You can then copy this file to /USR/LOCAL/BIN. Set permissions like so as root in a console: "chmod +rx mpg2avi" (without the quotes).
You can then run this in console from any directory and it will convert all MPEG files in it.
code:
Code:
#!/bin/bash
#mpg2avi (Convert mpeg streams into high quality mpeg4 avi with mp3 audio)
#requirements: mplayer
#Begin
clear
# variables
version=0.2b
current_directory=$( pwd )
# video bitrate (1100 = around 500 MB movie size)
vbitrate=1100
echo -e "* mpg2avi v${version}"
# remove spaces
for i in *.[Mm][Pp][Gg]; do mv "$i" `echo $i | tr ' ' '_'`; done > /dev/null 2>&1 &
# remove uppercase
for i in *.[Mm][Pp][Gg]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done > /dev/null 2>&1 &
# convert mpg movies into avi's with mencoder
for i in *.[Mm][Pp][Gg]; do nice -n 10 mencoder $i -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$vbitrate:vhq:vqmin=2:vlelim=-4:vcelim=9:lumi_mask=0.05:dark_mask=0.01 -vf pp=md -vop scale=640:480, -oac lavc -lavcopts acodec=mp3:abitrate=128 -o "`basename "$i"`.avi";echo "Conversion done";done
exit;
|
|
|
|
All times are GMT -5. The time now is 06:38 PM.
|
It's like taking a photograph that is underexposed and out of focus and trying to draw out of it a good picture: what isn't there in the first place.
One more time, it's like converting lossy JPEG image compression to lossless TIFF format. Once the compression to JPEG is performed, the losses are not recoverable, because the information is gone.
And, digital TV is transmitted over satellite and cable systems in slightly modified MPEG-2 format. PVRs can record that directly to a hard drive, with few translations.
Analog TV requires full MPEG encoding before it can be written to disk file. But analog TV is like 150 lines; not even close to the native resolution MPEG is designed to adequately preserve. So, converting to AVI is superflous.
You can digitize an analog signal into an HD format, but it doesn't then become HD quality. The quality remains the same or worse.
.mpg is not exactly a codec either for that matter. It generally refers to the mpeg-1 or mpeg-2 video codecs in one of several containers, usually either an mpeg-ts or mpeg-ps (the latter being a more restricted version for use with dvd video). Audio codecs include of course mp2 and mp3, although ac3 and raw pcm audio are also supported.
mp4 is a continuation of the mpeg standard, but AFAICT spins it off in a different direction from the older versions, with new codecs and new containers. divx/xvid and H.264 are different levels of mp4 codecs.
I suggest Wikipedia-ing for more details
In any case, AwesomeMachine is right about one thing. There's no way to get better video quality when converting from one lossy video codec to another. Like photocopies of photocopies, you'll only end up degrading the quality each time you re-encode. The best you can do is keep the loss to a minimum.
But then again, the OP didn't say anything about keeping the same quality, only that the intention was to convert them to another "high quality" format that has a smaller file size.