subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.21k stars 667 forks source link

[BUG] server processing error: VideoSourceError in instagrapi library #393

Closed MrProgrammer77 closed 2 years ago

MrProgrammer77 commented 2 years ago

I download a video from inside Telegram to my host, then I try to upload this video with the help of instagrapi library, but when uploading this video or any other video, the following error occurs. Please help me to solve this problem. I should also add that my video format is mp4 and I was able to upload this video without any problems through the Android Instagram app. If you want to help solve this problem, you can download this video via the link below and use it to test upload: https://www.instagram.com/p/CUfeO8NKNFU/?utm_source=ig_web_copy_link Part of my code to upload my files to Instagram:

import instagrapi bot=instagrapi.Client() user=show_user() bot.login(username=user[0],password=user[1],relogin=True) uploud_file=path.join(ROOT,'downloads',File_Name) bot.video_upload(uploud_file,caption=post_input['caption'])

The error I receive is as follows:

Analizing video file "f:\Telegram Project\downloads\singel_video.mp4" Generating thumbnail "f:\Telegram Project\downloads\singel_video.mp4.jpg"... server processing error: VideoSourceError Traceback (most recent call last): File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\private.py", line 270, in _send_private_request response.raise_for_status() File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 953, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/media/configure/?video=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\dispatcher.py", line 217, in handler_worker await handler.callback(self.client, args) File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\pyromod\listen\listen.py", line 93, in resolve_listener await self.user_callback(client, message, args) File "f:\Telegram Project\test.py", line 144, in get bot.video_upload(uploud_file,caption=post_input['caption']) File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\video.py", line 263, in video_upload raise e File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\video.py", line 244, in video_upload configured = self.video_configure( File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\video.py", line 338, in video_configure return self.private_request( File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\private.py", line 415, in private_request raise e File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\private.py", line 402, in private_request self._send_private_request(endpoint, kwargs) File "C:\Users\Mohammad-Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\instagrapi\mixins\private.py", line 326, in _send_private_request raise UnknownError(last_json) instagrapi.exceptions.UnknownError: server processing error: VideoSourceError

adw0rd commented 2 years ago

Cannot reproduce:

In [5]: paths = cl.album_download(cl.media_pk_from_url('https://www.instagram.com/p/CUfeO8NKNFU/?utm_source=ig_web_copy_link'))

In [6]: paths
Out[6]:
[PosixPath('/home/adw0rd/instagrapi2/sad__boy1998_2674989506404854727.mp4'),
 PosixPath('/home/adw0rd/instagrapi2/sad__boy1998_2674989598344173777.mp4')]

In [7]: cl.video_upload(paths[0], caption='test')
Analizing video file "/home/adw0rd/instagrapi2/sad__boy1998_2674989506404854727.mp4"
Generating thumbnail "/home/adw0rd/instagrapi2/sad__boy1998_2674989506404854727.mp4.jpg"...
Out[7]: Media(pk=2675077806332991084, id='2675077806332991084_1903424587', code='CUfyRd5AlZs', taken_at=datetime.datetime(2021, 10, 1, 18, 49, 15, tzinfo=datetime.timezone.utc), media_type=2, product_type='feed', thumbnail_url=HttpUrl('https://instagram.frix7-1.fna.fbcdn.net/v/t51.2885-15/e35/243812138_4380030472093508_7111444633936334673_n.jpg?_nc_ht=instagram.frix7-1.fna.fbcdn.net&_nc_cat=108&_nc_ohc=GBGAahdz0J8AX_HvocA&edm=ACqnv0EBAAAA&ccb=7-4&oh=a11fd0b24236990219ef1bb722261f2e&oe=615ED57B&_nc_sid=9ec724&ig_cache_key=MjY3NTA3NzgwNjMzMjk5MTA4NA%3D%3D.2-ccb7-4', scheme='https', host='instagram.frix7-1.fna.fbcdn.net', tld='net', host_type='domain', path='/v/t51.2885-15/e35/243812138_4380030472093508_7111444633936334673_n.jpg', query='_nc_ht=instagram.frix7-1.fna.fbcdn.net&_nc_cat=108&_nc_ohc=GBGAahdz0J8AX_HvocA&edm=ACqnv0EBAAAA&ccb=7-4&oh=a11fd0b24236990219ef1bb722261f2e&oe=615ED57B&_nc_sid=9ec724&ig_cache_key=MjY3NTA3NzgwNjMzMjk5MTA4NA%3D%3D.2-ccb7-4'), location=None, user=UserShort(pk=1903424587, username='adw0rd', full_name='Mikhail Andreev', profile_pic_url=HttpUrl('https://instagram.frix7-1.fna.fbcdn.net/v/t51.2885-19/s150x150/211450974_772680536745595_821547741411463983_n.jpg?_nc_ht=instagram.frix7-1.fna.fbcdn.net&_nc_ohc=DKmyf4oGW5QAX_rHSoA&edm=ACqnv0EBAAAA&ccb=7-4&oh=07d8b4f90eba71103fbc75fed1d68c76&oe=615DD3B1&_nc_sid=9ec724', scheme='https', host='instagram.frix7-1.fna.fbcdn.net', tld='net', host_type='domain', path='/v/t51.2885-19/s150x150/211450974_772680536745595_821547741411463983_n.jpg', query='_nc_ht=instagram.frix7-1.fna.fbcdn.net&_nc_ohc=DKmyf4oGW5QAX_rHSoA&edm=ACqnv0EBAAAA&ccb=7-4&oh=07d8b4f90eba71103fbc75fed1d68c76&oe=615DD3B1&_nc_sid=9ec724'), profile_pic_url_hd=None, is_private=False, stories=[]), comment_count=0, like_count=0, has_liked=False, caption_text='test', usertags=[], video_url=HttpUrl('https://instagram.frix7-1.fna.fbcdn.net/v/t50.2886-16/243927210_413534453714349_1253229388540663371_n.mp4?efg=eyJxZV9ncm91cHMiOiJbXCJpZ19wcm9ncmVzc2l2ZV91cmxnZW4ucHJvZHVjdF90eXBlLmZlZWRcIl0ifQ&_nc_ht=instagram.frix7-1.fna.fbcdn.net&_nc_cat=109&_nc_ohc=PIcffQdUYSgAX8EpnBF&edm=ACqnv0EBAAAA&ccb=7-4&oe=6159C44D&oh=b5828ac9b3874e1bf89489f8c96e0f69&_nc_sid=9ec724', scheme='https', host='instagram.frix7-1.fna.fbcdn.net', tld='net', host_type='domain', path='/v/t50.2886-16/243927210_413534453714349_1253229388540663371_n.mp4', query='efg=eyJxZV9ncm91cHMiOiJbXCJpZ19wcm9ncmVzc2l2ZV91cmxnZW4ucHJvZHVjdF90eXBlLmZlZWRcIl0ifQ&_nc_ht=instagram.frix7-1.fna.fbcdn.net&_nc_cat=109&_nc_ohc=PIcffQdUYSgAX8EpnBF&edm=ACqnv0EBAAAA&ccb=7-4&oe=6159C44D&oh=b5828ac9b3874e1bf89489f8c96e0f69&_nc_sid=9ec724'), view_count=0, video_duration=5.8, title='', resources=[])

and works fine.

adw0rd commented 2 years ago

https://t.me/instagrapi/8385

Student, [2 окт. 2021 г., 00:10:16]:

Well, with this method, I was able to upload that video, but how should I download it from Telegram and upload it on Instagram without any problem ?!

Mikhail Andreev, [2 окт. 2021 г., 00:11:51]:

Make sure your video takes less than a minute and compare codecs third time I tell you: compare what you download from Instagram and your video, how are they different? If your video is more than a minute, then upload it as IGTV

Student, [2 окт. 2021 г., 00:14:52]:

Undoubtedly, the video is less than a minute. The video that I downloaded from Telegram and use to upload to Instagram is the same video that I gave you the link to upload.

Student, [2 окт. 2021 г., 00:16:47]:

The difference is their size

Mikhail Andreev, [2 окт. 2021 г., 00:17:52]:

$ ffmpeg -i /home/adw0rd/instagrapi2/sad__boy1998_2674989506404854727.mp4 2>&1 | grep -i video
  Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, unknown/unknown/bt709), 480x600, 569 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
      handler_name    : VideoHandler

$ ffmpeg -i /tmp/video_2021-09-14_13-29-07.mp4 2>&1 | grep -i video
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/video_2021-09-14_13-29-07.mp4':
  Stream #0:1(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt470bg/smpte170m), 480x854, 1136 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
      handler_name    : VideoHandle

Mikhail Andreev, [2 окт. 2021 г., 00:17:52]:

is the same video that I gave you the link to upload.

These are different videos, which I told you about from the very beginning. They have a different format, bring your video to sad__boy1998_2674989506404854727.mp4 and you will be fine