slyfox1186

FFmpeg - Loop all vids, add thumbnail, and encode with x265

Dec 9th, 2019
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.41 KB | None | 0 0
  1. rem this script will loop all mkv files in folder
  2. rem it will create a single jpg from the mkv video found and embed it in the output video
  3. rem it will rename the video output by appending the text "(1080p)" to the end of file name
  4. rem at it will -map the video stream and name the stream "set title="%%~nI" (mkv video's name)
  5. rem it will capture audio stream 0:2 and name it "Surround 5.1 (DTS)"
  6. rem it will re-encode audio stream 0:2 to eac encoder
  7. rem it will delete the jpg at the end of encoding
  8.  
  9. @echo off
  10. setlocal enabledelayedexpansion
  11. prompt $g
  12. color 0a
  13.  
  14. pushd "%~dp0"
  15.  
  16. set FF=C:\MAB\local64\bin-video\ffmpeg.exe
  17.  
  18. :: create cover art jpg file
  19. for %%G in (*.mkv) do (
  20. %FF% -hide_banner -ss 30 -y -i "%%G" -vframes 1 -an cover.jpg
  21. )
  22.  
  23. :: run ffmpeg x265
  24. for %%I in (*.mkv) do (
  25. set fname="%%~nxI"
  26. set title="%%~nI"
  27. set fout="%%~nI(1080p).mkv"
  28. call :runFF !fname! !title! !fout!
  29. del /s /q *.jpg
  30. pause
  31. goto:eof
  32. )
  33.  
  34. :runFF
  35. %FF% ^
  36. -y ^
  37. -i "%~1" ^
  38. -attach cover.jpg ^
  39. -map_metadata 0 ^
  40. -map_chapters 0 ^
  41. -metadata title="%~2" ^
  42. -map 0:0 -metadata:s:v:0 language=eng -metadata:s:s:0 language=eng -metadata:s:s:0 title="English" -metadata:s:t:0 filename="cover.jpg" -metadata:s:t:0 mimetype="image/jpeg" ^
  43. -map 0:2 -metadata:s:a:0 language=eng -metadata:s:a:0 title="Surround 5.1 (DTS)" ^
  44. -c:v libx265 -preset medium -crf 20 -vf "scale=1920:-1" -threads 0 ^
  45. -c:a ac3 -b:a 640k -ac 6 ^
  46. "%~3"
  47. exit /b
Add Comment
Please, Sign In to add comment