tedowski commited on
Commit
66f9ab9
Β·
verified Β·
1 Parent(s): 99e4038

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +115 -65
README.md CHANGED
@@ -1,45 +1,58 @@
1
- # README.md
 
 
 
 
 
 
 
 
 
2
  # Video to Audio Extractor
3
 
4
- A FastAPI-based web application that extracts audio from video files using FFmpeg. Designed to run on Hugging Face Spaces.
5
 
6
- ## Features
7
 
8
- - πŸŽ₯ Supports multiple video formats (MP4, AVI, MOV, MKV, WebM, FLV, WMV, M4V)
9
- - 🎡 Multiple audio output formats (MP3, AAC, WAV, FLAC, M4A, OGG)
10
- - πŸ“Š Three quality levels (High, Medium, Low)
11
- - πŸš€ Automatic handling of small files (< 10MB) with direct response
12
- - πŸ“¦ Background processing for large files with job status tracking
13
- - 🌐 Web interface and REST API
14
- - 🧹 Automatic cleanup of temporary files
15
 
16
- ## API Endpoints
17
 
18
- - `GET /` - Web interface for easy testing
19
- - `POST /extract-audio` - Extract audio from video
20
- - `GET /status/{job_id}` - Check background job status
21
- - `GET /download/{job_id}` - Download processed audio
22
- - `GET /api/info` - Get API information and supported formats
23
 
24
- ## Usage
25
 
26
- ### Web Interface
27
- Simply visit the root URL and use the web form to upload a video file.
28
-
29
- ### API Usage
30
 
31
  ```bash
32
- # Extract audio (small file - direct response)
33
- curl -X POST -F "video=@video.mp4" -F "output_format=mp3" -F "quality=high" \
34
- https://your-space.hf.space/extract-audio \
35
- --output extracted.mp3
 
 
36
 
37
- # Extract audio (large file - background job)
38
- # First, submit the job
39
- response=$(curl -X POST -F "video=@large_video.mp4" -F "output_format=mp3" \
40
- https://your-space.hf.space/extract-audio)
41
 
42
- # Extract job_id from response
 
 
 
 
 
 
43
  job_id=$(echo $response | jq -r '.job_id')
44
 
45
  # Check status
@@ -49,64 +62,101 @@ curl https://your-space.hf.space/status/$job_id
49
  curl https://your-space.hf.space/download/$job_id --output audio.mp3
50
  ```
51
 
52
- ### Python Client Example
53
 
54
  ```python
55
  import requests
 
56
 
57
- # For small files
58
- with open('video.mp4', 'rb') as f:
59
- files = {'video': f}
60
- data = {'output_format': 'mp3', 'quality': 'high'}
61
- response = requests.post('https://your-space.hf.space/extract-audio',
62
- files=files, data=data)
 
63
 
64
  if response.headers.get('content-type', '').startswith('audio/'):
65
- # Direct file response
66
- with open('output.mp3', 'wb') as out:
67
- out.write(response.content)
68
  else:
69
- # Job response for large files
70
  job_data = response.json()
71
  job_id = job_data['job_id']
72
- # Poll status and download when ready
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ```
74
 
75
- ## Quality Settings
76
 
77
- - **High**: Best quality, larger file size
78
- - **Medium**: Balanced quality and file size (default)
79
- - **Low**: Smaller file size, acceptable quality
 
 
80
 
81
- ## Deployment on Hugging Face
82
 
83
- 1. Create a new Space on Hugging Face
84
- 2. Choose "Docker" as the SDK
85
- 3. Upload these files:
86
- - `app.py`
87
- - `requirements.txt`
88
- - `Dockerfile`
89
- - `README.md`
90
- 4. The Space will automatically build and deploy
91
 
92
- ## Local Development
93
 
94
  ```bash
 
 
 
 
95
  # Install dependencies
96
  pip install -r requirements.txt
97
 
98
- # Make sure FFmpeg is installed
99
- # Ubuntu/Debian: sudo apt-get install ffmpeg
100
- # macOS: brew install ffmpeg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- # Run the app
103
- uvicorn app:app --reload --port 7860
104
  ```
105
 
106
- ## Environment Variables
 
 
 
 
107
 
108
- No environment variables required! The app uses temporary file storage and cleans up automatically.
109
 
110
- ## License
111
 
112
- MIT License
 
1
+ ---
2
+ title: Video to Audio Extractor
3
+ emoji: 🎡
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ ---
10
+
11
  # Video to Audio Extractor
12
 
13
+ A FastAPI-based web application that extracts audio from video files using FFmpeg. Convert your videos to audio in various formats with customizable quality settings.
14
 
15
+ ## 🎯 Features
16
 
17
+ - πŸŽ₯ **Multiple video formats**: MP4, AVI, MOV, MKV, WebM, FLV, WMV, M4V
18
+ - 🎡 **Multiple audio formats**: MP3, AAC, WAV, FLAC, M4A, OGG
19
+ - πŸ“Š **Quality levels**: High, Medium, Low
20
+ - πŸš€ **Smart processing**: Direct response for small files, background jobs for large files
21
+ - 🌐 **Web interface**: User-friendly UI with real-time progress
22
+ - πŸ”Œ **REST API**: Full API access for programmatic use
23
+ - 🧹 **Auto-cleanup**: Temporary files cleaned automatically
24
 
25
+ ## πŸ–₯️ Web Interface
26
 
27
+ Visit the Space URL to access the web interface where you can:
28
+ - Upload video files via drag-and-drop or file selection
29
+ - Choose output format and quality
30
+ - Preview and download extracted audio
31
+ - See real-time processing status
32
 
33
+ ## πŸ“‘ API Usage
34
 
35
+ ### Extract Audio (Direct Response)
36
+ For files under 10MB, get immediate response:
 
 
37
 
38
  ```bash
39
+ curl -X POST -F "video=@video.mp4" \
40
+ -F "output_format=mp3" \
41
+ -F "quality=high" \
42
+ https://your-space.hf.space/extract-audio \
43
+ --output audio.mp3
44
+ ```
45
 
46
+ ### Extract Audio (Background Job)
47
+ For larger files:
 
 
48
 
49
+ ```bash
50
+ # Submit job
51
+ response=$(curl -X POST -F "video=@large_video.mp4" \
52
+ -F "output_format=mp3" \
53
+ https://your-space.hf.space/extract-audio)
54
+
55
+ # Get job ID
56
  job_id=$(echo $response | jq -r '.job_id')
57
 
58
  # Check status
 
62
  curl https://your-space.hf.space/download/$job_id --output audio.mp3
63
  ```
64
 
65
+ ### Python Example
66
 
67
  ```python
68
  import requests
69
+ import time
70
 
71
+ def extract_audio(video_path, output_format='mp3', quality='medium'):
72
+ url = 'https://your-space.hf.space/extract-audio'
73
+
74
+ with open(video_path, 'rb') as f:
75
+ files = {'video': f}
76
+ data = {'output_format': output_format, 'quality': quality}
77
+ response = requests.post(url, files=files, data=data)
78
 
79
  if response.headers.get('content-type', '').startswith('audio/'):
80
+ # Direct response - save file
81
+ return response.content
 
82
  else:
83
+ # Background job - poll for completion
84
  job_data = response.json()
85
  job_id = job_data['job_id']
86
+
87
+ while True:
88
+ status = requests.get(f'{url.replace("/extract-audio", "")}/status/{job_id}').json()
89
+ if status['status'] == 'completed':
90
+ audio = requests.get(f'{url.replace("/extract-audio", "")}/download/{job_id}')
91
+ return audio.content
92
+ elif status['status'] == 'failed':
93
+ raise Exception(f"Processing failed: {status.get('error')}")
94
+ time.sleep(2)
95
+
96
+ # Usage
97
+ audio_data = extract_audio('my_video.mp4', 'mp3', 'high')
98
+ with open('output.mp3', 'wb') as f:
99
+ f.write(audio_data)
100
  ```
101
 
102
+ ## πŸ”§ API Endpoints
103
 
104
+ - `GET /` - Web interface
105
+ - `POST /extract-audio` - Extract audio from video
106
+ - `GET /status/{job_id}` - Check job status
107
+ - `GET /download/{job_id}` - Download processed audio
108
+ - `GET /api/info` - API information and supported formats
109
 
110
+ ## πŸ“Š Quality Settings
111
 
112
+ | Quality | MP3 Bitrate | AAC Bitrate | Description |
113
+ |---------|-------------|-------------|-------------|
114
+ | High | 320 kbps | 256 kbps | Best quality, larger files |
115
+ | Medium | 192 kbps | 192 kbps | Balanced (default) |
116
+ | Low | 128 kbps | 128 kbps | Smaller files |
 
 
 
117
 
118
+ ## πŸš€ Local Development
119
 
120
  ```bash
121
+ # Clone the repository
122
+ git clone <your-repo>
123
+ cd video-to-audio-extractor
124
+
125
  # Install dependencies
126
  pip install -r requirements.txt
127
 
128
+ # Install FFmpeg
129
+ # Ubuntu/Debian
130
+ sudo apt-get update && sudo apt-get install ffmpeg
131
+
132
+ # macOS
133
+ brew install ffmpeg
134
+
135
+ # Windows
136
+ # Download from https://ffmpeg.org/download.html
137
+
138
+ # Run the application
139
+ uvicorn app:app --reload --host 0.0.0.0 --port 7860
140
+ ```
141
+
142
+ ## 🐳 Docker Deployment
143
+
144
+ ```bash
145
+ # Build the image
146
+ docker build -t video-to-audio-extractor .
147
 
148
+ # Run the container
149
+ docker run -p 7860:7860 video-to-audio-extractor
150
  ```
151
 
152
+ ## πŸ“ License
153
+
154
+ This project is licensed under the MIT License.
155
+
156
+ ## 🀝 Contributing
157
 
158
+ Contributions are welcome! Please feel free to submit a Pull Request.
159
 
160
+ ## πŸ› Issues
161
 
162
+ If you encounter any issues or have feature requests, please file them in the [Issues](https://huggingface.co/spaces/your-username/your-space-name/discussions) section.