How to stream all videos in a folder?
Asked Answered
H

1

6

Hi i want to stream videos over web using ffserver. i got this link as reference.

Now what i am not able to figure out is how to pass a folder(which content all videos i want to stream) as input to stream all videos. I also want add more videos dynamically to this folder in time to time and streaming should happen(like how it works in Darwin). now i can't use Darwin because it doesn't support for iOS.

please give me a suggestion.

is there any other open source tool by which i can do this?

Hyohyoid answered 18/6, 2013 at 9:54 Comment(1)
I am trying to do the same thing and have a feeling that: (1) you need to pre-configure each file you stream and (2) you can only do live streams (not too sure). Please note that these are other services like wowsa and red5. Good luck!Cogen
N
0

I wrote a bash script for this, it's working in ubuntu 16 Hopefully someone else can write it up in a less terrible language Here's the script:

echo -e "HTTPPort 8090\nHTTPBindAddress 0.0.0.0\nMaxHTTPConnections 2000\nMaxClients 1000\nMaxBandwidth 1000\nCustomLog -\n<Stream stat.html>\nFormat status\n</Stream>"
num=1
for i in *.mp3; do
echo -e "<Stream \"$(urlencode $i)\">\nFile \"$(pwd)/$i\"\nFormat mp2\nAudioCodec libmp3lame\nAudioBitRate 64\nAudioChannels 1\nAudioSampleRate 44100\nNoVideo\n</Stream>"
done

save this as a bash script in the folder you want to serve, I'll refer to it as:

./gen_ffserver_conf.sh

it's hard coded for mp3, you'd have to sort through my echos to get it to do another format. run the server with:

ffserver -f <(bash -e ./gen_ffserver_conf.sh)

I had to install a package for the url encoding:

sudo apt install gridsite-clients

(and of course you need ffserver as well, in the ffmpeg package)

I stream the files by going to:

http://<ip address of streaming server>:8090/stat.html

and clicking on the urlencoded values, (using chromium). This will open the stream and start playing.

Explanation: ffserver doesn't like wildcards, or at least I never figured that out, so I'm just creating an entry for each file in the server. The urlencoding is annoying but necessary for the stat page links to work properly.

Nigger answered 12/8, 2018 at 0:42 Comment(4)
Any idea of how that script automatically picked up newly added mp3 automatically).Hyohyoid
that's a strange behavior, it could be a newer version of ffserver that doesn't need my explicit for loop to generate an element in the conf for each file? That would be great.Nigger
Sorry, I think I created confusion here. I was asking if there was any way ffserver autodetect and add files to conf automatically?Hyohyoid
oh, you said it in past tense so I thought it had already happened. the only way I can see to do that is maybe with Inotify. Maybe use inotifywait to hang a process that kills and reboots the server. I think you'd have to reload the browser page though, if that's an issue. At this point, it might be easier to use a different solution. The bash script required sounds unwieldy.Nigger

© 2022 - 2024 — McMap. All rights reserved.