2015-02-10 79 views
3

我想流mp4,爲此我讀了關於ffserver。
因此,我搜索和閱讀ffserver文檔,但仍然無法傳輸一個簡單的文件。
爲此,我做了這些:
1-A win 8 and last VLC installed。
2-A帶有最後一個ffmpeg軟件包的Ubuntu 13。
3-ffserver.conf文件保存到/ etc /並從http://ffmpeg.org/sample.html複製(我只是將文本複製到一個新文件中)。
4運行此命令:ffserver -f /etc/ffconfig.conf,這是結果:從ffserver開始流簡單mp4

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檢查http://localhost:8090/stat.html和服務器的狀態是OK.It顯示我4流:test1.mpg,test.asf,stat.html,指數html的。
6運行此命令:ffmpeg -i test.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 @ 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-我看着錯誤,我找不到爲什麼發生,我走到哪裏錯了!

到現在爲止,我讀了很多關於ffserver的示例和教程,但其中大部分都是關於直播流的,但我只想傳輸一些mp4文件。

編輯:

我安裝了這樣的鏈接真正的ffmpeg:https://askubuntu.com/questions/373322/how-to-replace-avconv-with-the-real-ffmpeg-and-have-it-work-right但同樣的錯誤(只要改變PPA到ppa:mc3man/trusty-media的最後一個版本):

[email protected]:~$ 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! 

任何一個可以給我確切的命令是我應該跑步測試?
(我知道這是初學者一樣的問題,但我看了doc和我可以檢驗一切,但仍然沒有運氣)

+2

由於輸出提到,你沒有運行FFmpeg,而是avconv,因爲Ubuntu安裝的是avconv而不是FFmpeg。不過,我不知道這是否會引起你的問題。 – audionuma 2015-02-10 17:36:16

+0

我安裝了真正的ffmpeg像這樣的鏈接:http://askubuntu.com/questions/373322/how-to-replace-avconv-with-the-real-ffmpeg-and-have-it-work-right但是同樣的錯誤 – 2015-02-10 19:15:28

+0

請顯示最近ffmpeg的命令行輸出。 – slhck 2015-02-11 09:13:05

回答

3

使用ffserver的,因爲它包含在文件頭,這使得全球的元數據,因此無法串流mp4 vidoes隨機流訪問不可能。你可以選擇另一種格式像webm或使用MPEG-2傳輸流(蘋果HLS)參見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> 

視頻標籤內 <video> <source src="http://localhost:8090/streamwebm"> </video>

您可以編輯的參數,以滿足您需要

+0

我很困惑。在這個問題中,沒有答案,我讀了評論,但我無法找到如何做到這一點。你可以編輯你的答案,並解釋更多或演示? – 2015-02-13 12:17:15

+0

謝謝!我測試它,我應該從HTTPPort HTTPBindAddress中刪除HTTP,並刪除元數據,因爲ffserver表示它們是未知的,並且因爲libfaac unknown(Whay?)而刪除flv流的一部分。 – 2015-02-19 11:17:53

+0

另外我測試它並進入'http:// localhost:8090/streamwebm'並且播放器將會顯示,但是預覽圖像來自視頻的中間(當我運行命令時它看起來是視頻播放,但我希望每個用戶都播放他/她從開始的視頻),我也玩按鈕,但緩衝和緩衝和緩衝,沒有play.I應該說我用一個健康的mp4和一個新的fedora和Ubuntu與最後ffmpeg測試它。我錯過了什麼? – 2015-02-19 11:21:01