dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.93k stars 1.14k forks source link

Download instagram live streams #1574

Open Ho3einWave opened 2 years ago

Ho3einWave commented 2 years ago

Form

Put an [x] if you meet the condition, else leave [ ].

Question

A specific question, so it's understandable to anyone. You may add pictures.

how can I download Instagram live streams that are in MPEG-DASH - .mpd format? e.g : https://scontent.cdninstagram.com/hvideo-odn-cln/_nc_cat-111/v/rTzYdr0SduizJODiyq2MC/_nc_ohc-CDh-Ms32OqIAX9arrQ1/live-dash/dash-hd/17934656539854498.mpd?ccb=2-4&ms=m_CNP&sc_t=1&oh=00_AT9SLgwDTnjyubPMIc64761h9F1BuoeVxDNIW0o3VAQ_vA&oe=620833DE

Ho3einWave commented 2 years ago

Is this a stream that's already ended, or one that is ongoing? Also, do you have the original public URL?

I need to know how to download the Instagram live stream in .mpd (MPEG DASH). I tried to download it with FFmpeg; the video got so much lag. e.g. video: https://cdn.discordapp.com/attachments/942681184343826473/942693379756675082/file_1.mp4

Nerixyz commented 2 years ago

Take a look at this repository.

Using a python api, but you don't need to emulate anything to download the livestream (for example you could just open it in VLC or other players).

They're basically downloading all segments and afterwards stitch them together.

Ho3einWave commented 2 years ago

Take a look at this repository.

Using a python api, but you don't need to emulate anything to download the livestream (for example you could just open it in VLC or other players).

They're basically downloading all segments and afterwards stitch them together.

there is any way to download it in mp4 in nodejs? my app actually track and download user activities. I would be grateful if you could help me

Nerixyz commented 2 years ago

there is any way to download it in mp4 in nodejs?

I don't think there's a package that does this yet. However you can port the functionality to node. There are mpd-parsers and even ffmpeg wrappers.

Ho3einWave commented 2 years ago

there is any way to download it in mp4 in nodejs?

I don't think there's a package that does this yet. However you can port the functionality to node. There are mpd-parsers and even ffmpeg wrappers.

I will try to port this python script into node; if I get any helpful results, I will share it here

Nerixyz commented 2 years ago

I just noticed, that VLC can play the livestream fine. VLC also has the feature of converting video. These combined worked fine for me in saving the stream to an mp4 file. Though the ending of the livestream is always an issue. There you have to first stop the "playback" aka. conversion and it will write a valid file.

There's one issue I noticed though: VLC will always select the first representation for the video stream. This however isn't the best one. The best one for me was always last. So one might need to rewrite the .mpd requests/responses and remove all representations but the best one (or find the option that selects the representation for VLC).