All Rounder Tools Blogger-Best blog for blogger: Video to Audio Converter Tool with colorful styling and all its features use any free library...

Wednesday, September 25, 2024

Video to Audio Converter Tool with colorful styling and all its features use any free library...

 

Video to Audio Converter

Video to Audio Converter

body { font-family: Arial, sans-serif; background-color: #f0f4f8; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .container { background: linear-gradient(135deg, #6d5f9f, #b6b0d7); border-radius: 15px; padding: 20px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); text-align: center; color: white; } h1 { margin-bottom: 20px; } input[type="file"] { padding: 10px; border: none; border-radius: 5px; margin-bottom: 10px; } button { background-color: #ff6b6b; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s; } button:hover { background-color: #ff4c4c; } #message { margin-top: 10px; color: #ffd700; } document.getElementById('convertButton').addEventListener('click', function() { const videoInput = document.getElementById('videoInput'); const audioOutput = document.getElementById('audioOutput'); const message = document.getElementById('message'); if (videoInput.files.length === 0) { message.textContent = "Please select a video file."; return; } const videoFile = videoInput.files[0]; const audioContext = new (window.AudioContext || window.webkitAudioContext)(); const reader = new FileReader(); reader.onload = function(e) { const videoBlob = new Blob([e.target.result], { type: videoFile.type }); const videoURL = URL.createObjectURL(videoBlob); const video = document.createElement('video'); video.src = videoURL; video.addEventListener('loadedmetadata', function() { const source = audioContext.createMediaElementSource(video); const destination = audioContext.destination; source.connect(destination); video.play(); const audioBuffer = audioContext.createBufferSource(); const mediaRecorder = new MediaRecorder(audioContext.createMediaStreamDestination().stream); mediaRecorder.ondataavailable = function(event) { const audioBlob = new Blob([event.data], { type: 'audio/webm' }); const audioURL = URL.createObjectURL(audioBlob); audioOutput.src = audioURL; audioOutput.style.display = 'block'; message.textContent = "Conversion complete! Enjoy your audio."; }; mediaRecorder.start(); video.play(); video.addEventListener('ended', function() { mediaRecorder.stop(); audioContext.close(); }); }); }; reader.readAsArrayBuffer(videoFile); });

No comments:

Post a Comment