Skip to main content

Starts recording audio from the specified device using ffmpeg and stops recording after a specified number of seconds of silence

Project description

Starts recording audio from the specified device using ffmpeg and stops recording after a specified number of seconds of silence

pip install ffmpegaudiorecord

Tested against Windows 10 / Python 3.10 / Anaconda

The function first checks to see if the ffmpegexe path is in the system path. If not, it adds the path to the system path.

Next, the function gets the list of available audio devices using the get_all_devices function from the
ffmpegdevices module. It then tries to find the audio device that matches the audiodevice argument.
If no match is found, the function raises an exception.

The function then starts a new ffmpeg process to record audio from the specified device.
It creates a temporary file to store the recorded audio.
The function then enters a loop that reads the recorded audio from the temporary file and checks for silence.
If the audio is silent for a specified number of seconds, the function stops recording and returns the recorded
audio as an AudioSegment object. Any silence at the beginning is ignored.

Args:
	ffmpegexe: The path to the ffmpeg executable.
	audiodevice: The ID or name of the audio device to record from.
	silent_seconds_stop: The number of seconds of silence after which recording will stop.
	silence_threshold: The audio level below which silence is considered to have occurred.

Returns:
	The recorded audio as an AudioSegment object.


from ffmpegaudiorecord import start_recording
audio_data = start_recording(
ffmpegexe = r"C:\ffmpeg\ffmpeg.exe", audiodevice=1, silent_seconds_stop=3, silence_threshold=-30)
audio_data.export("c:\\bababababa.wav")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ffmpegaudiorecord-0.11.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

ffmpegaudiorecord-0.11-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file ffmpegaudiorecord-0.11.tar.gz.

File metadata

  • Download URL: ffmpegaudiorecord-0.11.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for ffmpegaudiorecord-0.11.tar.gz
Algorithm Hash digest
SHA256 8388ee8353e7b66d2b4aa08b396dfb2116ea27fe6fdb3506e4a26139d2beaf92
MD5 949a926b14fc8a03e47258e1ac6e8e56
BLAKE2b-256 db8aba98e85e2ea36e6ed87c9ca67bd0f1bd7cb4c1b08f71a279523138b2cf1f

See more details on using hashes here.

File details

Details for the file ffmpegaudiorecord-0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for ffmpegaudiorecord-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 88bb8e62fa8ca319864e81f4eab6bb1515fd83007be5864a9d7045ed687c93ba
MD5 f21dd6ae1a2eb0fc04540f6ecb484e9f
BLAKE2b-256 05ae12d5556a849832f78c74f420dc4af4402f77946943faa0bc4109cfb3019e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page