[root@localhost ffmpeg_new_v4l2_avi2]# ffmpeg -i test.avi -vcodec xvid output.avi
FFmpeg version SVN-r7773, Copyright (c) 2000-2006 Fabrice Bellard, et al.
configuration: --prefix=/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-dts --enable-pp --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplay
libavutil version: 49.2.0
libavcodec version: 51.29.0
libavformat version: 51.8.0
built on Feb 5 2007 12:52:57, gcc: 3.2.3 20030502 (Red Hat Linux 3.2.3-47.fc4)
Input #0, avi, from 'test.avi':
Duration: 00:00:40.0, start: 0.000000, bitrate: 19380 kb/s
Stream #0.0: Video: rawvideo, bgr24, 200x150, 25.00 fps(r)
Stream #0.1: Audio: pcm_s16le, 44100 Hz, stereo, 1411 kb/s
File 'output.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'output.avi':
Stream #0.0: Video: xvid, yuv420p, 200x150, q=2-31, 200 kb/s, 25.00 fps(c)
Stream #0.1: Audio: mp2, 44100 Hz, stereo, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 1175 q=2.0 Lsize= 1617kB time=47.0 bitrate= 281.8kbits/s
video:1159kB audio:375kB global headers:0kB muxing overhead 5.386455%
从上面ffmpeg输出的信息来看音频被压缩成了mp2,为什么不压缩成mp3呢?是不是mpeg出来的时候,mp3还没有被发明出来???但是由于原来存储的avi文件有丢帧的现象,导致998帧的视频被错误的压缩成1175帧,导致最后反复出现同样的音视频,错的很牛逼。
第二次使用正常的AVI文件压缩的时候,是1000帧的。ffmpeg输出信息如下:
[root@localhost ffmpeg_new_v4l2_avi2]# ffmpeg -i test.avi -vcodec xvid output.avi
FFmpeg version SVN-r7773, Copyright (c) 2000-2006 Fabrice Bellard, et al.
configuration: --prefix=/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-dts --enable-pp --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplay
libavutil version: 49.2.0
libavcodec version: 51.29.0
libavformat version: 51.8.0
built on Feb 5 2007 12:52:57, gcc: 3.2.3 20030502 (Red Hat Linux 3.2.3-47.fc4)
Input #0, avi, from 'test.avi':
Duration: 00:00:40.0, start: 0.000000, bitrate: 19416 kb/s
Stream #0.0: Video: rawvideo, bgr24, 200x150, 25.00 fps(r)
Stream #0.1: Audio: pcm_s16le, 44100 Hz, stereo, 1411 kb/s
File 'output.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'output.avi':
Stream #0.0: Video: xvid, yuv420p, 200x150, q=2-31, 200 kb/s, 25.00 fps(c)
Stream #0.1: Audio: mp2, 44100 Hz, stereo, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 1000 q=3.0 Lsize= 1379kB time=40.0 bitrate= 282.5kbits/s
video:996kB audio:312kB global headers:0kB muxing overhead 5.426410%
[root@localhost ffmpeg_new_v4l2_avi2]# mplayer output.avi
MPlayer 1.0pre7-3.2.3 (C) 2000-2005 MPlayer Team
CPU: Intel Pentium 4/Xeon/Celeron Foster (Family: 8, Stepping: 4)
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2
使用mplayer播放该压缩文件如下,效果还不错,压缩比相当的可人。
Playing output.avi.
AVI file format detected.
VIDEO: [xvid] 200x150 24bpp 25.000 fps 203.9 kbps (24.9 kbyte/s)
Clip info:
Software: Lavf51.8.0
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 64.0 kbit/4.54% (ratio: 8000->176400)
Selected audio codec: [mp3] afm:mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
vo: X11 running at 1024x768 with depth 24 and 32 bpp (":0" => local display)
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm:ffmpeg (FFmpeg MPEG-4)
==========================================================================
Checking audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
AF_pre: 44100Hz/2ch/s16le
AO: [oss] 44100Hz 2ch s16le (2 bps)
Building audio filter chain for 44100Hz/2ch/s16le -> 44100Hz/2ch/s16le...
Starting playback...
VDec: vo config request - 200 x 150 (preferred csp: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
VO: [xv] 200x150 => 200x150 Planar YV12
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
A: 40.0 V: 40.0 A-V: 0.010 ct: 0.010 1000/1000 1% 1% 0.7% 1 0
Exiting... (End of file)
从mplayer打印出来的信息我们可以看到mplayer的内核实际上也含有ffmpeg。
ffmpeg的编译还是废了一点的时间的,有空可以把编译过程发上来。
TODO:将xvid编码加入我的capture程序中,做到实时压缩并存成avi格式的。需要多少时间才能搞定呢?心理没底,总之加油吧!