How to choose between openH264 and x264 decoder

转自:https://stackoverflow.com/questions/42220081/how-to-choose-between-openh264-and-x264-decoder


I'm using the dev build from zeranoe.com which has OpenH264 and libx264 in it. How can i choose between these two Decoders to compare the decoding speed ?

avcodec_find_decoder(AVCodecID.AV_CODEC_ID_H264); 

only gives me the name "h264" but which decoder is it ?

And tries to force a specific decoder failed, like:

codec = avcodec_find_decoder _by_name("x264");
codec = avcodec_find_decoder _by_name("libx264");

Which other options i have to improve the decoding speed of avcodec_decode_video2 for highres (4k and higher) RTSP video streams ?


Answer:
 


FFmpeg can use OpenH264 (named libopenh264 in FFmpeg) to decode in addition to the native FFmpeg H.264 decoder (named h264). There are also several supported hardware assisted H.264 decoders, but I'm not going to go into detail about those.

Caveats

ffmpeg CLI tool examples

It appears you're working with the FFmpeg libraries, but here are some examples using ffmpeg.

To choose the decoder you want use the -c:v input option. Below are two decoding benchmark examples using the null muxer. The -map option is also used so only the (first) video stream is decoded and to ignore other, non-video streams such as audio.

Native FFmpeg H.264 decoder

$ ffmpeg -benchmark -i input.mp4 -map 0:v:0 -f null -
bench: utime=23.557s
bench: maxrss=57752kB
real    0m3.834s
user    0m23.573s
sys     0m0.213s

libopenh264

$ ffmpeg -benchmark -c:v libopenh264 -i input.mp4 -map 0:v:0 -f null -
bench: utime=20.927s
bench: maxrss=37404kB
real    0m21.002s
user    0m20.940s
sys     0m0.060s

Benchmark time

Note the benchmark option outputs user CPU time, not the elapsed real time. If you want real time as well add the time command before the ffmpeg command (if you're on Linux). I added the outputs from time in the example (the last three lines) for comparison purposes.

To verify the desired decoder is being used

View the console output. For example using the native H.264 decoder:

Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))

Using libopenh264:

Stream mapping:
  Stream #0:0 -> #0:0 (h264 (libopenh264) -> wrapped_avframe (native))
Weird.  ffmpeg -h decoder=h264  does not show openh264 as a decoder.

I'm using the dev build from zeranoe.com which has OpenH264 and libx264 in it. How can i choose between these two Decoders to compare the decoding speed ?

avcodec_find_decoder(AVCodecID.AV_CODEC_ID_H264); 

only gives me the name "h264" but which decoder is it ?

And tries to force a specific decoder failed, like:

codec = avcodec_find_decoder _by_name("x264");
codec = avcodec_find_decoder _by_name("libx264");

Which other options i have to improve the decoding speed of avcodec_decode_video2 for highres (4k and higher) RTSP video streams ?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值