# Need Help to Convert 600 mp3 to mp4 with just one still pic in it for YT

1. Hi All..
Newbie here to ask for help. I have 600 mp3 audio files. i want to post those on youtube but since youtube doesnt take mp3 so i have to convert them to video format mp4. For video i want to attach just one still pic for all those mp4 files. Plz suggest a software (preferably free) in which i can set a pic path for the one image file i have and set mp4 variables to batch-process all 600 mp3 files in one go. I tried FREEMAKE which can batch process all mp3 to mp4 but the problem is FREEMAKE asks to input Pic separately for each file which means probably some 1800+ clicks for these 600 files Anyone plz guide.
Dr. Bukhari
2. Using FFmpeg in Windows, this command will encode all your MP3s:

for %F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i %F -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a copy -shortest %~nF.mp4
3. Appreciate the help JVRaines (Y) but unfortunately being a novice i wont be able to do it from command line unless i learn a few basics about it. However i save it as a last resort if i couldnt find any Software Program with some interface (dunno what its called technically, GUI perhaps)
4. Originally Posted by JVRaines
Using FFmpeg in Windows, this command will encode all your MP3s:

for %F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i %F -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a copy -shortest %~nF.mp4
Just as a startup .. i went to command prompt ..
then D: (my hard drive is D)
cd F (F is the folder where i placed ffmpeg portable files)
cd Bin (bin is the folder where ffmpeg.exe and other 2 exe files are present)
[in this Bin folder i placed 2 mp3 files named 1.mp3 and 2.mp3 and one image file p.jpg

now plz guide which variable to tune and perform this command you told Sir
ffmpeg.exe -loop 1 -i my_image.jpg -i %F -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a copy -shortest %~nF.mp4

which command should i input there now considering mp3 and pic file names i mentioned?
5. SOME SUCCESS.. just using some common sense (as much as there is in old person of 70 years age) i gave this command

ffmpeg.exe -loop 1 -i m.jpg -i 1.mp3 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a copy -shortest 1.mp4

My input 1.mp3 was 4.71 MB and 128kbps and duration 00:04:34
Output file 1.mp4 got generated after 6 minutes with size 13MB , same duration, 25fps, video 1920x1080 at 262kbps and audio 128kbps

Issues now are:
1. is the conversion speed (showing in command window) 0.8x Okay? or there is some way to fine tune it?
2. while i succeeded after input of one of mp3 file (thanx to you) how to do with rest of 599 files? cant go one by one like this... where am i making mistake? plz specify.
3. If i want just 640x480 screen size of resultant video, what wud be the change in the command line you gave.

Thanx again JVRaines for help.. am so pleased at least i tried n got some partial success.. in this age
6. Put this in a batch file (named mp3_to_mp4.bat, for example) along with my_image.jpg and some mp3 files. Then double click on the batch file.

Code:
for %%F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i "%%F" -vf scale=640:-2 -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
pause
It will create an mp4 for each mp3 file with the image scaled to 640 by whatever height is needed to maintain aspect ratio.

Unfortunately, looping an image like this is very slow in ffmpeg, especially with large images. If your image is large scale it to 640x480 before running the batch file (and you won't need the "-vf scale=640:-2" in the batch file. With a 640x480 image I get about 12x realtime (quad core desktop).

Since you are using the same image for every mp3 file you can greatly speed things up by encoding the video first, then using that video in your batch conversion. I went from 20 seconds per mp3 file (~4 minutes each) to less than 1 second each.

Code:
for %%F in (*.mp3) do ffmpeg.exe -i my_image.mp4 -i "%%F" -c:v copy -c:a copy -shortest "%%~nF.mp4"
pause
Just make sure you video is longer than the longest mp3 file.
7. As jagabo wisely suggests, you can first encode the video stream from the image file:

ffmpeg.exe -loop 1 -i m.jpg -c:v libx264 -tune stillimage -pix_fmt yuv420p -s 640x480 -t mm:ss m.mp4

replacing mm:ss with a duration that is longer than your longest MP3 file. Then you can run this command to loop over all your MP3 files:

for %F in (x:\input\path\to\*.mp3) do ffmpeg.exe -i m.mp4 -i "%F" -c copy -shortest "x:\output\path\to\%~nF.mp4"

replacing x:\in(out)put\path\to\ with the appropriate paths to where your MP3 files are stored and where you would like the finished files to go.
8. By the way, the differences between the commands that JVRains and I are using are because of the differences between running directly from the command line vs. from a batch file. From the command line you only need one % in "%F", but from a batch file you need two "%%F".
9. Originally Posted by jagabo
Put this in a batch file (named mp3_to_mp4.bat, for example) along with my_image.jpg and some mp3 files. Then double click on the batch file.

Code:
for %%F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i "%%F" -vf scale=640:-2 -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
pause
It will create an mp4 for each mp3 file with the image scaled to 640 by whatever height is needed to maintain aspect ratio.

Unfortunately, looping an image like this is very slow in ffmpeg, especially with large images. If your image is large scale it to 640x480 before running the batch file (and you won't need the "-vf scale=640:-2" in the batch file. With a 640x480 image I get about 12x realtime (quad core desktop).

Since you are using the same image for every mp3 file you can greatly speed things up by encoding the video first, then using that video in your batch conversion. I went from 20 seconds per mp3 file (~4 minutes each) to less than 1 second each.

Code:
for %%F in (*.mp3) do ffmpeg.exe -i my_image.mp4 -i "%%F" -c:v copy -c:a copy -shortest "%%~nF.mp4"
pause
Just make sure you video is longer than the longest mp3 file.
Thanx first.. i understood the first Code.. but about the 2nd Code in ur reply, i got confused. Plz tell if you are asking to prepare a video image.mp4 by myself separately and then keep it in that folder? Also 2nd thing is.. i got all 600 mp3 with different duration.. so it will be really difficult to make videos for each mp3
10. Originally Posted by JVRaines
As jagabo wisely suggests, you can first encode the video stream from the image file:

ffmpeg.exe -loop 1 -i m.jpg -c:v libx264 -tune stillimage -pix_fmt yuv420p -s 640x480 -t mms m.mp4

replacing mms with a duration that is longer than your longest MP3 file. Then you can run this command to loop over all your MP3 files:

for %F in (x:\input\path\to\*.mp3) do ffmpeg.exe -i m.mp4 -i "%F" -c copy -shortest "x:\output\path\to\%~nF.mp4"

replacing x:\in(out)put\path\to\ with the appropriate paths to where your MP3 files are stored and where you would like the finished files to go.
Thank you so much again.. i understood the code except --> mms .. now this is what i dont want to do for each of 600 mp3 files.
11. Results when i executed a go.bat file with this code
for %%F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i "%%F" -vf scale=640:-2 -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
pause

Speed was 1.39 this time as shown while processing (too low i think)
and while i played one output mp4 file in MPC player it gave these properties.

Video: MPEG4 Video (H264) 640x360 25fps 27kbps [V: h264 high L3.0, yuv420p, 640x360, 27 kb/s]
Audio: MP3 44100Hz stereo 128kbps [A: mp3, 44100 Hz, stereo, 128 kb/s]
Audio: MP3 44100Hz stereo 127kbps [A: SoundHandler (mp3, 44100 Hz, stereo, 127 kb/s)]

why am i getting 2 audio lines instead of one as nomally we get? this additional "sound handler" line appears from where?
Will youtube be able to process despite this?
12. Originally Posted by Love
Results when i executed a go.bat file with this code
for %%F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i "%%F" -vf scale=640:-2 -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
pause

Speed was 1.39 this time as shown while processing (too low i think)
The processing is faster or slower depending on the size of the source image. I get about 12x if the source image is already 640 pixels wide. With a 320x240 image being upscaled to 640x480 I get about 25x. With a 1280x960 image downscaled to 640x480 I get about 4x. With a 4000x3000 image it was 0.1x.

But once again, since you are using the same image for every mp3 file there's no need to encode a video for each one. Create one long video file first and then simply remux that video with each mp3 file. ffmpeg showed a speed of 4000x when doing this.

Originally Posted by Love
and while i played one output mp4 file in MPC player it gave these properties.

Video: MPEG4 Video (H264) 640x360 25fps 27kbps [V: h264 high L3.0, yuv420p, 640x360, 27 kb/s]
Audio: MP3 44100Hz stereo 128kbps [A: mp3, 44100 Hz, stereo, 128 kb/s]
Audio: MP3 44100Hz stereo 127kbps [A: SoundHandler (mp3, 44100 Hz, stereo, 127 kb/s)]

why am i getting 2 audio lines instead of one as nomally we get? this additional "sound handler" line appears from where?
Will youtube be able to process despite this?
That appears to be some quirk in MPC. I see the same in MPCHC. But MediaInfo reports only one audio stream. Several other players I tried showed only one audio stream. Even the output of ffmpeg while it's encoding show only one audio track.
13. Originally Posted by Love
but about the 2nd Code in ur reply, i got confused. Plz tell if you are asking to prepare a video image.mp4 by myself separately and then keep it in that folder?
Yes.

Originally Posted by Love
Also 2nd thing is.. i got all 600 mp3 with different duration.. so it will be really difficult to make videos for each mp3
You don't need to make a video for each mp3. You make one long video (with no audio). When you use second the batch file I gave "-shortest" cuts the video to match the audio length. I recommend you create the video with fairly short GOPs -- say, 25 frames at 25 fps.
14. Originally Posted by jagabo
Originally Posted by Love
Results when i executed a go.bat file with this code
for %%F in (*.mp3) do ffmpeg.exe -loop 1 -i my_image.jpg -i "%%F" -vf scale=640:-2 -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy -shortest "%%~nF.mp4"
pause

Speed was 1.39 this time as shown while processing (too low i think)
The processing is faster or slower depending on the size of the source image. I get about 12x if the source image is already 640 pixels wide. With a 320x240 image being upscaled to 640x480 I get about 25x. With a 1280x960 image downscaled to 640x480 I get about 4x. With a 4000x3000 image it was 0.1x.

But once again, since you are using the same image for every mp3 file there's no need to encode a video for each one. Create one long video file first and then simply remux that video with each mp3 file. ffmpeg showed a speed of 4000x when doing this.

Originally Posted by Love
and while i played one output mp4 file in MPC player it gave these properties.

Video: MPEG4 Video (H264) 640x360 25fps 27kbps [V: h264 high L3.0, yuv420p, 640x360, 27 kb/s]
Audio: MP3 44100Hz stereo 128kbps [A: mp3, 44100 Hz, stereo, 128 kb/s]
Audio: MP3 44100Hz stereo 127kbps [A: SoundHandler (mp3, 44100 Hz, stereo, 127 kb/s)]

why am i getting 2 audio lines instead of one as nomally we get? this additional "sound handler" line appears from where?
Will youtube be able to process despite this?
That appears to be some quirk in MPC. I see the same in MPCHC. But MediaInfo reports only one audio stream. Several other players I tried showed only one audio stream. Even the output of ffmpeg while it's encoding show only one audio track.
Thanx.. got it.. will install mediainfo (Y)
15. Originally Posted by Love
Thank you so much again.. i understood the code except --> mms .. now this is what i dont want to do for each of 600 mp3 files.
That stands for "minutes and seconds." Supply a value which is longer than your longest MP3. For example, if your longest MP3 is 4 minutes and 26 seconds long, then you could supply the value "05:00". You are creating ONE video file that will be used in the second command, which will handle all of your MP3s AT ONCE. You only have to enter these two commands.
16. Originally Posted by JVRaines
Originally Posted by Love
Thank you so much again.. i understood the code except --> mms .. now this is what i dont want to do for each of 600 mp3 files.
That stands for "minutes and seconds." Supply a value which is longer than your longest MP3. For example, if your longest MP3 is 4 minutes and 26 seconds long, then you could supply the value "05:00". You are creating ONE video file that will be used in the second command, which will handle all of your MP3s AT ONCE. You only have to enter these two commands.
Thanx.. yes i had got that it was about minutes and seconds but was worried about executing it before every mp3

Job done. Bundle of thanx to all who participated (Y) Thanx to Admins of Forum too (Y)

Statistics