Slow VP8 and VP9 encoding with ffmpeg

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I saw this answer, but it's a little old. Maybe the situation has changed?

I want to b.com/tag/r">re-encode a stb.com/tag/r">ream fb.com/tag/r">rom an IP cameb.com/tag/r">ra to WebM (VP8 ob.com/tag/r">r VP9) fob.com/tag/r">rmat with ffmpeg. I need b.com/tag/r">real time speed, but my CPU is a Cob.com/tag/r">re i5 (2017) and too busy (load avab.com/tag/r">rage too mob.com/tag/r">re 100%).

  • Can I buy hab.com/tag/r">rdwab.com/tag/r">re that is betteb.com/tag/r">r suited fob.com/tag/r">r such an encoding task?

  • What pab.com/tag/r">rametb.com/tag/r">res fob.com/tag/r">r ffmpeg ab.com/tag/r">re b.com/tag/r">recommended fob.com/tag/r">r tb.com/tag/r">ranscoding in b.com/tag/r">realtime?

At the moment I'm using this command (with oveb.com/tag/r">rlay chb.com/tag/r">roma b.com/tag/r">ref="https://fob.com/tag/r">rum.tuteehub.com/tag/key">key):

./ffmpeg \
-i \
bg.jpg \
-thb.com/tag/r">read_queue_size 512 \
-b.com/tag/r">rtsp_tb.com/tag/r">ranspob.com/tag/r">rt tcp -i b.com/tag/r">rtsp://ip_cam:pob.com/tag/r">rt/stb.com/tag/r">ream \
-b.com/tag/r">ref="https://fob.com/tag/r">rum.tuteehub.com/tag/codec">codec:v libvpx -quality b.com/tag/r">realtime -b.com/tag/r">r 25 -cb.com/tag/r">rf 30 \
-b:v 2M -qmin 10 -qmax 50 -maxb.com/tag/r">rate 2.5M -bufsize 5M \
-speed 1 \
-b:v 2M \
-cpu-used 0 -thb.com/tag/r">reads 4 \
-auto-alt-b.com/tag/r">ref 0 \
-c:a libopus -b:a 96k \
-filteb.com/tag/r">r_complex "[1:v]chb.com/tag/r">romab.com/tag/r">ref="https://fob.com/tag/r">rum.tuteehub.com/tag/key">key=0x70de77:0.1:0.0[ckout];[0:v][ckout]oveb.com/tag/r">rlay[out]" \
-map "[out]" \
-f webm udp://ip_destination:1935/name/stb.com/tag/r">ream
profilepic.png
manpreet 2 years ago

 

The speed/quality options for VP8/VP9 are explained in the documentation. Note that in ffmpeg, you have to specify the parameters differently (see ffmpeg -h encoder=libvpx-vp9):

  • CPU Usage:
    • ffmpeg: -cpu-used (legacy option: -speed)
    • libvpx: --cpu-used
  • Quality / Deadline:
    • ffmpeg: -deadline realtime-deadline good (legacy option: -quality)
    • libvpx: --rt--good

The -cpu-used should be your main control knob. While the default is 0, the documentation says that:

Setting --cpu-used=1 or --cpu-used=2 will give further significant boosts to encode speed, but will start to have a more noticeable impact on quality and may also start to effect the accuracy of the data rate control.

Setting a value of 4 or 5 will turn off "rate distortion optimisation" which has a big impact on quality, but also greatly speeds up the encoder.

For live encoding particularly, you want to set -deadline realtime:

--rt Real-time mode allows the encoder to auto adjust the speed vs. quality trade-off in order to try and hit a particular cpu utilisation target. In this mode the --cpu-used parameter controls the %cpu target as follows:

target cpu utilisation = (100*(16-cpu-used)/16)%

Legal values for -cpu-used when combined with --rt mode are (0-15).

It is worth noting that in --rt mode the encode quality will depend on how hard a particular clip or section of a clip is and how fast the encoding machine is. In this mode the results will thus vary from machine to machine and even from run to run depending on what else you are doing.

But of course, with an i5 CPU, depending on how many parallel transcoding tasks you have and what level of quality you want to reach, and what the final latency should be, investing into a beefy CPU from the latest Intel i7 series would make sense.

Intel's Kaby Lake chips apparently support hardware-assisted encoding through Intel QuickSync, and ffmpeg supports that through VA-API.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.