Posts

Showing posts from January, 2024

Python Video Streaming Server

    Python Video Streaming Server import http.server     import socketserver     import os     PORT = 8000     VIDEO_PATH = ' test.mp4 '     CHUNK_SIZE = 10 ** 6   # Adjust the chunk size as needed (1000000 Bytes)->(1 MB)       class CustomRequestHandler ( http . server . SimpleHTTPRequestHandler ):         def do_GET ( self ):             if self .path == ' / ':                 self . send_response ( 200 )                 self . send_header (' Content-type ', ' text/html ')                 self . end_headers ()                 # Embed video with correct source                 self .wfile. write ( b ' <video width=250 src="/video" controls>...

Find Memory Consumption Of Your Python Program.

  import psutil def get_memory_usage ():     process = psutil. Process ( os . getpid ())     memory_info = process. memory_info ()         print ( f "Memory Usage: { memory_info . rss / ( 1024 ** 2 ) :.2f } MB" ) # Call this function in your code to print the memory usage get_memory_usage ()