instagram-private-api
instagram-private-api copied to clipboard
Video Upload Error
Bug Report
Read the Notes and fill out the form.
Notes
Your issue will be closed if you violate any rule below.
- You need to include a meaningful section of your code (not your entire project and not a single line).
- Please do not add screenshots as they're not easy to work with.
- Errors like
IgActionSpamError (feedback_required)
,IgCheckpointError (challenge_required)
,checkpont_required
,login_required
are "common" and there are multiple issues, search here. - You can delete this section after reading it.
Form
Put an [x]
if you meet the condition, else leave [ ]
.
Requirements
- [ x] I've searched the Issues
- [ x] I've read the basic concepts
- [x ] I'm using the latest version
- [x ] I've debugged my code using the
DEBUG
variable.
Platform
- [ x] I'm using Node.js version
16.14.2(node -v)
- [ ] I'm using electron
Description
A specific description of your bug, so it's understandable to anyone.
If you have pictures or videos to upload, please add a link like this: [title](url)
.
I am trying to upload a video but get an error :
IgUploadVideoError: POST /api/v1/media/upload_finish/?video=1 - 400 Bad Request; server processing error: VideoSourceVideoStreamCheckException at C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\instagram-private-api\dist\services\publish.service.js:26:23 at tryCatcher (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\util.js:16:23) at C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\catch_filter.js:17:41 at tryCatcher (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:547:31) at Promise._settlePromise (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:604:18) at Promise._settlePromise0 (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:649:10) at Promise._settlePromises (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:725:18) at _drainQueueStep (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:93:12) at _drainQueue (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:86:9) at Async._drainQueues (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:15:14) at processImmediate (node:internal/timers:466:21) { videoInfo: { duration: 7800, width: 844, height: 1350 } }
Code
Add a meaningful section of your code here. If you are using TypeScript replace js
with typescript
.
const cron = require("node-cron");
const Shop = require("./Shop");
const instagram = require("instagram-private-api");
const dotenv = require("dotenv");
const mongoose = require("mongoose");
const Logger = require("./Logger");
const ig = new instagram.IgApiClient();
dotenv.config();
mongoose.connect(process.env.MONGO);
/*Login(ig).then(async () => {
// Unfollow 50 users
});*/
Login(ig)
const fs = require('fs')
async function Login(client) {
client.state.generateDevice(process.env.IG_USERNAME);
//await ig.simulate.preLoginFlow()
const loggedInUser = await client.account.login(
process.env.IG_USERNAME,
process.env.IG_PASSWORD
);
Logger.log(`Logged in as ${loggedInUser.username}`);
ig.publish.video({
video : fs.readFileSync('shop/shop-CID_A_023_Athena_Commando_M_Skirmish_W1N7H.mp4'),
coverImage : fs.readFileSync("assets/shop/background.jpg"),
caption : "test post"
})
//Setup();
}
Error and Output
If you've got an error put it here.
You can get the stacktrace in the most environments using
Error.stack
(MDN Docs).
2022-05-03T12:05:37.276Z] Logged in as artlfmjyt
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
IgUploadVideoError: POST /api/v1/media/upload_finish/?video=1 - 400 Bad Request; server processing error: VideoSourceVideoStreamCheckException
at C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\instagram-private-api\dist\services\publish.service.js:26:23
at tryCatcher (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\util.js:16:23)
at C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\catch_filter.js:17:41
at tryCatcher (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\promise.js:725:18)
at _drainQueueStep (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\a_dep\Documents\GitHub\fortniteig\node_modules\bluebird\js\release\async.js:15:14)
at processImmediate (node:internal/timers:466:21) {
videoInfo: { duration: 7800, width: 844, height: 1350 }
}
I got below error:
Logged in as raghavrangani
(node:21104) UnhandledPromiseRejectionWarning: IgResponseError: POST /rupload_igphoto/1653989823939_0_8970372746 - 400 Bad Request;
at Request.handleResponseError (/Applications/MAMP/htdocs/rnd/instagramNodejs/node_modules/instagram-private-api/dist/core/request.js:126:16)
at Request.send (/Applications/MAMP/htdocs/rnd/instagramNodejs/node_modules/instagram-private-api/dist/core/request.js:54:28)
at async UploadRepository.photo (/Applications/MAMP/htdocs/rnd/instagramNodejs/node_modules/instagram-private-api/dist/repositories/upload.repository.js:18:26)
at async PublishService.video (/Applications/MAMP/htdocs/rnd/instagramNodejs/node_modules/instagram-private-api/dist/services/publish.service.js:97:9)
at async /Applications/MAMP/htdocs/rnd/instagramNodejs/server.js:15:20
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hey, don't know if you managed to fix this bug but I remember having similar issues so I thought I'd outline what I did to fix it for anyone else struggling with the same thing.
Basically, IG is finicky with its requirements for the video format. Obviously, the file must be MP4, but I also found that bitrate and samplerate could cause issues. I didn't really research what exactly IG requires, but if you just want your thing to work, try downloading a video from IG that you successfully uploaded (from your phone for example), then compare the codec information of the downloaded video to the one that you are failing to upload, and then use ffmpeg to change the failing video to match the downloaded video.
This works for me,
const { IgApiClient } = require('instagram-private-api');
const { readFile } = require('fs');
const { promisify } = require('util');
const readFileAsync = promisify(readFile);
const ig = new IgApiClient();
async function login() {
// basic login-procedure
ig.state.generateDevice(process.env.IG_USERNAME);
ig.state.proxyUrl = process.env.IG_PROXY;
await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
}
(async () => {
await login();
const videoPath = './test.mp4';
const coverPath = './output.jpg';
const publishResult = await ig.publish.video({
// read the file into a Buffer
video: await readFileAsync(videoPath),
coverImage: await readFileAsync(coverPath),
/*
this does also support:
caption (string), ----+
usertags, ----+----> See upload-photo.example.ts
location, ----+
*/
});
console.log(publishResult);
})();
You don't have to use fs from my understanding.
I am getting the error POST /rupload_igphoto/1700829675637_0_4089810121 - 400 Bad Request;