Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: created by slyfox1186
- :: stackoverflow.com https://stackoverflow.com/users/10572786/slyfox1186
- :: pastebin.com https://pastebin.com/u/slyfox1186/1/0/1/?o=h1
- @ECHO
- SETLOCAL
- TITLE FFMPEG CONVERT X264 TO X265
- PROMPT $G
- COLOR 0A
- REM This script was inspired by Endoro's expanded script (https://stackoverflow.com/a/16891696/10572786).
- REM This batch script will recursively search for all .mp4 files that don't have (x265) in the file name. Any valid results will be encoded with x265 using FFmpeg. The original .mp4 file will remain unchanged in it's original folder with the new x265 version.
- REM Example: %PATH%\A.mp4 > %PATH%\A(x265).mp4
- REM If you don't have ffmpeg.exe on your PC you must download or build it with Microsoft Visual Studios. I recommend you download and run media autobuild suite on GitHub: (https://github.com/jb-alvarado/media-autobuild_suite).
- REM Once ffmpeg is compiled/downloaded make sure to set it's folder path as an environmental variable in Windows before running the script or include the full path and make changes below as necessary. Change the working directory to your .mp4 files root folder.
- REM !!BEGIN SCRIPT!!
- REM Replace USER with your username.
- pushd C:\Users\%USER%\OneDrive\Desktop\Vids\
- REM Set mp4PATH to the root folder you wish to recursively search.
- SET "mp4PATH=C:\Users\%USER%\OneDrive\Desktop\Vids\"
- REM Create empty convert file.
- COPY NUL "convert_movies.bat" >NUL 2>&1
- REM Add ECHO off.
- ECHO @ECHO off >>"convert_movies.bat"
- REM Recursively search root folder.
- FOR /R "%mp4PATH%" %%G IN (*.mp4) DO (
- SET "fpath=%%~fG"
- SET "fname=%%~nG"
- SETLOCAL enabledelayedexpansion
- REM Ignore all files that have "(x265)" in the file name.
- IF "!fname!"=="!fname:*(x265)=!" (
- CALL :DO_FFmpeg_CLI "!fpath!"
- ECHO(>>"convert_movies.bat"
- ) ELSE ENDLOCAL
- )
- GOTO:EOF
- REM CALL variables for use in FFmpeg's command line.
- :DO_FFmpeg_CLI
- IF "%~1"=="" GOTO:EOF
- FOR %%A IN ("%~1") DO (
- SET "Folder=%%~dpA"
- SET "Name=%%~nxA"
- )
- REM Export info to "convert_movies.bat and run ffmpeg.exe's command line in the cmd.exe window.
- ECHO ffmpeg -y -i "%~1" -c:v libx265 -preset slow -crf 18 -c:a aac "%Folder%%~n1(x265).mp4">>"convert_movies.bat" && ffmpeg | ffmpeg -y -i "%~1" -c:v libx265 -preset slow -crf 18 -c:a aac "%Folder%%~n1(x265).mp4"
- PAUSE
- ENDLOCAL
- EXIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement