User Tools

Site Tools


ubuntu:video:change_ffmpeg_-threads_settings

Ubuntu - Video - Change ffmpeg -threads settings

The option flag you want is really just -threads and you would use it like this (for just one thread):

ffmpeg -i somefile.wmv -c:a libfdk_aac -c:v libx264  -threads 1 transcoded.mp4

However, there are quite a few subtleties that will raise your server load and ops time, such as rescaling, applying filters and final frame quality / frame rate - not to mention the fact that some VM architectures actually read and write everything twice (once natively and once virtually!!!)

Here are a few tips to get your speed up:

  • use a queue, so that only one item is ever being transcoded at a time
  • request smaller files from your users
  • use the full horsepower of your machine by:
    • reading and writing from a ramdisk
    • switching to bare metal for transcoding tasks
    • use -threads 0

Use docker

There is already a predefined ffmpeg image on github: https://github.com/jrottenberg/ffmpeg.

A single conversion will likely run slower because of the overhead but if you run multiple instances concurrently this could be a huge benefit.

Any this will scale very well, not to mention the improved security because each task is isolated from the underlying OS.

docker run jrottenberg/ffmpeg \
        -i http://url/to/media.mp4 \
        -stats \
        $ffmpeg_options  - > out.mp4
ubuntu/video/change_ffmpeg_-threads_settings.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki