feat(meta): write album art & metadata into destination file

This commit is contained in:
Unlock Music Dev
2022-12-06 23:55:43 +08:00
parent 02e065aac4
commit fd6f830916
5 changed files with 107 additions and 106 deletions

View File

@@ -1,6 +1,7 @@
package ffmpeg
import (
"bytes"
"context"
"encoding/json"
"io"
@@ -119,17 +120,20 @@ func ProbeReader(ctx context.Context, rd io.Reader) (*Result, error) {
cmd := exec.CommandContext(ctx, "ffprobe",
"-v", "quiet", // disable logging
"-print_format", "json", // use json format
"-show_format", "-show_streams", // retrieve format and streams
"-", // input from stdin
"-show_format", "-show_streams", "-show_error", // retrieve format and streams
"pipe:0", // input from stdin
)
cmd.Stdin = rd
out, err := cmd.Output()
if err != nil {
stdout, stderr := &bytes.Buffer{}, &bytes.Buffer{}
cmd.Stdout, cmd.Stderr = stdout, stderr
if err := cmd.Run(); err != nil {
return nil, err
}
ret := new(Result)
if err := json.Unmarshal(out, ret); err != nil {
if err := json.Unmarshal(stdout.Bytes(), ret); err != nil {
return nil, err
}