9

Is it possible to run jobs on multiple processor or threads to speed up avconv?
Is there a feature in progress, if not I wonder why?

2 Answers 2

11

You are after the -threads option of avconv. Safest setting would be:

 -threads auto

but you can also set an integer there if you want to experiment a little. A modern FFmpeg (now the standard in Ubuntu) sets this is auto by default as seen in this section of the 'ffmpeg-all' man pages:

threads integer (decoding/encoding,video)

Set the number of threads to be used, in case the selected
codec implementation supports multi-threading.

  Possible values:

     auto, 0
     automatically select the number of threads to set

 Default value is auto.

Note 2 important points:

  1. This setting will only have effect if the chosen codec supports multi-threading
  2. It is possible to set the thread count for individual streams rather than simply attempt a global thread setting
3
  • 1
    Correct me if you have a source to the contrary but I'm under the impression that Avconv and avplay still use -threads auto as default if not otherwise specified. System monitor appears to back this up.
    – Elder Geek
    Feb 3, 2016 at 14:08
  • 1
    I believe that it depends on the codec used for transcoding. This could be formally tested which would certainly make for an interesting test. Information that I could find on the issue online is not particularly helpful. Another issue would be the version of FFmpeg that is used, the threads options has been used differently in older versions...
    – andrew.46
    Feb 3, 2016 at 22:10
  • 1
    Yes. FFmpeg and avconv have gone in somewhat different directions since the fork. Further research indicates that -threads auto is the default in avconv if you use one of the presets on the command line.
    – Elder Geek
    Feb 3, 2016 at 22:38
3

If you are doing audio transcoding of lots of files, look into using GNU Parallel. It will take a list of files as input and process them in parallel based on the number of cores in your system. For example, here is a bash example that will convert music into the opus audio format in parallel using ffmpeg.

find ./* -depth -type f -name \*.ogg -o -name \*.flac -o -name \*.m4a -o -name \*.mp3 -o -name \*.ogg | parallel -j+0 --gnu nice -n 19 ffmpeg -i "{}" -acodec libopus "{.}.opus" -loglevel quiet

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .