VideoHelp Forum
+ Reply to Thread
Results 1 to 12 of 12
Thread
  1. Member
    Join Date
    May 2012
    Location
    Canada
    Search PM
    Hi all,
    I'm trying to livestream from a DirectShow video capture device to Flash Media Server using ffmpeg on Windows. I've tried all sorts of different options with very limited success. The command below is the best I've been able to do; it manages to connect to the server, but it keeps on showing messages like "Real-time buffer XX% full. Frame dropped!" and it drops a lot of the frames (sometimes all of them for several seconds in a row). The CPU and RAM usage is low (25% CPU, 2GB RAM of 6GB), and the bitrate is only around 300-400kbps, so I don't think that the problem is a lack of system resources. Does anyone have any tips as to what I'm doing wrong? Any help would be greatly appreciated!

    ffmpeg\bin\ffmpeg.exe -f dshow -framerate 29.97 -i video="vMix Virtual Capture":audio="Microphone (Fast Track)" -pix_fmt yuv420p -sample_fmt s16 -vcodec libx264 -s vga -vb 500k -r 24 -re -g 120 -vprofile baseline -preset ultrafast -tune zerolatency -level 21 -acodec libvo_aacenc -ab 48k -ac 1 -ar 22050 -async 1 -threads 4 -rtbufsize 2000M -f flv "rtmp://<server-address>"
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I would try stream with vlc instead, http://www.videolan.org/doc/streaming-howto/en/ . You can use h264 insde a rtmp stream. I use it to stream all my tvsport-channels.
    Quote Quote  
  3. Member
    Join Date
    May 2012
    Location
    Canada
    Search PM
    I looked into using VLC before, but I didn't think that it could do RTMP. Which option should I select under "New destination" in the Destinations screen of the Stream Output wizard?
    Quote Quote  
  4. Member
    Join Date
    May 2012
    Location
    Canada
    Search PM
    By the way, is anyone successfully using ffmpeg to stream to Flash Media Server from a live capture device? If so, could you post your command line? Anything else I could try would be great!
    Quote Quote  
  5. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    I see. I didn't use rtmp mode, I use http{mime=video/x-flv},mux=ffmpeg{mux=flv} mode. RTMP isn't fully supported yet, see http://forum.videolan.org/viewtopic.php?f=7&t=97803

    I have never tried just with ffmpeg.
    Quote Quote  
  6. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Have you tried streaming a video file to the server? If you're still getting problems with that, your upload speed might be a bottleneck. Check your connection with http://speedtest.net/ and post the details.

    The syntax of ffmpeg has changed over the years and it's possible ffmpeg is ignoring some of your parameters, such as bitrate. While ffmpeg is running what bitrate is it encoding to? Also, what version of ffmpeg are you using?

    I don't know anything about the rtbufsize option, but 2000M is HUGE.

    The server you're trying to connect to might be a factor.

    I can't help with streaming from a live capture device - I use ffmpeg on linux, and the way that it reads from devices is different to the Windows version.
    Quote Quote  
  7. Member
    Join Date
    May 2012
    Location
    Canada
    Search PM
    Hi,
    Streaming a video file using the same parameters works fine. My connection is 1mbps upstream, and it should definitely be able to handle this.
    The bitrate stays around where I set it; it doesn't seem to go a lot over, so I think ffmpeg must be recognizing my bitrate settings. I just downloaded ffmpeg from http://ffmpeg.zeranoe.com/builds/, so it's a very recent version.

    As for rtbufsize, I read online that it's supposed to set the real time buffer size, and since ffmpeg was complaining about the buffer being full, I thought I'd try making it nice and big -- didn't seem to help at all . Maybe ffmpeg doesn't recognize that option anymore; I didn't find any mention of it in the official documentation.

    My conclusion at this point is that this an issue with ffmpeg's DirectShow capturing. I can stream prerecorded files to the server without any issues. When I capture from the DirectShow device to a file instead of publishing to the RTMP server, it works fine for a bit (a few minutes) and then completely quits with more "Real time buffer full" messages.

    I think I've come up with a feasible workaround. The video mixing application that I'm using has the ability to record the video to a file. I'll probably set my video mixing program to record to an MPEG file and have ffmpeg transcode and stream that file in realtime, as it's being written. I tried it tonight, and it seemed to work. Not as nice as capturing properly, but hey, it does the trick!

    Thanks everyone for the replies and suggestions!
    Quote Quote  
  8. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Do you have a quad core system? I see you've got the -threads option set, but 25% CPU usage sounds like a single core being maxed out.

    If you drop the framerate down to 5 or 10fps does it work any better?
    Quote Quote  
  9. Member
    Join Date
    May 2012
    Location
    Canada
    Search PM
    No, it's a dual-core PC. I tried lowering the framerate but it didn't seem to make any difference.
    Quote Quote  
  10. Member
    Join Date
    Oct 2010
    Location
    England
    Search Comp PM
    Originally Posted by jonhall View Post
    No, it's a dual-core PC. I tried lowering the framerate but it didn't seem to make any difference.
    I'm pretty much out of suggestions.

    One thing I've noticed with ffmpeg is the -re option (read input at native frame rate) only seems to work if it's the first command line option after ffmpeg.exe

    I've found it useful when streaming existing video files, otherwise ffmpeg sends the stream to the server too quickly. I don't know if it has any effect when reading from a device though.

    But at least you've found a workaround.
    Quote Quote  
  11. Member
    Join Date
    May 2012
    Location
    Canada
    Search PM
    Thanks for all your suggestions, I appreciate it!
    Quote Quote  
  12. Sorry to chime in late. Anyway here's how I (somewhat successfully) did an experiment stream once from FFmpeg to FMS.
    http://betterlogic.com/roger/2012/08/ffmpeg-receiving-rtmp-stream-from-flash-media-server/
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!