如何在openH264和x264解码器之间进行选择 [英] How to choose between openH264 and x264 decoder

查看:337
本文介绍了如何在openH264和x264解码器之间进行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自zeranoe.com的开发版本,该版本中包含OpenH264和libx264. 如何在这两个解码器之间进行选择以比较解码速度?

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); 

只给我起了名字"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");

对于高分辨率(4k或更高)RTSP视频流,我还需要提高avcodec_decode_video2的解码速度吗?

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

推荐答案

FFmpeg除了可以使用本机FFmpeg H.264解码器(名为h264)之外,还可以使用OpenH264(在FFmpeg中名为libopenh264)进行解码.还有几种受支持的硬件辅助的H.264解码器,但是我不打算讨论有关这些细节.

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.

  • OpenH264 can only decode Constrained Baseline profile, so its usefulness may be limited.

原生FFmpeg H.264解码器具有线程功能(帧和切片),而OpenH264没有.

The native FFmpeg H.264 decoder has threading capabilities (frame and slice) but OpenH264 does not.

您似乎正在使用FFmpeg库,但这是一些使用ffmpeg的示例.

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

要选择所需的解码器,请使用-c:v输入选项.以下是使用 null多路复用器的两个解码基准测试示例.还使用-map选项,以便仅对(第一个)视频流进行解码,并忽略其他非视频流,例如音频.

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.

$ 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

基准时间

请注意,基准测试选项输出的是用户CPU时间,而不是经过的实时时间.如果还想实时显示,请在ffmpeg命令之前添加time命令(如果在Linux上).我在示例(最后三行)中添加了time的输出,以进行比较.

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.

查看控制台输出.例如,使用本地H.264解码器:

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

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

使用libopenh264:

Using libopenh264:

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

这篇关于如何在openH264和x264解码器之间进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆