Skip to content

Instantly share code, notes, and snippets.

@mark-kubacki
Last active March 30, 2024 21:25
Show Gist options
  • Save mark-kubacki/ed9d6aa124d39be6d7e8770c1d748b6c to your computer and use it in GitHub Desktop.
Save mark-kubacki/ed9d6aa124d39be6d7e8770c1d748b6c to your computer and use it in GitHub Desktop.
make Proxies for video cutting in Davinci Resolve
Param(
$outdir
)
function Show-Notification {
[CmdletBinding()]
Param (
[string] $Title,
[string] [parameter(ValueFromPipeline)] $Text
)
Add-Type -AssemblyName System.Windows.Forms
$global:balloon = New-Object System.Windows.Forms.NotifyIcon
$path = (Get-Process -Id $pid).Path
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Info
$balloon.BalloonTipTitle = $Title
$balloon.BalloonTipText = $Text
$balloon.Visible = $true
$balloon.ShowBalloonTip(0)
}
Get-ChildItem DJI*_D.MP4 | ForEach-Object {
if (Test-Path -path ($outdir + "\" + $_.Name)) {
return
}
ffmpeg -y -hide_banner -nostdin `
-hwaccel dxva2 `
-i $_.FullName -map 0:v:0 -map 0:a? -map_metadata:s:v "-1" `
-c:a copy `
-s "-2:720" -c:v h264_amf -usage "lowlatency_high_quality" -quality speed `
-tag:v avc1 `
($outdir + "\" + $_.Name)
}
Show-Notification "Encoding" "It’s done!"
#!/bin/bash
# Makes proxy videos for cutting.
set -upo pipefail
mkdir -p ProxyItems
declare -i rotation err=0
sources=( DJI*_D.MP4 )
for fname in "${sources[@]}"; do
if [[ -s "ProxyItems/${fname}" ]]; then continue; fi
ffmpeg -y -hide_banner -nostdin \
-hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \
-i "${fname}" -map 0:v:0 -map "0:a?" -map_metadata:s:v "-1" \
-c:a copy \
-c:v h264_vaapi -vf "format=vaapi,scale_vaapi=-2:720:format=nv12" -profile:v high -crf 21 -b: 6400K \
-tag:v avc1 \
"ProxyItems/${fname}"
err=$?
if [[ -e "ProxyItems/${fname}" && ! -s "ProxyItems/${fname}" ]]; then rm "ProxyItems/${fname}"; fi
if (( $err > 0 )); then break; fi
let rotation=0
if rotation=$(ffprobe -v 0 -select_streams v:0 -show_entries stream_side_data=rotation -of default=nw=1:nk=1 "${fname}") && \
(( rotation != 0 ))
then
exiftool -rotation=$(( -rotation )) -overwrite_original "ProxyItems/${fname}" &
fi
done
wait
exit $err
@mark-kubacki
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment