Permalink
Browse files

gh init

  • Loading branch information...
xenotor committed Aug 2, 2016
0 parents commit 8d5530db561fd92e6bb1644f1db8837fad1578e9
Showing with 5,165 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +18 −0 .project
  3. +50 −0 README.md
  4. +71 −0 chrometizer.go
  5. +135 −0 config/config.go
  6. BIN dist/chrometizer
  7. +1 −0 dist/md5sum.txt
  8. +140 −0 ffmpeg/ffmpeg_wrap.go
  9. +131 −0 ffmpeg/transcoder.go
  10. +14 −0 fs/cache.go
  11. +136 −0 fs/files.go
  12. +1,698 −0 web/bindata.go
  13. +38 −0 web/bindata_serv.go
  14. +119 −0 web/cast.go
  15. +79 −0 web/server.go
  16. +82 −0 web/settings.go
  17. +66 −0 web/webclient/assets/css/bootstrap-theme.css
  18. +6 −0 web/webclient/assets/css/bootstrap.min.css
  19. +1 −0 web/webclient/assets/css/bootstrap.min.css.map
  20. +376 −0 web/webclient/assets/css/gplayer.css
  21. +1 −0 web/webclient/assets/css/jquery.typeahead.min.css
  22. BIN web/webclient/assets/favicon.ico
  23. +202 −0 web/webclient/assets/fonts/Roboto/LICENSE.txt
  24. BIN web/webclient/assets/fonts/Roboto/Roboto-Black.ttf
  25. BIN web/webclient/assets/fonts/Roboto/Roboto-BlackItalic.ttf
  26. BIN web/webclient/assets/fonts/Roboto/Roboto-Bold.ttf
  27. BIN web/webclient/assets/fonts/Roboto/Roboto-BoldItalic.ttf
  28. BIN web/webclient/assets/fonts/Roboto/Roboto-Italic.ttf
  29. BIN web/webclient/assets/fonts/Roboto/Roboto-Light.ttf
  30. BIN web/webclient/assets/fonts/Roboto/Roboto-LightItalic.ttf
  31. BIN web/webclient/assets/fonts/Roboto/Roboto-Medium.ttf
  32. BIN web/webclient/assets/fonts/Roboto/Roboto-MediumItalic.ttf
  33. BIN web/webclient/assets/fonts/Roboto/Roboto-Regular.ttf
  34. BIN web/webclient/assets/fonts/Roboto/Roboto-Thin.ttf
  35. BIN web/webclient/assets/fonts/Roboto/Roboto-ThinItalic.ttf
  36. BIN web/webclient/assets/fonts/glyphicons-halflings-regular.eot
  37. +288 −0 web/webclient/assets/fonts/glyphicons-halflings-regular.svg
  38. BIN web/webclient/assets/fonts/glyphicons-halflings-regular.ttf
  39. BIN web/webclient/assets/fonts/glyphicons-halflings-regular.woff
  40. BIN web/webclient/assets/fonts/glyphicons-halflings-regular.woff2
  41. BIN web/webclient/assets/fonts/lg.eot
  42. +42 −0 web/webclient/assets/fonts/lg.svg
  43. BIN web/webclient/assets/fonts/lg.ttf
  44. BIN web/webclient/assets/fonts/lg.woff
  45. BIN web/webclient/assets/img/audio_bg.png
  46. BIN web/webclient/assets/img/audio_bg_level.png
  47. BIN web/webclient/assets/img/audio_bg_track.png
  48. BIN web/webclient/assets/img/audio_indicator.png
  49. BIN web/webclient/assets/img/audio_off.png
  50. BIN web/webclient/assets/img/audio_on.png
  51. BIN web/webclient/assets/img/cast_icon_active.png
  52. BIN web/webclient/assets/img/cast_icon_error.png
  53. BIN web/webclient/assets/img/cast_icon_idle.png
  54. BIN web/webclient/assets/img/cast_icon_warning.png
  55. BIN web/webclient/assets/img/casticon.on.png
  56. BIN web/webclient/assets/img/fullscreen_collapse.png
  57. BIN web/webclient/assets/img/fullscreen_expand.png
  58. BIN web/webclient/assets/img/ic_media_route_off_custom.png
  59. BIN web/webclient/assets/img/ic_media_route_on_custom.png
  60. BIN web/webclient/assets/img/loading.gif
  61. BIN web/webclient/assets/img/pause-hover.png
  62. BIN web/webclient/assets/img/pause.png
  63. BIN web/webclient/assets/img/play-hover.png
  64. BIN web/webclient/assets/img/play-press.png
  65. BIN web/webclient/assets/img/play.png
  66. BIN web/webclient/assets/img/timeline_bg_progress.png
  67. BIN web/webclient/assets/img/timeline_bg_track.png
  68. BIN web/webclient/assets/img/timeline_indicator.png
  69. BIN web/webclient/assets/img/video-play.png
  70. BIN web/webclient/assets/img/vimeo-play.png
  71. BIN web/webclient/assets/img/youtube-play.png
  72. +7 −0 web/webclient/assets/js/bootstrap.min.js
  73. +3 −0 web/webclient/assets/js/cast_sender.js
  74. +1,092 −0 web/webclient/assets/js/cast_videos.js
  75. +97 −0 web/webclient/assets/js/config_page.js
  76. +6 −0 web/webclient/assets/js/jquery-1.11.3.min.js
  77. +1 −0 web/webclient/assets/js/jquery.min.map
  78. +11 −0 web/webclient/assets/js/jquery.typeahead.min.js
  79. +139 −0 web/webclient/cast.html
  80. +114 −0 web/webclient/config.html
@@ -0,0 +1 @@
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>chrometizer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.googlecode.goclipse.goBuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.googlecode.goclipse.core.goNature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,50 @@
# Chrometizer
Transcode and cast your local video files. It's written in Go and does transcoding off-line (upfront).
#### General
The design is KISS & DRY (as much as possible) and the whole project can be described as : transcode all of your video files upfront, use only the filesystem as state/storage, cast, stream, watch the transcoded files to as many clients as you need at the same time with minimum load on the server.
#### FFmpeg
Chrometizer uses FFMPEG for transcoding and you will need to compile it with nonfree codecs.
Simple, straightforward guide for Ubuntu/Debian can be found [here](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu).
Chrometizer will test your FFmpeg installation and will refuse to start (no point) if there is no support for : x264 and libfdk_aac encoder.
Simple tests for required codecs :
```
ffmpeg -formats 2> /dev/null | grep "E mp4"
E mp4 MP4 (MPEG-4 Part 14)
ffmpeg -formats 2> /dev/null | grep "E matroska"
E matroska Matroska
ffmpeg -codecs 2> /dev/null | grep "libfdk_aac"
DEA.L. aac AAC ...
ffmpeg -codecs 2> /dev/null | grep "libx264"
DEV.LS h264 H.264
```
#### Installation
If you managed to get FFmpeg with aac & x264 you are ready to install. If not, keep [trying](https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu) - again chrometizer will refuse to start if they are not avalable.
##### Binary
If you are runing on 64 bit Linux you should be able to just grab the binary from the dist folder put it in the desired directory and :
```
chmod +x chrometizer
sudo setcap 'cap_net_bind_service=+ep' chrometizer
./chrometizer
```
The second line is to allow to bind to port 80 (chromecast refuses to load from diffrent ports(?)).
You can compare the md5sum to make sure the binary is the one uploaded here.
DO NOT run as root!
##### Source
Assumingyou have [golang set](https://golang.org/doc/code.html) then :
```
go install github.com/mobileblobs/chrometizer
```
#### Usage/Running
@@ -0,0 +1,71 @@
package main
import (
"errors"
"fmt"
"github.com/mobileblobs/chrometizer/config"
"github.com/mobileblobs/chrometizer/ffmpeg"
"github.com/mobileblobs/chrometizer/web"
"net"
"os"
)
func main() {
if !ffmpeg.TestFFmpeg() {
fmt.Printf("\nffmpeg error!\nmake sure : " +
"\n1. ffmpeg is configured and compiled with non-free codecs : " +
"https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu" +
"\n2. ffmpeg is on the path (you may need to remove default one!)\n" +
"\nexiting now!")
os.Exit(1)
}
eip, err := externalIP()
if err != nil {
fmt.Println(err)
}
// load config from file & if OK scan for VFs
if config.LoadConfig(eip) == nil {
ffmpeg.TranscodeAll()
}
web.StartHttp()
}
func externalIP() (string, error) {
ifaces, err := net.Interfaces()
if err != nil {
return "", err
}
for _, iface := range ifaces {
if iface.Flags&net.FlagUp == 0 {
continue // interface down
}
if iface.Flags&net.FlagLoopback != 0 {
continue // loopback interface
}
addrs, err := iface.Addrs()
if err != nil {
return "", err
}
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
case *net.IPAddr:
ip = v.IP
}
if ip == nil || ip.IsLoopback() {
continue
}
ip = ip.To4()
if ip == nil {
continue // not an ipv4 address
}
return ip.String(), nil
}
}
return "", errors.New("are you connected to the network?")
}
@@ -0,0 +1,135 @@
package config
import (
"encoding/json"
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/user"
)
const FFMPEG_CMD = "ffmpeg"
const FFPROBE_CMD = "ffprobe"
const TRIMED_VP8_MARK = "VIDEO:VP8"
const TRIMED_H264_MARK = "VIDEO:H264"
const H264_UNSUP = "HIGH10"
const AAC_AUDIO_MARK = "AUDIO:AAC"
// this CS is actually : scale="iw*min(384/iw\,216/ih):ih*min(384/iw\,216/ih), pad=384:216:(384-iw*min(384/iw\,216/ih))/2:(216-ih*min(384/iw\,216/ih))/2"
const THUMB_W = "384" // thumb width in pixels
const THUMB_H = "216" // thumb height in pixels
const THUMB_SCALE = "scale='iw*min(" + THUMB_W +
"/iw\\," + THUMB_H + "/ih)':'ih*min(" + THUMB_W + "/iw\\," + THUMB_H +
"/ih)', pad='" + THUMB_W + "':'" + THUMB_H + "':'(" + THUMB_W + "-iw*min(" +
THUMB_W + "/iw\\," + THUMB_H + "/ih))/2':'(" + THUMB_H + "-ih*min(" +
THUMB_W + "/iw\\," + THUMB_H + "/ih))/2'"
const FILE_READY_EXT = "-cast-ready"
const TEMP_EXT = "-temp_transcoding"
const DURATION_MARK = "DURATION:"
const MTIME_DES = 0
const MTIME_ASC = 1
const FNAME_ASC = 2
const FNAME_DES = 3
var SFE = [...]string{"MKV", "MP4", "AVI", "MPEG", "MPG", "FLV", "3GP", "WEBM"}
var REQ_CODECS = [...]string{"E MP4", "E MATROSKA", "E ADTS", "E H264"}
type Config struct {
Config_loc string
Media_loc string
Exclude []string
Remove_orig bool
Server_eip string
}
var Conf Config
func LoadConfig(server_eip string) error {
// IPs change often so we just load it on startup
Conf.Server_eip = server_eip
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
flag.StringVar(&Conf.Config_loc, "c", usr.HomeDir+"/.chrometizer.json", "chrometizer -c=/path/to/.chrometizer.json")
flag.Parse()
err = readConfig()
if err != nil {
return err
}
tc, jm := ConfigTest(&Conf)
if !tc {
fmt.Printf("\nbad media location dir! Resetting config %s!", Conf.Config_loc)
os.Remove(Conf.Config_loc)
Conf.Config_loc = usr.HomeDir + "/.chrometizer.json"
Conf.Media_loc = ""
Conf.Exclude = nil
Conf.Remove_orig = false
return errors.New(jm.Message)
}
fmt.Printf("\nusing %s as config!", Conf.Config_loc)
return nil
}
func StoreConfig() error {
jb, err := json.MarshalIndent(Conf, "", " ")
if err != nil {
fmt.Printf("\nMarshal error: %v\n", err)
return err
}
return ioutil.WriteFile(Conf.Config_loc, jb, 0644)
}
func readConfig() error {
file, e := ioutil.ReadFile(Conf.Config_loc)
if e != nil {
return e
}
// config there & OK - scan & transcode
return json.Unmarshal(file, &Conf)
}
// tests Media_loc - writable directory
func ConfigTest(temp_conf *Config) (bool, JsonMessage) {
ml := temp_conf.Media_loc
fi, err := os.Stat(ml)
if err != nil && os.IsNotExist(err) {
return false, JsonMessage{"Media_loc", err.Error()}
}
if !fi.IsDir() {
return false, JsonMessage{"Media_loc", "Not a directory"}
}
err = ioutil.WriteFile(ml+"/temp.txt", []byte("test"), 0644)
if err != nil {
return false, JsonMessage{"Media_loc", "Can not write to media directory"}
}
err = os.Remove(ml + "/temp.txt")
if err != nil {
return false, JsonMessage{"Media_loc", "Can not write to media directory"}
}
return true, JsonMessage{}
}
type JsonMessage struct {
Id string
Message string
}
Binary file not shown.
@@ -0,0 +1 @@
6beacafad5463c67de28621c309954d0 chrometizer
Oops, something went wrong.

0 comments on commit 8d5530d

Please sign in to comment.