Skip to content

Commit

Permalink
Fix hybrid encoding
Browse files Browse the repository at this point in the history
Needed MKV

Closes #41
  • Loading branch information
nelsonjchen committed Sep 24, 2023
1 parent 17c1a47 commit bf182d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions clip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ if [ "$NVIDIA_DIRECT_ENCODING" = "on" ]; then
elif [ "$NVIDIA_HYBRID_ENCODING" = "on" ]; then
# Directly encode with nvidia hardware to the target file with the smear amount also recorded.
# Then lop it off with copy mode.
ffmpeg -framerate "$RECORD_FRAMERATE" -video_size 1920x1080 -f x11grab -draw_mouse 0 -i :0.0 -vcodec h264_nvenc -preset llhp -b:v "$TARGET_BITRATE" -maxrate "$TARGET_BITRATE" -g 20 -r 20 -filter:v "setpts=$SPEEDHACK_AMOUNT*PTS,scale=1920:1080,$DRAW_TEXT_FILTER" -y -t "$RECORDING_LENGTH_PLUS_SMEAR" "$VIDEO_OUTPUT"
ffmpeg -framerate "$RECORD_FRAMERATE" -video_size 1920x1080 -f x11grab -draw_mouse 0 -i :0.0 -vcodec h264_nvenc -preset llhp -b:v "$TARGET_BITRATE" -maxrate "$TARGET_BITRATE" -g 20 -r 20 -filter:v "setpts=$SPEEDHACK_AMOUNT*PTS,scale=1920:1080,$DRAW_TEXT_FILTER" -y -t "$RECORDING_LENGTH_PLUS_SMEAR" "$VIDEO_RAW_OUTPUT"
cleanup
ffmpeg -y -i "$VIDEO_OUTPUT" -ss "$SMEAR_AMOUNT" -c:v copy -movflags +faststart -f MP4 "$VIDEO_OUTPUT"
ffmpeg -y -ss "$SMEAR_AMOUNT" -i "$VIDEO_RAW_OUTPUT" -vcodec copy -movflags +faststart -f MP4 "$VIDEO_OUTPUT"
elif [ "$NVIDIA_FAST_ENCODING" = "on" ]; then
# Directly save the full video, then reencode with acceleration /cut it so the smear amount is cut off the front.
# For some reason, when Nvidia "direct" encoding is used, the first few frames stutter on CPU bound systems.
Expand Down
2 changes: 1 addition & 1 deletion predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def predict(
f"--speedhack-ratio={speedhackRatio}",
f"--target-mb={fileSize}",
f"--nv-hardware-rendering",
f"--nv-hybrid-encoding",
f"--data-dir={data_dir}",
f"--output=cog-clip.mp4",
]
command.append("--nv-direct-encoding")
# if debugCommand != "":
# # Run bash with the command
# command = ["bash", "-c", debugCommand]
Expand Down

0 comments on commit bf182d8

Please sign in to comment.