Start gstream process read audio from stream
(self)
| 95 | raise |
| 96 | |
| 97 | def start_ffmpeg_process_whep(self): |
| 98 | """Start gstream process read audio from stream""" |
| 99 | ffmpeg_cmd = [ |
| 100 | "gst-launch-1.0", |
| 101 | "-q", |
| 102 | "whepsrc", |
| 103 | f"whep-endpoint={self.stream_url}", |
| 104 | "video-caps=none", |
| 105 | "!rtpopusdepay", |
| 106 | "!opusdec", |
| 107 | "plc=false", |
| 108 | "!audioconvert", |
| 109 | "!audioresample", |
| 110 | f"!audio/x-raw,format=S16LE,channels={self.audio_channels},rate={self.sample_rate}", |
| 111 | "!fdsink", |
| 112 | "fd=1", |
| 113 | ] |
| 114 | try: |
| 115 | self.ffmpeg_process = subprocess.Popen( |
| 116 | ffmpeg_cmd, |
| 117 | stdout=subprocess.PIPE, |
| 118 | # stderr=subprocess.PIPE, |
| 119 | bufsize=0, |
| 120 | ) |
| 121 | logger.info(f"FFmpeg audio pull process started with PID: {self.ffmpeg_process.pid}") |
| 122 | logger.info(f"FFmpeg command: {' '.join(ffmpeg_cmd)}") |
| 123 | except Exception as e: |
| 124 | logger.error(f"Failed to start FFmpeg process: {e}") |
| 125 | raise |
| 126 | |
| 127 | def audio_worker(self): |
| 128 | logger.info("Audio pull worker thread started") |