From 44fb681955f05fd4db6ef6b1abc58c322f04f7a4 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 18 Mar 2024 15:55:36 +0200 Subject: [PATCH] Don't convert audio message if file is already ogg --- portal.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/portal.go b/portal.go index f78c352..1e1a31e 100644 --- a/portal.go +++ b/portal.go @@ -1231,13 +1231,15 @@ func (portal *Portal) convertGoogleMedia(ctx context.Context, source *User, inte // TODO convert weird formats to mp4 case "audio": msgtype = event.MsgAudio - data, err = ffmpeg.ConvertBytes(ctx, data, ".ogg", []string{}, []string{"-c:a", "libopus"}, mime) - if err != nil { - return nil, nil, fmt.Errorf("%w (%s to ogg): %w", errMediaConvertFailed, mime, err) + if mime != "audio/ogg" { + data, err = ffmpeg.ConvertBytes(ctx, data, ".ogg", []string{}, []string{"-c:a", "libopus"}, mime) + if err != nil { + return nil, nil, fmt.Errorf("%w (%s to ogg): %w", errMediaConvertFailed, mime, err) + } + fileName += ".ogg" + mime = "audio/ogg" } extra["org.matrix.msc3245.voice"] = map[string]any{} - fileName += ".ogg" - mime = "audio/ogg" } content := &event.MessageEventContent{ MsgType: msgtype,