FORUMS: list search recent posts

combine audio tracks with similar file names

COW Forums : FFmpeg

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Jack Passmore
combine audio tracks with similar file names
on Sep 13, 2013 at 5:06:29 pm

I have a folder full of 44.1/16 Wave files like this:

NYAC-1234-A.wav
NYAC-1234-B.wav
NYAC-3456-A.wav
NYAC-3456-B.wav

I want to use ffmpeg to combine the A and B tracks with the same prefixes into single Wave files. Is there a way to do this with ffmpeg? I know I can combine each set of two files one at a time. But is there a way to use a regular expression or something to combine the above files and get the following results in a new folder?

NYAC-1234.wav
NYAC-3456.wav


Return to posts index

Lou Logan
Re: combine audio tracks with similar file names
on Sep 13, 2013 at 6:29:30 pm

[Jack Passmore] "
I want to use ffmpeg to combine the A and B tracks with the same prefixes into single Wave files."


"Combine" is ambiguous. Do you want to concatenate (join one after the other) or merge two or more audio streams into a single multi-channel stream?

Please show the complete ffmpeg console output of:
ffmpeg -i NYAC-1234-A.wav -i NYAC-1234-B.wav -i NYAC-3456-A.wav -i NYAC-3456-B.wav


Return to posts index

Jack Passmore
Re: combine audio tracks with similar file names
on Sep 13, 2013 at 7:18:31 pm

Apologies, so I want to concatenate the two (join one after the other - they are hours one and two of a two hour program). Here's the -i output



D:\Local_Audio\ffmpeg\bin>ffmpeg -i NYAC-1234-A.wav -i NYAC-1234-B.wav -i NYAC-3
456-A.wav -i NYAC-3456-B.wav

ffmpeg version N-56254-gb7bd688 Copyright (c) 2000-2013 the FFmpeg developers
built on Sep 12 2013 21:00:14 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264
--enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 43.100 / 52. 43.100
libavcodec 55. 31.101 / 55. 31.101
libavformat 55. 16.102 / 55. 16.102
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 84.100 / 3. 84.100
libswscale 2. 5.100 / 2. 5.100
libswresample 0. 17.103 / 0. 17.103
libpostproc 52. 3.100 / 52. 3.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'NYAC-1234-A.wav':
Metadata:
genre : Unknown
album : Album 02107D01
date : 0000
Duration: 01:10:21.65, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, wav, from 'NYAC-1234-B.wav':
Metadata:
genre : Unknown
album : Album 32110904
date : 0000
Duration: 01:12:41.03, bitrate: 1411 kb/s
Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
Guessed Channel Layout for Input Stream #2.0 : stereo
Input #2, wav, from 'NYAC-3456-A.wav':
Metadata:
genre : Unknown
album : Album 020FB801
date : 0000
Duration: 01:07:04.05, bitrate: 1411 kb/s
Stream #2:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
Guessed Channel Layout for Input Stream #3.0 : stereo
Input #3, wav, from 'NYAC-3456-B.wav':
Metadata:
genre : Unknown
album : Album 02100901
date : 0000
Duration: 01:08:25.57, bitrate: 1411 kb/s
Stream #3:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
At least one output file must be specified


Return to posts index


Lou Logan
Re: combine audio tracks with similar file names
on Sep 13, 2013 at 8:45:27 pm

You can use the concat demuxer to concatenate these files:

$ cat list1.txt
file 'NYAC-1234-A.wav'
file 'NYAC-1234-B.wav'

$ cat list2.txt
file 'NYAC-3456-A.wav'
file 'NYAC-3456-B.wav'

$ ffmpeg -f concat -i list1.txt -codec copy NYAC-1234.wav
$ ffmpeg -f concat -i list2.txt -codec copy NYAC-3456.wav


Also see:


Return to posts index


stephen dixon
Re: combine audio tracks with similar file names
on Sep 14, 2013 at 1:20:28 pm

To expand a little on the previous post, to automatically go through the folder and create the lists you can use shell expansion and pattern matching like so:

for i in NYAC-*-A.wav; do
echo "file $i">temp.txt
echo "file ${i/-A/-B}">>temp.txt
ffmpeg -f concat -i temp.txt -codec copy "${i/-A/}"
done
rm temp.txt


The first line creates a loop that matches all file that look like NYAC-anything-A.wav, substituting the name of the file for the variable $i wherever it appears inside the loop.

The second line creates a text file "temp.txt" containing the line
file NYAC-1234-A.wavand the third appendsfile NYAC-1234-B.wavto the file

This third line uses parameter expansion to substitute -B for -A in the file names. Not that this will only work if the file names are similar to the pattern you gave. If your file name had say NYAC-Afternoon-A.wav in the title this would get changed to NYAC-Bfternoon-A.wav
Then it does the ffmpeg-ing using the temp.txt file, and lastly removes the temp file. Obviously if you have a file called temp.txt it would be destroyed by this script.

Stephen Dixon
Editor, Animator, Motionographer
Museum Victoria


Return to posts index

Jack Passmore
Re: combine audio tracks with similar file names
on Sep 18, 2013 at 3:39:57 pm

Thanks,
Is this bash? It doesn't seem to work in my windows shell.
J


Return to posts index


stephen dixon
Re: combine audio tracks with similar file names
on Sep 19, 2013 at 9:06:04 am

yes, bash or zsh etc. Not for windows I'm afraid, though it might work with cygwin ( http://www.cygwin.org )

Stephen Dixon
Editor, Animator, Motionographer
Museum Victoria


Return to posts index

Jack Passmore
Re: combine audio tracks with similar file names
on Sep 25, 2013 at 12:38:43 am

I finally got my hands on a linux box and this works great. I still need to figure out the syntax for .bat but many thanks!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]