avconv on multiple threads

7,761

Solution 1

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

Solution 2

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
Share:
7,761

Related videos on Youtube

Shubham Chaudhary
Author by

Shubham Chaudhary

Updated on September 18, 2022

Comments

  • Shubham Chaudhary
    Shubham Chaudhary almost 2 years

    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?

  • Elder Geek
    Elder Geek over 8 years
    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.
  • andrew.46
    andrew.46 over 8 years
    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...
  • Elder Geek
    Elder Geek over 8 years
    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.