Re:mpv a free, open-source, and cross-platform media player
by latexr on Sunday August 18, 2024 @05:55AM
(#41281339)
> I even use it when an image I saved ends up as .html for some reason and then use the info screen to determine the real extension it should be so I can rename it
If you’re on Linux on macOS, you’ll have access to the `file` command-line tool which can do it effectively. In a couple of lines of shell scripting you can even have it auto-change the extension.
Re:mpv a free, open-source, and cross-platform media player
by opan on Sunday August 18, 2024 @06:11AM
(#41281394)
I had someone try to tell me this or some similar alternative method once, but for this particular use-case my method seemed faster. Usually I'm viewing the dir with the file in ranger, hit r (shortcut for :open_with ), type mpv, enter, I in mpv for info, q to quit, a in ranger to rename the file with old name pretyped in. It's a pretty smooth workflow. Assuming I start from the same place in ranger I have to press colon and type `shell -w file %s` and hit enter which may or may not be faster but I think is more keystrokes. I could bind it to a key in ranger if I found an open one and then that might be better. It's sometimes weeks between instances of the mis-saved images or else I might've tried harder to optimize this. The shell script idea is neat.
Re:mpv a free, open-source, and cross-platform media player
by latexr on Sunday August 18, 2024 @08:27AM
(#41281935)
> The shell script idea is neat.
Could be something as simple as:
file_path="${1}"
mime="$(file --mime-type --brief "${file_path}")"
ext="${mime#image/}"
mv "${file_path}" "${file_path%.*}.${ext}"
That does no checks (e.g. is the file an image) and may not work on something on something like a video, but it’ll do for common image types such as png, jpeg, webp, heic, gif…
Re:mpv a free, open-source, and cross-platform media player
by amiga386 on Sunday August 18, 2024 @01:30PM
(#41283769)
Personally I use a shell script to do it automatically for me... with "file":
#!/bin/bash
# Usage: fix-extensions <media file(s)>
# Renames the files to consistent file extensions based on content
for file in "$@"; do
[ -f "$file" ] || continue
dir=$(dirname "$file")
name=$(basename "$file")
prefix="${name%.*}"
ext="${name##*.}"
magic=$(file -b "$file")
newext=""
case "$magic" in
*"Apple QuickTime movie"*) newext=mov;;
"ISO Media, Apple iTunes Video"*) newext=mp4;;
"ISO Media, MP4"*) newext=mp4;;
"ISO Media, MPEG-4 (.MP4)"*) newext=mp4;;
"Macromedia Flash data"*) newext=swf;;
"Macromedia Flash Video") newext=flv;;
"Matroska data") newext=mkv;;
"Microsoft ASF"*) newext=wmv;;
"MPEG sequence"*) newext=mpeg;;
"Ogg data, OGM video"*) newext=ogm;;
"RealMedia file") newext=rm;;
"RIFF "*" data, AVI,"*) newext=avi;;
"WebM") newext=webm;;
esac
if [ -z "$newext" ]; then
echo >&2 "$file: not renaming, unknown extension for type '$magic'"
elif [ "$ext" != "$newext" ]; then
mv -v "$file" "$dir/$prefix.$newext"
fi
done
Re:mpv a free, open-source, and cross-platform media player
by BoingBoomTschak on Sunday August 18, 2024 @03:15PM
(#41284652)
As someone who went MPC-HC + MadVR + ReClock -> mpv years ago (well, I also switched to Gentoo, to be fair). This is completely right.
BUT mpv still isn't perfect. The script in https://github.com/mpv-player/mpv/issues/8463 is really needed to handle some stuff (mainly clandestine anime) and the libplacebo/gpu-next transition wasn't exactly the smoothest (my config still has hotfixes for https://github.com/mpv-player/mpv/issues/10716 and https://github.com/mpv-player/mpv/issues/14474).
Nitpicking aside, it really is the new gold standard these days, and for good reasons.
I thought VLC was awesome while growing up, and at the time it probably was compared to Windows Media Player and such. I remember a common bit of praise was that it supported more types of video files. I haven't really run into anything mpv won't play (I even use it when an image I saved ends up as .html for some reason and then use the info screen to determine the real extension it should be so I can rename it), but also I'm guessing we've standardized more on codecs and containers these days which doesn't hurt.