Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/video thumbnails #6

Merged
merged 12 commits into from
Feb 24, 2019
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
debug*
tmpout
tmpcache
screenshottemp
main-packr.go
a_main-packr.go
packrd
mediaweb
mediaweb.exe
mediaweb.log
mediaweb_windows_x64_setup.exe
mediaweb_windows_x64_setup.exe
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ The main design goal of MediaWEB is that no additional dependencies shall be nee
* The mediaweb executable
* A configuration file, mediaweb.conf

Optional dependencies are:

* [ffmpeg](https://www.ffmpeg.org/) for video thumbnail support

No additional stuff, such as dockers and similar is required.

MediaWEB is well suited to run on small platforms such as Raspberry Pi, Banana Pi, ROCK64 and similar. It is still very fast and can be used with advantage on PC:s running Windows, Linux or Mac OS.

## Screenshots

![browser](testmedia/screenshot_browser.jpg)

![viewer](testmedia/screenshot_viewer.jpg)

## Features

* Simple WEB GUI for viewing your images and videos
* Thumbnail support, primary by reading of EXIF thumbnail if it exist, otherwise thumbnails will be created and stored in a thumbnail cache
* Thumbnail support for images and videos, primary by reading of EXIF thumbnail if it exist, otherwise thumbnails will be created and stored in a thumbnail cache. Video thumbnails requires [ffmpeg](https://www.ffmpeg.org/) to be installed.
* Automatic rotation JPEG images when needed (based on EXIF information)
* Optional authentication with username and password

Expand Down Expand Up @@ -49,6 +59,10 @@ Then run following for all Linux platforms:

Follow the instructions in the service.sh script.

For video thumbnail support, install ffmpeg:

sudo apt-get install ffmpeg

To perform additional configuration, edit:

sudo vi /etc/mediaweb.conf
Expand All @@ -72,6 +86,8 @@ Run the installer and follow the instructions.
To modify changes just edit mediaweb.conf in the installation directory and restart the mediaweb
service in task manager.

You need to install [ffmpeg](https://www.ffmpeg.org/) separately and put ffmpeg into your PATH to get video thumbnail support.

## Build from source (any platform)

To build from source on any platform you need to:
Expand Down Expand Up @@ -108,7 +124,6 @@ On Linux platforms execute following to install MediaWEB as a service:

## Future improvements

* Create thumbnails for videos (probably using ffmpeg)
* Add support for TLS/SSL


Expand Down
17 changes: 11 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@ stack: go 1.11
install:
# Windows
- cmd: set PATH=%GOPATH%\bin;%PATH%
- cmd: go get github.com\mattn\goveralls
- cmd: '%GOPATH%\src\github.com\midstar\mediaweb\scripts\install_deps.bat'

# Linux
- sh: export GOPATH=/usr/go
- sh: export PATH=$GOPATH/bin:$PATH
- sh: sudo chmod -R a+rwx $GOPATH
- sh: go get github.com/mattn/goveralls
- sh: sh $GOPATH/src/github.com/midstar/mediaweb/scripts/install_deps.sh


# Linux install ffmpeg
- sh: sudo apt -yq update > /dev/null
- sh: sudo apt install -yq --no-install-suggests --no-install-recommends ffmpeg > /dev/null

build_script:
# Common
- go test -v -cover github.com/midstar/mediaweb -coverprofile=coverage.out

# Windows and publish result on coveralls.io
- cmd: '%GOPATH%/bin/goveralls -coverprofile=coverage.out -service=appveyor-ci -repotoken=%COVERALLS_TOKEN%'
# Publish result on coveralls.io (pick the Linux result since we have ffmpeg there)
- sh: '$GOPATH/bin/goveralls -coverprofile=coverage.out -service=appveyor-ci -repotoken=$COVERALLS_TOKEN'

# Windows build and zip
- cmd: '%GOPATH%\src\github.com\midstar\mediaweb\scripts\build.bat %APPVEYOR_BUILD_VERSION%'
- cmd: 'copy scripts\service.bat .'
- cmd: 'copy configs\mediaweb.conf .'
Expand All @@ -40,14 +46,13 @@ build_script:
# Windows rename tempates directory to secure that packr is working
- cmd: 'rename templates old_templates'


# Windows Test service installation/uninstallation script
- cmd: 'scripts/service_test.bat'

# Windows create windows setup (installer)
- cmd: 'makensis -DVERSION=%APPVEYOR_BUILD_VERSION% %GOPATH%\src\github.com\midstar\mediaweb\scripts\windows_installer.nsi'

# Linux PC/x64
# Linux PC/x64 build and zip
- sh: 'sh $GOPATH/src/github.com/midstar/mediaweb/scripts/build.sh $APPVEYOR_BUILD_VERSION'
- sh: 'cp scripts/service.sh .'
- sh: 'cp configs/mediaweb.conf .'
Expand Down
19 changes: 19 additions & 0 deletions assert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,74 @@ package main

import (
"fmt"
"os"
"runtime/debug"
"testing"
)

func assertTrue(t *testing.T, message string, check bool) {
t.Helper()
if !check {
debug.PrintStack()
t.Fatal(message)
}
}

func assertFalse(t *testing.T, message string, check bool) {
t.Helper()
if check {
debug.PrintStack()
t.Fatal(message)
}
}

func assertExpectNoErr(t *testing.T, message string, err error) {
t.Helper()
if err != nil {
debug.PrintStack()
t.Fatalf("%s : %s", message, err)
}
}

func assertExpectErr(t *testing.T, message string, err error) {
t.Helper()
if err == nil {
debug.PrintStack()
t.Fatal(message)
}
}

func assertEqualsInt(t *testing.T, message string, expected int, actual int) {
t.Helper()
assertTrue(t, fmt.Sprintf("%s\nExpected: %d, Actual: %d", message, expected, actual), expected == actual)
}

func assertEqualsStr(t *testing.T, message string, expected string, actual string) {
t.Helper()
assertTrue(t, fmt.Sprintf("%s\nExpected: %s, Actual: %s", message, expected, actual), expected == actual)
}

func assertEqualsBool(t *testing.T, message string, expected bool, actual bool) {
t.Helper()
assertTrue(t, fmt.Sprintf("%s\nExpected: %t, Actual: %t", message, expected, actual), expected == actual)
}

func assertEqualsSlice(t *testing.T, message string, expected []uint32, actual []uint32) {
t.Helper()
assertEqualsInt(t, fmt.Sprintf("%s\nSize missmatch", message), len(expected), len(actual))
for index, expvalue := range expected {
actvalue := actual[index]
assertTrue(t, fmt.Sprintf("%s\nIndex %d - Expected: %d, Actual: %d", message, index, expvalue,
actvalue), expvalue == actvalue)
}
}

func assertFileExist(t *testing.T, message string, name string) {
t.Helper()
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
debug.PrintStack()
t.Fatalf("%s : %s", message, err)
}
}
}
2 changes: 1 addition & 1 deletion main_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ func mainCommon() *WebAPI {
llog.Info("Version: %s", applicationVersion)
llog.Info("Build time: %s", applicationBuildTime)
llog.Info("Git hash: %s", applicationGitHash)
media := createMedia(s.mediaPath, s.thumbPath, s.enableThumbCache, s.autoRotate)
box := packr.New("templates", "./templates")
media := createMedia(box, s.mediaPath, s.thumbPath, s.enableThumbCache, s.autoRotate)
webAPI := CreateWebAPI(s.port, "templates", media, box, s.userName, s.password)
return webAPI
}
Loading