MCPcopy Index your code
hub / github.com/CScorza/IntelOSINT / api_media_process

Function api_media_process

IntelOSINT.py:19772–21637  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19770
19771@app.route('/api/media/process', methods=['POST'])
19772def api_media_process():
19773 def _resolve_ffmpeg_bin():
19774 sys_ffmpeg = shutil.which("ffmpeg")
19775 if sys_ffmpeg:
19776 return sys_ffmpeg
19777 try:
19778 import imageio_ffmpeg
19779 exe = imageio_ffmpeg.get_ffmpeg_exe()
19780 if exe and Path(exe).exists():
19781 return exe
19782 except Exception:
19783 try:
19784 _install_python_package("imageio-ffmpeg")
19785 import imageio_ffmpeg
19786 exe = imageio_ffmpeg.get_ffmpeg_exe()
19787 if exe and Path(exe).exists():
19788 return exe
19789 except Exception:
19790 pass
19791 return None
19792
19793 def _resolve_ffprobe_bin(ffmpeg_bin=None):
19794 sys_ffprobe = shutil.which("ffprobe")
19795 if sys_ffprobe:
19796 return sys_ffprobe
19797 if ffmpeg_bin:
19798 candidate = Path(ffmpeg_bin).with_name("ffprobe.exe" if os.name == "nt" else "ffprobe")
19799 if candidate.exists():
19800 return str(candidate)
19801 return None
19802
19803 def _compute_hashes(video_path: Path, chunk_size: int = 1024 * 1024):
19804 md5_h = hashlib.md5()
19805 sha256_h = hashlib.sha256()
19806 with open(video_path, "rb") as fh:
19807 while True:
19808 chunk = fh.read(chunk_size)
19809 if not chunk:
19810 break
19811 md5_h.update(chunk)
19812 sha256_h.update(chunk)
19813 return {"md5": md5_h.hexdigest(), "sha256": sha256_h.hexdigest()}
19814
19815 def _format_report_value(v):
19816 if v is None:
19817 return "N/D"
19818 if isinstance(v, (dict, list)):
19819 try:
19820 return json.dumps(v, ensure_ascii=False, indent=2, default=str)
19821 except Exception:
19822 return str(v)
19823 if isinstance(v, bool):
19824 return "Sì" if v else "No"
19825 return str(v)
19826
19827 def _latin1(v):
19828 return str(v).encode("latin-1", "ignore").decode("latin-1")
19829

Callers

nothing calls this directly

Calls 11

_parse_rgb_deltaFunction · 0.85
_resolve_ffmpeg_binFunction · 0.85
_safe_floatFunction · 0.85
_run_ffmpegFunction · 0.85
probe_metadataFunction · 0.85
_build_media_reportFunction · 0.85
safe_json_dumpFunction · 0.85
_build_segment_concatFunction · 0.85
probe_image_metadataFunction · 0.85
_install_python_packageFunction · 0.85

Tested by

no test coverage detected