From e9bb8ef1bc0d90c2ad0e0511d65d6821afedc4ef Mon Sep 17 00:00:00 2001 From: Daniel Samson <12231216+daniel-samson@users.noreply.github.com> Date: Thu, 22 Jan 2026 10:15:59 +0000 Subject: [PATCH] docs: use cross-platform barn commands only Remove shell-specific commands (tail, watch, grep) in favor of barn describe --logs for cross-platform compatibility. Co-Authored-By: Claude Opus 4.5 --- docs/ffmpeg.md | 68 +++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 42 deletions(-) diff --git a/docs/ffmpeg.md b/docs/ffmpeg.md index e53ee4d..a871864 100644 --- a/docs/ffmpeg.md +++ b/docs/ffmpeg.md @@ -154,49 +154,31 @@ Example error response: } ``` -### Complete Example Script +### Polling Example + +Poll until job completes: ```bash -#!/bin/bash -set -e +# Submit job and get ID +barn run --output=json -- ffmpeg -y -progress pipe:1 -threads 0 -i input.mkv -c:v libx264 output.mp4 +# Returns: {"id": "job-abc123", "state": "QUEUED", ...} -INPUT="/path/to/input.mkv" -OUTPUT="/path/to/output.mp4" +# Poll for status +barn describe job-abc123 --output=json +# Check "state" field: "queued", "running", "succeeded", "failed" -# Submit job -RESPONSE=$(barn run --output=json -- ffmpeg -y -progress pipe:1 -threads 0 -i "$INPUT" -c:v libx264 "$OUTPUT") -JOB_ID=$(echo "$RESPONSE" | jq -r '.id') -echo "Started job: $JOB_ID" - -# Poll until complete -while true; do - STATUS=$(barn describe "$JOB_ID" --output=json) - STATE=$(echo "$STATUS" | jq -r '.state') - - case "$STATE" in - "queued"|"running") - # Get progress - PROGRESS=$(barn describe "$JOB_ID" --logs --output=json | jq -r '.logs.stdout' | grep -o 'speed=[0-9.]*x' | tail -1) - echo "Status: $STATE $PROGRESS" - sleep 2 - ;; - "succeeded") - echo "Job completed successfully" - exit 0 - ;; - "failed") - ERROR=$(echo "$STATUS" | jq -r '.error') - echo "Job failed: $ERROR" - exit 1 - ;; - *) - echo "Job ended with state: $STATE" - exit 1 - ;; - esac -done +# Get progress while running +barn describe job-abc123 --logs --output=json +# Parse "logs.stdout" for progress fields (frame=, speed=, progress=) ``` +The polling loop logic: +1. Call `barn describe --output=json` +2. Check `state` field +3. If `queued` or `running`, sleep and repeat +4. If `succeeded`, job is done (exitCode = 0) +5. If `failed`, check `error` and `logs.stderr` for details + --- ## Recommended FFmpeg Command @@ -275,16 +257,18 @@ This is correct behavior, not a bug. Use `-progress pipe:1` to get progress in s ## Monitoring FFmpeg Jobs -To watch FFmpeg progress in real-time: +To check FFmpeg progress: ```bash -# Watch the stdout log (with -progress pipe:1) -tail -f /tmp/barn/jobs//logs/stdout.log +# Get current progress (human-readable) +barn describe --logs -# Or use barn describe with --logs -watch -n 2 'barn describe --logs --output=json | jq -r .logs.stdout' +# Get current progress (JSON for parsing) +barn describe --logs --output=json ``` +The `logs.stdout` field contains the `-progress pipe:1` output with fields like `frame=`, `fps=`, `speed=`, and `progress=`. + ## FFmpeg Exit Codes | Exit Code | Meaning |