Skip to content

Commit

Permalink
Fix GPU h264_nvenc encoding not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomofa committed Feb 24, 2024
1 parent bc8d1a8 commit e798541
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions moviepy/video/io/ffmpeg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ def __init__(
]
if audiofile is not None:
cmd.extend(["-i", audiofile, "-acodec", "copy"])
cmd.extend(["-vcodec", codec, "-preset", preset])

if (codec == "h264_nvenc") :
cmd.extend(["-c:v", codec])
else :
cmd.extend(["-vcodec", codec])

cmd.extend(["-preset", preset])

if ffmpeg_params is not None:
cmd.extend(ffmpeg_params)
if bitrate is not None:
Expand All @@ -129,8 +136,9 @@ def __init__(
if threads is not None:
cmd.extend(["-threads", str(threads)])

if (codec == "libx264") and (size[0] % 2 == 0) and (size[1] % 2 == 0):
if (codec == "libx264" or codec == "h264_nvenc") and (size[0] % 2 == 0) and (size[1] % 2 == 0):
cmd.extend(["-pix_fmt", "yuv420p"])

cmd.extend([filename])

popen_params = cross_platform_popen_params(
Expand Down

0 comments on commit e798541

Please sign in to comment.