Skip to main content

Topic: Join FLAC files on decoding process (Read 7628 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • mikilion
  • [*]
Join FLAC files on decoding process
Is it possible by command line to join more FLAC files on decoding process and write to stdout?

  • phofman
  • [*][*][*][*]
Join FLAC files on decoding process
Reply #1
Code: [Select]
sox file1.flac file2.flac ..... fileN.flac -t wav -

  • CoRoNe
  • [*][*][*]
Join FLAC files on decoding process
Reply #2
For something like this using Foobar's converter is much easier. Avisynth is even another option, but it can be done by command line:

Code: [Select]
ffmpeg.exe -i track1.flac -i track2.flac -i track3.flac ... -i trackN.flac -filter_complex "[0:0][1:0][2:0][3:0][4:0][5:0][6:0][7:0]concat=n=8:v=0:a=1" -f wav - | Takc.exe -e -pMax -ihs - album.tak

Code: [Select]
ffmpeg.exe -i "concat:track1.flac|track2.flac|track3.flac|...|trackN.flac" -f wav - | Takc.exe -e -pMax -ihs - album.tak

or as phofman has pointed out...
Code: [Select]
sox.exe track1.flac track2.flac track3.flac ... trackN.flac -t wav - | Takc.exe -e -pMax - album.tak

Note that for transcoding to Opus, for ffmpeg you'd need -f s16le instead of -f wav and for sox you'd need -t raw instead of -t wav.
DC-Bass Source Mod: http://reino.degeelebosch.nl

  • phofman
  • [*][*][*][*]
Join FLAC files on decoding process
Reply #3
For something like this using Foobar's converter is much easier.


Easier is a relative term. I am done with the task using CLI tools before foobar even starts up  Of course it requires a decent shell of which cmd is not a good example.

  • mikilion
  • [*]
Join FLAC files on decoding process
Reply #4
I'm a Linux user. I would be able to get something like this:
Code: [Select]
flac -cd track1.flac track2.flac track3.flac  | lame - joined_tracks.mp3

  • phofman
  • [*][*][*][*]
Join FLAC files on decoding process
Reply #5
I'm a Linux user. I would be able to get something like this:
Code: [Select]
flac -cd track1.flac track2.flac track3.flac  | lame - joined_tracks.mp3


You have been already given two ways - sox, ffmpeg

Code: [Select]
sox track1.flac track2.flac track3.flac -t wav - | lame - joined_tracks.mp3


What is wrong with that?

  • greynol
  • [*][*][*][*][*]
  • Global Moderator
Join FLAC files on decoding process
Reply #6
I looked at an old script to see how do it. I decoded to PCM, concatenated and reencoded. I would have used Sox had I thought to try.
13 February 2016: The world was blessed with the passing of a truly vile and wretched person.

Your eyes cannot hear.

  • mikilion
  • [*]
Join FLAC files on decoding process
Reply #7
I'm looking for a Linux script to decode and concatenate on fly without using extra software as SOX or FFmpeg.
SOX and FFmpeg are valid tools but I'd like to harness the Linux script power.

  • greynol
  • [*][*][*][*][*]
  • Global Moderator
Join FLAC files on decoding process
Reply #8
You've been offered two nice power lawn mowers and you decide you can't even use a push mower.

Enjoy watching your grass grow, I guess.

  • Last Edit: 29 September, 2013, 11:55:48 AM by greynol
13 February 2016: The world was blessed with the passing of a truly vile and wretched person.

Your eyes cannot hear.

  • phofman
  • [*][*][*][*]
Join FLAC files on decoding process
Reply #9
SOX and FFmpeg are valid tools but I'd like to harness the Linux script power.


Well then I am afraid it is time for your to learn the linux script power yourself, not ask others to do it for you :-)

  • CoRoNe
  • [*][*][*]
Join FLAC files on decoding process
Reply #10
I'm a Linux user. I would be able to get something like this:
Code: [Select]
flac -cd track1.flac track2.flac track3.flac  | lame - joined_tracks.mp3

Interesting. I didn't know flac.exe accepts multiple inputs just like sox.exe. BUT unlike sox and ffmpeg, with flac's (piped) output you can hear a nasty click on each transition. Maybe I'm forgetting something, I don't know.
Btw, lame.exe needs -r (raw input) to handle flac's output.
DC-Bass Source Mod: http://reino.degeelebosch.nl

Join FLAC files on decoding process
Reply #11
BUT unlike sox and ffmpeg, with flac's (piped) output you can hear a nasty click on each transition.
That sounds like it's outputting wav headers. Add --force-raw-format to the command line.

  • Kohlrabi
  • [*][*][*][*][*]
  • Global Moderator
Join FLAC files on decoding process
Reply #12
I'm looking for a Linux script to decode and concatenate on fly without using extra software as SOX or FFmpeg.
SOX and FFmpeg are valid tools but I'd like to harness the Linux script power.

Harnessing the power of the Windows command shell, I came up with this:
Code: [Select]
for %%i in (*.flac) do flac -d "%%i" --endian=little --sign=signed --force-raw-format -c >> merged.raw
lame -r --signed --little-endian merged.raw merged.mp3
del merged.raw

I guess you can do something less verbose (avoid the tempfile) in Linux bash/csh/whatever and also Windows cmd/Powershell, but that is pretty straightforward.
  • Last Edit: 29 September, 2013, 04:00:07 PM by Kohlrabi
It's only audiophile if it's inconvenient.

  • skamp
  • [*][*][*][*][*]
  • Developer
Join FLAC files on decoding process
Reply #13
I'm a Linux user. I would be able to get something like this:
Code: [Select]
flac -cd track1.flac track2.flac track3.flac  | lame - joined_tracks.mp3


Code: [Select]
flac -d -c --force-raw-format --endian=little --sign=signed *.flac | lame -r --signed --little-endian --preset standard - joined_tracks.mp3
See my profile for measurements, tools and recommendations.

  • CoRoNe
  • [*][*][*]
Join FLAC files on decoding process
Reply #14
Perhaps a bit off-topic, but what about TAK? Takc.exe doesn't accept flac's output that way.
DC-Bass Source Mod: http://reino.degeelebosch.nl

  • Kohlrabi
  • [*][*][*][*][*]
  • Global Moderator
Join FLAC files on decoding process
Reply #15
Code: [Select]
flac -d -c --force-raw-format --endian=little --sign=signed *.flac | lame -r --signed --little-endian --preset standard - joined_tracks.mp3
Sometimes I hate that Windows cmd doesn't expand the wildcard operator...  Time to use Powershell.

Perhaps a bit off-topic, but what about TAK? Takc.exe doesn't accept flac's output that way.
You could use SoX to add a WAV header to that raw output stream, since Takc apparently doesn't accept raw input. Isn't it fun running in circles?
  • Last Edit: 30 September, 2013, 02:33:07 AM by Kohlrabi
It's only audiophile if it's inconvenient.

  • CoRoNe
  • [*][*][*]
Join FLAC files on decoding process
Reply #16

That's why I much prefer Foobar for this task!
DC-Bass Source Mod: http://reino.degeelebosch.nl

  • nu774
  • [*][*][*][*][*]
  • Developer
Join FLAC files on decoding process
Reply #17
Code: [Select]
flac -d -c --force-raw-format --endian=little --sign=signed *.flac | lame -r --signed --little-endian --preset standard - joined_tracks.mp3
Sometimes I hate that Windows cmd doesn't expand the wildcard operator...  Time to use Powershell.

Although cmd doesn't expand wildcard,  flac 1.3.0 will expand it for you.
That's the side effect of new flac using __wgetmainargs() function, in order to support Unicode pathnames on Windows.

  • mikilion
  • [*]
Join FLAC files on decoding process
Reply #18
Code: [Select]
flac -d -c --force-raw-format --endian=little --sign=signed *.flac | lame -r --signed --little-endian --preset standard - joined_tracks.mp3

This is wonderful, it works!
I tried this and it works also:

Code: [Select]
flac -cd --force-raw-format --endian=little --sign=signed track1.flac track2.flac track3.flac | lame -r --signed --little-endian --preset standard - joined_tracks.mp3


Thanks!