{"record":{"id":"004a31268a4edea4","repo":"ATH-MaaS/Pixelle-Video","slug":"failed-to-pad-video-error-msg","errorCode":null,"errorMessage":"Failed to pad video: {error_msg}","messagePattern":"Failed to pad video: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/video.py","lineNumber":1003,"sourceCode":"                \n                (\n                    ffmpeg\n                    .output(\n                        video_stream,\n                        output,\n                        vcodec='libx264',\n                        preset='fast',\n                        crf=23\n                    )\n                    .overwrite_output()\n                    .run(capture_stdout=True, capture_stderr=True, quiet=True)\n                )\n            \n            return output\n        except ffmpeg.Error as e:\n            error_msg = e.stderr.decode() if e.stderr else str(e)\n            logger.error(f\"FFmpeg error padding video: {error_msg}\")\n            raise RuntimeError(f\"Failed to pad video: {error_msg}\")\n\n","sourceCodeStart":985,"sourceCodeEnd":1005,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/video.py#L985-L1005","documentation":"_pad_video_to_duration catches ffmpeg.Error from the padding step (extending the last frame or adding black frames to reach target duration) and re-raises RuntimeError with ffmpeg's stderr. It signals the ffmpeg pad filtergraph failed, distinct from the trim failure at the same call site.","triggerScenarios":"merge_audio_video calls _pad_video_to_duration and ffmpeg fails: input codec/filter incompatibility with tpad or the freeze strategy, invalid target_duration (<= 0), unwritable output path, or missing ffmpeg binary.","commonSituations":"Videos with codecs the pad filter chain cannot handle (e.g. unusual pixel formats with 'freeze' strategy); duration values parsed from float rounding errors; ffmpeg build lacking needed filters.","solutions":["Inspect the stderr in the message for the specific filter/codec complaint","Try the other pad_strategy ('black' vs 'freeze') if one fails on this codec","Re-encode/normalize the input video to h264/yuv420p before padding","Verify target_duration > 0 and ffmpeg supports the required filters (`ffmpeg -filters | grep tpad`)"],"exampleFix":"// before\nservice._pad_video_to_duration('clip.mkv', 12.5, pad_strategy='freeze')\n// after\nservice._pad_video_to_duration('clip.mkv', 12.5, pad_strategy='black')  # fallback strategy","handlingStrategy":"fallback","validationCode":"import shutil\n\ndef ffmpeg_available() -> bool:\n    return shutil.which('ffmpeg') is not None\n\ndef validate_pad_target(duration: float) -> float:\n    if not (duration > 0):\n        raise ValueError(f'target_duration must be positive: {duration}')\n    return duration","typeGuard":null,"tryCatchPattern":"try:\n    padded = service._pad_video_to_duration(video, target, pad_strategy='freeze')\nexcept RuntimeError:\n    padded = service._pad_video_to_duration(video, target, pad_strategy='black')","preventionTips":["Normalize inputs to h264/yuv420p before filter-heavy operations","Fall back between pad strategies on failure","Verify required ffmpeg filters exist (`ffmpeg -filters`) in your deployment"],"tags":["ffmpeg","runtime-error","video-padding","subprocess"],"backgroundTag":"ffmpeg-command-failed","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}