@@ -72,7 +72,6 @@ def resolve_recording(filename: str) -> Path:
7272def parse_duration_ns (discover_output : str ) -> int :
7373 duration_ns = 0
7474 for line in discover_output .splitlines ():
75- line = line .decode ("utf-8" , "ignore" )
7675 # Example: Duration: 0:00:12.345678000
7776 if "Duration:" not in line :
7877 continue
@@ -107,6 +106,8 @@ async def build_thumbnail_bytes(path: Path) -> bytes:
107106 text = False ,
108107 )
109108 stdout , stderr = await discover_proc .communicate ()
109+ stdout = stdout .decode ("utf-8" , "ignore" )
110+ stderr = stderr .decode ("utf-8" , "ignore" )
110111 if discover_proc .returncode != 0 :
111112 logger .error (f"gst-discoverer-1.0 failed for { path } : { stderr .strip ()} " )
112113 raise HTTPException (
@@ -145,16 +146,17 @@ async def build_thumbnail_bytes(path: Path) -> bytes:
145146 stderr = asyncio .subprocess .PIPE ,
146147 text = False ,
147148 )
148- out_bytes , err_bytes = await play_proc .communicate ()
149- if play_proc .returncode != 0 or not out_bytes :
150- stderr = err_bytes .decode ("utf-8" , "ignore" )
149+ stdout , stderr = await play_proc .communicate ()
150+ stdout = stdout .decode ("utf-8" , "ignore" )
151+ stderr = stderr .decode ("utf-8" , "ignore" )
152+ if play_proc .returncode != 0 or not stdout :
151153 logger .error (f"gst-play-1.0 failed for { path } (code={ play_proc .returncode } ): { stderr } " )
152154 raise HTTPException (
153155 status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
154156 detail = "Failed to generate thumbnail." ,
155157 )
156158
157- return out_bytes
159+ return stdout
158160
159161
160162async def extract_mcap_recordings () -> None :
@@ -190,12 +192,14 @@ async def extract_mcap_recordings() -> None:
190192 text = False ,
191193 )
192194 stdout , stderr = await process .communicate ()
195+ stdout = stdout .decode ("utf-8" , "ignore" )
196+ stderr = stderr .decode ("utf-8" , "ignore" )
193197 if process .returncode != 0 :
194198 logger .error (
195- f"MCAP extract failed for { mcap_path } (code={ process .returncode } ): { stderr . decode ( 'utf-8' , 'ignore' ) } " ,
199+ f"MCAP extract failed for { mcap_path } (code={ process .returncode } ): { stderr } " ,
196200 )
197201 else :
198- logger .info (f"MCAP extract completed for { mcap_path } : { stdout .decode ( 'utf-8' , 'ignore' ). strip ()} " )
202+ logger .info (f"MCAP extract completed for { mcap_path } : { stdout .strip ()} " )
199203 except Exception as exception :
200204 logger .exception (f"MCAP extraction loop failed: { exception } " )
201205
0 commit comments