live stream player

Here’s a live stream player based on video.js. <html> <head> <link href="https://vjs.zencdn.net/7.19.2/video-js.css" rel="stylesheet" /> </head> <body> <video id="my-video" class="video-js vjs-big-play-centered vjs-theme-sea" controls preload="auto" fluid="true" poster="https://www.tutorialspoint.com/videos/sample.png" data-setup='{}' > </video> <script src="https://vjs.zencdn.net/7.17.0/video.min.js"> </script> <script src="https://unpkg.com/videojs-contribhls/dist/videojs-contrib-hls.js"></script> <script> var player = videojs('my-video'); player.src({ src: 'http://localhost:8090/hls/stream.m3u8', type: 'application/x-mpegURL' }); // Assuming you have a reference to your video element const videoElement = document.getElementById('my-video'); // Style the video element to center it both horizontally and vertically videoElement.style.display = 'block'; // Ensure it behaves like a block element videoElement.style.margin = '0 auto'; // Center it horizontally videoElement.style.position = 'absolute'; // Position it absolutely to center vertically videoElement.style.top = '50%'; // Vertically center videoElement.style.left = '50%'; // Horizontally center videoElement.style.transform = 'translate(-50%, -50%)'; // Adjust for exact centering videoElement.style.maxWidth = '90%'; // Optional: limit the video size to 90% of the screen width videoElement.style.maxHeight = '80vh'; // Optional: limit the video height to 80% of the viewport height </script> </body> </html>

January 8, 2025 · 1 min · ulysses

nginx rtmp streaming docker

Create a nginx.conf file. worker_processes 1; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; hls on; hls_path /hls; } } } http { server { listen 80; root /hls; location / { add_header 'Access-Control-Allow-Origin' '*'; index index.html index.htm; } location /hls { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } add_header 'Access-Control-Allow-Origin' '*'; alias /hls; } } } Create a docker-compose.yml file. ...

January 8, 2025 · 1 min · ulysses

convert mp3 to wav

How to convert a MP3 file to WAV using Python. from pydub import AudioSegment def convert_mp3_to_wav(mp3_file, wav_file): """Converts an MP3 file to WAV format.""" sound = AudioSegment.from_mp3(mp3_file) sound.export(wav_file, format="wav") if __name__ == "__main__": mp3_file = "gettysburg10.mp3" # Replace with your MP3 file wav_file = "output.wav" # Replace with desired output WAV filename convert_mp3_to_wav(mp3_file, wav_file) print(f"Conversion complete: {mp3_file} -> {wav_file}")

January 6, 2025 · 1 min · ulysses

convert mp4 to hls

Here’s how to convert MP4 to HLS video format. import ffmpeg def convert_to_hls(input_file, output_file): """Converts an MP4 file to HLS format.""" output_file = f"{output_dir}/output.m3u8" stream = ffmpeg.input(input_file) stream = ffmpeg.output(stream, output_file, format='hls', hls_time=10, hls_list_size=0, start_number=0) ffmpeg.run(stream) if __name__ == "__main__": input_file = "bunny.mp4" output_dir = "files" convert_to_hls(input_file, output_dir)

January 6, 2025 · 1 min · ulysses

convert wav mp3

Here’s how to convert a WAV file to MP3 in Python. from pydub import AudioSegment def convert_wav_to_mp3(wav_file, mp3_file): """Converts a WAV file to MP3.""" sound = AudioSegment.from_wav(wav_file) sound.export(mp3_file, format="mp3") if __name__ == "__main__": wav_file = "gettysburg10.wav" mp3_file = "output.mp3" convert_wav_to_mp3(wav_file, mp3_file) print(f"Converted {wav_file} to {mp3_file}")

January 6, 2025 · 1 min · ulysses

gcloud could not setup log file

I was getting this error whenever Apache runs a gcloud command. WARNING: Could not setup log file in /usr/share/httpd/.config/gcloud/logs, (Error: Could not create directory [/usr/share/httpd/.config/gcloud/logs/2025.01.06]: Permission denied. Please verify that you have permissions to write to the parent directory.. The configuration directory may not be writable. To learn more, see https://cloud.google.com/sdk/docs/configurations#creating_a_configuration ERROR: (gcloud.compute.disks.list) Could not create directory [/usr/share/httpd/.config/gcloud]: Permission denied. Please verify that you have permissions to write to the parent directory. So, here’s the fix. The .config directory under /usr/share/httpd/ is missing. ...

January 6, 2025 · 1 min · ulysses

hls player

Here’s an HLS video player using hls.js. <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.5.14/hls.js"></script> </head> <body> <p><video id="video" controls muted autoplay style="width: 80%"></video></p> <script> var video = document.getElementById('video'); var videoSrc = '/bunny/output.m3u8'; // Initialize HLS.js if supported if (Hls.isSupported()) { var hls = new Hls(); hls.loadSource(videoSrc); hls.attachMedia(video); hls.on(Hls.Events.MANIFEST_PARSED, function () { video.muted = true; video.play(); }); } else if (video.canPlayType('application/vnd.apple.mpegurl')) { video.src = videoSrc; } // Assuming you have a reference to your video element const videoElement = document.getElementById('video'); // Style the video element to center it both horizontally and vertically videoElement.style.display = 'block'; // Ensure it behaves like a block element videoElement.style.margin = '0 auto'; // Center it horizontally videoElement.style.position = 'absolute'; // Position it absolutely to center vertically videoElement.style.top = '50%'; // Vertically center videoElement.style.left = '50%'; // Horizontally center videoElement.style.transform = 'translate(-50%, -50%)'; // Adjust for exact centering videoElement.style.maxWidth = '90%'; // Optional: limit the video size to 90% of the screen width videoElement.style.maxHeight = '80vh'; // Optional: limit the video height to 80% of the viewport height // Create a button to unmute the player const unmuteButton = document.createElement('button'); unmuteButton.textContent = 'Unmute'; // Style the button to make it bigger unmuteButton.style.fontSize = '30px'; // Larger font size unmuteButton.style.padding = '20px 40px'; // Larger button size unmuteButton.style.backgroundColor = '#007BFF'; // Button color unmuteButton.style.color = 'white'; // Text color unmuteButton.style.border = 'none'; // Remove border unmuteButton.style.borderRadius = '10px'; // Rounded corners unmuteButton.style.cursor = 'pointer'; // Pointer cursor on hover unmuteButton.style.position = 'absolute'; // Absolute positioning unmuteButton.style.top = '50%'; // Vertically center unmuteButton.style.left = '50%'; // Horizontally center unmuteButton.style.transform = 'translate(-50%, -50%)'; // Adjust for exact centering // Add an event listener to the button unmuteButton.addEventListener('click', () => { videoElement.muted = false; // Unmute the video unmuteButton.remove(); // Remove the button once clicked }); // Add the button to the DOM document.body.appendChild(unmuteButton); </script> </body>

January 6, 2025 · 2 min · ulysses

generate qrcode

This is a Python code that generates QR Codes. Save file as qrcode.py. Provide a URL and you’re good to go. import pyqrcode from pyqrcode import QRCode # String which represent the QR code s = "https://uly.me" # Generate QR code url = pyqrcode.create(s) # Create and save the png file naming "myqr.png" url.svg("site.svg", scale = 8) I use Python’s virtual environment for my programs so each one is isolated. Here’s the command to start one. ...

January 5, 2025 · 1 min · ulysses

delete files recursively

Here’s one way to delete files recursively in the current directory in Linux. cd /home/ulysses/photos/ find . -name "*.pp3" -type f -delete The run command with delete is fast. The files are gone in seconds.

January 1, 2025 · 1 min · ulysses

install azure cli

Install the Azure CLI on a Linux Desktop. This one of 2 options, but this is by far the easiest. curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash Validate Azure CLI is installed az --version To upgrade az upgrade

December 30, 2024 · 1 min · ulysses