0

I'm trying to create a command for converting all audio files selected in vifm using ffmpeg. Here's what I've tried so far:

command opus ffmpeg -i %f -q 7 %f:s|flac|opus|

This has two problems, however.

First, it only works if only one file is selected. If, for example, two are selected, ffmpeg stops with the question, File 'foo.flac' already exists. Overwrite ? [y/N], where foo.flac is the second file.

Second, it only works if the extension of the original files is flac. (I used vifm's substitution macro for replacing flac with opus in the file name in the example.) I don't know how to include other extensions, too.

0

After hours of trial and error, I've managed to figure it out.

Write a bash script in a separate file, like ffmpeg-opus.sh:

#!/bin/bash

for file; do
    ffmpeg -i "$file" -ab 128k "${file%.*}".opus
done

And create a command for it in vifmrc:

command opus ffmpeg-opus.sh %f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.