Shuffle a random video from directory or play a defined number of videos.

Allanbuzzy

New Member
So I want to create a locally streamed channel to my PC, and to save the hassle of having to add every individual episode I sort of want to make it easier for myself by just adding the directory into the VLC Video Source playlist. One of my suggestions is maybe a number of videos the playlist should play within the directory, or play a random video from that directory. Before you say that this is essentially just shuffling the playlist, it is slightly different in the fact that the playlist would retain it's original order, but the playlist would play something random on that directory and nothing more. Also, the directory would be given a number it should play of that directory before moving to the next item in the playlist.

The best way to describe it is by demonstrating it:

[directory of video] - If this is being used for repeats, one of the ways which this could be used for is by having it only show 1 video from the directory picked from a random episode. This would be limited to the number, so once the video is done it then goes to the next entity on playlist.
[bumper for stream] - Works in the same way as the previous entity. This would choose a random bumper to play.
[next bumper] - Manually added by user
[directory of commercials] - A typical advert/commercial lasts between 15 secs to 1 minute, average of 30 seconds, so it depends on country's limit on minutes. Let's just say around 15-20 videos of adverts/commercials would be used here.
[promos for stream] - Same as other entities.
[now bumper] - Manually added by user
[directory of video again] - This may be a little complicated, but if the video that was played before was episode 1, potentially play the next episode. This would automate quickly and wouldn't need the user to insert the episode manually. Useful for marathons of shows or videos.

I am unsure if this has been requested before, but if it hasn't this idea would definitely be appreciated, especially for those simply running a local stream of content. Plus, this would be easier for the user since they wouldn't need to manually add adverts/commercials, bumpers and promos for their stream and would simply just be running off the software without needing any lengthy process.
 

TAG

New Member
I don't think you will get an answer. I honestly do not thing the DEVS understand what we want. For my BRB screen, all I want to do is play random video clips from a folder of my choosing. And each time I go to the BRB scene I want a different RANDOM video to play. I don't care if a previous video randomly plays..but the way it is now, the VLC plugin just randomizes when you hit the Shuffle button and never changes the order. To me this is a cop out and cheesy programming. I need it to randomize every time the scene fires. This doesn't seem like too much to ask for.
 

UpDownLeftDie

New Member
I was google searching for a solution to this.
If there's no method of doing it in OBS my fall back is an HTML page with embedded video player and some JS that will handle randomizing the videos
 

UpDownLeftDie

New Member
I was google searching for a solution to this.
If there's no method of doing it in OBS my fall back is an HTML page with embedded video player and some JS that will handle randomizing the videos

Scratch this. I forgot I use this technique on a muted video but this won't work with videos that have audio due to chrome blocking autoplay on those.
 

dahlor

New Member
This is exactly what I needed! It is, however, just giving me a black screen when I try to use it. I checked my paths and everything *seems* to be fine. How are you formatting the path to the folder, assuming you are in Windows? I think that might be the problem, but I don't know for sure. Thank you!
 

UpDownLeftDie

New Member
This is exactly what I needed! It is, however, just giving me a black screen when I try to use it.
How are you formatting the path to the folder, assuming you are in Windows? I think that might be the problem, but I don't know for sure.

Did you try it in OBS? This won't work outside of OBS. Check the readme on the Github page.

Yes, I'm using windows. Paths are relative, exactly like the example.
Mine is ../videos/brb/ with mp4s in the "brb" folder that is up once and down inside "videos" folder.
If they're in the same folder as the HTML you'd probably set "videoFolder" to an empty string: ""
 
Last edited:

BioFUSION

Member
Wish we had something similar to this for transitions, I could make like 8 transition vids, and it would randomly pick one when I switched scenes
 

WerewolfJesus_

New Member
Actually, OBS a does have the autoplay flag get so I was able to make this

Hope it helps!

I am code illiterate. How exactly should this be used in OBS, and what things would I need to change to get this to work for me? Is it a browser source? Video source? I have a folder made already for my BRB videos. There are 10 videos at the moment, and I will definitely be adding more. Will I need to make adjustments in OBS as I add more videos? Thanks in advance.
 

Krazypickle

New Member
Actually, OBS a does have the autoplay flag get so I was able to make this

Hope it helps!

Thank you for this, I can get it semi working. The mp4 videos play just a few frames and then pauses, the audio continues just fine. Anyway to get the video to play with some smoothness?
 

beemop

New Member
Did you try it in OBS? This won't work outside of OBS. Check the readme on the Github page.

Yes, I'm using windows. Paths are relative, exactly like the example.
Mine is ../videos/brb/ with mp4s in the "brb" folder that is up once and down inside "videos" folder.
If they're in the same folder as the HTML you'd probably set "videoFolder" to an empty string: ""

Thank you for making this - however I can't get it to work either... I've triple checked my paths and am using .mp4's but just get a blank screen after using the index.html as a browser source. I've tried moving around to different directories as well...
 

beemop

New Member
Thank you for making this - however I can't get it to work either... I've triple checked my paths and am using .mp4's but just get a blank screen after using the index.html as a browser source. I've tried moving around to different directories as well...

Got it working, it just seems to really hate spaces in folder names so if you're having trouble, I recommend putting the HTML page in the same folder as the video files and just leaving the path as ''
 

freshvibe

New Member
I've got this working, however, I'm trying to figure out how to prevent the videos from autoplaying-- when I show the source, I would like it to randomly play just one video. Can any HTML gurus help?
 

DJHCKR

New Member
Remove or comment out this line, now commented out in my example:
<!-- player.addEventListener('ended', playNext, false); -->
That is working for me.
 

WerewolfJesus_

New Member
I can't get this to work. Maybe I have my path wrong? Do I need to include the path all the way back to the C drive? As for video names. Do I just need to add the name, or is .mp4 required after each. I'm not code literate so I'm not exactly sure if my edits to the code are working. The parts that I have to edit are currently reading as follows:
const videoFolder = '../Videos/BRB/'
const videosList = [
'RocketLeague1',
'RocketLeague2'
 

WerewolfJesus_

New Member
I can't get this to work. Maybe I have my path wrong? Do I need to include the path all the way back to the C drive? As for video names. Do I just need to add the name, or is .mp4 required after each. I'm not code literate so I'm not exactly sure if my edits to the code are working. The parts that I have to edit are currently reading as follows:
const videoFolder = '../Videos/BRB/'
const videosList = [
'RocketLeague1',
'RocketLeague2'

Got it to work.
 

Zukanna

New Member
I am feeling completely out of my depth here. I've copied the html code, edited the video folder, added in the videos list but nothing is working. I am pretty much code illiterate. Can someone please help explain step by step how to set this up? I want to be able to play random clips i've downloaded one at a time (so I know to remove the line <!-- player.addEventListener('ended', playNext, false); --> to allow that).
 

Vashzaron

New Member
Actually, OBS a does have the autoplay flag get so I was able to make this

Hope it helps!

Works great for me, that said can I be greedy and ask if its possible to do the same with audio files too? I know I could convert audio to mp4 for example and use it as is but if there is any cleaner method it would be cool to know, thanks.
 

UpDownLeftDie

New Member
Wish we had something similar to this for transitions, I could make like 8 transition vids, and it would randomly pick one when I switched scenes
I think there's a plugin that will do this. If this doesn't work maybe you can request it over there

I am code illiterate. How exactly should this be used in OBS, and what things would I need to change to get this to work for me? Is it a browser source? Video source? I have a folder made already for my BRB videos. There are 10 videos at the moment, and I will definitely be adding more. Will I need to make adjustments in OBS as I add more videos? Thanks in advance.
I updated the readme for you: https://github.com/UpDownLeftDie/obs-random-video

I am feeling completely out of my depth here. I've copied the html code, edited the video folder, added in the videos list but nothing is working. I am pretty much code illiterate. Can someone please help explain step by step how to set this up? I want to be able to play random clips i've downloaded one at a time (so I know to remove the line <!-- player.addEventListener('ended', playNext, false); --> to allow that).
You DON'T want to comment that line out if you want to keep playing videos. If you comment that line out it will stop after the first one.
Are you testing this inside of OBS? This won't autoplay in your browser outside of OBS.
For step-by-step instructions read the readme on the page: https://github.com/UpDownLeftDie/obs-random-video

Works great for me, that said can I be greedy and ask if its possible to do the same with audio files too? I know I could convert audio to mp4 for example and use it as is but if there is any cleaner method it would be cool to know, thanks.
Mp3 files should work just fine already.

Anyone else reading this. Please don't comment on this thread for support.
I didn't even know people were replying here. Please open Issues on the GitHub repo if you have any questions or need support.
I just went though this thread and suggestions and added some features and cleaned up some stuff to hopefully make it easier to use
 

TBO1981

New Member
Thanks for this, this forum amazes me sometimes, just what I needed and even in a code I can customize easily, will be checking out some of your other stuff on git also.
 
Top