Update app.py
Browse files296 unmodified lines297298299300301302303304305306307308309310311312313314315316317318319296 unmodified lines@app.route('/video/mp4')def video_mp4():"""MP4 streaming endpoint"""cmd = ['ffmpeg','-f', 'rawvideo','-pix_fmt', 'rgb24','-s', f'{VIDEO_WIDTH}x{VIDEO_HEIGHT}','-r', str(VIDEO_FPS),'-i', '-','-c:v', 'libx264','-preset', 'ultrafast','-tune', 'zerolatency','-b:v', '2M','-f', 'mp4','-movflags', 'frag_keyframe+empty_moov','-']process = subprocess.Popen(cmd,stdin=subprocess.PIPE,296 unmodified lines297298299300301302303304305306307308309310311312313314315316317318319320321322323296 unmodified lines@app.route('/video/mp4')def video_mp4():"""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', '30','-i', '-','-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