3

I want to do the following conversion:

for f in *.m4a; do 
    (  ffmpeg -i "$f" -f wav - | opusenc --bitrate 38 - "${f%.m4a}.opus" ) & 
done

I know I could use ffmpeg directly to convert to opus, but I want to use opusenc in this case, since it's a newer version.

When I run opusenc after the ffmpeg it works fine, but when I try to run the above I just get a bunch of Stopped and nothing happens.

0

2 Answers 2

2

If you use GNU Parallel then this works:

parallel 'ffmpeg -i {} -f wav - | opusenc --bitrate 38 - {.}.opus' ::: *m4a

Maybe that is good enough?

It has the added benefit that it only runs 1 job per cpu thread, so if you have 1000 files you will not overload your machine.

1
0

I came up with this construction (... &) but I am not sure why it works:

for f in R*.mp3
do
  (time ffmpeg -loglevel 0 -i "$f" -ac 1 -y "${f%mp3}new.mp3" && date && ls -l "$f" &)
done

With 4 files:

real    0m0.784s
user    0m0.795s
sys     0m0.048s
So 10 Sep 2023 16:36:43 UTC
-rw-r--r-- 1 root root 1363436   10.Sep 10:04  REC-005.mp3

real    0m1.037s
user    0m1.064s
sys     0m0.040s
So 10 Sep 2023 16:36:43 UTC
-rw-r--r-- 1 root root 1540076   10.Sep 10:04  REC-003.mp3

real    0m1.822s
user    0m1.882s
sys     0m0.055s
So 10 Sep 2023 16:36:44 UTC
-rw-r--r-- 1 root root 2948588   10.Sep 10:04  REC-002.mp3

real    0m2.196s
user    0m2.253s
sys     0m0.061s
So 10 Sep 2023 16:36:44 UTC
-rw-r--r-- 1 root root 3402476   10.Sep 10:04  REC-004.mp3

The largest file ends last. I have time and a bash-list. But without (...&) I also get "Stopped" jobs (with unexpandend variables).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .