{"record":{"id":"f711d20fd086a7f5","repo":"jackwener/OpenCLI","slug":"instagram-private-story-publish-does-not-support-t","errorCode":null,"errorMessage":"Instagram private story publish does not support trimming long videos on ${process.platform}","messagePattern":"Instagram private story publish does not support trimming long videos on (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":519,"sourceCode":"    const bytes = fs.readFileSync(filePath);\n    const metadata = readVideoMetadata(filePath);\n    const coverImage = generateVideoCoverImage(filePath);\n    return {\n        filePath,\n        fileName: path.basename(filePath),\n        mimeType: 'video/mp4',\n        width: metadata.width,\n        height: metadata.height,\n        durationMs: metadata.durationMs,\n        byteLength: bytes.length,\n        bytes,\n        coverImage,\n        cleanupPaths: coverImage.cleanupPath ? [coverImage.cleanupPath] : [],\n    };\n}\nfunction trimVideoForInstagramStory(filePath, maxDurationMs) {\n    if (process.platform !== 'darwin') {\n        throw new CommandExecutionError(`Instagram private story publish does not support trimming long videos on ${process.platform}`, 'Use macOS for private story video publishing, or trim the video to 15 seconds first');\n    }\n    const outputPath = buildPrivateStoryVideoPath(filePath);\n    runSwiftJsonScript(`\nimport AVFoundation\nimport Foundation\n\nlet inputPath = CommandLine.arguments[1]\nlet outputPath = CommandLine.arguments[2]\nlet durationMs = Int(CommandLine.arguments[3]) ?? 15000\nlet asset = AVURLAsset(url: URL(fileURLWithPath: inputPath))\nguard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality) else {\n  fputs(\"{\\\\\"error\\\\\":\\\\\"missing-export-session\\\\\"}\", stderr)\n  exit(1)\n}\nexportSession.outputURL = URL(fileURLWithPath: outputPath)\nexportSession.outputFileType = .mp4\nexportSession.shouldOptimizeForNetworkUse = true\nexportSession.timeRange = CMTimeRange(","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L501-L537","documentation":"trimVideoForInstagramStory re-encodes videos longer than 15 seconds with an AVFoundation Swift script, which only works on macOS; elsewhere it throws at clis/instagram/_shared/private-publish.js:519. The hint says to use macOS or trim the video to 15 seconds yourself first.","triggerScenarios":"Calling trimmedPath (via trimVideoForInstagramStory) with a video exceeding maxDurationMs while process.platform is not 'darwin'.","commonSituations":"Publishing stories from a Linux CI job where the source video is 30+ seconds; Windows automation scripts handling user-uploaded long videos; teams that moved their automation off Mac hardware.","solutions":["Trim the video to 15 seconds before calling the library (e.g. `ffmpeg -i in.mp4 -t 15 -c copy out.mp4`)","Run the publish on macOS where AVFoundation trimming is available","Use the UI story publish flow which trims client-side","Check duration beforehand (readVideoMetadata) and only call trim on macOS"],"exampleFix":"// before\nconst out = await trimmedPath(longVideo, 15000);\n// after\nif (process.platform !== 'darwin') {\n  execSync(`ffmpeg -i ${longVideo} -t 15 -c copy ${trimmed}`);\n  return trimmed;\n}\nreturn trimmedPath(longVideo, 15000);","handlingStrategy":"validation","validationCode":"if (process.platform !== 'darwin') {\n  const { execSync } = require('child_process');\n  execSync(`ffmpeg -y -i ${videoPath} -t 15 -c copy ${trimmedPath}`);\n  return trimmedPath;\n}","typeGuard":null,"tryCatchPattern":"try { const out = await trimmedPath(videoPath, 15000); }\ncatch (e) {\n  if (/does not support trimming long videos/.test(e.message)) return ffmpegTrim(videoPath, 15);\n  throw e;\n}","preventionTips":["Enforce the 15-second story limit before calling the publisher","Use the platform guard to pick ffmpeg trimming vs AVFoundation trimming","Keep source videos within story duration to avoid the trim path entirely"],"tags":["platform","macos-only","video-trim","story"],"backgroundTag":"unsupported-platform","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}