GithubHelp home page GithubHelp logo

shimberger / gohls Goto Github PK

View Code? Open in Web Editor NEW
557.0 25.0 87.0 3.33 MB

A server that exposes a directory for video streaming via web interface

Home Page: https://shimberger.github.io/gohls/

License: Other

Go 57.90% JavaScript 1.12% HTML 0.71% Shell 3.18% TypeScript 37.07%
hls ffmpeg golang react video-stream videojs hacktoberfest

gohls's Introduction

Golang HLS Streamer

GitHub Actions: Build, and may release a new snapshot GoDoc

Simple server that exposes a directory for video streaming via HTTP Live Streaming (HLS). Uses ffmpeg for transcoding.

This project is cobbled together from all kinds of code I had lying around so it's pretty crappy all around. It also has some serious shortcomings.

Running it

Important: You need the ffmpeg and ffprobe binaries in your PATH. The server will not start without them. You can find builds most operating systems at https://ffmpeg.org/download.html.

1. Download the binary for your operating system

You can find the latest release on the releases page https://github.com/shimberger/gohls/releases or just download a current snapshot:

2. Create a configuration file

The configuration is stored in JSON format. Just call the file gohls-config.json or whatever you like. The format is as follows:

{
	"folders": [
		{
			"path": "~/Videos",
			"title": "My Videos"
		},
		{
			"path": "~/Downloads",
			"title": "My Downloads"
		}
	]
}

This will configure which directories on your system will be made available for streaming. See the screenshot for details:

3. Run the server

Execute the command gohls serve -config <path-to-config> e.g. gohls serve -config gohls-config.json to serve the videos specified by the config file. To make the server listen on another port or address just use the serve command with --listen like so (the example uses port 7000 on all interfaces): gohls serve --listen :7000 -config <path-to-config>

4. Open a web browser

Visit the URL http://127.0.0.1:8080 to access the web interface.

Contributing

Requirements

Initial setup

  1. Clone the repository [email protected]:shimberger/gohls.git
  2. Build frontend cd ui/ && npm install && npm run build && cd ..

Running server

To then run the development server execute: ./scripts/run.sh serve

License

See LICENSE.txt

gohls's People

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

gohls's Issues

Failed at the [email protected] build script

I tried to build this project on my own.
But when I run npm run build, there's always something wrong.

YiqiangdeMacBook-Pro:gohls alai04$ ./scripts/prep_release.sh alai04

> [email protected] build /Users/alai04/go/src/github.com/shimberger/gohls/ui
> react-scripts-ts build

Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
ts-loader: Using [email protected] and /Users/alai04/go/src/github.com/shimberger/gohls/ui/tsconfig.prod.json
No valid rules have been specified for JavaScript files
Failed to compile.

/Users/alai04/go/src/github.com/shimberger/gohls/node_modules/@types/react/index.d.ts
(2687,13): Subsequent property declarations must have the same type.  Property 'a' must be of type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>', but here has type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts-ts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I guess it's issue of dependency, but I don't know how to solve it.
Thanks.

wonderful project

few issues

  • gohls does not detect new media in folder without restarting server for me.

  • ffmpeg supports , presets HLS encoding ,
    ultrafast , superfast ,veryfast , faster, fast , medium – default preset, slow , slower, very slow
    would be nice to have in the config these options. - for the speed encoding issue, it might be
    better to try ultrafast encoding to HLS , this is a similar project in node
    https://github.com/mifi/hls-vod , which i used in past, it does not have any buffering encoding
    issue, might help you somehow.

  • encode multiple outputs in parallel 480,p 720p, 1080p, option to pick stream type.

  • detect srt subtitles in folder and convert to webvtt

  • detect subtitles inside MKV , encode together to HLS.

  • template options , view list, grid list ,

  • small admin panel to control deletion , server settings , encoding etc.

Support archives

Hello,

I think it would be awesome if gohls can look into non-compressed archives (zip/rar) as well and do ffmpeg with its video on the fly.

What do you think about that?

Cya
midzer

Don't use external resources

ATM the project uses external JS and CSS files. This doesn't work offline. Fix it by bundling everything into a vendor.js at first.

Unable to visit the ui list as `HTTP/1.1 302 Found`

Help wanted:) @shimberger
After running run_dev , the terminal output success information as bellow:

# ./scripts/run_dev.sh serve /srv/go/gohls/videos
Path to ffmpeg executable: /srv/go/gohls/tools/ffmpeg
Path to ffprobe executable: /srv/go/gohls/tools/ffprobe
Home directory: /root/.gohls/
Serving videos in /srv/go/gohls/videos
Visit http://localhost:8080/

However when I visit the url, 302 was reutrn( hls runs inside docker image,and redirect 8080 to 127.0.0.1:6000)

aven-mac-pro-2:gohls aven$ curl -i 127.0.0.1:6000
HTTP/1.1 302 Found
Location: /ui/
Date: Fri, 24 Nov 2017 05:37:26 GMT
Content-Length: 27
Content-Type: text/html; charset=utf-8

<a href="/ui/">Found</a>.

Unable to build the application for Development.

I downloaded the code as per instructions and did:
./scripts/run.sh

I get the below error:
internal/api/assets.go:2: running "go-bindata": exec: "go-bindata": executable file not found in $PATH

github.com/shimberger/gohls/internal/fileindex

internal/fileindex/index_mem.go:191:2: undefined: logrus.Tracef

Audio choppy

The audio is sometimes choppy between segments.

[BUG] do not contain binary CI-Build / snapshots

snapshots build by CI does not cotains the binary anymore.

Looks like the go-bindata are missed on container.

log of CI under ./scripts/release_snapshot.sh:

./scripts/prep_release.sh: line 17: go-bindata: command not found
darwin
amd64
go: finding github.com/mitchellh/go-homedir v1.0.0
go: finding github.com/google/subcommands v0.0.0-20181012225330-46f0354f6315
go: finding github.com/sirupsen/logrus v1.2.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
go: finding golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
go: downloading github.com/sirupsen/logrus v1.2.0
go: downloading github.com/mitchellh/go-homedir v1.0.0
go: downloading github.com/google/subcommands v0.0.0-20181012225330-46f0354f6315
go: downloading golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
go: downloading golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
# command-line-arguments
./http_singleasset.go:23:15: undefined: Asset
./http_singleasset.go:26:16: undefined: Asset
./
./LICENSE.txt
./README.md

entire page is blank

the page is all white, nothing there. i added ffmpeg in tools and ffprobe. go 1.3

go run *.go ~/mnt

Playback broken on some files

Hi,

while using current master code in development I reconed some files do no play properly:

Basically video.js is throwing an error. After a long time of research (and moving to hls.js meanwhile) I figured out it is because of our ffmpeg audio encoding.

I managed to fix it and want to show it to you in a PR. Is that okay?

Cheers
midzer

Error encoding on Ubuntu 16.04 using Linux snapshot

Using the linux snapshot on ubuntu 16.04.
Downloading the video from the UI works completely fine but I can't play the video

Path to ffmpeg executable: /usr/local/bin/ffmpeg
Path to ffprobe executable: /usr/local/bin/ffprobe
HLS data directory: /home/stan/.gohls/
Visit http://localhost:8080/
ERRO[002] Error encoding Command failed exit status 1

Unable to build the application on windows

build github.com/shimberger/gohls: cannot load github.com/shimberger/gohls/internal/buildinfo: cannot find module providing package github.com/shimberger/gohls/internal/buildinfo

Compact layout

Hallo,

I really like the overall design. But especially on mobile only one card layout can make list very long.

We could introduce a button which switches to a more compact view (with smaller fonts and double the columns).

What do you think about this idea?

Search bar layout on mobile

Good evening,

right now search bar overlaps title in top bar on mobile.

I am thinking of a way of how we can fix this. Maybe make it smaller in general and move its icon and placeholder text inside more to the left? In addition I would recommend right aligning the bar that it matches card container below.

Best regards
midzer

Download filename

Hi,

great project first of all! 👍

While investigation current master I've realized in Save File Dialog after Download filename appears between ''. I have a fix ready and would be happy to provide a PR if you like!

Cheers
midzer

Cannot download video file by Firefox from gohls on osx

MacBook Pro, MacOS 10.14
Run gohls serve <video_dir>, then open Firefox to http://localhost:8080. When I click 'Download' button on video, Firefox open a new tab to http://localhost:8080/list, not start a download process.

$ DEBUG=1 ./gohls serve v2
Path to ffmpeg executable: /usr/local/bin/ffmpeg
Path to ffprobe executable: /usr/local/bin/ffprobe
Home directory: v2/.gohls/
Serving videos in v2
Visit http://localhost:8080/
DEBU[0003] HTTP GET /api/list/20180929                  
DEBU[0003] Executing ffprobe for v2/20180929/bbzx_20180929150713_0.mp4 
DEBU[0003] ffprobe for v2/20180929/bbzx_20180929150713_0.mp4 returned%!(EXTRA map[string]interface {}=map[format:map[filename:v2/20180929/bbzx_20180929150713_0.mp4 nb_programs:0 start_time:0.080000 size:4770310 bit_rate:831064 probe_score:100 tags:map[major_brand:isom minor_version:512 compatible_brands:isomiso2avc1mp41 title:MonitorSession encoder:Lavf58.12.100] nb_streams:1 format_name:mov,mp4,m4a,3gp,3g2,mj2 format_long_name:QuickTime / MOV duration:45.920000]]) 
DEBU[0003] Executing ffprobe for v2/20180929/bbzx_20180929232518_2.mp4 
DEBU[0003] ffprobe for v2/20180929/bbzx_20180929232518_2.mp4 returned%!(EXTRA map[string]interface {}=map[format:map[start_time:0.000000 duration:40.720000 probe_score:100 tags:map[major_brand:isom minor_version:512 compatible_brands:isomiso2avc1mp41 title:MonitorSession encoder:Lavf58.12.100] filename:v2/20180929/bbzx_20180929232518_2.mp4 nb_streams:1 nb_programs:0 format_name:mov,mp4,m4a,3gp,3g2,mj2 format_long_name:QuickTime / MOV size:3917634 bit_rate:769672]]) 
DEBU[0003] HTTP GET /api/frame/20180929/bbzx_20180929150713_0.mp4 
DEBU[0003] HTTP GET /api/frame/20180929/bbzx_20180929232518_2.mp4 
DEBU[0006] HTTP GET /favicon.ico                        
DEBU[0006] HTTP GET /api/list/                          
DEBU[0006] HTTP GET /service-worker.js                  
DEBU[0007] HTTP GET /service-worker.js                  

When click 'Download' button, gohls print DEBU[0006] HTTP GET /api/list/
But when I use Chrome browser, it's OK, debug info like this:

DEBU[0053] HTTP GET /api/download/20180929/bbzx_20180929150713_0.mp4 

If use wget, it is OK too:

$ wget http://localhost:8080/api/download/20180929/bbzx_20180929150713_0.mp4
--2018-10-16 14:54:19--  http://localhost:8080/api/download/20180929/bbzx_20180929150713_0.mp4
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4770310 (4.5M) [video/mp4]
Saving to: ‘bbzx_20180929150713_0.mp4’

bbzx_20180929150713 100%[===================>]   4.55M  --.-KB/s    in 0.02s   

2018-10-16 14:54:19 (270 MB/s) - ‘bbzx_20180929150713_0.mp4’ saved [4770310/4770310]

And when I run gohls on linux, video file can be downloaded by Firefox or Chrome. This problem only appears on gohls for osx + Firefox browser.

Unable to play MKV

I am unable to play MKV files.
I serve the server like this and there is no unexpected output or error in the command line.

.\gohls serve -config config.json
Path to ffmpeg executable: C:\ffmpeg\bin\ffmpeg.exe
Path to ffprobe executable: C:\ffmpeg\bin\ffprobe.exe
HLS data directory: C:\Users\Techassi/.gohls/
Visit http://localhost:8080/

The only error I get is:

VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported.

and

Uncaught (in promise) DOMException: Failed to load because no supported source was found.

`npm run build` failed

I tried to build this project on my own, ui package already run npm install.
but whenever I run npm run build, there's always something wrong.

> [email protected] build /usr/local/gocode/src/github.com/shimberger/gohls/ui
> react-scripts-ts build

Creating an optimized production build...
Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
ts-loader: Using [email protected] and /usr/local/gocode/src/github.com/shimberger/gohls/ui/tsconfig.prod.json
Failed to compile.

Module not found: Error: Can't resolve 'typeface-roboto' in '/usr/local/gocode/src/github.com/shimberger/gohls/ui/src/Components'


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts-ts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mine/.npm/_logs/2018-08-05T08_31_13_682Z-debug.log

cannot find a way to solve it even after google it.
I'm not a nodejs or front coder, need help.
thanks

A note of thank you and a request.

First of all, thank you for this amazing project. It is really elegant and informative especially about hls with ffmpeg. I was searching relentlessly on how to generate good (equal spaced) hls streams using ffmpeg. There is very little information on the web and the ffmpeg docs can be intimidating to a newbie. I have read through gohls source code and found answers to many questions.

Coming to the feature requests / improvements :

  1. I see that 720p is hardcoded as default resolution. This can be probably be solved by following this guide along with a small change in parsing the api path.

  2. Also I was wondering if dash could be implemented.

Please feel free to update the title as required.

Streaming uses a lot of CPU and is slow

Look into the following options:

  • compare source / target encoding to maybe skip transcoding all together
  • get HW acceleration to work
  • use different profiles / resolutions
  • use bigger HLS chunks
  • batch multiple HLS chunks together

Display nothing with chrome/firefox in Macbook

Hi, i just followed the guide to setup an environment, all works fine but it doesn't work with chrome or firefox, only works in Safari. Besides the cpu consumption is high? is that a normal phenomenon?

macOS 10.12.1
Chrome: 54.0.2840.98 (64-bit)
firefox 45.5.1
safari: Version 10.0.1 (12602.2.14.0.7)

Binary release 0.1.0-win64 is a macOS binary

$ md5sum gohls-windows-amd64-0.1.0.tar.gz
1f5d0a65cd4285beb22d856e292bb1c3 *gohls-windows-amd64-0.1.0.tar.gz

$ ./gohls.exe
bash: ./gohls.exe: cannot execute binary file: Exec format error

$ file gohls.exe
gohls.exe: Mach-O 64-bit x86_64 executable

Expected PE format.

Can you check the build script?

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.