Skip to content

Commit

Permalink
ensure ffmpeg muxer gets set correctly by setting input file extensio…
Browse files Browse the repository at this point in the history
…n before clean (#3142)
  • Loading branch information
NyaaaWhatsUpDoc authored Jul 26, 2024
1 parent ecfea10 commit d9e70b9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions internal/media/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,23 @@ func ffmpegClearMetadata(ctx context.Context, filepath string, ext string) error
// Get directory from filepath.
dirpath := path.Dir(filepath)

// Generate output file path with ext.
// Update filepath to add extension.
filepathExt := filepath + "." + ext

// First we need to rename filepath to have extension.
if err := os.Rename(filepath, filepathExt); err != nil {
return gtserror.Newf("error renaming to %s - >%s: %w", filepath, filepathExt, err)
}

// Generate cleaned output path with ext.
outpath := filepath + "_cleaned." + ext

// Clear metadata with ffmpeg.
if err := ffmpeg(ctx, dirpath,
"-loglevel", "error",

// Input file.
"-i", filepath,
// Input file path.
"-i", filepathExt,

// Drop all metadata.
"-map_metadata", "-1",
Expand All @@ -69,7 +77,7 @@ func ffmpegClearMetadata(ctx context.Context, filepath string, ext string) error

// Move the new output file path to original location.
if err := os.Rename(outpath, filepath); err != nil {
return gtserror.Newf("error renaming %s: %w", outpath, err)
return gtserror.Newf("error renaming %s -> %s: %w", outpath, filepath, err)
}

return nil
Expand Down

0 comments on commit d9e70b9

Please sign in to comment.