From 9f1d1255cb2f1ff7cb2623b63c3da14bf0d0a598 Mon Sep 17 00:00:00 2001 From: lukas Date: Sat, 25 Sep 2021 22:50:32 +0200 Subject: [PATCH] install build dep during build use correct jpeg encoding codec --- .gitlab-ci.yml | 2 ++ .../Thumbnailparser_shared_ffmpeg.go | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d753b0..59317f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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/ diff --git a/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go b/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go index 56f57a5..d76291a 100644 --- a/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go +++ b/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go @@ -2,6 +2,17 @@ package thumbnail +/* + +#cgo pkg-config: libavcodec + +#include +#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) }