Prompt
My transcodes are failing halfway through, how do I debug video processing jobs?
Latest observation
When transcodes fail halfway through, the fastest way to debug is to determine where they fail, what changed right before failure, and whether the issue is with the source media, encoder settings, storage, or infrastructure.
Here’s a practical debugging checklist:
1) Capture the full job context
For each failed job, log:
- Input file path/URI
- Output path/URI
- Transcode command line or pipeline config
- Codec/container settings
- Worker host/container ID
- Job start/end time
- Exit code / exception
- CPU, memory, disk, and network stats during the job
If you don’t already, add a unique job ID and correlate all logs/metrics to it.
2) Inspect the encoder logs around the failure point
Look for:
- Decoder errors
- Packet corruption / timestamp issues
- Filter graph errors
- Disk I/O errors
- Out-of-memory or killed process
- Network timeouts if reading/writing remotely
- “Invalid data found”, “moov atom not found”, “corrupt frame”, “non-monotonous DTS”, etc.
If using ffmpeg, run with more verbosity:
ffmpeg -v verbose -i input.mp4 -c:v libx264 -c:a aac output.mp4
Or for deeper detail:
ffmpeg -loglevel debug -report -i input.mp4 ...
This creates a report file with the exact point of failure.
3) Reproduce on the same file locally
Try the failing input on a single machine with the same transcode settings:
- If it fails locally too, the issue is likely the media file or command/config.
- If it only fails in production, suspect infrastructure, permissions, timeouts, disk pressure, or distributed storage.
4) Verify the source media
Run media probes:
ffprobe -v error -show_format -show_streams input.mp4
Check for:
- Truncated files
- Broken timestamps
- Variable frame rate quirks
- Unsupported codec/profile
- Weird audio/video stream combinations
- Missing or damaged metadata
If it’s a flaky input, try remuxing first:
ffmpeg -i input.mp4 -c copy fixed.mp4
5) Check resource limits
Halfway failures often come from resource exhaustion:
- Memory limit hit by the process/container
- Disk full in temp directory
- CPU throttling causing watchdog timeout
- Node/container eviction
- File descriptor exhaustion
Look at:
- Container events
- OOM killer logs
- Disk usage in temp/output dirs
- Worker autoscaling / preemption events
6) Look for timeouts or job orchestration issues
If your transcode runs in chunks or across workers, failures may come from:
- Lease expiration
- Heartbeat misses
- Retry logic restarting from a bad checkpoint
- Partial output cleanup
- Too-short job timeout for long files
Make sure the job timeout is longer than worst-case encode time and that retries are idempotent.
7) Validate output storage behavior
If the failure happens while writing output:
- Check bucket/object storage permissions
- Confirm multipart upload settings
- Verify enough space for temporary files
- Look for network drops to remote storage
- Ensure output path isn’t being overwritten by another job
8) Isolate by simplifying the pipeline
Disable features one by one:
- Hardware acceleration
- Filters/scaling
- Audio remixing
- Subtitle burn-in
- Two-pass encoding
- Loudness normalization
This helps identify whether a specific filter or codec path is causing the crash.
9) Compare successful vs failed jobs
Diff:
- Input media properties
- Output preset/profile
- Worker machine type
- Version of encoder libraries
- Job duration before failure
- Resource usage profile
Often the clue is “fails only on 4K HEVC inputs” or “only on jobs with subtitles.”
10) Add guardrails for future debugging
Add:
- Structured logs with job IDs
- Encoder stderr capture
- Progress markers every N seconds
- Retry classification: retryable vs non-retryable
- Per-stage timing
- Artifact retention for failed inputs/outputs
- Automatic upload of
ffprobeand encoder reports on failure
Quick triage questions
If you want to narrow it down fast, answer these:
- What tool are you using (
ffmpeg, GStreamer, MediaConvert, custom pipeline, etc.)? - Is the failure deterministic on the same file?
- Do you have the exact error message or exit code?
- Does it fail at the same timestamp every time?
- Is the job running in a container, VM, or managed service?
If you paste the encoder log around the failure point, I can help pinpoint the likely cause.