Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2025
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. :: Look for all .webm files in the directory
  5. for %%f in (*.webm) do (
  6. set "filename=%%~nf"
  7. set "fullfile=%%f"
  8.  
  9. :: Use string manipulation to extract the audio URL
  10. for /f "tokens=2 delims=[]" %%a in ("!filename!") do (
  11. set "tag=%%a"
  12. for /f "tokens=2 delims==" %%b in ("!tag!") do (
  13. set "escaped_url=%%b"
  14. set "url=!escaped_url:%%2F=/!"
  15.  
  16. :: Decode %2F to / (you can add more decode cases if needed)
  17. set "url=!url:%%2E=.!"
  18. set "url=!url:%%3A=:!"
  19. set "url=!url:%%3F=?!"
  20. set "url=!url:%%26=&!"
  21. set "url=!url:%%3D==!"
  22.  
  23. :: Generate base name (remove [sound=...] tag)
  24. set "basename=%%~nf"
  25. for /f "tokens=1 delims=[" %%c in ("!basename!") do (
  26. set "basename=%%c"
  27. )
  28.  
  29. echo Processing !fullfile! with audio from !url!
  30.  
  31. :: Download the audio
  32. curl -L -o "temp_audio.mp3" "!url!"
  33.  
  34. :: Combine video and audio
  35. ffmpeg -y -i "!fullfile!" -i "temp_audio.mp3" -c:v copy -c:a aac -shortest "!basename!.mp4"
  36.  
  37. del temp_audio.mp3
  38. )
  39. )
  40. )
  41.  
  42. echo Done.
  43. pause
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement