21

I'm currently doing a stream that is supposed to display correctly within Flowplayer. First I send it to another PC via RTP. Here, I also checked with VLC that the codec etc. arrive correctly, which they do.

Now I want to expose this stream to Flowplayer as a file, so it can be displayed, via something I used in VLC: http://localhost:8080/test.mp4 for example.

The full line I got is: ffmpeg -i input -f mp4 http://localhost:8080/test.mp4

However, no matter how I try to do this, I only get an input/output error. Is this only possible with something like ffserver or another?

What I think is this doesn't work because ffmpeg can't act as a server; on VLC it works since it can. (Though VLC ruins the codecs I set and it can't be read afterwards for some reason)

A (sort of) workaround I can use is saving the RTP stream to a file, and then letting flowplayer load it. This, however, only works once the file is not accessed anymore; I get a codec error otherwise.

Boehmi
  • 951
  • 3
  • 9
  • 20
  • 1
    check the docs : https://trac.ffmpeg.org/wiki/StreamingGuide – Robert Rowntree Jun 03 '14 at 14:52
  • I've already read through them a few times, but it did not resolve my specific issue. – Boehmi Jun 03 '14 at 15:00
  • Use flv instead of mp4 if you're attempting live streaming: `ffmpeg -i input -c:v libx264 -maxrate 1000k -bufsize 2000k -g 50 http://localhost:8080/test.flv` Also see http://trac.ffmpeg.org/wiki/EncodingForStreamingSites – llogan Jun 03 '14 at 17:23
  • Sadly, I'm still getting `http://localhost:8080/test.flv: Input/output error` then. – Boehmi Jun 04 '14 at 07:26
  • Where you able to fix it? – Cito Jan 13 '15 at 19:55
  • @Cito I don't think I was, but now I am creating m3u8 playlists over HTTP, which Flowplayer can read in using a plugin. Works very well. – Boehmi Jan 14 '15 at 09:36
  • What error message? – rogerdpack Dec 04 '17 at 18:58
  • Please also provide information like an error message and what software you are using to provide the file over `https://localhost:8080/` as this requires serving the file from the system you're using ffmpeg on. The best guess I can make now is that there is nothing serving the file on the system where ffmpeg is being run from – RivenSkaye May 15 '20 at 14:32

2 Answers2

7

To have FFmpeg act as an HTTP server, you need to pass the -listen 1 option. Additionally, -f mp4 will result in a non-fragmented MP4, which is not suitable for streaming. You can get a fragmented MP4 with -movflags frag_keyframe+empty_moov. A full working command line is:

ffmpeg -i input -listen 1 -f mp4 -movflags frag_keyframe+empty_moov http://localhost:8080

Other options you may find helpful are -re to limit the streaming speed to the input framerate, -stream_loop -1 to loop the input, and -c copy to avoid reencoding.

leo60228
  • 754
  • 11
  • 21
  • 1
    When I do this ffmpeg shows a bunch of lines and then 'handler_name : VideoHandler' and then sits there idling. I can't seem to play the stream from another computer. When I try to play this with vlc I get in the logs: 'no access_demux modules matched'. Any suggestions? – captcha Feb 26 '23 at 05:21
-3

you need this command line

ffmpeg -f v4l2 -s 320x240 -r 25 -i /dev/video0 -f alsa -ac 1 -i hw:0 http://localhost:8090/feed1.ffm

make sure that your feed name ends with ".ffm" and if it's not the case, then add "-f ffm" before your feed URL, to manually specify the output format (because ffmpeg won't be able to figure it out automatically any more), like this "-f ffm http://localhost:8090/blah.bleh".

SPWW
  • 62
  • 6