Begin stream simple mp4 with ffserver
Asked Answered
T

1

4

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-A win 8 and last VLC installed.
2-A Ubuntu 13 with last ffmpeg package.
3-A ffserver.conf file saved to /etc/ and copied from http://ffmpeg.org/sample.html (I just copy text in a new file).
4-Run this command : ffserver -f /etc/ffconfig.conf and this is result :

avserver version 0.8.13-6:0.8.13-0ubuntu0.13.10.1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 15 2014 13:53:49 with gcc 4.8.1
Tue Feb 10 07:29:07 2015 AVserver started.

5-Check http://localhost:8090/stat.html and server status is OK.It shows me 4 stream : test1.mpg,test.asf,stat.html,index.html.
6-Run this command : ffmpeg -i test.mp4 http://localhost:8090/feed1.ffm and this is result :

ffmpeg version 0.8.13-6:0.8.13-0ubuntu0.13.10.1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 15 2014 13:53:49 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2015-02-05 20:35:09
  Duration: 00:21:36.12, start: 0.000000, bitrate: 788 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 720x404, 677 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2015-02-05 17:05:45
    Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 106 kb/s
    Metadata:
      creation_time   : 2015-02-05 20:35:12
Incompatible sample format '(null)' for codec 'mp2', auto-selecting format 's16'
    Last message repeated 1 times
Incompatible sample format '(null)' for codec 'libmp3lame', auto-selecting format 's16'
[buffer @ 0x900f0c0] w:720 h:404 pixfmt:yuv420p
[scale @ 0x8ea5080] w:720 h:404 fmt:yuv420p -> w:160 h:128 fmt:yuv420p flags:0x4
[buffer @ 0x8ea34a0] Invalid pixel format string '-1'
Error opening filters!

7-I look at error and I can not find why this happen and where I go wrong!

Until now I read many sample and tutorials about ffserver but most of them is about live streaming but I just want to stream some mp4 files.

EDIT:

I installed real ffmpeg like this link : https://askubuntu.com/questions/373322/how-to-replace-avconv-with-the-real-ffmpeg-and-have-it-work-right but same error (Just change ppa to ppa:mc3man/trusty-media for last release):

pp@ubuntu:~$ ffmpeg -i big.mp4 http://localhost:8090/feed1.ffm
ffmpeg version 0.8.13-6:0.8.13-0ubuntu0.13.10.1, Copyright (c) 2000-2014 the Libav developers
  built on Jul 15 2014 13:53:49 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'big.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isom
    creation_time   : 2015-02-05 20:35:09
  Duration: 00:21:36.12, start: 0.000000, bitrate: 788 kb/s
    Stream #0.0(und): Video: h264 (High), yuv420p, 720x404, 677 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc
    Metadata:
      creation_time   : 2015-02-05 17:05:45
    Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 106 kb/s
    Metadata:
      creation_time   : 2015-02-05 20:35:12
Incompatible sample format '(null)' for codec 'mp2', auto-selecting format 's16'
    Last message repeated 1 times
Incompatible sample format '(null)' for codec 'libmp3lame', auto-selecting format 's16'
[buffer @ 0xa04e0c0] w:720 h:404 pixfmt:yuv420p
[scale @ 0x9ee4080] w:720 h:404 fmt:yuv420p -> w:160 h:128 fmt:yuv420p flags:0x4
[buffer @ 0x9ee24a0] Invalid pixel format string '-1'
Error opening filters!

Can any one give me exact commands that I should run for test?
(I know this is like beginners problem but I read doc and test everything as I can but still no luck)

Theodoratheodore answered 10/2, 2015 at 15:34 Comment(6)
As output mentions, you are not running FFmpeg but avconv, as Ubuntu installs avconv instead of FFmpeg. I don't know whether this is causing your issue, though.Troostite
I installed real ffmpeg like this link : askubuntu.com/questions/373322/… but same errorTheodoratheodore
Please show the command-line output from the recent ffmpeg.Obvious
Your second console output is also from the ancient, forked version.Diplegia
! As I said I done this like askubuntu.com/questions/373322/… and test it 3 time.Do you know a better way to get real ffmpeg?Theodoratheodore
Possible duplicate of Is mp4 stream able with ffserver?Modifier
B
4

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

Bakken answered 13/2, 2015 at 10:21 Comment(5)
I am confused.In that question there is no answer and I read comments but I cant find out how to do this.Can you edit your answer and explain more or a working demo?Theodoratheodore
Thank you!I test it and I should delete HTTP from HTTPPort HTTPBindAddress and delete Metadata because of ffserver said they are unknown and Delete flv stream part because libfaac unknown(Whay?).Theodoratheodore
Also I test it and go to http://localhost:8090/streamwebm and player will be shown but preview image is from middle of video(it seem video play when I run command but I want every user play his/her video from begining) and also I hit play button but buffering and buffering and buffering and no play.I should say I test it with a healthy mp4 and a new fedora and Ubuntu with last ffmpeg.I missed something?Theodoratheodore
Also running in ubuntu said about Failed to set value ''libvx' for option 'c:v'. Imust thank you for your help because until now no body else help me in this problem.Thank you.Theodoratheodore
I wish I could accept it but about that problems,I still cant stream videos.Theodoratheodore

© 2022 - 2024 — McMap. All rights reserved.