-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how can I use GPU in write_videofile #2011
Comments
hello, the bottleneck is not |
yeah, look into the |
you can use torch to accelerate, in the file
then modify file |
Please always include your specs like we ask for in our issue templates – MoviePy version, platform used etc. Code samples and logs should be code-formatted for better readability. |
This is giving me the following error with my RTX 3070:
I really do appreciate the thought being put into this though, being able to utilize a GPU to help mitigate this bottleneck would be massive. |
You can use
|
It works for me! 3 times faster.
@JasonChoate As for this error, just modify function iter_frames in Clip.py as follows:
|
@sixyang Is this fully utilizing the NVENC of 40-series GPUs? |
In my case, I use from viztracer import VizTracer
with VizTracer(ignore_frozen=True, ignore_c_function=True) as _:
final_clip.write_videofile(f"{fn}.mp4",
# threads=16, # ffmpeg 不是瓶颈
codec='h264_nvenc', # 2ms per frame, 不是瓶颈
write_logfile=f"{fn}.log"
) |
@tburrows13 @mgaitan <!--
Hello! If you think that it is a simple problem, then consider asking instead on our Gitter channel: https://gitter.im/movie-py/. This makes it easier to have a back-and-forth discussion in real-time.
You can format code by putting ``` (that's 3 backticks) on a line by itself at the beginning and end of each code block. For example:
I rewrite the file:ffmpeg_writer: add -hwaccle nvdec
line[97]
cmd = [
FFMPEG_BINARY,
"-hwaccel","nvdec",
"-y",
"-loglevel",
"error" if logfile == sp.PIPE else "info",
"-f",
"rawvideo",
"-vcodec",
"rawvideo",
"-s",
"%dx%d" % (size[0], size[1]),
"-pix_fmt",
pix_fmt,
"-r",
"%.02f" % fps,
"-an",
"-i",
"-",
]
if audiofile is not None:
cmd.extend(["-i", audiofile, "-acodec", "copy"])
cmd.extend(["-vcodec", codec, "-preset", preset])
if ffmpeg_params is not None:
cmd.extend(ffmpeg_params)
if bitrate is not None:
cmd.extend(["-b", bitrate])
The GPU memory is being occupied, but the GPU utilization is almost negligible. As a result, the time taken to write the video does not show any significant improvement.
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.85.12 Driver Version: 525.85.12 CUDA Version: 12.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 On | 00000000:00:1E.0 Off | 0 |
| N/A 37C P0 34W / 70W | 216MiB / 15360MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 3427015 C /usr/local/bin/ffmpeg 211MiB |
+-----------------------------------------------------------------------------+
-->
The text was updated successfully, but these errors were encountered: