這是我已經嘗試過的一些事情。

這是我已經嘗試過的一些事情。

您好,我正在嘗試將視訊檔案(位於本地電腦的硬碟中)串流到家庭網路/區域網路。

我現在正嘗試從一周開始做這件事。我嘗試了所有我能找到的資源,然後作為最後的手段在這裡提出這個問題。

1. 視訊檔案存在於本機硬碟中。
2.需要透過HTTP協定進行串流傳輸。
3. 任何 GPL 伺服器都可以使用,但喜歡 ffmpeg 或 vlc。

謝謝。我很感謝對此的任何幫助。

這是我已經嘗試過的一些事情。

可見光通信:

這間歇性地起作用。但沒有音訊傳來,只收到影片。

在伺服器端:

ffmpeg -i sample.mp4 -vcodec libx264 -acodec aac -ar 48000 -strict experimental -f flv "rtmp://127.0.0.1:1935/live/myStream"

vlc rtp://@10.1.10.102:9001

ffmpeg:

步驟1:

運行 ffmpeg 伺服器

 ffserver -d  -f /etc/ffserver.conf 
ffserver version N-80026-g936751b Copyright (c) 2000-2016 the FFmpeg developers

步驟 2:串流媒體

ffmpeg -i SampleVideo_1280x720_2mb.mp4 -vcodec libx264 -acodec aac -ar 48000 -strict experimental -f flv "rtmp://localhost/live/myStream"
ffmpeg version N-80026-g936751b Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 42.100 / 57. 42.100
  libavformat    57. 36.100 / 57. 36.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 45.100 /  6. 45.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SampleVideo_1280x720_2mb.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.24.2
  Duration: 00:00:13.50, start: 0.000000, bitrate: 1248 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 862 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 381 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : SoundHandler
[tcp @ 0x3a4c920] Connection to tcp://localhost:1935 failed: Connection refused
[rtmp @ 0x3a4c8a0] Cannot open connection tcp://localhost:1935
rtmp://localhost/live/myStream: Connection refused

更多指令:

ffmpeg -i "SampleVideo_1280x720_2mb.mp4"  -re -f mpegts "udp://127.0.0.1:2000"
ffmpeg version N-80026-g936751b Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 42.100 / 57. 42.100
  libavformat    57. 36.100 / 57. 36.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 45.100 /  6. 45.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'SampleVideo_1280x720_2mb.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 1970-01-01 00:00:00
    encoder         : Lavf53.24.2
  Duration: 00:00:13.50, start: 0.000000, bitrate: 1248 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 862 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 381 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01 00:00:00
      handler_name    : SoundHandler
Option re (read input at native frame rate) cannot be applied to output file udp://127.0.0.1:2000 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for output file udp://127.0.0.1:2000.
Error opening output files: Invalid argument

我的 ffmpeg 設定檔:

cat /etc/ffserver.conf 
Port 8090                      # Port to bind the server to
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000             # Maximum bandwidth per client
                               # set this high enough to exceed stream bitrate
CustomLog -
NoDaemon                       # Remove this if you want FFserver to daemonize after start

<Feed feed1.ffm>               # This is the input feed where FFmpeg will send
   File ./feed1.ffm            # video stream.
   FileMaxSize 1G              # Maximum file size for buffering video
   ACL allow 127.0.0.1         # Allowed IPs
</Feed>

<Stream test.webm>              # Output stream URL definition
   Feed feed1.ffm              # Feed from which to receive video
   Format webm

   # Audio settings
   AudioCodec vorbis
   AudioBitRate 64             # Audio bitrate

   # Video settings
   VideoCodec libvpx
   VideoSize 720x576           # Video resolution
   VideoFrameRate 25           # Video FPS
   AVOptionVideo flags +global_header  # Parameters passed to encoder
                                       # (same as ffmpeg command-line parameters)
   AVOptionVideo cpu-used 0
   AVOptionVideo qmin 10
   AVOptionVideo qmax 42
   AVOptionVideo quality good
   AVOptionAudio flags +global_header
   PreRoll 15
   StartSendOnKey
   VideoBitRate 400            # Video bitrate
</Stream>

<Stream status.html>            # Server status URL
   Format status
   # Only allow local people to get the status
   ACL allow localhost
   ACL allow 192.168.0.0 192.168.255.255
</Stream>

<Redirect index.html>    # Just an URL redirect for index
   # Redirect index.html to the appropriate site
   URL http://www.ffmpeg.org/
</Redirect>

筆記 :

以下命令不會給出任何錯誤。但客戶端沒有顯示任何視頻或音頻,

ffmpeg -re -i "SampleVideo_1280x720_2mb.mp4"  -f mpegts "udp://10.1.10.102:2000"

這個說的是破管子:

ffmpeg -re -i SampleVideo_1280x720_2mb.mp4 -acodec copy -vcodec copy -f flv rtmp://10.1.10.102:8090/SampleVideo_1280x720_2mb.mp4

答案1

我不確定我的答案是否對您有幫助,但如果您只需要透過 LAN 播放視訊文件,您可以簡單地使用 HTTP(甚至 FTP)伺服器共享它們。

在託管視訊檔案(伺服器)的電腦上,安裝您選擇的 Web 伺服器,例如

sudo apt-get install apache2
# or
sudo apt-get install lighttpd

將您的影片檔案放在 Web 目錄中(通常是/var/www)或在那裡進行符號連結。

在要播放影片的電腦(客戶端)上,執行

wget http://server/something.avi -O - | mplayer -cache 8192 -

或者您可以啟動vlc並告訴它打開http://server/something.avi文件。

除非您的 LAN 中有 DNS,否則您可能必須替換server為它的位址,通常看起來像192.168.X.Y

相關內容