HydrogenAudio

Lossless Audio Compression => FLAC => Topic started by: mikilion on 2013-09-14 12:56:58

Title: Join FLAC files on decoding process
Post by: mikilion on 2013-09-14 12:56:58
Is it possible by command line to join more FLAC files on decoding process and write to stdout?
Title: Join FLAC files on decoding process
Post by: phofman on 2013-09-14 16:59:59
Code: [Select]
sox file1.flac file2.flac ..... fileN.flac -t wav -
Title: Join FLAC files on decoding process
Post by: CoRoNe on 2013-09-15 12:33:54
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.
Title: Join FLAC files on decoding process
Post by: phofman on 2013-09-15 17:41:59
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.
Title: Join FLAC files on decoding process
Post by: mikilion on 2013-09-16 13:08:31
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
Title: Join FLAC files on decoding process
Post by: phofman on 2013-09-16 13:46:07
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?
Title: Join FLAC files on decoding process
Post by: greynol on 2013-09-16 15:51:33
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.
Title: Join FLAC files on decoding process
Post by: mikilion on 2013-09-29 16:27:07
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.
Title: Join FLAC files on decoding process
Post by: greynol on 2013-09-29 16:31:01
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.

Title: Join FLAC files on decoding process
Post by: phofman on 2013-09-29 17:03:20
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 :-)
Title: Join FLAC files on decoding process
Post by: CoRoNe on 2013-09-29 17:24:37
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.
Title: Join FLAC files on decoding process
Post by: Octocontrabass on 2013-09-29 18:35:57
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.
Title: Join FLAC files on decoding process
Post by: Kohlrabi on 2013-09-29 20:56:33
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.
Title: Join FLAC files on decoding process
Post by: skamp on 2013-09-29 21:14:04
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
Title: Join FLAC files on decoding process
Post by: CoRoNe on 2013-09-29 21:46:17
Perhaps a bit off-topic, but what about TAK? Takc.exe doesn't accept flac's output that way.
Title: Join FLAC files on decoding process
Post by: Kohlrabi on 2013-09-30 07:10:33
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 (http://www.hydrogenaudio.org/forums/index.php?showtopic=102645&view=findpost&p=844857) 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 (http://www.hydrogenaudio.org/forums/index.php?showtopic=102645&view=findpost&p=844857)?
Title: Join FLAC files on decoding process
Post by: CoRoNe on 2013-09-30 09:36:31

That's why I much prefer Foobar for this task!
Title: Join FLAC files on decoding process
Post by: nu774 on 2013-09-30 09:59:18
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.
Title: Join FLAC files on decoding process
Post by: mikilion on 2013-10-07 15:50:57
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!