你好,我正在尝试将视频文件(位于本地机器的硬盘中)传输到家庭网络/LAN。
我从一周前就开始尝试这样做了。我尝试了所有能找到的资源,然后作为最后的手段在这里问了这个问题。
1. 视频文件位于本地机器的硬盘中。2
. 需要通过 HTTP 协议进行流式传输。3
. 任何 GPL 服务器都可以使用,但最好使用 ffmpeg 或 vlc。
谢谢。我很感激任何帮助。
以下是我已经尝试过的一些方法。
可变速率控制器(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
将您的视频文件放在网络目录中(通常/var/www
)或在那里建立符号链接。
在要播放视频的计算机(客户端)上运行
wget http://server/something.avi -O - | mplayer -cache 8192 -
或者您可以启动vlc
并告诉它打开http://server/something.avi
文件。
除非你的 LAN 中有 DNS,否则你可能必须用server
它的地址替换它,它通常看起来像192.168.X.Y