{"record":{"id":"d19321451672a47e","repo":"sgl-project/sglang","slug":"bad-metadata-dur-duration-h-original-height-w","errorCode":null,"errorMessage":"bad metadata: dur={duration} h={original_height} w={original_width}","messagePattern":"bad metadata: dur=(.+?) h=(.+?) w=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/dots_note_omni_video_core/preprocess.py","lineNumber":121,"sourceCode":"    decoder,\n    seq_length,\n    visual_budget,\n    *,\n    pf_floor=V2_PF_FLOOR,\n    pf_ceil=V2_PF_CEIL,\n    fps_cap=V2_FPS_CAP,\n    fps_min=V2_FPS_MIN,\n    overhead=V2_OVH,\n    jpeg_quality=85,\n):\n    \"\"\"Decode, resize, and JPEG-encode frames selected by the v2 policy.\"\"\"\n    metadata = decoder.metadata\n    duration = float(metadata.duration_seconds or 0)\n    original_height = int(metadata.height)\n    original_width = int(metadata.width)\n    total_frames = int(metadata.num_frames or 0)\n    if duration <= 0 or original_height <= 0 or original_width <= 0:\n        raise ValueError(\n            f\"bad metadata: dur={duration} h={original_height} w={original_width}\"\n        )\n    original_fps = float(metadata.average_fps or 0) or 25.0\n    if total_frames <= 0:\n        total_frames = max(1, int(duration * original_fps))\n\n    aligned_height = max(ALIGN, round(original_height / ALIGN) * ALIGN)\n    aligned_width = max(ALIGN, round(original_width / ALIGN) * ALIGN)\n    original_patches = (aligned_height // ALIGN) * (aligned_width // ALIGN)\n    num_frames, _, target_patches = v2_solve_degrade(\n        visual_budget,\n        duration,\n        original_patches,\n        original_fps,\n        seq_length,\n        fps_cap=fps_cap,\n        fps_min=fps_min,\n        pf_floor=pf_floor,","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/dots_note_omni_video_core/preprocess.py#L103-L139","documentation":"Raised by extract_frames_v2 in dots_note_omni_video_core when the video decoder's metadata reports a non-positive duration, height, or width. Frame extraction needs valid dimensions and duration to compute the sampling grid, so it aborts immediately.","triggerScenarios":"Feeding a corrupt/truncated video file, a non-video file, or a stream whose container metadata is missing (duration_seconds None -> 0, or height/width 0) through process_sample_video / extract_frames_v2.","commonSituations":"Partially downloaded or re-muxed videos with stripped headers; placeholder/zero-byte files; some WebM/MKV variants where decord/torchaudio metadata fields are unpopulated.","solutions":["Re-encode/remux the file with ffmpeg (ffmpeg -i in.mp4 -c copy fixed.mp4) to rebuild clean metadata","Verify the file plays and probe it: ffprobe shows duration/width/height > 0 before sending","Reject or replace videos with missing metadata in your ingest pipeline"],"exampleFix":"# before\nresp = requests.get(url); open('v.mp4','wb').write(resp.content)  # may be truncated\n# after\nimport subprocess; subprocess.run(['ffmpeg','-v','error','-i','v_raw.mp4','-c','copy','v.mp4'], check=True)\n# then send v.mp4","handlingStrategy":"validation","validationCode":"import subprocess, json\nmeta = json.loads(subprocess.check_output(['ffprobe','-v','error','-select_streams','v:0','-show_entries','stream=width,height:format=duration','-of','json', path]))\nw = meta['streams'][0].get('width', 0); h = meta['streams'][0].get('height', 0)\ndur = float(meta['format'].get('duration', 0) or 0)\nassert w > 0 and h > 0 and dur > 0, f'bad metadata: dur={dur} h={h} w={w}'","typeGuard":null,"tryCatchPattern":"try:\n    frames = extract_frames_v2(video_path)\nexcept ValueError as e:\n    if e.args[0].startswith('bad metadata'):\n        subprocess.run(['ffmpeg','-v','error','-i',video_path,'-c','copy',fixed], check=True)\n        frames = extract_frames_v2(fixed)  # retry with remuxed file","preventionTips":["Probe videos with ffprobe at ingest; reject zero duration/dimensions","Re-mux downloads from unreliable sources before serving"],"tags":["multimodal","video","corrupt-metadata","decoding"],"backgroundTag":"corrupt-media-metadata","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}