jeff1evesque / LeQue

Activate installed microphone, and analyze sound input
13 stars 2 forks source link

Bash: Adjust ffmpeg code to avconv format #357

Closed jeff1evesque closed 10 years ago

jeff1evesque commented 10 years ago

Since we are now using avconv, we will need to adjust converter_wav_rate to use the avconv syntax rather than the current ffmpeg command:

ffmpeg -i ../audio/recording/"$file" -acodec pcm_s16le -ac 1 -ar 16000 -y ../audio/recording_converted/"$filename"
jeff1evesque commented 10 years ago

The ffmpeg command can be replaced with avconv, along with the appropriate flags, which is almost identical:

IRC #ubuntu (07/29/14 ~ 9:20pm EST):

jeffreylevesque: i keep finding that everyone uses ffmpeg - https://www.google.com/?gws_rd=ssl#q=libav+convert+wav+to+16+bit+mono+16+kHz jeffreylevesque: why did ubuntu switch to libav?

Pici: jeffreylevesque: because debian switched to libav.

k1l_: jeffreylevesque: because debian did.

IRC #libav (07/29/14 ~ 9:20pm EST):

jeffreylevesque: I updated my Ubuntu 11.04 to Ubuntu 14.04. I couldn't install ffmpeg as the system suggested me to install avconv jeffreylevesque: could someone assist me with the equivalent code in 'avconv' - https://github.com/jeff1evesque/audio-analyzer/issues/357

koda: jeffreylevesque: umh it works as is with ffmpeg replaced with avconv

jeffreylevesque: koda, will avconv -i ../audio/recording/"$file" -acodec pcm_s16le -ac 1 -ar 16000 -y ../audio/recording_converted/"$filename" work?

koda: it works here :)

jeff1evesque commented 10 years ago

The output of the conversion parameter needs an extension. The following example demonstrates this need:

$ avconv -i pocketsphinx/audio/sample.wav -acodec pcm_s16le -ac 1 -ar 16000 -y delete
avconv version 9.14-6:9.14-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 15 2014 13:57:40 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[wav @ 0x197ffe0] max_analyze_duration reached
Guessed Channel Layout for  Input Stream #0.0 : mono
Input #0, wav, from 'pocketsphinx/audio/sample.wav':
  Duration: 00:00:11.49, bitrate: 256 kb/s
    Stream #0.0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
Unable to find a suitable output format for 'delete'

However, if include the extension, it works:

$ avconv -i pocketsphinx/audio/sample.wav -acodec pcm_s16le -ac 1 -ar 16000 -y delete.wav
avconv version 9.14-6:9.14-0ubuntu0.14.04.1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 15 2014 13:57:40 with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
[wav @ 0x684020] max_analyze_duration reached
Guessed Channel Layout for  Input Stream #0.0 : mono
Input #0, wav, from 'pocketsphinx/audio/sample.wav':
  Duration: 00:00:11.49, bitrate: 256 kb/s
    Stream #0.0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
Output #0, wav, to 'delete.wav':
  Metadata:
    ISFT            : Lavf54.20.4
    Stream #0.0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le -> pcm_s16le)
Press ctrl-c to stop encoding
size=     359kB time=11.50 bitrate= 256.1kbits/s    
video:0kB audio:359kB global headers:0kB muxing overhead 0.021203%

Note: sample.wav is already properly configured to 16 bit, 16 kHz, mono.

acc119d: We adjust converter_wav_rate such that the audio file properly reconfigures, and is saved without a file extension.