Discussion:
AI Can Write FFMPEG Scripts
(too old to reply)
Dr. Noah Bodie
2024-03-22 19:20:52 UTC
Permalink
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono mp3s
and it did it in one take.

This could make using FFMPEG easier for certain tasks.
Big Al
2024-03-22 19:41:08 UTC
Permalink
I just found out that AI can write short scripts that use FFMPEG. I asked it to write an app that
would convert stereo mp3s into mono mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
--
Linux Mint 21.3 Cinnamon 6.0.4 Kernel 6.5.0-26-generic
Al
Paul
2024-03-22 23:30:43 UTC
Permalink
Post by Big Al
I just found out that AI can write short scripts that use FFMPEG. I asked it to write an app that would convert stereo mp3s into mono mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
CoPilot:

$ Give a command line invocation of FFMPEG to convert a stereo MP3 into a monophonic MP3

ffmpeg -i input.mp3 -c:a libmp3lame -q:a 2 -ac 1 output.mp3

Explanation:

-i input.mp3: Specifies the input stereo MP3 file.
-c:a libmp3lame: Sets the audio codec to libmp3lame for the output.
-q:a 2: Controls the audio quality (2 is a reasonable value).
-ac 1: Converts the audio to mono (single channel).
output.mp3: Specifies the output monophonic MP3 file.

*******

https://trac.ffmpeg.org/wiki/AudioChannelManipulation

"Mix a single stereo stream down to a mono stream.
Both channels of the stereo stream will be downmixed into the stream"

Paul
Brian Gregory
2024-03-23 17:37:45 UTC
Permalink
Post by Paul
Post by Big Al
I just found out that AI can write short scripts that use FFMPEG. I asked it to write an app that would convert stereo mp3s into mono mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
$ Give a command line invocation of FFMPEG to convert a stereo MP3 into a monophonic MP3
ffmpeg -i input.mp3 -c:a libmp3lame -q:a 2 -ac 1 output.mp3
-i input.mp3: Specifies the input stereo MP3 file.
-c:a libmp3lame: Sets the audio codec to libmp3lame for the output.
-q:a 2: Controls the audio quality (2 is a reasonable value).
-ac 1: Converts the audio to mono (single channel).
output.mp3: Specifies the output monophonic MP3 file.
*******
https://trac.ffmpeg.org/wiki/AudioChannelManipulation
"Mix a single stereo stream down to a mono stream.
Both channels of the stereo stream will be downmixed into the stream"
Paul
I've used both Bing chat and the Google one for similar things.
At first I thought Bing chat was the better one but Google Gemini, as
they now call it, is getting a lot better.
--
Brian Gregory (in England).
Dr. Noah Bodie
2024-03-23 11:39:55 UTC
Permalink
Post by Big Al
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono mp3s
and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
https://chat.openai.com/

me:
"write an ffmpeg script that will convert every mp3 in the current
folder to 96KB mono"

ai:
#!/bin/bash

# Check if ffmpeg is installed
if ! command -v ffmpeg &>/dev/null; then
echo "Error: ffmpeg is not installed."
exit 1
fi

# Iterate over each MP3 file in the current directory
for file in *.mp3; do
# Generate output file name
output_file="${file%.mp3}_mono.mp3"

# Run ffmpeg command to convert to 96kbps mono
ffmpeg -i "$file" -ac 1 -b:a 96k "$output_file"

# Output conversion result
if [ $? -eq 0 ]; then
echo "Conversion of $file successful."
else
echo "Error converting $file."
fi
done
Big Al
2024-03-23 15:45:08 UTC
Permalink
Post by Dr. Noah Bodie
Post by Big Al
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono mp3s
and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
https://chat.openai.com/
"write an ffmpeg script that will convert every mp3 in the current folder to 96KB mono"
#!/bin/bash
# Check if ffmpeg is installed
if ! command -v ffmpeg &>/dev/null; then
echo "Error: ffmpeg is not installed."
exit 1
fi
# Iterate over each MP3 file in the current directory
for file in *.mp3; do
# Generate output file name
output_file="${file%.mp3}_mono.mp3"
# Run ffmpeg command to convert to 96kbps mono
ffmpeg -i "$file" -ac 1 -b:a 96k "$output_file"
# Output conversion result
if [ $? -eq 0 ]; then
echo "Conversion of $file successful."
else
echo "Error converting $file."
fi
done
Wow, that's interesting, error checking and all. I have to hand to AI.
--
Linux Mint 21.3 Cinnamon 6.0.4 Kernel 6.5.0-26-generic
Al
Dr. Noah Bodie
2024-03-23 19:39:21 UTC
Permalink
Post by Big Al
Post by Dr. Noah Bodie
Post by Big Al
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono mp3s
and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
https://chat.openai.com/
"write an ffmpeg script that will convert every mp3 in the current folder to 96KB mono"
#!/bin/bash
# Check if ffmpeg is installed
if ! command -v ffmpeg &>/dev/null; then
echo "Error: ffmpeg is not installed."
exit 1
fi
# Iterate over each MP3 file in the current directory
for file in *.mp3; do
# Generate output file name
output_file="${file%.mp3}_mono.mp3"
# Run ffmpeg command to convert to 96kbps mono
ffmpeg -i "$file" -ac 1 -b:a 96k "$output_file"
# Output conversion result
if [ $? -eq 0 ]; then
echo "Conversion of $file successful."
else
echo "Error converting $file."
fi
done
Wow, that's interesting, error checking and all. I have to hand to AI.
AI can also write simple PHP apps, like bulk mailing programs that send
emails to a dozen people.
Paul
2024-03-23 16:29:41 UTC
Permalink
Post by Dr. Noah Bodie
Post by Big Al
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono mp3s
and it did it in one take.
This could make using FFMPEG easier for certain tasks.
what AI program did you use?
https://chat.openai.com/
"write an ffmpeg script that will convert every mp3 in the current folder to 96KB mono"
#!/bin/bash
# Check if ffmpeg is installed
if ! command -v ffmpeg &>/dev/null; then
echo "Error: ffmpeg is not installed."
exit 1
fi
# Iterate over each MP3 file in the current directory
for file in *.mp3; do
# Generate output file name
output_file="${file%.mp3}_mono.mp3"
# Run ffmpeg command to convert to 96kbps mono
ffmpeg -i "$file" -ac 1 -b:a 96k "$output_file"
# Output conversion result
if [ $? -eq 0 ]; then
echo "Conversion of $file successful."
else
echo "Error converting $file."
fi
done
How did the AI know that you wanted a bash script ?

If this was a student assignment, we would expect
better of them. There are some assumptions in the
script. The script is still a bit lazy.

The script has erroneously assumed that MP3 files
always end in .mp3 , which may not be the case.
The OS does not make mistakes like that. The OS
uses the "file" command to ID items.

And as has been so ably demonstrated by lawyers, you
cannot just verbatim copy the output of an AI
and run with it. It needs error checking and analysis.
Just as in OCR, you would thoroughly review the
workmanship, for the 1% expected error rate.

Still, I'll give it five points for writing a "pretty"
script. You can give some prompts, to change the
"style" of the kind of script it writes. It did
work step-by-step, so maybe the available prompt
has already been given.

The danger with giving too many constraints, is
driving the AI off into the weeds.

My very first question for an AI, I gave it an
unbounded question :-) Purely an accident on my part.
A lazy input, dood. I got a lot of babbling, then
it erased the output and declared a "timeout"
as it was taking too long to go to infinity and beyond.
I'm sure the fans were spinning for a few seconds
until it cooled off.

It's like when we had this crusty database at work
(distributed, on multiple mainframes), and when you
logged into it, there was a warning in red to
"Don't give it the following command and light up
the entire database!". Failure to listen to the
instructions about careless queries, was loss of
your account. Back then they did not "suffer fools".

Paul
Fokke Nauta
2024-03-23 20:39:29 UTC
Permalink
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono mp3s
and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?

Fokke
Nic
2024-03-23 20:44:02 UTC
Permalink
Post by Fokke Nauta
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono
mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?
Fokke
The resultant file is smaller.
Fokke Nauta
2024-03-24 08:14:46 UTC
Permalink
Post by Nic
Post by Fokke Nauta
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono
mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?
Fokke
The resultant file is smaller.
But the quality of the music is less.
Nic
2024-03-24 11:12:47 UTC
Permalink
Post by Fokke Nauta
Post by Nic
Post by Fokke Nauta
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono
mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?
Fokke
The resultant file is smaller.
But the quality of the music is less.
Monophonic does not imply lower fidelity or quality. I recall many years
ago that monophonic was the better quality and stereo which was new at
the time was not the first choice of high fidelity enthusiasts.

A little music to exercise those voice coils-



Sibelius Karelia suite Op 11
Paul
2024-03-24 12:49:22 UTC
Permalink
Post by Fokke Nauta
Post by Nic
Post by Fokke Nauta
I just found out that AI can write short scripts that use FFMPEG. I asked it to write an app that would convert stereo mp3s into mono mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?
Fokke
The resultant file is smaller.
But the quality of the music is less.
Monophonic does not imply lower fidelity or quality. I recall many years ago that monophonic was the better quality and stereo which was new at the time was not the first choice of high fidelity enthusiasts.
A little music to exercise those voice coils-
http://youtu.be/rMp7M3kx3E4
 Sibelius Karelia suite Op 11
But part of this is psychology.

Back when we had 78 RPM records, there would be clicks
and hiss and a non-flat spectrum.

You become so used to the artifacts, that the artifacts
become "an objective", an expectation, of the listener.
You're not listening to "an immersive recording of the
Philharmonic", you're listening to "a 78RPM recording
of the Philharmonic with original pops and hiss".

"It doesn't sound right", when a new technology comes along.
"It sound flat and lifeless". Yes, if you're used to a lot
of high frequency artifact, and you listen to a cleaner system,
it does not sound right.

Multichannel systems are intended to be immersive. CD recordings
would have had more than two tracks (stereo), if we could have
fitted them in.

At one time, long play albums were recorded in the studio on
four track tape, and mixed down to stereo. There were no
fancy HRTFs to do that, just like making soup "I will take
40% from channel1 and 60% from channel2 and make L". The studio
was not really all that much more sophisticated than the user.

Even today, people have a fetish for certain sound qualities.
We don't go for "the most realistic immersive experience",
we like the even harmonics of vacuum tube distortions.

I bet people who were inured to low bandwidth MP3s with
compression artifacts, those people have the same kind of
expectations as the 78RPM listeners waiting for the hiss
and pops :-) If you gave them sample-accurate (uncompressed)
sound, it would not sound right. But that's the psychology
of it, at work.

Too much "digital mutilation" of recorded content, and when
you actually do go to the Philharmonic, it's nothing like
the 22 channel Dolby ATMOS you were listing to at home :-)
The live session doesn't sound right.

At least one of the concert halls, was redesigned, and
has improved acoustics (and fewer seats). Now at least, when
you visit in person, it's getting closer to the
22 channel Dolby ATMOS they made artificially in the mixer.

Paul
Nic
2024-03-24 20:29:17 UTC
Permalink
Post by Paul
Post by Fokke Nauta
Post by Nic
Post by Fokke Nauta
I just found out that AI can write short scripts that use FFMPEG. I asked it to write an app that would convert stereo mp3s into mono mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?
Fokke
The resultant file is smaller.
But the quality of the music is less.
Monophonic does not imply lower fidelity or quality. I recall many years ago that monophonic was the better quality and stereo which was new at the time was not the first choice of high fidelity enthusiasts.
A little music to exercise those voice coils-
http://youtu.be/rMp7M3kx3E4
 Sibelius Karelia suite Op 11
But part of this is psychology.
Back when we had 78 RPM records, there would be clicks
and hiss and a non-flat spectrum.
You become so used to the artifacts, that the artifacts
become "an objective", an expectation, of the listener.
You're not listening to "an immersive recording of the
Philharmonic", you're listening to "a 78RPM recording
of the Philharmonic with original pops and hiss".
"It doesn't sound right", when a new technology comes along.
"It sound flat and lifeless". Yes, if you're used to a lot
of high frequency artifact, and you listen to a cleaner system,
it does not sound right.
Multichannel systems are intended to be immersive. CD recordings
would have had more than two tracks (stereo), if we could have
fitted them in.
At one time, long play albums were recorded in the studio on
four track tape, and mixed down to stereo. There were no
fancy HRTFs to do that, just like making soup "I will take
40% from channel1 and 60% from channel2 and make L". The studio
was not really all that much more sophisticated than the user.
Even today, people have a fetish for certain sound qualities.
We don't go for "the most realistic immersive experience",
we like the even harmonics of vacuum tube distortions.
I bet people who were inured to low bandwidth MP3s with
compression artifacts, those people have the same kind of
expectations as the 78RPM listeners waiting for the hiss
and pops :-) If you gave them sample-accurate (uncompressed)
sound, it would not sound right. But that's the psychology
of it, at work.
Too much "digital mutilation" of recorded content, and when
you actually do go to the Philharmonic, it's nothing like
the 22 channel Dolby ATMOS you were listing to at home :-)
The live session doesn't sound right.
At least one of the concert halls, was redesigned, and
has improved acoustics (and fewer seats). Now at least, when
you visit in person, it's getting closer to the
22 channel Dolby ATMOS they made artificially in the mixer.
Paul
Yet not much has been done with microphone technology, it is still some
sound amplification of our mutters and grunts converted to electrical
impulses recorded on some magnetic mediam. Is it psychological to assume
that the possible existence of a soul would seriously damage the matrix
continuum I hope there is an OS that can sort all this.

Voice Coil Exercise 



Entrance Of The Gods Into Valhalla

John Williamson
2024-03-24 13:25:29 UTC
Permalink
Post by Nic
Post by Fokke Nauta
But the quality of the music is less.
Monophonic does not imply lower fidelity or quality. I recall many years
ago that monophonic was the better quality and stereo which was new at
the time was not the first choice of high fidelity enthusiasts.
Whereas now, a lot of hifi enthusiasts claim that vinyl sounds better
than CD. There are, however, differences in the mastering which can make
vinyl sound more pleasant in a poorly treated room. I can equaliseda CD
to sound as muffled as an LP either on playbackro when I am mastering it.

As far as the difference between mono and stereo goes, what is being
recorded, where and how it has been recorded, mixed and mastered matter
a lot, and even the quality of the playback equipment makes a major
difference.
--
Tciao for Now!

John.
Monsieur
2024-03-24 13:59:55 UTC
Permalink
Post by Fokke Nauta
Post by Nic
Post by Fokke Nauta
Post by Dr. Noah Bodie
I just found out that AI can write short scripts that use FFMPEG. I
asked it to write an app that would convert stereo mp3s into mono
mp3s and it did it in one take.
This could make using FFMPEG easier for certain tasks.
Why would you convert a stereo mp3 into a mono mp3?
Fokke
The resultant file is smaller.
But the quality of the music is less.
Not important for audiobooks or podcasts. No need for stereo effects
when listening to vocal recordings.

Also the two channels are simply mixed, there is no real loss of quality.
Loading...