Last active
December 23, 2024 23:09
-
-
Save samilkorkmaz/1adb1dd26bbdc60cb3ac42e15d97e51b to your computer and use it in GitHub Desktop.
Convert mp3 files to mp4 files with a static cover image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Convert all mp3 files inside the folder to mp4 files using ffmpeg | |
:: Each mp3 file should have a correponding png file with name of the form cover1.png | |
:: Şamil Korkmaz, 11 July 2024 | |
@echo off | |
setlocal enabledelayedexpansion | |
set count=1 | |
for %%f in (*.mp3) do ( | |
echo input mp3: %%f | |
set "coverImage=cover!count!.png" | |
echo count: !count! | |
echo coverImage: !coverImage! | |
if not exist "!coverImage!" ( | |
echo Error: Cover image !coverImage! not found. | |
goto :eof | |
) | |
set "inFile=%%f" | |
set "baseName=%%~nf" | |
set "outFile=!baseName!.mp4" | |
if not exist "!inFile!" ( | |
echo Error: Input file !inFile! not found. | |
goto :eof | |
) | |
echo Creating video !outFile! from audio !inFile! with cover image !coverImage!... | |
ffmpeg -loop 1 -i "!coverImage!" -i "!inFile!" -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest "!outFile!" | |
if !errorlevel! neq 0 ( | |
echo Error occurred during conversion of !inFile!. | |
) else ( | |
echo Conversion of !inFile! completed successfully. | |
) | |
set /a count+=1 | |
) | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
greattttttttttttt, it works
put all mp3 files and cover files in same folder
length and width of cover1.png has to divisible by 2
install ffmeg by this video :- https://www.youtube.com/watch?v=JR36oH35Fgg
then run the bat file in command prompt