0

I want to use ffmpeg to encode and publish a live stream to Flash Media Server. In order to support iOS devices, I need to implement HTTP Live Streaming as well. The video needs to be in H.264 format and the audio should be AAC. I don't have much experience working with ffmpeg, and I'm having a hard time getting this to work. This is the command that I've tried (and some variations as well):

ffmpeg.exe -threads 15 -f dshow -i video="USB2.0 UVC WebCam":audio="Microphone (Realtek High Defini" \
      -map_channel 0.1.1 -r 24 -acodec libvo_aacenc -ar 22050 -ab 128k -vcodec libx264 \
      -s vga -vb 100k -f flv "rtmp://<public-dns>/livepkgr/livestream1?adbe-live-event=liveevent" \
      -r 24 -acodec libvo_aacenc -ar 22050 -ab 128k -vcodec libx264 -s qvga -vb 200k \
      -f flv "rtmp://<public-dns>/livepkgr/livestream2?adbe-live-event=liveevent" \
      -r 24 -acodec libvo_aacenc -ar 22050 -ab 128k -vcodec libx264 -s vga -vb 350k 
      -f flv "rtmp://<public-dns>/livepkgr/livestream3?adbe-live-event=liveevent"

When I run this, it appears to connect to FMS, but then I get a lot of error messages about dropped frames - I'm not sure if ANY frames get encoded successfully. My CPU usage is very high as well. I get a 404 error from FMS when I enter the URL of the *.m3u8 file for one of the individual streams (the main livestream.m3u8 file is accessible though). I have also tried outputting to a file instead of FMS, with no success. All I get is some very garbled sound and no video.

Any suggestions for what options/commands I should use to get this working? Is anyone using ffmpeg with FMS to do HTTP Dynamic Streaming / HLS with MP4 video? I've been struggling to get HDS/HLS working for some time now, and any help would be much appreciated! It shouldn't make a difference, but I'm using FMS on Amazon EC2 with their AMI image.

Thanks!

Stu Thompson
  • 38,370
  • 19
  • 110
  • 156
Jonathan
  • 183
  • 1
  • 4
  • 9
  • http://blog.denivip.ru/index.php/2011/07/1893/?lang=en and http://betterlogic.com/roger/2012/08/ffmpeg-receiving-rtmp-stream-from-flash-media-server/ may help – rogerdpack Sep 06 '12 at 17:31

1 Answers1

2
-threads 15

I'm deeply suspicious of that value. My own research and experimentation with the threads switch says that any value above 4 is a mistake. Try removing it, using a lower value, and/or a value divisible by 2.

-f flv

I'm also deeply suspicious of this value. FLV and h.264 don't play well together. Use the MP4 instead.

You mention the CPU is "high", but you don't mention a percentage. Also note that you are encoding three different bit rates--effectively three simultaneous encoding jobs. And you don't mention the CPU you are running on. A Pentium 4 or Core 2? I'd not be surprised. A modern Core i7, well ok.

Why are you using FFmpeg? It very well may be easier to use Adobe's Flash Media Live Encoder.

Stu Thompson
  • 38,370
  • 19
  • 110
  • 156
  • In case some sees that post years later, "-f flv" is the correct parameter for RTMP – greg Jul 03 '20 at 15:13