jackwener/OpenCLI · error · CommandExecutionError
Instagram private story publish does not support trimming lo
Error message
Instagram private story publish does not support trimming long videos on ${process.platform} What it means
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.
Source
Thrown at clis/instagram/_shared/private-publish.js:519
const bytes = fs.readFileSync(filePath);
const metadata = readVideoMetadata(filePath);
const coverImage = generateVideoCoverImage(filePath);
return {
filePath,
fileName: path.basename(filePath),
mimeType: 'video/mp4',
width: metadata.width,
height: metadata.height,
durationMs: metadata.durationMs,
byteLength: bytes.length,
bytes,
coverImage,
cleanupPaths: coverImage.cleanupPath ? [coverImage.cleanupPath] : [],
};
}
function trimVideoForInstagramStory(filePath, maxDurationMs) {
if (process.platform !== 'darwin') {
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');
}
const outputPath = buildPrivateStoryVideoPath(filePath);
runSwiftJsonScript(`
import AVFoundation
import Foundation
let inputPath = CommandLine.arguments[1]
let outputPath = CommandLine.arguments[2]
let durationMs = Int(CommandLine.arguments[3]) ?? 15000
let asset = AVURLAsset(url: URL(fileURLWithPath: inputPath))
guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality) else {
fputs("{\\"error\\":\\"missing-export-session\\"}", stderr)
exit(1)
}
exportSession.outputURL = URL(fileURLWithPath: outputPath)
exportSession.outputFileType = .mp4
exportSession.shouldOptimizeForNetworkUse = true
exportSession.timeRange = CMTimeRange(View on GitHub (pinned to 49907e53dc)
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
Example fix
// before
const out = await trimmedPath(longVideo, 15000);
// after
if (process.platform !== 'darwin') {
execSync(`ffmpeg -i ${longVideo} -t 15 -c copy ${trimmed}`);
return trimmed;
}
return trimmedPath(longVideo, 15000); Defensive patterns
Strategy: validation
Validate before calling
if (process.platform !== 'darwin') {
const { execSync } = require('child_process');
execSync(`ffmpeg -y -i ${videoPath} -t 15 -c copy ${trimmedPath}`);
return trimmedPath;
} Try / catch
try { const out = await trimmedPath(videoPath, 15000); }
catch (e) {
if (/does not support trimming long videos/.test(e.message)) return ffmpegTrim(videoPath, 15);
throw e;
} Prevention
- 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
When it happens
Trigger: Calling trimmedPath (via trimVideoForInstagramStory) with a video exceeding maxDurationMs while process.platform is not 'darwin'.
Common situations: 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.
Related errors
- Instagram private mixed-media publish does not support readi
- Instagram private mixed-media publish does not support gener
- Instagram private story publish does not support auto-normal
- Instagram private story publish failed to normalize ${asset.
- Instagram story publish could not derive current user id fro
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f711d20fd086a7f5.
Report an issue: GitHub.