FFmpeg error when converting FLAC to mp3

2

I received the following error when converting a FLAC to MP3 with FFmpeg

[flac @ 0x7fe841000800] Format flac detected only with low score of 1, misdetection possible!
[flac @ 0x7fe841000800] Could not find codec parameters for stream 0 (Audio: flac, 0 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' and 'probesize' options

After using the following command:

for a in ./*.flac; do
        ffmpeg -analyzeduration 2147483647 -probesize 2147483647  -i "$a"  -c:v copy  -q:a 0  "${a/%[.][Ff][Ll][Aa][Cc]/.mp3}"
        rm "$a"
        mv "${a/%[.][Ff][Ll][Aa][Cc]/.mp3}" "/Users/adrianvanburen/Music/Music/Media/Automatically Add to Music.localized"
done

With some FLACs that I downloaded via SFTP from a remote server. All the FLACs converted OK except for just one, which gave the above error.

Adrian Van Buren

Posted 2019-11-10T22:37:24.967

Reputation: 51

1Happy you self-solved this, but what was your original command in the context of all of this. Please edit your question to add the original command for perspective. – JakeGould – 2019-11-10T22:45:15.977

@JakeGould Thank you. I updated the question. I learned why the tilde caused the issue, which was actually in SFTP, so I updated the answer as well. This issue should be easy to re-create now. – Adrian Van Buren – 2019-11-11T23:29:18.147

Answers

3

I solved this by removing an invalid character from the input file name before downloading it over SFTP.

In my case, it was something like this:

Song - ~Author~.FLAC

The tilde (~) character was causing the issue.

My FTP client did not raise an alarm, but for some reason it downloaded the file containing about 8MB worth of 0 bits. I opened the file in a hex editor to discover that it's indeed a large, correctly sized, file of "zero" bits. This made the error difficult to spot at first, because I thought it must be with FFmpeg, but in fact I was inputing an invalid FLAC file to FFmpeg.

I renamed the file excluding the invalid character on the remote server. Then re-downloaded it, and it converted just fine.

Adrian Van Buren

Posted 2019-11-10T22:37:24.967

Reputation: 51

Great self-solved work! – JakeGould – 2019-11-12T01:18:48.150