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



## Allanbuzzy (Jan 25, 2020)

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.


----------



## TheAncientGamer (Mar 24, 2020)

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 (Jun 3, 2020)

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 (Jun 4, 2020)

UpDownLeftDie said:


> 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.


----------



## UpDownLeftDie (Jun 4, 2020)

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








						GitHub - UpDownLeftDie/obs-random-videos: Easily create a random playlist of videos or music
					

Easily create a random playlist of videos or music - GitHub - UpDownLeftDie/obs-random-videos: Easily create a random playlist of videos or music




					github.com
				




Hope it helps!


----------



## dahlor (Jun 4, 2020)

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 (Jun 11, 2020)

dahlor said:


> 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: ""


----------



## BioFUSION (Aug 30, 2020)

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_ (Oct 19, 2020)

UpDownLeftDie said:


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



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 (Nov 5, 2020)

UpDownLeftDie said:


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



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 (Dec 15, 2020)

UpDownLeftDie said:


> 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 (Dec 15, 2020)

beemop said:


> 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 (Jan 28, 2021)

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 (Feb 1, 2021)

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


----------



## WerewolfJesus_ (Feb 9, 2021)

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_ (Feb 12, 2021)

WerewolfJesus_ said:


> 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 (Mar 9, 2021)

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 (Mar 29, 2021)

UpDownLeftDie said:


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



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 (Apr 13, 2021)

BioFUSION said:


> 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





						Transition Table
					

Inspired by OBS Transition Matrix  Donations You can donate to me via PayPal, GitHub or Patreon.




					obsproject.com
				






WerewolfJesus_ said:


> 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



Zukanna said:


> 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



Vashzaron said:


> 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 (Jul 31, 2021)

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.


----------



## bcoyle (Jul 31, 2021)

You guys might want to come over and look at this thread. Its about 24/7 automation





						Automate 24/7 Stream for a scheduled Playlist
					

Hi, What is the best workflow to automate obs streaming a scheduled playlist Hi,  What is the best workflow to automate obs streaming a scheduled playlist that will be managed by an in-house application, I did a workaround by adding a scene with vlc source form a directory and I tried to drop...




					obsproject.com


----------



## bcoyle (Jul 31, 2021)

Here is an example of some of the work I'm doing. This is a R.E.M song with a cartoon background, showing the possibilities.








						2021 07 28 16 33 45 ALBUM=THE BEST OF REMGROUP=REMARTIST=REMTRACK=8,SONG=ORANGE CRUSH
					






					www.youtube.com


----------



## TBO1981 (Aug 2, 2021)

SO I'm wondering, I sure there is but not sure how easy it would be to edit the exe to ask for a folder location of the videos rather than just having the exe in the same folder?


----------



## Slick_J (Sep 8, 2021)

Thank You for posting this. I had an idea but did not know how to carry it out. For those still having issues you will follow the instructions to install the OBS plug-ins but to trigger it I use triggerfyre which you can find at https://overlays.thefyrewire.com/. You will have to have OBS open and in triggerfyre connect to OBS then you will trigger a source select the source that you created for the random video and set the rules for what you want it to do. I am doing mine through a channel point redemption but you can also just do a command. Mine is working perfectly


----------



## bcoyle (Dec 2, 2021)

Vashzaron said:


> 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.


How do you like this: This is automated. uses info in the file name to fill in the text fields with album,song etc









						2021 07 28 16 33 45 ALBUM=THE BEST OF REMGROUP=REMARTIST=REMTRACK=8,SONG=ORANGE CRUSH
					






					www.youtube.com


----------

