How to Stream a static video file
I'm not sure if my answer will help you, but if all you need is to play video files via LAN, you can simply share them using an HTTP (or even FTP) server.
On the computer which hosts video files (server), install a web server of your choice, e.g.
sudo apt-get install apache2
# or
sudo apt-get install lighttpd
Put your video files in the web directory (usually /var/www
) or symlink them there.
On the computer which should play the video (client), run
wget http://server/something.avi -O - | mplayer -cache 8192 -
or you can start vlc
and tell it to open http://server/something.avi
file.
Unless you have DNS in your LAN, you'll probably have to replace server
with its address, which usually looks like 192.168.X.Y
Related videos on Youtube
monk
Updated on September 18, 2022Comments
-
monk over 1 year
Hi I am trying to stream a video file (located in local machine's hard disk.) to home network/LAN.
I am trying to do this from a week now. I tried all the resource I could find then then as a last resort asking this question here.
1. Video file is present in local machine's hard disk.
2. need to stream through HTTP protocol.
3. Any GPL server would work , however would prefer ffmpeg or vlc.Thanks. I appreciate any help on this.
Here are few things I already tried.
VLC:
This intermittently works. But no audio is coming , only video is received.
On server end:
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 :
step-1:
running ffmpeg server
ffserver -d -f /etc/ffserver.conf ffserver version N-80026-g936751b Copyright (c) 2000-2016 the FFmpeg developers
step-2: stream
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
more commands :
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
My ffmpeg configuration file:
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>
Note :
Following command does not give any error. but client is not showing any video or audio,
ffmpeg -re -i "SampleVideo_1280x720_2mb.mp4" -f mpegts "udp://10.1.10.102:2000"
This one says broken pipe:
ffmpeg -re -i SampleVideo_1280x720_2mb.mp4 -acodec copy -vcodec copy -f flv rtmp://10.1.10.102:8090/SampleVideo_1280x720_2mb.mp4
-
P.... over 7 years@PIMP_JUICE_IT - I will get back to you once I get hold of server again. Its down since weekend for maintenance. Thanks
-
P.... over 7 years@PIMP_JUICE_IT : Naa It didn't worked. I have added the error in question in the end.
-
Zenexer over 7 yearsThis looks like it might be relevant: stackoverflow.com/questions/26999595/…
-
Ian M over 7 yearsSince you didn't go into much depth on what you are trying to accomplish, I'll throw a suggestion out there, why not try something like the media server Plex? plex.tv You don't need to re-invent the wheel.
-
Quinton M. over 7 yearsWhy say that you have a restriction to use only HTTP and one of your uses RTMP?
-
-
P.... over 7 years_thanks for your reply, this is very helpful to me. _