I need some help with bulk combining hundreds of audio files (mp3s) that I fully own with the same picture to create mp4 files with identical names as the audios. It would be even better if I could do this on a parent directory with the audio files spread out in subdirectories rather than have all the audios in one large folder.
I've tried using ffmpeg but am unable to do this in batch and on files with names that includes spaces. There are also seems to be some discrepancies between different ffmpeg versions but I'm using the latest one (20171229)
Edit:
I've used the following command for single files and no spaces but have been unable to write something for bulk action ffmpeg -loop 1 -framerate 2 -i input.png -i audio.m4a -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest -pix_fmt yuv420p output.mkv
These are the references and commands that I've used without any success
https://forum.videohelp.com/threads/354099-Batch-combining-jpg-with-audio#post2225351
https://stackoverflow.com/questions/13688374/ffmpeg-batch-image-multiple-audio-to-video
+ Reply to Thread
Results 1 to 26 of 26
-
Last edited by MD_89; 31st Dec 2017 at 11:27.
-
With the picture as metadata or a video track?
files with names that includes spaces -
A separate picture, i.e. not the cover art. But I want to use the same picture for each audio/video
Edit: I want to use the picture as a still in the videosLast edited by MD_89; 31st Dec 2017 at 11:35.
-
Subdirectories can be tricky and or you will write result in same subfolder as source (e.g. %~f1 Expand %1 to a Fully qualified path name for output) or you need to recreate first subdirectory structure in some other place.
Spaces in name and in folder can be very tricky for ffmpeg (not for windows environment) and even quotation may not work, i usually use variable as it seem to be processed correctly by ffmpeg however some limitations still exist - i assume special escaping is required from ffmpeg perspective. -
With Picture.jpg being you picture you could try a batch job like (Windows) for your d: drive:
Code:for /f "tokens=*" %%g in ('dir /b /s "d:\*.mp3"') do ( ffmpeg -loop 1 -i "Picture.jpg" -i "%%g" -c:a copy -c:v libx264 -shortest "%%~ng.mp4" )
-
Fine, I'll give up on subdirectories, although I don't mind if the videos end up the source folders, in the same structure elsewhere or in one folder. That's less of a problem.
Any other tips? It doesn't have to be ffmpeg. However, that's the only free solution I found that would allow me to select the background picture of the video, does not watermark the videos and works in bulk -
Thank you, but I made one big silly mistake. I used the word batch as a synonym for bulk and now realise that's something else. Will this solution work if I just run CMD as usual and run this script?
When I run it, it says that my picture with that name (which is in the directory) does not existLast edited by MD_89; 31st Dec 2017 at 12:03.
-
picture.jpg must be in the same folder as the the batch file*. Or just use the full path to the image.
* This may vary depending on what OS you are running. I seem to recall that old versions of Windows ran batch files in C:\users\username\ rather than the folder in which they appear.Last edited by jagabo; 31st Dec 2017 at 13:11.
-
I added the full url and received a error with a link to the picture and "Invalid argument"
When I added the picture to C:\users\username\, I got error saying "%%g: No such file or directory"
I'm using Windows 10. -
Update:
I got it to work by only using one % instead of two (since I didn't run it in batch). However the output folder became C:\users\username\. Is there any way that I can change that? -
-
-
Make a batch file with:
Code:for /R %%g in ("*.mp3") do ( ffmpeg -loop 1 -i "Bud_009.jpg" -i "%%g"^ -map_metadata 1^ -map_metadata:s:v 1:s:v^ -map_metadata:s:a 1:s:a^ -c:a copy -c:v libx264^ -shortest "%%~dpng.mp4" )
[Attachment 44252 - Click to enlarge]
[Attachment 44253 - Click to enlarge] -
If you can live with an all black (or other color) video instead of a jpg image you can get much faster conversions with something like:
Code:for /R %%g in ("*.mp3") do ( "G:\Program Files\ffmpeg\bin\ffmpeg.exe" -y -f lavfi -i color=c=black:s=640x480:r=1.0 -i "%%g"^ -map_metadata 1^ -map_metadata:s:v 1:s:v^ -map_metadata:s:a 1:s:a^ -c:a copy -c:v libx264 -preset ultrafast -tune stillimage^ -shortest "%%~dpng.mp4" )
-
-
One other thing you can do to speed up processing is reduce the frame rate (1 fps instead of the default 25 fps?) before importing the image. Using a fast preset for x264lib and stillimage tuning will help too. Those changes increased the encoding rate by about 20 fold on my computer. Some programs/devices might have trouble with 1 fps. though.
Budman1's batch file (and hence my mod) produces an empty mp4 file if the mp3 file has no metadata.Last edited by jagabo; 1st Jan 2018 at 12:55.
-
Do you mind explaining how I can do those things? I'm completely new to scripts.
Also, is there any way to solve the problem of empty mp4 files when the mp3 files have no metadata?
I'm also curious about how the script would look like if I instead wanted to use a different picture depending on which folder the mp3 file is in, i.e. using the picture titled "Image.jpg" that is found in the same folder as the mp3 files, instead of using the same picture for all mp3 files.
I'm very grateful for all help thus far and realise you have better things to do than to answer my questions so feel free to ignore these requests if you've had enough of this -
Faster processing using Budman1's batch file:
Code:for /R %%g in ("*.mp3") do ( ffmpeg -r 1.0 -loop 1 -i "Bud_009.jpg" -i "%%g"^ -map_metadata 1^ -map_metadata:s:v 1:s:v^ -map_metadata:s:a 1:s:a^ -c:a copy -c:v libx264 -preset superfast -tune stillimage^ -shortest "%%~dpng.mp4" )
Using a different image for each folder for each is easy if you put the images in the folders. Then you can just change
Code:-i "Bud_009.jpg"
Code:-i "%%~dpgBud_009.jpg"
-
-
-
-
I followed the above instructions but am having three issues
1. As for md_89, the screen is black initially
2. The quality of the image that is used appears somewhat reduced with this script. How can I ensure a high resolution of the image without it resulting ridiculously large files and slow processing?
3. Finally and most importantly, I get the following error on some files: "track 1: muxing mp3 at *** is not standard". How can I address this in bulk without losing audio quality? Should I re-encode or stream copy all audios first? Can I do it in the same instance as I merge the files? Any suggestions on scripts? -
Some players don't like slow frame rates like 1 fps. Try changing the frame rate to a more normal video frame rate like 24 fps or 30 fps. The resulting file will be bigger and it will take longer to encode. Or use a different player.
Video is normally encoded with the colors at half the resolution (each axis). So you expect to see very small colored text and objects, and sharp colored edges, become blurry. For example:
https://forum.videohelp.com/threads/319360-DVD-LAB-PRO-color-map#post1977264
Are you seeing something worse than that?
What's the exact error message? Is it VBR or CBR mp3?Last edited by jagabo; 28th Nov 2018 at 19:43.
-
I don't know about VBR vs CBR. This is the error message that I was referring to (The number of hz varies though):
Code:[mp4 @ 00000182ecf7e500] track 1: muxing mp3 at 11025hz is not standard, to mux anyway set strict to -1 Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument Error initializing output stream 0:0 --
I also noticed another "red error message" that reads: "Stream specifier v does not match any streams."
Consequently, those audios aren't converted. Any suggestions on how I can address this?
Finally, I also get this following "yellow error message":
Code:[mp3 @ 0000026a489a6300] Estimating duration from bitrate, this may be inaccurate
Last edited by DennisO; 29th Nov 2018 at 08:52.
-
Probable errors show up if you include
'-map_metadata:v 1
:v^'
Remove that portion.
Also tried playing resulting MP4 in VLC and there is indeed a Black screen at the beginning. Apparently it doesn't like to show the image until the audio starts, which is after the image which had no audio. Windows Media player and Potplayer do not show the Black screen.
There is no Black frames as tested with FFprobe and Avisynth.:
[Attachment 47346 - Click to enlarge]
Similar Threads
-
Combining mkv files (video, audio, subtitles) to create a proper episode...
By Cinderwolf in forum Newbie / General discussionsReplies: 2Last Post: 26th Dec 2017, 21:16 -
Combining multiple MTS files into one with transitions
By Cyber Akuma in forum Newbie / General discussionsReplies: 12Last Post: 9th Jul 2015, 06:55 -
combining two mp4 files into one..how?!?
By illuro in forum Newbie / General discussionsReplies: 6Last Post: 16th May 2015, 19:40 -
What program can batch convert JUST audio of .mp4 files then re-mux?
By Whitezombie455 in forum Video ConversionReplies: 18Last Post: 25th Jan 2015, 09:36 -
Create multiple AVI files in batch from sets of JPEGs
By MRICE in forum Newbie / General discussionsReplies: 4Last Post: 23rd Oct 2014, 11:13