How to trancode other video formats to AVS using
ffmpeg under Linux
This document will show you how to enable the AVS encoder inside ffmpeg and
transcode from other video formats to AVS video under Linux.
1. How to Compile ffmpeg to support XAVS encoding
2. How to use ffmpeg to transcode videos to AVS
3. XAVS to FFmpeg options mapping
#########################################################################
##############How to Compile ffmpeg
to support XAVS encoding###################
#########################################################################
1. Download the ffmpeg sourcecode
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
Download the xavs sourcecode
svn co https://xavs.svn.sourceforge.net/svnroot/xavs/trunk xavs
2. Compile the xavs code
install your xavs and Prefix the .h file and the .a
file into the system directory like /usr/local.
./configure --enable-shared
make
make install (the libxavs.so.x will be installed at /usr/local/lib/
3. Configure ffmpeg
When you run the configure file, add the following two commands:
#./configure --enable-gpl --enable-libxavs
You should make sure that the ffmpeg project also prefix to the same location
where you prefix your avs library file. That is /usr/local in our example.
make
make install
Check for XAVS support
#./ffmpeg -formats |less
DE cavsvideo raw Chinese AVS video
The avs video encoder is built successfully in the ffmpeg.
#########################################################################
###############How to use
ffmpeg to transcode videos to AVS######################
#########################################################################
Command line to accomplish the trancoding should be like this:
./ffmpeg -vframes 300 -cqp 29 -refs 2 -bf 2 -g 16 -s widthxheight -i "INPUT_FILE_NAME"
-vcodec libxavs "OUTPUT_FILE_NAME"
You should have some basic knowledge of the ffmpeg parameters to set the
transcoding configure. We provide you some commonly used parameters as a
reference:
-b/-vb set the bitrate/video bitrate
-s resoltion should be in the format of widthxheight
-r frame rate
-refs number of reference frames
-bf how many B frame enabled
-g gop size: frame distance between each I frames
-cqp value of this parameter should be integer larger or equal to 0. And this
shows that you are going to use constant QP.
-me_method [zero, full, epzs,esa,tesa,dia, log, phod, x1, hex, umh, iter]
-qmin/-qmax min/max quantization step
-vframes how many frames are going to encode
example:
A. 264 -> avs (without B frames)
#./ffmpeg -i test0.avi -g 60 -b 600k -vcodec libxavs output1.cavs
Input #0, avi, from 'test.avi':
Metadata:
ISFT : Lavf52.68.0
Duration: 00:00:40.46, start: 0.000000, bitrate: 313 kb/s
Stream #0.0: Video: h264, yuv420p, 576x432, 30 fps, 30 tbr, 30 tbn, 60 tbc
Output #0, avs, to 'output.avs':
Metadata:
encoder : Lavf52.68.0
Stream #0.0: Video: libxavs, yuv420p, 576x432, q=2-31, 600 kb/s, 90k tbn, 30 tbc
#./ffmpeg -i output.avs
Input #0, cavsvideo, from 'output1.cavs':
Duration: N/A, bitrate: N/A
Stream #0.0: Video: cavs, yuv420p, 576x432, 30 fps, 30 tbr, 1200k tbn, 30 tbc
[libxavs @ 0xaad0030]mb I I16..4: 0.0% 100.0% 0.0%
[libxavs @ 0xaad0030]mb P I16..4: 0.0% 3.1% 0.0% P16..4: 27.7% 9.3% 3.0% 0.0%
0.0% skip:56.9%
frame= 1214 fps= 3 q=-2.0 Lsize= 2925kB time=40.47 bitrate= 592.2kbits/s
Check Done from RM52k
B. 264 -> avs (with B frames)
#./ffmpeg -i test0.avi -b 600k -bf 2 -vcodec libxavs output2.cavs
[libxavs @ 0x9d83030]mb I I16..4: 0.0% 100.0% 0.0%
[libxavs @ 0x9d83030]mb P I16..4: 0.0% 5.7% 0.0% P16..4: 30.2% 10.2% 3.6% 0.0%
0.0% skip:50.3%
[libxavs @ 0x9d83030]mb B I16..4: 0.0% 0.4% 0.0% B16..8: 33.3% 0.8% 0.9% direct:
0.2% skip:64.4%
frame= 1214 fps= 3 q=-2.0 Lsize= 3304kB time=40.47 bitrate= 668.9kbits/s
C. PSNR of the trancoding or encoding , use -psnr
option
./ffmpeg -s cif -i /mnt/d/sequences/ak.yuv -psnr -vcodec libxavs test.cavs
D. Set the bitrate of the AVS video
./ffmpeg -s cif -i /mnt/d/sequences/ak.yuv -b 300k -vcodec libxavs test.cavs
﹛
﹛
﹛