Bash Script for Batch Converting Audio in MKVs to FLAC

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bash Script for Batch Converting Audio in MKVs to FLAC

Josh Blagden
Hi Folks,

    I have a number of videos on my hard drive that I've copied from
Blu-Rays. They'll play on my Roku, but the sound doesn't work, so I have
to change the audio track from DTS to FLAC. I've been doing this
manually for a while, but I'd really like a one-line bash script so I
can avoid the tedium and time-intensive activity of converting these
one-by-one or having to spend a half hour just writing FFMPEG commands.


Here's an example of one of those commands: ffmpeg -i '01x12 - The
Flax.mkv' -c:v copy -c:s copy -c:a flac '01x12 - The Flax(flac).mkv'


I just want to convert the audio track to FLAC and then add "(flac) to
the file name so I can hang onto the originals temporarily to make sure
everything went well or that I didn't miss some other conversion I had
to do.


Thanks in advance,

                                Josh Blagden


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".

pEpkey.asc (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Bash Script for Batch Converting Audio in MKVs to FLAC

Moritz Barsnick
On Sat, Oct 20, 2018 at 14:09:07 -0400, Joshua Blagden wrote:
> Here's an example of one of those commands: ffmpeg -i '01x12 - The
> Flax.mkv' -c:v copy -c:s copy -c:a flac '01x12 - The Flax(flac).mkv'
>
> I just want to convert the audio track to FLAC and then add "(flac) to
> the file name so I can hang onto the originals temporarily to make sure
> everything went well or that I didn't miss some other conversion I had
> to do.

That's more of a shell scripting question than an ffmpeg question, but
here we go, using a subdirectory for the results (so they don't mix
with the originals):

$ mkdir flac
$ for infile in *.mkv; do outfile=flac/${infile%.mkv}'(flac)'.mkv; echo ffmpeg -i "$infile" -c:v copy -c:s copy -c:a flac "$outfile"; done

(Untested.)

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Bash Script for Batch Converting Audio in MKVs to FLAC

Moritz Barsnick
On Sat, Oct 20, 2018 at 23:26:29 +0200, Moritz Barsnick wrote:
> $ mkdir flac
> $ for infile in *.mkv; do outfile=flac/${infile%.mkv}'(flac)'.mkv; echo ffmpeg -i "$infile" -c:v copy -c:s copy -c:a flac "$outfile"; done

I failed to mention: This is bash syntax. zsh may or may not be
different. Other shells may need other "magic" for converting the file
names.

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".