Begin stream simple mp4 with ffserver

后端 未结 1 1239
旧巷少年郎
旧巷少年郎 2020-12-21 06:39

I want to stream a mp4 and for this I read about ffserver.
So I search and read ffserver documentations but still cant stream a simple file.
For this I done these:

相关标签:
1条回答
  • 2020-12-21 07:12

    You can't stream mp4 vidoes using ffserver because it contains global metadata in the file header, which makes random stream access impossible. You can choose another format like webm or use MPEG-2 Transport Streams (Apple's HLS).See https://superuser.com/questions/563591/streaming-mp4-with-ffmpeg

    HTTPPort 8090
    HTTPBindAddress 0.0.0.0
    MaxHTTPConnections 2000
    MaxClients 1000
    MaxBandwidth 100000
    CustomLog -
    <Feed streamwebm.ffm>
      File /tmp/streamwebm.ffm
      FileMaxSize 50M
      ACL allow localhost
      ACL allow 128.199.149.46
      #ACL allow 127.0.0.1
      ACL allow 192.168.0.0 192.168.0.255
    </Feed>
    <Stream streamwebm>
    #in command line run : ffmpeg -i yourvideo.mp4 -c:v libvpx -cpu-used 4 -threads 8    http://localhost:8090/streamwebm.ffm
    Feed streamwebm.ffm
    Format webm
    
    # Video Settings
    VideoFrameRate 30
    VideoSize 624x368
    
    # Audio settings
    AudioCodec libvorbis
    AudioSampleRate 48000
    AVOptionAudio flags +global_header
    
    MaxTime 0
    AVOptionVideo me_range 16
    AVOptionVideo qdiff 4
    AVOptionVideo qmin 4
    AVOptionVideo qmax 40
    #AVOptionVideo good
    AVOptionVideo flags +global_header
    
    # Streaming settings
    PreRoll 10
    StartSendOnKey
    
    Metadata author "author"
    Metadata copyright "copyright"
    Metadata title "Web app name"
    Metadata comment "comment"
    
    </Stream>
    
    #stream for flv format
    <Feed streamflv.ffm>
      File /tmp/streamflv.ffm
      FileMaxSize 50M
      ACL allow localhost
      ACL allow 192.168.88.89
      #ACL allow 127.0.0.1
      ACL allow 192.168.0.0 192.168.255.255
    </Feed>
    
    <Stream streamflv>
      Feed streamflv.ffm
      Format flv
      #Video Settings
    
      VideoCodec libx264
      VideoFrameRate 30
      VideoSize 640x360
      VideoBitRate 1000
    
      # Audio settings
      AudioCodec libfaac
      AudioSampleRate 22050
      AudioChannels 2 #this is creating problem
      AVOptionAudio flags +global_header
    
      MaxTime 0
      AVOptionVideo me_range 16
      AVOptionVideo qdiff 4
      AVOptionVideo qmin 4
      AVOptionVideo qmax 40
      #AVOptionVideo good
      AVOptionVideo flags +global_header
    
      # Streaming settings
      PreRoll 10
      StartSendOnKey
    
    </Stream>
    
    <Stream stat.html>
      Format status
      ACL allow localhost
      ACL allow 192.168.0.0 192.168.255.255
    </Stream>
    
    # Redirect index.html to the appropriate site
    
    <Redirect index.html>
      URL http://yoururl.com
    </Redirect>
    

    inside your video tag <video> <source src="http://localhost:8090/streamwebm"> </video>

    you can edit the parameters to suit your needs

    0 讨论(0)
提交回复
热议问题