install build dep during build

use correct jpeg encoding codec
This commit is contained in:
lukas 2021-09-25 22:50:32 +02:00
parent 800a48c610
commit 9f1d1255cb
2 changed files with 24 additions and 4 deletions

View File

@ -28,6 +28,8 @@ Build_Backend:
image: golang:latest
stage: build_backend
script:
- apt update
- apt install libffmpeg-ocaml-dev
- cd apiGo
- go build -v -tags sharedffmpeg -o openmediacenter
- cp -r ../build/ ./static/

View File

@ -2,6 +2,17 @@
package thumbnail
/*
#cgo pkg-config: libavcodec
#include <stdlib.h>
#include "libavcodec/avcodec.h"
#include "libavutil/pixfmt.h"
*/
import "C"
import (
"github.com/3d0c/gmf"
"io"
@ -10,10 +21,10 @@ import (
)
func Parse(filename string, time uint64) (*string, *VidInfo, error) {
dta, inf, err := decodePic(filename, "png", time)
if len(dta) > 0 && err == nil {
dta, inf, err := decodePic(filename, "mjpeg", time)
if err == nil && dta != nil {
// base64 encode picture
enc := EncodeBase64(dta, "image/png")
enc := EncodeBase64(dta, "image/jpeg")
return enc, inf, nil
} else {
return nil, nil, err
@ -23,6 +34,8 @@ func Parse(filename string, time uint64) (*string, *VidInfo, error) {
func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]byte, info *VidInfo, err error) {
var swsctx *gmf.SwsCtx
gmf.LogSetLevel(gmf.AV_LOG_ERROR)
stat, err := os.Stat(srcFileName)
if err != nil {
// file seems to not even exist
@ -55,7 +68,12 @@ func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]
cc.SetTimeBase(gmf.AVR{Num: 1, Den: 1})
cc.SetPixFmt(gmf.AV_PIX_FMT_RGBA).SetWidth(srcVideoStream.CodecPar().Width()).SetHeight(srcVideoStream.CodecPar().Height())
// add missing codecs in lib
var (
AV_PIX_FMT_YUVJ444P int32 = C.AV_PIX_FMT_YUVJ444P
)
cc.SetPixFmt(AV_PIX_FMT_YUVJ444P).SetWidth(srcVideoStream.CodecPar().Width()).SetHeight(srcVideoStream.CodecPar().Height())
if codec.IsExperimental() {
cc.SetStrictCompliance(gmf.FF_COMPLIANCE_EXPERIMENTAL)
}