Skip to main content
February 3, 2010
Question

Live encoding H264 to FMS via ffmpeg command-line or Java code

  • February 3, 2010
  • 2 replies
  • 9925 views

Hi folks,

We just shipped Xuggler 3.4 this weekend which now has the ability to record and publish RTMP streams.  That means you can now write Xuggler (a Java API for encoding and decoding video) programs that can publish to FMS or record from FMS.

We've worked closely with the FFmpeg team to get the core RTMP stack into that project, and have put together a tutorial on how to use FFmpeg to record or publish streams, including re-encoding media to H264/AAC while publishing.  You can find that tutorial here.

I thought people here would like to know.

- Art

www.xuggle.com/

    This topic has been closed for replies.

    2 replies

    New Participant
    August 16, 2010

    Hi, Art,

    I want to stream encode a file live into H264  and stream it to a FMS server using your native RTMP functionality.  I followed your livestream tutotrial:

    http://wiki.xuggle.com/Live_Encoding_Tutorial

    I run the following command

    ffmpeg -i /testFiles/testScooter.flv -acodec copy -vcodec libx264 -fpre /usr/local/xuggler/share/ffmpeg/libx264-default.ffpreset -re -f flv rtmp://encoding02.testserver.tv/stream/1479_a92bf8927f8914ac23d66485abcfdce5

    Then I get this error:

    FFmpeg version SVN-r21566-xuggle-3.4.843, Copyright (c) 2000-2010 Fabrice Bellard, et al.
      built on Jan 31 2010 12:41:33 with gcc 4.2.4 (Ubuntu 4.2.4-1ubuntu3)
      configuration: --prefix=/usr/local --extra-version=xuggle-3.4.843 --extra-cflags=-I/mnt/hudson/data/jobs/xuggle_xuggler_binary_build/workspace/jdk/JDK5/label/Linux_i386/build/native/i686-pc-linux-gnu/captive/usr/local/include --extra-ldflags=-L/mnt/hudson/data/jobs/xuggle_xuggler_binary_build/workspace/jdk/JDK5/label/Linux_i386/build/native/i686-pc-linux-gnu/captive/usr/local/lib --enable-shared --enable-gpl --enable-nonfree --enable-version3 --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-pthreads
      libavutil     50. 8. 0 / 50. 8. 0
      libavcodec    52.49. 0 / 52.49. 0
      libavformat   52.48. 0 / 52.48. 0
      libavdevice   52. 2. 0 / 52. 2. 0
      libswscale     0. 9. 0 /  0. 9. 0
    [flv @ 0x92a03a0]Estimating duration from bitrate, this may be inaccurate

    Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 10.00 (10/1)
    Input #0, flv, from '/home/joro/Documents/makeTV/testFiles/testScooter.flv':
      Metadata:
        duration        : 17
        width           : 192
        height          : 154
        videodatarate   : 40
        framerate       : 10
        videocodecid    : 4
        audiodatarate   : 16
        audiodelay      : 0
        audiocodecid    : 2
        canSeekToEnd    : 1
        creationdate    : Fri Feb 03 12:25:53 2006

      Duration: 00:00:16.89, start: 0.000000, bitrate: 56 kb/s
        Stream #0.0: Video: vp6f, yuv420p, 192x154, 40 kb/s, 10 tbr, 1k tbn, 1k tbc
        Stream #0.1: Audio: mp3, 11025 Hz, 1 channels, s16, 16 kb/s
    Server error: Connection failed.
    Could not open 'rtmp://encoding02.testserver.tv/stream/1479_a92bf8927f8914ac23d66485abcfdce5'

    I think this is the reason:

    Xuggler interprets stream as the app and 1479_a92bf8927f8914ac23d66485abcfdce5 as the stream name. However my FMS  server encoding02.testserver.tv has app name  stream/1479_a92bf8927f8914ac23d66485abcfdce5.

    It works with wowza. And there is no restrictions from the server.

    So what would be a possible soution to that?

    Thank you for your time,

    regards Georgi

    calmchessplayer
    Inspiring
    February 3, 2010

    I couldn't even get the program to install correctly on windows Vista .................I didn't try to install as administrator......is that a requirement?

    February 3, 2010

    Yes, it needs administrator privledges to set the PATH variable in Windows to point to the location of the necessary DLLs.

    calmchessplayer
    Inspiring
    February 4, 2010

    I get nothing but errors when i try to play .flv which i have recorded with fms...........I also get similar errors with video which was converted to .flv

    c:\Program Files\Adobe\Flash Media Server 3.5\applications\fmsuser\streams\insta
    nce>java -cp "%XUGGLE_HOME%\share\java\jars\xuggle-xuggler.jar" com.xuggle.xuggl
    er.demos.DecodeAndPlayVideo home4.flv
    2010-02-03 18:36:08,234 [main] ERROR org.ffmpeg - [flv @ 0x28fb60] Bad picture s
    tart code
    2010-02-03 18:36:08,250 [main] ERROR org.ffmpeg - [flv @ 0x28fb60] header damage
    d
    Exception in thread "main" java.lang.RuntimeException: got error decoding video
    in: home4.flv
            at com.xuggle.xuggler.demos.DecodeAndPlayVideo.main(DecodeAndPlayVideo.j
    ava:153)

    c:\Program Files\Adobe\Flash Media Server 3.5\applications\fmsuser\streams\insta
    nce>