Coder Social home page Coder Social logo

Comments (2)

puerdon avatar puerdon commented on May 29, 2024 1

Hi @ZobaJakColbert, I am having the same question as you, and I just found a solution.

Because the 16:9 video has to be transformed into 9:16 before sending to Instagram, it is impossible to use the Custom RTMP on Restream for Instagram.

Instead you need some other softwares to achieve this:

  • recording function settings in OBS
  • ffmpeg (for transforming the video, to be more specific, using video filter of ffmpeg)
  • local nginx RTMP server (for relaying signal from OBS to stunnel)
  • stunnel (for relaying signal from nginx RTMP server to Instagram's RTMPS server, since IG has deprecated RTMP server and only supported RTMPS)

Below is a simple signal flow:
OBS recording -> local nginx rtmp server -> transforming from 16:9 to 9:16 using ffmpeg -> stunnel -> Instagram rtmps server

=============

After having download ffmpeg, nginx with RTMP module, and stunnel (not sure what operating system you are using, I am using OS X, so I download these softwares with homebrew), we have to tweak some config file.

Below are my config files for your reference:

# nginx.conf

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;
            record off;
            exec_options on;

            # to local stunnel server (with exec_push)
            exec_push /usr/local/bin/ffmpeg -rtbufsize 256M -re -i 'rtmp://localhost:1935/live' -acodec libmp3lame -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v baseline -bufsize 6000k -vb 400k -maxrate 1500k -deinterlace -vcodec libx264 -preset veryfast -g 60 -r 30 -vf "scale=720:1280:force_original_aspect_ratio=decrease,pad=720:1280:(ow-iw)/2:(oh-ih)/2,setsar=1" -f flv 'rtmp://localhost:19350/rtmp/<your_ig_stream_key>';
        }
    }
}

As you can see, the ffmpeg is used in the exec_push part of nginx.conf. Lots of ffmpeg parameters setting are from Itsagramlive's sample code with the addition of padding 16:9 to 9:16 (reference)

Also, the IG streaming key got from Itsgramlive.start() has to replace the <your_ig_stream_key> in the above config file.

Next is stunnel.conf, which is much more simpler:

# stunnel.conf

[ig-live]
client = yes
accept = 127.0.0.1:19350
connect = live-upload.instagram.com:443
verifyChain = no

Last part is the OBS setting:

  1. Preference > Settings > Output > Recording Tab:
  • set "Type" to "Custom Output FFmpeg"
  • set "File path or URL" to "rtmp://localhost:1935/live" (which is our local nginx local server)

So with everything above being set, you can press "Start Recording" on OBS, so the signal can be streamed to Instagram successfully. It means that, you need to "Start Streaming" (to Restream) and "Start Recording" (to Instagram) at the same time.


kind of messy for all of these information. I've tried it and it worked. you can try googling "nginx rtmp, stunnel". Hope this helps.

Also I really appreciate the author of the Instagramlive package, really helpful. Thank you!

from itsagramlive.

harrypython avatar harrypython commented on May 29, 2024

I believe that there are other libraries in Python that can manipulate the video as you wish, but that is not the focus of this project. Sorry.

from itsagramlive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.