Skip to content

Commit

Permalink
Don't convert audio message if file is already ogg
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Mar 18, 2024
1 parent a0602d6 commit 44fb681
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 44fb681

Please sign in to comment.