Update app.py
Browse files296 unmodified lines297298299300300301302303304305306307306308309308309310310311312313314315316317318319320321322323296 unmodified lines
@app.route('/video/mp4')def video_mp4(): """MP4 streaming endpoint""" """GPU-accelerated MP4 streaming using NVENC""" cmd = [ 'ffmpeg', '-hwaccel', 'cuda', # Use GPU for decoding '-hwaccel_output_format', 'cuda', # Keep data on GPU '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-s', f'{VIDEO_WIDTH}x{VIDEO_HEIGHT}', '-r', str(VIDEO_FPS), '-r', '30', '-i', '-', '-c:v', 'libx264', '-preset', 'ultrafast', '-tune', 'zerolatency', '-c:v', 'h264_nvenc', # NVIDIA's GPU encoder '-preset', 'p4', # p1-p7, p4 is good balance '-tune', 'll', # Low latency tuning '-b:v', '2M', '-bufsize', '4M', '-f', 'mp4', '-movflags', 'frag_keyframe+empty_moov', '-' ] process = subprocess.Popen( cmd, stdin=subprocess.PIPE,app.py+9-5