-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ffmpeg 4.0 NVIDIA NVDEC-accelerated Support ? #790
Comments
What ended up happening with this? |
For me this is work out of the box |
How to use this with moviepy ? |
I'm also interested if anyone found a way to enable ffmpeg gpu acceleration in moviepy? |
I have the same problem |
Same issue here. If I modify the ffmpeg_reader.py file' cmd variable into that, I get the same error as above. |
This is an old thread but seeing recent interest in it, I'll throw in my 2 cents. I'm assuming this is about video DECODING, not encoding. OP's post is confusing as it talks about decoding, the ffmpeg_reader file is modified, but the edits are on the encoding part of the ffmpeg command. I can see several problems why it's not working for you:
Example working code: Before you spend a lot of energy on accelerating decoding, it's worth doing a few tests if it would even speed things up as you expect. I have mixed results with CPU vs GPU cuvid decoding; on some of my PCs the CPU decoding is faster, albeit it uses more CPU power obviously. The above way is not optimal in any case: I suspect that each frame is transferred about 3 times between the CPU and GPU (1 to GPU for decoding after loading, 2 to CPU into moviepy frame array, 3 to GPU to be displayed). |
Interested in how to use GPU for mac
|
so this may help. I've cherry picked some code I slapped together over time. _NIVIDIA_ACCELERATOR = 'cuvid'
_NIVIDIA_DECODER = 'h264_cuvid'
_NIVIDIA_ENCODER = 'h264_nvenc'
_FFMPEG_COPY_ENCODER = 'copy'
_NVIDIA_CUDA = 'cuda'
_NVIDIA_CV_ENCODER = 'hevc_nvenc'
LIBX = "libx264"
# HERE THE VIDEO IS NOT ENCODED....
input_args = {
# "hwaccel": _NIVIDIA_ACCELERATOR,
# "vcodec": _NIVIDIA_DECODER,
# # "c:v": _NIVIDIA_DECODER,
# "hwaccel_output_format": _NVIDIA_CUDA
}
output_args = {
"vcodec": _NIVIDIA_ENCODER,
# "vcodec": LIBX,
# "c:v": LIBX,
# ultrafast - superfast - veryfast - faster - fast - medium(default preset) - slow -
"preset": "fast",
# slower - veryslow - placebo
"r": 29.97,
# "crf": 21,
# "b:v": "800k",
# "ac": 1, # Mono
# "b:a": "128k",
"crf": 0,
"b:v": "20M",
"acodec": _FFMPEG_COPY_ENCODER, # copy
}
# H264 Encoding
print('Begin H264 Encoding')
try:
(ffmpeg
.input(outputMovie, **input_args)
.output(h264_file, **output_args)
.overwrite_output()
.run(capture_stderr=True)
)
except ffmpeg.Error as ex:
print("FFMPEG: error converting video")
raise Exception("Failed transcode") |
do you get the answer? |
Thank you for your contributions and for reporting issues in this repository. With the release of v2, which introduces significant changes to the codebase and API, we’ve reviewed the backlog of open PRs and issues. Due to the length of the backlog and the likelihood that many of these are either fixed or no longer applicable, we’ve made the decision to close all previous PRs and issues. If you believe that any of these are still relevant to the current version or if you'd like to reopen a related discussion, please feel free to create a new issue or pull request, referencing the old one. Thank you for your understanding and continued support! |
ffmpeg 4.0 has released the
NVIDIA NVDEC-accelerated H.264, HEVC, MJPEG, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding
added.see more ffmpeg 4.0 NVENC
my ffmpeg
Here is my idea:
ffmpeg_reader.py
inmoviepy
moviepy/video/io/ffmpeg_reader.py
line89-95I guess the
cmd
is made up of multiple parameters, so I modified as the followingBUT, I got :
check the file '
moviepy/video/io/ffmpeg_reader.py
line 135-140maybe
not hasattr(self, 'lastread')
is the problem.Is there another way to solve this problem?
The text was updated successfully, but these errors were encountered: