Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Why is Xvid file same size as MPEG1 I transcoded it from?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
kommissar
Tux's lil' helper
Tux's lil' helper


Joined: 19 May 2005
Posts: 78

PostPosted: Tue Feb 26, 2008 2:51 am    Post subject: Why is Xvid file same size as MPEG1 I transcoded it from? Reply with quote

So I have a mpg that I encoded to Xvid, because I thought that doing so would make the video file smaller. I assumed that the MPEG1 file is uncompressed, or not as compressed as Xvid, and that by converting it to Xvid I would gain some hard disk space back without losing quality. Apparently I'm wrong, and I'm not understanding how these video codecs work, so perhaps someone could fill me in on the proper way to do this, or tell me why my theory is false.

I mean, if the two have the same bit rate, I thought that since Xvid is more efficient than MPEG1 that overall the file would be smaller?

I have this MPEG file:
Code:

-rw-r--r-- 1 chris chris 233M 2008-02-25 18:02 myvid.mpg


So I check it out with Mplayer, to see what the bit rate is and stuff.

Code:

MPEG-PS file format detected.
VIDEO:  MPEG1  480x336  (aspect 1)  29.970 fps  1150.0 kbps (143.8 kbyte/s)
[gl] using extended formats. Use -vo gl:nomanyfmts if playback fails.
==========================================================================
Trying to force video codec driver family ffmpeg...
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmpeg1] vfm: ffmpeg (FFmpeg MPEG-1)
==========================================================================
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 224.0 kbit/15.87% (ratio: 28000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)


So I see the bit rate is 1150 kbps, and that the sound is 224 kbit, and I figure that these would be good settings for my output Xvid, but I'll use VBR MP3 to save some extra space, setting the rate to 224 like in the source.

I used this script to do the transcoding.

Code:

#!/bin/bash

#video inputs below
for j in "../myvid.mpg"
do
   transcode -i $j -w 1150 -b 224,vbr,5,0 -R 1 -o /dev/null -y xvid4,null &&
   rm divx4.log &&
   transcode -i $j -w 1150 -b 224,vbr,5,0 -R 2 -o $j.avi -y xvid4
done


This resulted in a video almost the exact same size (the new file is 45 KB smaller)

Code:

-rw-r--r-- 1 chris chris 233M 2008-02-25 21:16 myvid.avi


Which looks like this when I play it in Mplayer:

Code:

AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [XVID]  480x336  24bpp  29.970 fps  1149.9 kbps (140.4 kbyte/s)
Clip info:
 Software: transcode-1.0.4
[gl] using extended formats. Use -vo gl:nomanyfmts if playback fails.
==========================================================================
Trying to force video codec driver family ffmpeg...
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 224.0 kbit/15.87% (ratio: 28000->176400)
Back to top
View user's profile Send private message
Gusar
Advocate
Advocate


Joined: 09 Apr 2005
Posts: 2665
Location: Slovenia

PostPosted: Tue Feb 26, 2008 9:12 am    Post subject: Reply with quote

If you use the same bitrate for the xvid as the original video had, of course it will be the same size! Specify a lower bitrate when trnascoding if you want a smaller file.
Back to top
View user's profile Send private message
Hupf
Tux's lil' helper
Tux's lil' helper


Joined: 11 Sep 2005
Posts: 112
Location: Germany

PostPosted: Tue Feb 26, 2008 10:03 am    Post subject: Reply with quote

Just experiment a little with the parameters and compare the quality of the resulting XviDs with the original MPEG. The best choice heavily depends on the type of the video (Anime/Real-World, Fast/Slow motions, ...), the quality of the input (Artifacts like blocks or rings, noise, ...; all of these can and should be reduced with filters beforehand for better compressibility, most encoding suites like mencoder provide such tools) and our human perception, so it cannot be done automatically.
A pretty good place for video encoding questions would be www.doom9.org.
Back to top
View user's profile Send private message
kommissar
Tux's lil' helper
Tux's lil' helper


Joined: 19 May 2005
Posts: 78

PostPosted: Tue Feb 26, 2008 6:18 pm    Post subject: Reply with quote

Gusar wrote:
If you use the same bitrate for the xvid as the original video had, of course it will be the same size! Specify a lower bitrate when trnascoding if you want a smaller file.

Okay, I thought that the bitrate referred to the bitrate of the video after it is decompressed by the codec.

Am I right to assume that an xvid file at a lower bitrate is able to produce an image of approximately the same quality as the MPEG1 because it uses more efficient ways to store the video data?

Hupf wrote:
Just experiment a little with the parameters and compare the quality of the resulting XviDs with the original MPEG. The best choice heavily depends on the type of the video (Anime/Real-World, Fast/Slow motions, ...), the quality of the input (Artifacts like blocks or rings, noise, ...; all of these can and should be reduced with filters beforehand for better compressibility, most encoding suites like mencoder provide such tools) and our human perception, so it cannot be done automatically.
A pretty good place for video encoding questions would be www.doom9.org.

Thanks, this is informative. I'll check it out.
Back to top
View user's profile Send private message
Gusar
Advocate
Advocate


Joined: 09 Apr 2005
Posts: 2665
Location: Slovenia

PostPosted: Tue Feb 26, 2008 6:31 pm    Post subject: Reply with quote

kommissar wrote:
Am I right to assume that an xvid file at a lower bitrate is able to produce an image of approximately the same quality as the MPEG1 because it uses more efficient ways to store the video data?
Transcoding always means loss of quality. So whatever you do with your mpeg1 file, the result will always look worse.

But if you had a video and transcoded it twice with the same bitrate, once with mpeg1 and once with xvid, the xvid one would be much higher quality.
Back to top
View user's profile Send private message
MostAwesomeDude
Guru
Guru


Joined: 12 Aug 2007
Posts: 373

PostPosted: Tue Feb 26, 2008 6:36 pm    Post subject: Reply with quote

Gusar wrote:
If you use the same bitrate for the xvid as the original video had, of course it will be the same size! Specify a lower bitrate when trnascoding if you want a smaller file.


This. Use H.264 with no specified bitrate if you want it to lower the size while not losing quality. (Of course, this is still lossy transcoding, so some stuff will vanish, but you won't notice it. It's like uploading an MPEG to Youtube.)
_________________
Don't believe the "n00b" under my name.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum