Giter Club home page Giter Club logo

sync's Introduction

Wetfish Sync v0.2

Synchronize HTML5 audio and video between friends!

Prerequisite Packages

  • ffmpeg and ffprobe, Sync uses shell commands in order to determine the length of audio and video files

How to use

  • clone the repository
  • cd sync
  • npm install
  • copy .env.example to .env and edit it to suit your needs
  • place mp4,ogv,mp3,flac,oga,wav,webm, or ogg files within /public/media. Files will be played in lexicographic order. A simple way to ensure they are played in the desired order is to prefix the name with a number, e.g. to play foo.mp4 before bar.webm, you would name them 01_foo.mp4 and 02_bar.webm.
  • npm start

M3U support

-in order to use an m3u file feature simply start sync like this 'npm run start -- --m3u=/path/to/playlist.m3u' or node server.js --m3u="path/to/playlist.m3u8" where root is the public folder.

-the m3u file can be located anywhere on the system, however the files it refrences must be in the public directory. otherwise you'll have a black screen, and a file name that says it's playing on the server backend.

-.webm and .ogg are unsupported filetypes if using the m3u option.

sync's People

Contributors

angelgzs avatar dependabot[bot] avatar djallen89 avatar frobthebuilder avatar itsrachelfish avatar jonathanschwob avatar meleeman01 avatar mozai avatar tmccurbin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sync's Issues

Autoplay on firefox, otherwise display a play button

Firefox allows videos to be autoplayed with audio. When a user connects to sync with Firefox, the video should automatically start playing unmuted.

Chromium based browsers like Chrome, Opera, and Safari require user interaction before a video can be played with audio. If the user connects to sync with any browser that isn't Firefox, a big play button should be displayed that the user has to click before starting the video.

By forcing the user to click a play button first, we'd be able to always start the stream with audio enabled, instead of starting the video without audio and requiring the user to unmute.

Add playlist file support (.m3u, etc)

Research which media formats are used as playlist files and what it would take to add support for reading files from them. It may be as simple as running a command to get the files in the playlist and parsing the output in node, or there could be node packages for reading media files natively.

req: skip non-media files

Error: /media/0000-00-00.m3u is an unsuported file type
[nodemon] app crashed - waiting for file changes before starting..

media folders often old non-video / non-audio files (ie. .m3u playlists, .nfo text, .jpg cover art). You already examine each file to get stream duration, could raise a warning about incompatible files and just keep going without including them in the playlist the daemon generates at starttime.

Fullscreen button

There should be a button to make the video fullscreen, right now the only way to do that is by right clicking.

sync/media-player.js:49

/sync/media-player.js:49
throw Error(${url} has no video or audio content);
^

Error: ./public/media/tiny-bird.webm has no video or audio content
at playlist.forEach (/home/zeus/sync/media-player.js:49:31)
at Array.forEach ()
at MediaPlayer.getMediaTypes (/home/zeus/sync/media-player.js:32:23)
at MediaPlayer.init (/home/zeus/sync/media-player.js:112:14)
at Object. (/home/zeus/sync/server.js:42:13)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)

'm' key for mute to update toolbar

Seen:

  • pressing 'm' key during playback will toggle mute
  • clicking the speaker icon will toggle mute and change the speaker icon to a cancelled-speaker icon and back

Desired:

  • pressing 'm' key will also change the speaker icon to a cancelled-speaker icon and back.

video gets out of sync on pause

this is fairly simple problem, the resyncing needs to take place in socket-app.js since that is the easiest way to access the server time rather than having the calculations be done in the client which as of this writing has no knowledge of what the server time is unless the page is refreshed or the player itself is instantiated.

Periodically scan the media folder for changes

Whenever a media file ends, the sync server should update the playlist from the current state of the media folder. Before a media file starts playing, the length of the video should be checked, instead of only checking once when the server first starts.

Readme missing important information

The readme does not list the command line dependencies of the project (ffmpeg & ffprobe) and it also doesn't explain the public/media/ folder.

req: different port #

currently the daemon listens (and serves http) on port 3000.
some sites already have Node.JS daemons (or other daemons) using port 3000. Would need the daemon to listen on other port #s, especially is using an SSL offloader for serving https.

Would be great if I could tell it to use a UNIX socket file instead of tcp/ip, too, but maybe that's asking too much.

Background should be black

The background is white, which doesn't look very good unless you right click and make the video fullscreen.

"404 file not found" for bulma, fscreen and solid

Using the master branch on 2019-07-28. Running sync my browser is looking for files that aren't there:

  • 404 /bulma.min.css
  • 404 /fscreen.js
  • 404 /solid.svg
  • 404 /favicon.ico

... favicon.ico is probably a genuine oversight. The other three could be floatsam from a different branch that was not completel merged into the 'master' branch.

Error during WebSocket handshake: 'Connection' header value must contain 'Upgrade'

Probably another quiet update to the websockets standard that will break stuff when Chrome+Firefox decides to be a hardass. Seeing this in the JS console

socket.io.js:8 WebSocket connection to 'wss://sync.wetfish.net/socket.io/?EIO=3&transport=websocket&sid={redacted}' failed: Error during WebSocket handshake: 'Connection' header value must contain 'Upgrade'

req: iterate N times then quit

When this daemon will be used for scheduled events, would be nice to say "present the media list once, then quit." My particular use-case is N=2, but I could simulate that by having multiple links to the same file in ascii order. (ie files named A,B,C,D,E,F,G where E links to B and F links to C).

I could have two cronjobs, one to start and a second hours later to pkill the first, but that'd require running ffprobe on every file and having to do the duration arithmetic on paper. Would rather just say "do each file once then quit", or even better "do the folder N times then quit."

Volume control & mute

There should be a mute / unmute button as well as a volume control slider.

The selected volume and mute should persist, even after pausing and restarting the stream.

Documentation: how to tell daemon which media files & how clients can toggle audio

Could use more instructions, needed a human to tell me "it only looks in ./public/media/"

Should mention that is expects every file in ./public/media/ to be video files (had an *.m3u file in there, and it crashed the daemon).

Should mention is only scans the dir and gets media duration information at start-time. I removed a file during runtime and it still sent the URL to that file to clients, and waited for that file's duration before prompting clients to fetch/play the next. I also swapped out one of the files for another (re-using the filename), and it DID send the new data, but it prompted the clients to fetch/play the next file at the end of the original file, not at the end of the new file.

Should mention the webbrowser client can toggle mute-audio by pressing the Shift key. (nice feature, useful)

Should mention webbrowsers usually don't play audio of autoplaying

Should mention the progress bar appears immediately on mouseover, but has an N-second delay to vanish on mouseout.

refactor code

as it stands Sync is working and working well, however, the current code could be refactored and simplified and leverage the vue.js framework more. one instance could be moving the template code in vue-app.js into it's on vue file, and importing it into vue-app.js.

Resync button should track time since last server update

The server sends a websocket heartbeat to clients every three seconds which update the current media timestamp (vueApp.serverTime). This means that if you click the resync button repeatedly, you will always be brought back to the last time that the server sent you a heartbeat.

To keep clients in sync more accurately, a date object should be saved on the client side each time the server sends a new timestamp. When you click on the resync button, the mediaPlayer.currentTime should be set to vueApp.serverTime plus the difference between the current time and the last heartbeat.

Assumes endpoint is '/'

What I tried:

  • set up nginx with proxypass so it can handle the SSL certs, but did not use '/' as the location
    # --- meleeman's sync sometimes in a docker container
    location /sync/ {
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_pass http://127.0.0.1:9623/ ;  # ending slash is important!
    }
    
  • started in a docker container
    docker run -it --publish "9623:3000"  \
    --volume "${mediadir}:/home/node/node_modules/sync/public/media" \
    --env "URL=https://${hostname}/sync/media/" \
    wetfish-sync:latest  -- "--m3u=public/media/playlist.m3u"
    

What I expected:

  • the show at https://hostname/sync/

What I got:

  • got the HTML for the player page, but it appears blank
  • '404 Not Found' errors for things like /style.css, /vue.js, /socket.io.js and more

Extend Readme

Hi, I just found this repo. From the description it looks like the idea is to

  • playback an audio file in sync to a youtube/vimeo video, eg to replace the audio stream that would be embedded in that video.

If that is the case, it would be great to add a minimum example
If thats not the case some description of what the purpose of this project is would be nice.

warn: Souce map error - status 404 for socket.io.js

macOS 10.13, Firefox 67.0.4

Seems to work as expected, but I have this warning in the dev condole at (client) starttime:

Source map error: request failed with status 404
Resource URL: http://[hostname]:3000/socket.io.js
Source Map URL: socket.io.js.map [Learn More]

Also seeing this in the js console repeatedly:
removing (controls.js:12:21)

New sync UI

As a part of refactoring the project (#51) we'll want to start using this new UI.

When first opening the video player

sync-big-play-button

Due to browser restrictions, we can't autoplay a video with audio when the page is first loaded. The user has to actively click on a button before we can start playing video with audio. This is how the current sync site works, however we want the play button to be more prominent with a blur effect on the background.

The play button should be grey by default and blue on hover.

After clicking the play button

sync-playing

After clicking on the play button, the controls will appear and the video should start playing.

Here are all of the icons used in the new design:
SVG icons.zip

Playlist sidebar

For now don't worry about implementing the playlist sidebar. You can make the HTML / CSS for the sidebar if you want, however the backend is going to need to be updated to send playlist information. Additionally, we may want to hide the names of files in the playlist until they have started playing to prevent spoilers. Or we might want to hide the playlist sidebar entirely unless you are an admin.

Remove nodemon from the project

The version of nodemon we are currently using has known security vulnerabilities according to npm. nodemon is unnecessary and the package.json file has already been updated to add a command which simply runs a node server.

Use a config file instead of system environment variables

Inevitably we are going to add more configuration options and it would be nice if all of them were exposed in a single place.

There should be a gitignored config file (and a tracked config example file) for all of the options in the project, similar to an .env file in Laravel.

video is paused on new media during m3uOption

specifically this seems to happen on remote media, some theories as to why this might happen would be due to sync making a remote request to load a video which the browser controls by default will prompt the user to click the play button. consequently the play button is also not reactive and should display the behavior so users understand more quickly that the video is paused and should be clicked to play the media.

Preserve volume in localstorage

When you select a volume, it should get saved in localstorage. Then when you come back to sync the volume should be automatically set to whatever the saved value is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.