Exemplo n.º 1
0
// Execute processes a command instruction.
func (c *SpriteCommand) Execute(inFile, outFile string) {
	defer func() {
		(*c.chanFinished) <- true
	}()

	f := ffmpeg.New(inFile)
	f.SkipSeconds = core.Opts.SkipSeconds

	len := int(f.Length())
	interval := 0
	if len < core.Opts.Count {
		interval = len
	} else {
		interval = len / core.Opts.Count
	}

	width := 180
	if core.Opts.Width != 0 {
		width = core.Opts.Width
	}

	err := f.CreateThumbnailSprite(interval, width, outFile)
	if err != nil {
		(*c.chanError) <- err
		return
	}

	core.VPrintf("Sprite thumbnail for video %q written to %q.", inFile, outFile)
}
Exemplo n.º 2
0
func Go() {
	router := mux.NewRouter()
	router.Handle("/thumbnail/simple", handlers.NewSimple()).Methods("POST")
	router.Handle("/thumbnail/sprite", handlers.NewSprite()).Methods("POST")
	router.Handle("/help", handlers.NewHelp()).Methods("GET")
	router.Handle("/pulse", handlers.NewPulse()).Methods("GET")

	core.VPrintf("Listening for requests on %s:%d...", core.Opts.Host, core.Opts.Port)
	conn := core.Opts.Host + ":" + strconv.Itoa(core.Opts.Port)
	err := http.ListenAndServe(conn, router)
	if err != nil {
		panic(err)
	}
}
Exemplo n.º 3
0
// Execute processes a command instruction.
func (c *SimpleCommand) Execute(inFile, outFile string) {
	defer func() {
		(*c.chanFinished) <- true
	}()

	f := ffmpeg.New(inFile)
	f.SkipSeconds = core.Opts.SkipSeconds

	err := f.CreateThumbnail(core.Opts.Width, outFile)
	if err != nil {
		(*c.chanError) <- err
		return
	}

	core.VPrintf("Simple thumbnail for video %q written to %q.", inFile, outFile)
}
Exemplo n.º 4
0
// getFile returns the uploaded file.
func getFile(w http.ResponseWriter, r *http.Request) *Upload {
	files, _ := writeUploadedFiles(r)
	if len(files) > 1 {
		numErrors++
		w.WriteHeader(400)
		w.Write([]byte("Only a single file allowed."))
		return nil
	} else if len(files) == 0 {
		numErrors++
		w.WriteHeader(400)
		w.Write([]byte("No files uploaded."))
		return nil
	}

	core.VPrintf("Got upload %#v\n", files[0])
	return &files[0]
}