Command encoding h264 baseline profile, level 1, with FFmpeg and libx264

ffmpegvideo streaming

Can anyone suggest a command to encode video to h264 baseline profile (level 1)?

Here is a link for reference: http://blog.mediacoderhq.com/h264-profiles-and-levels/

I used this command but FFmpeg says it is Main profile, not Baseline.

ffmpeg -i <SOURCE> -vcodec libx264 -coder 0 -flags +loop+mv4 \
-partitions +parti4x4+parti8x8+parti4x4+partp8x8+partb8x8 -me_method hex -subq 7 \
-trellis 1 -refs 5 -bf 0 -flags2 +mixed_refs -coder 0 -me_range 16 -threads 2 \
-s 240x160 -b:v 64k -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 \
-qmin 10 -qmax 51 -qdiff 4 -strict experimental -acodec aac -ac 1 -ab 48000 \
-f mpegts udp://127.0.0.1:10006?pkt_size=1316

Best Answer

Make sure you've got the latest FFmpeg and libx264 – this is really important * – and then try something like:

ffmpeg -i … -c:v libx264 -profile:v baseline -level 1 …

This will result in:

[libx264 @ 0x10180fa00] profile Constrained Baseline, level 1.0

Of course, you can supply the -preset and -tune options to x264 as well. Refer to x264 --fullhelp for more info.

Here are the x264 options used:

cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 
sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0
constrained_intra=0 bframes=0 weightp=0 keyint=250 
keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 
rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 
qpstep=4 ip_ratio=1.40 aq=1:1.00

* It works with FFmpeg 0.9 and x264 core 118. The -vprofile option was undocumented in FFmpeg, now it's -profile:v. It now basically works just like -profile, which again is supposed to replace -vpre. It uses x264's built-in profiles instead of relying on .ffpreset files.

Related Question