MCPcopy Create free account
hub / github.com/JasonLSC/GSCodec_Studio / _build_hm_encode_cmd

Method _build_hm_encode_cmd

gsplat/compression/video_codec.py:194–230  ·  view source on GitHub ↗

Builds the encoding command for HM (TAppEncoder).

(self, i_path: Path, o_path: Path, p: Dict[str, Any])

Source from the content-addressed store, hash-verified

192 return cmd
193
194 def _build_hm_encode_cmd(self, i_path: Path, o_path: Path, p: Dict[str, Any]) -> List[str]:
195 """Builds the encoding command for HM (TAppEncoder)."""
196 for key in ['width', 'height', 'qp', 'pix_fmt', 'frame_num']:
197 if key not in p:
198 raise ValueError(f"Missing required parameter for HM: '{key}'")
199
200 pix_fmt_map = {'yuv420p': '420', 'yuv422p': '422', 'yuv444p': '444', 'yuv400p': '400'}
201 chroma_format = pix_fmt_map.get(p['pix_fmt'])
202 if not chroma_format:
203 raise ValueError(f"Unsupported pix_fmt for HM: {p['pix_fmt']}")
204
205 # Use lossless config if qp < 0
206 if p['qp'] < 0:
207 config_path = self.intra_lossless_config_path if p.get('use_all_intra') else self.inter_lossless_config_path
208 qp_value = 4
209 else:
210 config_path = self.intra_lossy_config_path if p.get('use_all_intra') else self.inter_lossy_config_path
211 qp_value = p['qp']
212
213 cmd = [
214 str(self.encoder_path),
215 '-c', config_path,
216 '-i', str(i_path),
217 '-b', str(o_path),
218 '-wdt', str(p['width']),
219 '-hgt', str(p['height']),
220 '-q', str(qp_value),
221 '-cf', chroma_format, # output chroma format
222 '-fr', '30',
223 '-f', str(p['frame_num']),
224 f'--InputChromaFormat={chroma_format}', # input chroma format
225 ]
226 if p.get('all_intra', False):
227 cmd.extend(['--IntraPeriod', '1'])
228 if 'extra_params' in p:
229 cmd.extend(p['extra_params'])
230 return cmd
231
232 def _build_ffmpeg_encode_cmd(self, i_path: Path, o_path: Path, p: Dict[str, Any]) -> List[str]:
233 """Builds the encoding command for FFmpeg (e.g., using libx265)."""

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected