{"library":"pymp3","title":"pymp3 Library","description":"pymp3 is a lightweight Python library for reading and writing MP3 files, primarily providing low-level access to MP3 frames and PCM data. It is currently at version 0.2.0 and has an infrequent release cadence, focusing on stability and essential bug fixes.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install pymp3"],"cli":null},"imports":["from pymp3 import MP3Decoder","from pymp3 import MP3Encoder","from pymp3 import PCMFrame"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import io\nfrom pymp3 import MP3Decoder\n\n# In a real application, mp3_data would come from a file or network stream\n# For demonstration, we'll use a placeholder or minimal real data if available.\n# Note: A real MP3 file's header is required for successful decoding.\n# This example uses a very small, non-functional byte string as a stand-in\n# to illustrate the API without requiring a file. Expect decoding errors with this.\n# Replace with actual MP3 data for practical use.\n\n# Example of dummy data (will likely fail to decode, but shows API):\nmp3_data = b'\\xff\\xfb\\x90\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\n\ntry:\n    decoder = MP3Decoder()\n    frames = decoder.decode(mp3_data)\n\n    if not frames:\n        print(\"No frames decoded. Ensure 'mp3_data' contains valid MP3 content.\")\n    else:\n        print(f\"Decoded {len(frames)} PCM frames.\")\n        for i, frame in enumerate(frames):\n            if i < 3: # Print details for first few frames\n                print(f\"Frame {i+1}: Sample Rate={frame.sample_rate}Hz, Channels={frame.channels}, Data Size={frame.data_size} bytes\")\n            # frame.data contains the raw PCM bytes\n\nexcept Exception as e:\n    print(f\"An error occurred during decoding: {e}\")\n    print(\"HINT: Ensure the 'mp3_data' variable contains actual, valid MP3 audio data.\")\n\n\n# --- Example of encoding (conceptual, requires PCM data) ---\n# from pymp3 import MP3Encoder, PCMFrame\n#\n# # Assuming you have some PCM data (e.g., from decoding or generation)\n# # This is highly conceptual as valid PCM data is required.\n# dummy_pcm_data = b'\\x00\\x00\\x00\\x00' * 1024 # Placeholder 16-bit stereo silence\n# sample_rate = 44100\n# channels = 2\n# pcm_frame = PCMFrame(sample_rate, channels, dummy_pcm_data)\n#\n# try:\n#     encoder = MP3Encoder(sample_rate=sample_rate, channels=channels, bitrate=128)\n#     encoded_mp3_data = encoder.encode([pcm_frame]) # encode expects a list of frames\n#     print(f\"Encoded {len(encoded_mp3_data)} bytes of MP3 data (conceptual).\")\n# except Exception as e:\n#     print(f\"An error occurred during encoding: {e}\")\n#     print(\"HINT: Ensure PCMFrame data and encoder parameters are valid.\")\n","lang":"python","description":"This quickstart demonstrates how to use `pymp3.MP3Decoder` to process MP3 data into PCM frames. It also includes a conceptual example for `MP3Encoder`. For actual use, replace the placeholder `mp3_data` with valid MP3 content from a file or stream. The library provides low-level access to audio frames, not high-level ID3 tag manipulation.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"0.2.0","pypi_latest":"0.2.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":80,"avg_install_s":1.7,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"19M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"20.1M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"21M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"12.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pymp3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pymp3","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pymp3","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"18M"}]}}