mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2024-11-26 22:30:25 +00:00
ensure ffmpeg muxer gets set correctly by setting input file extension before clean (#3142)
This commit is contained in:
parent
ecfea10e35
commit
d9e70b942f
1 changed files with 12 additions and 4 deletions
|
@ -41,15 +41,23 @@ func ffmpegClearMetadata(ctx context.Context, filepath string, ext string) error
|
||||||
// Get directory from filepath.
|
// Get directory from filepath.
|
||||||
dirpath := path.Dir(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
|
outpath := filepath + "_cleaned." + ext
|
||||||
|
|
||||||
// Clear metadata with ffmpeg.
|
// Clear metadata with ffmpeg.
|
||||||
if err := ffmpeg(ctx, dirpath,
|
if err := ffmpeg(ctx, dirpath,
|
||||||
"-loglevel", "error",
|
"-loglevel", "error",
|
||||||
|
|
||||||
// Input file.
|
// Input file path.
|
||||||
"-i", filepath,
|
"-i", filepathExt,
|
||||||
|
|
||||||
// Drop all metadata.
|
// Drop all metadata.
|
||||||
"-map_metadata", "-1",
|
"-map_metadata", "-1",
|
||||||
|
@ -69,7 +77,7 @@ func ffmpegClearMetadata(ctx context.Context, filepath string, ext string) error
|
||||||
|
|
||||||
// Move the new output file path to original location.
|
// Move the new output file path to original location.
|
||||||
if err := os.Rename(outpath, filepath); err != nil {
|
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
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue