Commit 9c7bf1bc authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Set the default #threads to 1 in StreamWriter (#3370)

Summary:
Similrt to https://github.com/pytorch/audio/issues/2949

Pull Request resolved: https://github.com/pytorch/audio/pull/3370

Differential Revision: D47298746

Pulled By: mthrok

fbshipit-source-id: 0cc0f395772b33f8b2f5f55253d659e451f506c4
parent 9210cba2
...@@ -184,6 +184,11 @@ void open_codec( ...@@ -184,6 +184,11 @@ void open_codec(
} }
} }
// Default to single thread execution.
if (!av_dict_get(opt, "threads", nullptr, 0)) {
av_dict_set(&opt, "threads", "1", 0);
}
int ret = avcodec_open2(codec_ctx, codec_ctx->codec, &opt); int ret = avcodec_open2(codec_ctx, codec_ctx->codec, &opt);
clean_up_dict(opt); clean_up_dict(opt);
TORCH_CHECK(ret >= 0, "Failed to open codec: (", av_err2string(ret), ")"); TORCH_CHECK(ret >= 0, "Failed to open codec: (", av_err2string(ret), ")");
......
...@@ -62,7 +62,29 @@ _encoder_option = """Options passed to encoder. ...@@ -62,7 +62,29 @@ _encoder_option = """Options passed to encoder.
To list encoder options for a encoder, you can use To list encoder options for a encoder, you can use
``ffmpeg -h encoder=<ENCODER>`` command. ``ffmpeg -h encoder=<ENCODER>`` command.
Default: ``None``.""" Default: ``None``.
|
In addition to encoder-specific options, you can also pass options related
to multithreading. They are effective only if the encoder support them.
If neither of them are provided, StreamReader defaults to single thread.
``"threads"``: The number of threads (in str).
Providing the value ``"0"`` will let FFmpeg decides based on its heuristics.
``"thread_type"``: Which multithreading method to use.
The valid values are ``"frame"`` or ``"slice"``.
Note that each encoder supports different set of methods.
If not provided, a default value is used.
- ``"frame"``: Encode more than one frame at once.
Each thread handles one frame.
This will increase decoding delay by one frame per thread
- ``"slice"``: Encode more than one part of a single frame at once.
|
"""
_encoder_format = """Format used to encode media. _encoder_format = """Format used to encode media.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment