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.10.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ffmpegaudiorecord-0.10.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.10.tar.gz
Algorithm Hash digest
SHA256 1f8712e521b5b8fd954b529770ee7d6d99aedff2387027300c83952617ee4a9a
MD5 a20f55218c5c55280265c2efad66d65f
BLAKE2b-256 6ebaf553e6f67711797de4f7e781987966107421157050f6345c4fe7d541bd5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ffmpegaudiorecord-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 a2612ceafade0c6d717b7e1d84b87eb01ec5b78426bbda87d40e54c2aa2d5106
MD5 7a6886742eecaa4c02461f561a3ea597
BLAKE2b-256 342ea1b47728d31bee1520ef2bac055633f421010d837016c080282935037f0e

See more details on using hashes here.

Supported by

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