I need a button that will merge the selected mp3 files in the current source path into one new mp3 into the same path. I guess ffmpeg could do that with one button to automate the whole thing but I'm stuck.
According to this page, there are 2 ways to use the concat command from ffmpeg.
Let's say we want to merge the files 1.mp3 & 2.mp3 into a file named 1_join.mp3.
First example that use one simple command line:
"D:\My path to\ffmpeg.exe" -i "concat:D:\files to merge\1.mp3|D:\files to merge\2.mp3" -acodec copy "D:\files to merge\1_join.mp3"
I don't know how to handle the " | " that split the files list. Maybe with the MS-DOS batch function instead of the standard one.
Second example that use a text file containing the files path to concatenate:
files list in list.txt must have this form
file "D:\files to merge\1.mp3"
file "D:\files to merge\2.mp3"
then the command line will be
Unfortunately, I'm still using the v10. I don't feel the need to upgrade because of my old current laptop running XP. I will when I get a new computer one day. But for now, I'm stuck with the v10.
For security purpose Windows Scripting Host is disabled on my computer so js & vbs fies won't run. Only bat or cmd files can be used for this. I estimate the maximum number of files to join to 10.
I would say now you have a need, I would do this in a script and could assist you if you could run scripts.
An alternative approach would be to use Powershell if you cant do what you want in BAT.
Thanks.The new script feature seems very powerful. I'll come back when I upgrade in the course of the year. In the meantime, if someone have an idea with batch in v10...
Quick and dirty powershell version (actually this was not so very quick, as handling named and unnamed params at the same time, did not work out, so there's no usage of powershells regular param() handling here, but things should work as expected nonetheless, just keep params in expected order).
Save to "join.ps1"
$ffmpeg, $destfolder, $files = $args;
&"$ffmpeg" -i ('"concat:'+($files -join '|')+'" -acodec copy "'+(join-path -path $destfolder -childpath $files[0].split('.')[0])+'_joined.mp3"')
DO Button (edit path to "join.ps1" and "ffmpeg.exe", maybe remove @leavedoswindowopen after tests):
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>Join MP3s with ffmpeg</label>
<tip>Join MP3s with ffmpeg to destination</tip>
<icon1>#join</icon1>
<function type="batch">
<instruction>@filesonly </instruction>
<instruction>@nodeselect </instruction>
<instruction>@leavedoswindowopen </instruction>
<instruction>powershell.exe -file join.ps1 "C:\path to\ffmpeg.exe" {d} {O}</instruction>
<instruction />
<instruction>//content of powershell script "join.ps1"</instruction>
<instruction>//----------------------------------------</instruction>
<instruction>//$ffmpeg, $destfolder, $files = $args;</instruction>
<instruction>//&"$ffmpeg" -i ('"concat:'+($files -join '|')+'" -acodec copy "'+(join-path -path $destfolder -childpath $files[0].split('.')[0])+'_joined.mp3"')</instruction>
<instruction>//----------------------------------------</instruction>
</function>
</button>
Not tested with ffmpeg, in case it fails, you should be able to fix it. Instead of ffmpeg.exe I used a minimal batch file to get the resulting params printed, maybe it is of help to you too, here it is:
I was going to post this same question myself, but a search took me here and saved me the trouble. By tinkering with the answers above, I was able to get it to work.
"C:\Program Files\Serviio\lib\ffmpeg.exe" -f concat -i list.txt -c copy "{d!}{Rs|Output file name? (mp3 will be appended}.mp3"
del list.txt[/quote]
Simple enough to adjust the output etc, or auto select the input, but it works, I while I don't have a v10 to test it on, it apprears the the @nofilenamequoting exists in 10, so it will work I think. It works in 11, that much I know.
Yes it should work. I was planning to code an autoit app that would act as a launcher with command line options so it could face any situations, even the specific as this one. But I have no time at all at the moment to do it.
Well, as you can imagine, this isn't very robust, but it does (almost) exactly what you want. I just reread the original post and see that you wanted the output to source not dest, so just change it to...
"C:\Program Files\Serviio\lib\ffmpeg.exe" -f concat -i list.txt -c copy "{Rs|Output file name? (mp3 will be appended)}.mp3"
I just discovered two shortcomings of the above command. The first is that with long paths, it will fail. The second is that it won't work in flat mode.
A bit of tweaking and these are circumvented.
@nofilenamequoting
echo >>c:\list.txt file '{fs}'
"C:\Program Files\Serviio\lib\ffmpeg.exe" -f concat -i c:\list.txt -c copy "{d!}{Rs|Output file name? (mp3 will be appended)}.mp3"
del c:\list.txt
pause