[gst-devel] Mapping ffmpeg libx264 preset options to x264enc "option-string" parameter

Sameer Naik sameer.subscriptions at damagehead.com
Mon Nov 8 15:02:42 CET 2010


Hello,
I am trying to stream a live h264 video stream (from a dvbsrc) over
the internet at 1Mbps bitrate. For achieving a good enough quality i
have been experimenting with ffmpeg. I arrived at combination of
experimental settings for x264 encoder and set it as a preset for
ffmpeg. Following are my preset values

FILE: /usr/share/ffmpeg/libx264-custom.ffpreset
b=800k
bt=850k
flags=+loop
me_method=hex
subq=6
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
qcomp=0.6
qmin=10
qmax=51
qdiff=4
refs=2
trellis=1
coder=0
bf=0
level=30

In essence, the above setting encode the stream in h264 baseline level
3.0 at 800k. Using the ffmpeg command i am able to encode with the
specified settings.

-----------------------
ffmpeg -i INFILE.mp4 -vcodec libx264 -vpre custom -threads 0 -an -s
320x180 OUTFILE.avi
-----------------------

The quality of the converted file is ATM good enough and the bitrate
is within the defined limits. I decided to use the same settings on
the x264enc plugin and use gstreamer for the encoding.

Using the ffmpeg to x264 option mapping guide located at
http://rob.opendot.cl/index.php/useful-stuff/x264-to-ffmpeg-option-mapping/,
i converted the above ffmpeg options to the following x264 options:

bitrate=800
ratetol=1.06
deblock
partitions=i8x8i4x4p8x8b8x8
me=hex
subme=6
merange=16
keyint=250
min-keyint=25
scenecut=40
ipratio=0.71
qcomp=0.6
qpmin=10
qpmax=51
qpstep=4
ref=2
trellis=1
no-cabac
bframes=0
level=30

If i set the above options on x264enc via the option-string argument,

--------------
gst-launch filesrc location=INFILE.mp4 ! qtdemux ! ffdec_h264 !
videoscale ! "video/x-raw-yuv, width=(int)320, height=(int)180" !
x264enc threads=0
option-string="bitrate=800:ratetol=1.06:deblock:partitions=i8x8i4x4p8x8b8x8:me=hex:subme=6:merange=16:keyint=250:min-keyint=25:scenecut=40:ipratio=0.71:qcomp=0.6:qpmin=10:qpmax=51:qpstep=4:ref=2:trellis=1:no-cabac:bframes=0:level=30"
! avimux ! filesink location=OUTFILE.avi
--------------

The quality of the encoded video is not as good and at the same time
the specified bitrate is not respected. The resulting encoded avi is
way larger that what is expected, making is unsuitable for streaming
on a 1Mbps broadband connection.

I am trying to figure this out. I appreciate any help in this regard.

P.S. The above mentioned pipeline is only to test the encoding of the
stream in the h.264 format at real time and at respectable qualities.
The actual streaming is done via RTP and stuff.

Thanks and Regards
~Sameer




More information about the gstreamer-devel mailing list