Skip to content

Commit

Permalink
transcode audio
Browse files Browse the repository at this point in the history
  • Loading branch information
tyr84 committed Nov 11, 2023
1 parent 7ceac9e commit 6c0ce7f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ async def _start_proxy_stream(self):
while exit_code > 0:
self.proxy_stream = await asyncio.create_subprocess_exec(
*(['ffmpeg', '-i', 'pipe:'] + self.ffmpeg_out),
stdin=self.proxy_reader, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
stdin=self.proxy_reader,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
exit_code = await self.proxy_stream.wait()

Expand All @@ -145,10 +147,13 @@ async def _start_idle_stream(self):
exit_code = 1
while exit_code > 0:
self.stream = await asyncio.create_subprocess_exec(
*['ffmpeg', '-re', '-stream_loop', '-1',
'-i', 'idle.mp4', '-c:v', 'copy', '-c:a', 'copy',
'-bsf', 'dump_extra', '-f', 'mpegts', 'pipe:'],
stdin=subprocess.DEVNULL, stdout=self.proxy_writer, stderr=subprocess.DEVNULL
*['ffmpeg', '-re', '-stream_loop', '-1', '-i', 'idle.mp4',
'-c:v', 'copy',
'-c:a', 'libmp3lame', '-ar', '44100',
'-bsf', 'dump_extra', '-f', 'mpegts', 'pipe:'],
stdin=subprocess.DEVNULL,
stdout=self.proxy_writer,
stderr=subprocess.DEVNULL
)
exit_code = await self.stream.wait()

Expand All @@ -170,9 +175,12 @@ async def _start_stream(self):
self.stop_stream()

self.stream = await asyncio.create_subprocess_exec(
*['ffmpeg', '-i', stream, '-c:v', 'copy', '-c:a', 'copy',
'-bsf', 'dump_extra', '-f', 'mpegts', 'pipe:'],
stdin=subprocess.DEVNULL, stdout=self.proxy_writer, stderr=subprocess.DEVNULL
*['ffmpeg', '-i', stream, '-c:v', 'copy',
'-c:a', 'libmp3lame', '-ar', '44100',
'-bsf', 'dump_extra', '-f', 'mpegts', 'pipe:'],
stdin=subprocess.DEVNULL,
stdout=self.proxy_writer,
stderr=subprocess.DEVNULL
)

async def _stream_timeout(self):
Expand Down

0 comments on commit 6c0ce7f

Please sign in to comment.