I want to stream videos via ffserver. My videos are in container formats like mkv and avi and sometimes have multiple audio/video tracks. How can I tell ffserver which track to use? It seems to always take the first one.
If you look at this page they show this technique of using ffmpeg to do the slicing and then having it forward it to the ffserver:
$ ffmpeg \ -f v4l2 -s 320x240 -r 25 -i /dev/video0 \ -f alsa -ac 1 -i hw:0 \ http://localhost:8090/feed1.ffm
The above command is doing the following:
- The first part
-f v4l2 -s 320x240 -r 25 -i /dev/video0represents the first input for
ffmpegand captures our webcam video. For more info, you can read more about How to capture a webcam input.
- The second part
-f alsa -ac 1 -i hw:0represents the second input for
ffmpegand captures our audio, depending on our system audio configuration. For more info, you can read more about Capturing audio with FFmpeg and ALSA.
- The last, but not the least important, part
http://localhost:8090/feed1.ffmrepresents the feed URL, which tells ffmpeg to connect to ffserver and send it the audio + video streams for broadcast. In this example we used the hostname
localhostwhich means that everything is running on our computer, but if you need to feed the live online ffserver, you'll need to change the
localhostto the real host name or IP address of your ffserver computer. Also make sure that your feed name ends with
.ffmand if it's not the case, then add
-f ffmbefore your feed URL, to manually specify the output format (because
ffmpegwon't be able to figure it out automatically any more), like this
-f ffm http://localhost:8090/blah.bleh.
As soon as you type the command above, you should see ffmpeg displaying some statistics about your input streams and counting output frames, which is a pretty good sign that everything works (so far).