fix(ffmpeg): free memory on close
This commit is contained in:
parent
2b72572127
commit
01ad70e46c
2 changed files with 6 additions and 2 deletions
|
|
@ -88,6 +88,9 @@ func (av *AVContext) ExportImage() ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (av *AVContext) Close() {
|
func (av *AVContext) Close() {
|
||||||
|
if av.hasFrame {
|
||||||
|
C.av_frame_free(&av.frame)
|
||||||
|
}
|
||||||
freeFormatContext(av)
|
freeFormatContext(av)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,10 +96,10 @@ func (p *Processor) Process(ctx context.Context, in *imagor.Blob, params imagorp
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var filename = file.Name()
|
var filename = file.Name()
|
||||||
imagor.Defer(ctx, func() {
|
defer func() {
|
||||||
_ = os.Remove(filename)
|
_ = os.Remove(filename)
|
||||||
p.Logger.Debug("cleanup", zap.String("file", filename))
|
p.Logger.Debug("cleanup", zap.String("file", filename))
|
||||||
})
|
}()
|
||||||
if size, err = io.Copy(file, reader); err != nil {
|
if size, err = io.Copy(file, reader); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -116,6 +116,7 @@ func (p *Processor) Process(ctx context.Context, in *imagor.Blob, params imagorp
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer av.Close()
|
||||||
meta := av.Metadata()
|
meta := av.Metadata()
|
||||||
if params.Meta {
|
if params.Meta {
|
||||||
out = imagor.NewBlobFromJsonMarshal(meta)
|
out = imagor.NewBlobFromJsonMarshal(meta)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue