0

In my code:

ffmpeg -i "video.m2ts" -vn -sn -acodec flac "audio.flac"

The output .flac audio file gives me 500kbps bitrate, which makes the file size big. I want to lower down the audio bitrate but I can't find any options to do that. Any ideas to solve this? Thanks.

(I just need to audio file by the way)

2 Answers 2

2

FLAC is a lossless codec, so compressibility is limited.

At best, you can use

ffmpeg -i "video.m2ts" -vn -sn -acodec flac -compression_level 12 "audio.flac"

Since you have a MPEG transport stream, you can also try

ffmpeg -i "video.m2ts" -vn -sn -acodec copy "audio.mp4"

This will extract the audio without re-compression.

0

Technically, it's possible to change the bitrate of any lossless audio file by converting it to Ogg and to FLAC again.


# Converting to Ogg...
ffmpeg -i "Real.flac" -ab 450k -ar "Fake.ogg"

# And to FLAC
ffmpeg -i "Fake.ogg" -max_muxing_queue_size 9999 "Fake.flac"

# Extracting side channels (useful for examining some cases)
ffmpeg -i "Fake.flac" -af "stereotools=mode=ms>rr" "Verify.wav"

Comparisons

mutagen - Mutagen is a Python module to handle audio metadata.

>>> from mutagen import File as mFile
>>>
>>> Files = "Real.flac", "Fake.ogg", "Fake.flac"
>>> for File in Files:
...     print('Bitrate of "{0}" is {1}kb/s.'.format(File, mFile(File).info.bitrate // 1024))
...
Bitrate of "Real.flac" is 1239kb/s
Bitrate of "Fake.ogg" is 439kb/s
Bitrate of "Fake.flac" is 1994kb/s
>>>

Funny, fake FLAC file has greater bitrate than the original. 😅

Original Converted Converted (side)

Spectrograms were generated using sox.

3
  • 1
    This is pointless and nonsensical. Yes, when content changes the compression could change too, nobody is disputing this. You can not only convert to OGG to change content, for instance, convert to MP3, AAC, equalize it, denoise it, add a reverb, etc., the compression will change because the content changes. But the whole point of FLAC is that the content does not change; this idea is to compress as much as possible under the restriction that the decompressed data will be bit by bit exactly as it was in the original. Your ogg (vorbis) conversion breaks this core restriction. Jan 18, 2023 at 18:28
  • @NikitaKipriyanov Yes, but the question was about changing the bitrate of the output FLAC file - transcoding is the only technical way to reduce it, because - as stated - the bitrate of the FLAC file is inherited from the input file - which is assumed to be lossless. Apr 12, 2023 at 21:27
  • "Setting a bitrate" of a lossy codec assumes it is subject to the same input. What you're doing by transcoding is changing the input, which is not allowed. You don't compress the same thing, therefore the results are incomparable and can't count as "changing bitrate of a codec", and it would be that way even if we were discussing a lossy codec. The only possible valid answer to the real question (behind the statement) is: there could be no possibility to set bitrate of a lossless codec, it will always be as large as it takes to store the original data exactly. Apr 13, 2023 at 3:14

You must log in to answer this question.

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