Skip to content

Instantly share code, notes, and snippets.

@abakum
Last active August 1, 2022 13:27
Show Gist options
  • Save abakum/2c8c321dd7634b303b6c594b5ed80ac5 to your computer and use it in GitHub Desktop.
Save abakum/2c8c321dd7634b303b6c594b5ed80ac5 to your computer and use it in GitHub Desktop.
Convert .mov files with pcm to .mkv files with flac as DaVinci Resolve helper
SetLocal EnableExtensions EnableDelayedExpansion
:forfiles
if "%~1"=="nul" (
call :doit "%~2"
goto :EOF
)
:main
if "%~1"=="" (
if not exist "%UserProfile%\SendTo\%~n0.lnk" (
if defined ChocolateyInstall (
"%ChocolateyInstall%\tools\shimgen.exe" -o "%UserProfile%\SendTo\%~n0.exe" -p "%~f0"
) else (
copy /b "%~f0" "%UserProfile%\SendTo\%~nx0"
)
echo "%~f0" is placed in "%UserProfile%\SendTo"
)
)
echo Convert .mov files with pcm to .mkv files with flac
echo Run "MOV2MKV.bat" without parameters to place it in "%UserProfile%\SendTo"
echo Send files or dirs: "c:\d\e.mov" "c:\e" ... to "MOV2MKV"
echo or drop it to "MOV2MKV.bat"
echo Then look at "z:\d\e.mov" "z:\e""
rem choco install ffmpeg
set cmd="cmd /c "%~f0" nul "@path""
:loop
if "%~1"=="" (
echo Thanks Chocolatey https://chocolatey.org
echo Thanks DaVinci Resolve https://www.blackmagicdesign.com/products/davinciresolve
echo Thanks FFmpeg https://ffmpeg.org
pause
goto :EOF
)
forfiles /s /p "%~1" /m *.mov /c %cmd% 2>nul||call :doit "%~1"
shift
goto :loop
:doit
if not exist "%~f1" goto :EOF
if /i not ".mov"=="%~x1" goto :EOF
set flac=-1 -c:a flac
ffprobe -v error -i "%~f1" -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1|find "pcm"
if ERRORLEVEL 1 set flac=0 -c:a copy
ffmpeg -i "%~f1" -c:v copy -metadata title="%~n1" -map_metadata 0:g -map_metadata:s:v 0 -map_metadata:s:a %flac% -y "z:%~pn1.mkv"
@abakum
Copy link
Author

abakum commented Jul 24, 2022

Run "MOV2MKV.bat" without parameters to place it in "%UserProfile%\SendTo"
Send files or dirs: "c:\d\e.mov" "c:\e" ... to "MOV2MKV"
or drop it to "MOV2MKV.bat"
Then look at "z:\d\e.mov" "z:\e""

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