|  | <!DOCTYPE html> | 
					
						
						|  | <html lang="en"> | 
					
						
						|  | <head> | 
					
						
						|  | <meta charset="UTF-8"> | 
					
						
						|  | <title>MP4 to WebM Converter</title> | 
					
						
						|  | <style> | 
					
						
						|  | body { | 
					
						
						|  | font-family: Arial, sans-serif; | 
					
						
						|  | max-width: 600px; | 
					
						
						|  | margin: 20px auto; | 
					
						
						|  | padding: 20px; | 
					
						
						|  | } | 
					
						
						|  | .container { | 
					
						
						|  | border: 2px dashed #ccc; | 
					
						
						|  | padding: 20px; | 
					
						
						|  | text-align: center; | 
					
						
						|  | } | 
					
						
						|  | #preview { | 
					
						
						|  | max-width: 100%; | 
					
						
						|  | margin-top: 20px; | 
					
						
						|  | } | 
					
						
						|  | .hidden { | 
					
						
						|  | display: none; | 
					
						
						|  | } | 
					
						
						|  | button { | 
					
						
						|  | padding: 10px 20px; | 
					
						
						|  | background: #4CAF50; | 
					
						
						|  | color: white; | 
					
						
						|  | border: none; | 
					
						
						|  | cursor: pointer; | 
					
						
						|  | margin: 10px; | 
					
						
						|  | } | 
					
						
						|  | button:disabled { | 
					
						
						|  | background: #cccccc; | 
					
						
						|  | } | 
					
						
						|  | </style> | 
					
						
						|  | </head> | 
					
						
						|  | <body> | 
					
						
						|  | <div class="container"> | 
					
						
						|  | <h2>MP4 to WebM Converter</h2> | 
					
						
						|  | <input type="file" id="fileInput" accept="video/mp4"> | 
					
						
						|  | <button id="convertBtn" disabled>Convert to WebM</button> | 
					
						
						|  | <a id="downloadLink" class="hidden"><button>Download WebM</button></a> | 
					
						
						|  | <video id="preview" controls></video> | 
					
						
						|  | </div> | 
					
						
						|  |  | 
					
						
						|  | <script> | 
					
						
						|  | const fileInput = document.getElementById('fileInput'); | 
					
						
						|  | const convertBtn = document.getElementById('convertBtn'); | 
					
						
						|  | const downloadLink = document.getElementById('downloadLink'); | 
					
						
						|  | const preview = document.getElementById('preview'); | 
					
						
						|  |  | 
					
						
						|  | let mediaRecorder; | 
					
						
						|  | let recordedChunks = []; | 
					
						
						|  |  | 
					
						
						|  | fileInput.addEventListener('change', async (e) => { | 
					
						
						|  | const file = e.target.files[0]; | 
					
						
						|  | if (!file) return; | 
					
						
						|  |  | 
					
						
						|  | const url = URL.createObjectURL(file); | 
					
						
						|  | preview.src = url; | 
					
						
						|  | convertBtn.disabled = false; | 
					
						
						|  | }); | 
					
						
						|  |  | 
					
						
						|  | convertBtn.addEventListener('click', async () => { | 
					
						
						|  | if (!preview.src) return; | 
					
						
						|  |  | 
					
						
						|  | try { | 
					
						
						|  | convertBtn.disabled = true; | 
					
						
						|  | convertBtn.textContent = 'Converting...'; | 
					
						
						|  |  | 
					
						
						|  | const stream = await preview.captureStream(); | 
					
						
						|  | recordedChunks = []; | 
					
						
						|  |  | 
					
						
						|  | mediaRecorder = new MediaRecorder(stream, { | 
					
						
						|  | mimeType: 'video/webm; codecs=vp9' | 
					
						
						|  | }); | 
					
						
						|  |  | 
					
						
						|  | mediaRecorder.ondataavailable = (e) => { | 
					
						
						|  | if (e.data.size > 0) recordedChunks.push(e.data); | 
					
						
						|  | }; | 
					
						
						|  |  | 
					
						
						|  | mediaRecorder.onstop = () => { | 
					
						
						|  | const blob = new Blob(recordedChunks, { type: 'video/webm' }); | 
					
						
						|  | const url = URL.createObjectURL(blob); | 
					
						
						|  | downloadLink.href = url; | 
					
						
						|  | downloadLink.download = `converted_${Date.now()}.webm`; | 
					
						
						|  | downloadLink.classList.remove('hidden'); | 
					
						
						|  | convertBtn.textContent = 'Convert to WebM'; | 
					
						
						|  | convertBtn.disabled = false; | 
					
						
						|  | }; | 
					
						
						|  |  | 
					
						
						|  | mediaRecorder.start(); | 
					
						
						|  | preview.play(); | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | preview.addEventListener('ended', () => { | 
					
						
						|  | mediaRecorder.stop(); | 
					
						
						|  | }); | 
					
						
						|  |  | 
					
						
						|  | } catch (error) { | 
					
						
						|  | console.error('Conversion error:', error); | 
					
						
						|  | alert('Error during conversion: ' + error.message); | 
					
						
						|  | convertBtn.textContent = 'Convert to WebM'; | 
					
						
						|  | convertBtn.disabled = false; | 
					
						
						|  | } | 
					
						
						|  | }); | 
					
						
						|  | </script> | 
					
						
						|  | </body> | 
					
						
						|  | </html> |