Results 1 to 10 of 12

Thread: FFMPEG streaming to Justin.tv/Twitch.tv

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Location
    Mount Pleasant, PA USA
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    FFMPEG streaming to Justin.tv/Twitch.tv

    Does anyone have any advice on how to make this work? I am using a modified script found using google.
    Running Ubuntu 11.10 with Unity

    Code:
    #Streaming screen to Justin.tv
    streaming() {
    INRES="1920x1080" # input resolution
    OUTRES="1280x720"
    FPS="30" # target FPS
    QUAL="medium"  # one of the many FFMPEG preset
    STREAM_KEY="$1"
    URL="rtmp://live.justin.tv/app/$STREAM_KEY" #flashver=FMLE/3.0\20(compatible;\20FMSc/1.0)"  
    
    #ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0 -ab 22050\
    # -f alsa -ac 2 -i pulse -vcodec libx264 -s "$OUTRES" -level 30 -f mpegts \
    # -acodec libmp3lame -ac 1  \
    # -f flv "$URL"
    
    
    
    
    ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0  -ab 96k \
        -f alsa -ac 2 -i pulse -vcodec libx264 -crf 30 -vpre "$QUAL" -s "1280x720" \
        -acodec libmp3lame -ar 44100 -threads 8 \
        -f flv "$URL"
    }
    After modifying slighly I have it working, somewhat, it doesn't throw errors in the command line, but I don't get any video coming through when I load my channel on Juistin.tv.

    Any sugestions? Pointers? and please don't say Webcamstudio, ffmpeg is far lighter weight, and all things considered easier to deal with. Aside from this little hiccup of course.
    Last edited by SAKeeler; April 7th, 2012 at 03:14 PM. Reason: Added OS version and desktop manager detail

  2. #2
    Join Date
    Apr 2006
    Location
    USA
    Beans
    404

    Re: FFMPEG streaming to Justin.tv/Twitch.tv


  3. #3
    Join Date
    Jul 2007
    Location
    Mount Pleasant, PA USA
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: FFMPEG streaming to Justin.tv/Twitch.tv

    Quote Originally Posted by guitara View Post
    I really was trying to avoid it, but I will be giving it a read through and testing it this weekend. Still tinkering with the ffmpeg solution though,
    it's infuriating, it should work but just isn't, and I can't figure out why.
    Makes me crazy.

    Thanks for the link btw.

  4. #4
    Join Date
    Apr 2006
    Location
    USA
    Beans
    404

    Re: FFMPEG streaming to Justin.tv/Twitch.tv

    LOL -- ok, here's an example of ffmpeg working

    Code:
    #!/bin/bash
    API_KEY="live_*****************"
    FPS="15"
    
    INRES='1280x1024'
    OUTRES='1280x1024'
    
    ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0+1280 \
           -f alsa -i pulse -vcodec libx264  -s "$OUTRES"  \
           -acodec libmp3lame -ab 64k -ar 22050 -threads 0 \
           -f flv "rtmp://live.justin.tv/app/$API_KEY"

  5. #5
    Join Date
    Jul 2012
    Beans
    2

    Re: FFMPEG streaming to Justin.tv/Twitch.tv

    It's actually kinda weird that this issue hasn't been resolved yet. At least I just couldn't find any solution whether googling or posting the official FFmpeg IRC channels. Any idea why I get a blank video on such RTMP resources as justin.tv, own3d and so on. Once again, there's no issue with local recordings, it works just fine.

  6. #6
    Join Date
    Jul 2012
    Beans
    2

    Wink Re: FFMPEG streaming to Justin.tv/Twitch.tv

    The solution came from a member of FFmpeg development group. Since the video itself is fine when it's examined locally, there must be some trouble with some of the formats. Actually it was all about pixel format.

    If we capture the screen locally with the output option set as -f flv out.flv, the later examining of the video with ffprobe out.flv would show that the pixel format is 444, and it's not yet widely supported. Hence, it's necessary to add -pix_fmt yuv420p in the encoder properties to get your video playable by justin, twitch, own3d, ustream and other rtmp services

  7. #7
    Join Date
    Jul 2007
    Location
    Mount Pleasant, PA USA
    Beans
    19
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: FFMPEG streaming to Justin.tv/Twitch.tv

    Man, I'll have to make note and try it when i get a Ubuntu box up and running again.

    thanks, wouldn't have thought of that.

    Quote Originally Posted by vitrums View Post
    The solution came from a member of FFmpeg development group. Since the video itself is fine when it's examined locally, there must be some trouble with some of the formats. Actually it was all about pixel format.

    If we capture the screen locally with the output option set as -f flv out.flv, the later examining of the video with ffprobe out.flv would show that the pixel format is 444, and it's not yet widely supported. Hence, it's necessary to add -pix_fmt yuv420p in the encoder properties to get your video playable by justin, twitch, own3d, ustream and other rtmp services

  8. #8
    Join Date
    Sep 2006
    Beans
    3,713

    Re: FFMPEG streaming to Justin.tv/Twitch.tv

    Why do you want to "save CPU power"? What's the actual question here? Why do you not want ffmpeg to take advantage of all available resources? It's a tradeoff: fewer resources = lower frame rate and/or frame size.

    • Why do you use "-threads 6"? libx264 automatically determines the optimal number of threads by default so you generally do not need to declare threads unless you want to reduce them.
    • "-qscale" and "-b" are mutually exclusive, but luckily libx264 ignores "-qscale".
    • "-b" is ambiguous and you should use a stream specifier with this option: "-b:v" or "-b:a" (same with "-qscale").
    • A better suggestion may be to base your encoding options on your upload rate if that is a limiting factor. I will expand on this later when I return from a trip. What is your max upload rate?
    • There is no "lossless_ultrafast" preset unless you're using ancient or fake ffmpeg. Lossless = huge files which would probably not be good for uploading a live stream to this video service.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •