Skip to content

Commit

Permalink
Add MUSIC and VIDEOS players
Browse files Browse the repository at this point in the history
- Add new video player (based on mpv 0.32.0)
- Add new music player (based on mpv 0.32.0) + fix ffmpeg libretro core
- Add script to extract music covers for MainUI
- Add script to generate playlist from a music subfolder
- New icons created for these players

Notes :
music player supports playlists, wav, mp3, flac ,ogg,m3u...
added a kind of visual equalizer, credits : https://blog.fraggod.net/2018/04/12/mpv-audio-visualization.html
Libretro ffmpeg cores is slow for videos, the visual for music is fun (but in low resolution)
mpv can read 1080p video really well
mpv has been configured to resume video at the same time position
mpv version is a little old (doesn't support lua scripts)
mpv launch scripts use gptokeyb2 to rebind controls into a classical keyboard (credits: PortMaster)

dev remarks:
more keys could be mapped to control mpv
an updated version could bring some nice feature thanks to lua scripts
Controls :
A/B/Start = play pause
up_down = seek 1 minute forward
down_down = seek 1 minute backward
left = seek 5 seconds backward
right = seek 5 seconds forward
l1/r1 = previ / next track
Menu = exit
  • Loading branch information
cizia64 committed Jun 8, 2024
1 parent 55b4768 commit 74f23d7
Show file tree
Hide file tree
Showing 51 changed files with 2,731 additions and 3 deletions.
Empty file added Apps/Scraper/Menu/.gitkeep
Empty file.
196 changes: 196 additions & 0 deletions Emus/MUSIC/.config/mpv/input.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# mpv keybindings

Location of user-defined bindings: ~/.config/mpv/input.conf

Lines starting with # are comments. Use SHARP to assign the # key.
Copy this file and uncomment and edit the bindings you want to change.

List of commands and further details: DOCS/man/input.rst
List of special keys: --input-keylist
Keybindings testing mode: mpv --input-test --force-window --idle

Use 'ignore' to unbind a key fully (e.g. 'ctrl+a ignore').

Strings need to be quoted and escaped:
KEY show-text "This is a single backslash: \\ and a quote: \" !"

You can use modifier-key combinations like Shift+Left or Ctrl+Alt+x with
the modifiers Shift, Ctrl, Alt and Meta (may not work on the terminal).

The default keybindings are hardcoded into the mpv binary.
You can disable them completely with: --no-input-default-bindings

Developer note:
On compilation, this file is baked into the mpv binary, and all lines are
uncommented (unless '#' is followed by a space) - thus this file defines the
default key bindings.

If this is enabled, treat all the following bindings as default.
default-bindings start

MBTN_LEFT ignore # don't do anything
MBTN_LEFT_DBL cycle fullscreen # toggle fullscreen
MBTN_RIGHT cycle pause # toggle pause/playback mode
MBTN_BACK playlist-prev # skip to the previous file
MBTN_FORWARD playlist-next # skip to the next file

Mouse wheels, touchpad or other input devices that have axes
if the input devices supports precise scrolling it will also scale the
numeric value accordingly
WHEEL_UP add volume 2
WHEEL_DOWN add volume -2
WHEEL_LEFT seek -10 # seek 10 seconds backward
WHEEL_RIGHT seek 10 # seek 10 seconds forward

# Seek units are in seconds, but note that these are limited by keyframes
RIGHT seek 5 # seek 5 seconds forward
LEFT seek -5 # seek 5 seconds backward
UP seek 60 # seek 1 minute forward
DOWN seek -60 # seek 1 minute backward
Do smaller, always exact (non-keyframe-limited), seeks with shift.
Don't show them on the OSD (no-osd).
Shift+RIGHT no-osd seek 1 exact # seek exactly 1 second forward
Shift+LEFT no-osd seek -1 exact # seek exactly 1 second backward
Shift+UP no-osd seek 5 exact # seek exactly 5 seconds forward
Shift+DOWN no-osd seek -5 exact # seek exactly 5 seconds backward
Ctrl+LEFT no-osd sub-seek -1 # seek to the previous subtitle
Ctrl+RIGHT no-osd sub-seek 1 # seek to the next subtitle
Ctrl+Shift+LEFT sub-step -1 # change subtitle timing such that the previous subtitle is displayed
Ctrl+Shift+RIGHT sub-step 1 # change subtitle timing such that the next subtitle is displayed
Alt+left add video-pan-x 0.1 # move the video right
Alt+right add video-pan-x -0.1 # move the video left
Alt+up add video-pan-y 0.1 # move the video down
Alt+down add video-pan-y -0.1 # move the video up
Alt++ add video-zoom 0.1 # zoom in
ZOOMIN add video-zoom 0.1 # zoom in
Alt+- add video-zoom -0.1 # zoom out
ZOOMOUT add video-zoom -0.1 # zoom out
Ctrl+WHEEL_UP add video-zoom 0.1 # zoom in
Ctrl+WHEEL_DOWN add video-zoom -0.1 # zoom out
Alt+BS set video-zoom 0 ; set video-pan-x 0 ; set video-pan-y 0 # reset zoom and pan settings
PGUP add chapter 1 # seek to the next chapter
PGDWN add chapter -1 # seek to the previous chapter
Shift+PGUP seek 600 # seek 10 minutes forward
Shift+PGDWN seek -600 # seek 10 minutes backward
[ multiply speed 1/1.1 # decrease the playback speed
] multiply speed 1.1 # increase the playback speed
{ multiply speed 0.5 # halve the playback speed
} multiply speed 2.0 # double the playback speed
BS set speed 1.0 # reset the speed to normal
Shift+BS revert-seek # undo the previous (or marked) seek
Shift+Ctrl+BS revert-seek mark # mark the position for revert-seek
t quit
Q quit-watch-later # exit and remember the playback position
q {encode} quit 4
ESC set fullscreen no # leave fullscreen
ESC {encode} quit 4
p cycle pause # toggle pause/playback mode
. frame-step # advance one frame and pause
, frame-back-step # go back by one frame and pause
SPACE cycle pause # toggle pause/playback mode
n playlist-next # skip to the next file
ENTER playlist-next # skip to the next file
< playlist-prev # skip to the previous file
f no-osd cycle-values osd-level 3 1 # toggle displaying the OSD on user interaction or always
g show-progress # show playback progress
P show-progress # show playback progress
i script-binding stats/display-stats # display information and statistics
I script-binding stats/display-stats-toggle # toggle displaying information and statistics
` script-binding console/enable # open the console
z add sub-delay -0.1 # shift subtitles 100 ms earlier
Z add sub-delay +0.1 # delay subtitles by 100 ms
x add sub-delay +0.1 # delay subtitles by 100 ms
ctrl++ add audio-delay 0.100 # change audio/video sync by delaying the audio
ctrl+- add audio-delay -0.100 # change audio/video sync by shifting the audio earlier
Shift+g add sub-scale +0.1 # increase the subtitle font size
Shift+f add sub-scale -0.1 # decrease the subtitle font size
9 add volume -2
/ add volume -2
0 add volume 2
* add volume 2
m cycle mute # toggle mute
1 add contrast -1
2 add contrast 1
3 add brightness -1
4 add brightness 1
5 add gamma -1
6 add gamma 1
7 add saturation -1
8 add saturation 1
Alt+0 set window-scale 0.5 # halve the window size
Alt+1 set window-scale 1.0 # reset the window size
Alt+2 set window-scale 2.0 # double the window size
b cycle deband # toggle the debanding filter
d cycle deinterlace # cycle the deinterlacing filter
r add sub-pos -1 # move subtitles up
R add sub-pos +1 # move subtitles down
t add sub-pos +1 # move subtitles down
v cycle sub-visibility # hide or show the subtitles
Alt+v cycle secondary-sub-visibility # hide or show the secondary subtitles
V cycle sub-ass-vsfilter-aspect-compat # toggle stretching SSA/ASS subtitles with anamorphic videos to match the historical renderer
u cycle-values sub-ass-override "force" "scale" # toggle overriding SSA/ASS subtitle styles with the normal styles
j cycle sub # switch subtitle track
J cycle sub down # switch subtitle track backwards
SHARP cycle audio # switch audio track
_ cycle video # switch video track
T cycle ontop # toggle placing the video on top of other windows
f cycle fullscreen # toggle fullscreen
s screenshot # take a screenshot of the video in its original resolution with subtitles
S screenshot video # take a screenshot of the video in its original resolution without subtitles
Ctrl+s screenshot window # take a screenshot of the window with OSD and subtitles
Alt+s screenshot each-frame # automatically screenshot every frame; issue this command again to stop taking screenshots
w add panscan -0.1 # decrease panscan
W add panscan +0.1 # shrink black bars by cropping the video
e add panscan +0.1 # shrink black bars by cropping the video
A cycle-values video-aspect-override "16:9" "4:3" "2.35:1" "-1" # cycle the video aspect ratio ("-1" is the container aspect)
BTN_SOUTH quit
PLAY cycle pause # toggle pause/playback mode
ENTER cycle pause # toggle pause/playback mode
PLAYPAUSE cycle pause # toggle pause/playback mode
PLAYONLY set pause no # unpause
PAUSEONLY set pause yes # pause
STOP quit
FORWARD seek 60 # seek 1 minute forward
REWIND seek -60 # seek 1 minute backward
NEXT playlist-next # skip to the next file
b playlist-prev # skip to the previous file
VOLUME_UP add volume 2
VOLUME_DOWN add volume -2
MUTE cycle mute # toggle mute
CLOSE_WIN quit
CLOSE_WIN {encode} quit 4
ctrl+w quit
E cycle edition # switch edition
l ab-loop # set/clear A-B loop points
L cycle-values loop-file "inf" "no" # toggle infinite looping
ctrl+c quit 4
DEL script-binding osc/visibility # cycle OSC visibility between never, auto (mouse-move) and always
ctrl+h cycle-values hwdec "auto-safe" "no" # toggle hardware decoding
F8 show-text ${playlist} # show the playlist
F9 show-text ${track-list} # show the list of video, audio and sub tracks
g ignore
g-p script-binding select/select-playlist
g-s script-binding select/select-sid
g-S script-binding select/select-secondary-sid
g-a script-binding select/select-aid
g-v script-binding select/select-vid
g-t script-binding select/select-track
g-c script-binding select/select-chapter
g-l script-binding select/select-subtitle-line
g-d script-binding select/select-audio-device
g-b script-binding select/select-binding
g-r script-binding select/show-properties


Legacy bindings (may or may not be removed in the future)

! add chapter -1 # seek to the previous chapter
@ add chapter 1 # seek to the next chapter


Not assigned by default
(not an exhaustive list of unbound commands)


? cycle sub-forced-events-only # display only DVD/PGS forced subtitle events
? stop # stop playback (quit or enter idle mode)
1 change: 1 addition & 0 deletions Emus/MUSIC/.config/mpv/mpv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-position-on-quit
Empty file.
Empty file.
40 changes: 40 additions & 0 deletions Emus/MUSIC/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"label": "MUSIC",
"label.ch.lang": "FF视频播放",
"icon": "/mnt/SDCARD/Icons/Default/Emus/MUSIC.png",
"background": "/mnt/SDCARD/Backgrounds/Default/MUSIC.png",
"themecolor": "DDEEFF",
"launch": "mpv.sh",
"rompath": "../../Roms/MUSIC",
"imgpath": "../../Imgs/MUSIC",
"useswap": 0,
"shortname": 0,
"hidebios": 1,
"extlist": "mp4|mkv|avi|mpg|mpeg|wmv|asf|rm|rmvb|m4v|ts|mp3|m3u|wma|jpg|png|bmp|flac|ogg",
"launchlist": [
{
"name": "mpv with album cover",
"launch": "mpv.sh"
},
{
"name": "mpv with visualization",
"launch": "mpv_visualisation.sh"
},
{
"name": "Libretro ffmpeg",
"launch": "ffmpeg.sh"
},
{
"name": "---------------",
"launch": ""
},
{
"name": "Extract album covers",
"launch": "cover_extract.sh"
},
{
"name": "Create m3u playlist",
"launch": "m3u_creator.sh"
}
]
}
95 changes: 95 additions & 0 deletions Emus/MUSIC/cover_extract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/sh
echo $0 $*
progdir=$(dirname "$0")
mp3_directory=$(dirname "$1")

tkdir=/mnt/SDCARD/Apps/ScreencapTK
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/trimui/lib/:$tkdir/lib
mp3_directory=$(realpath "$mp3_directory")

if [ "$mp3_directory" = "/mnt/SDCARD/Roms/MUSIC" ]; then
echo "The given directory is the root directory. Please create a subfolder."
/mnt/SDCARD/System/bin/sdl2imgshow \
-i "/mnt/SDCARD/trimui/res/crossmix-os/bg-info.png" \
-f "/mnt/SDCARD/System/resources/DejaVuSans.ttf" \
-s 25 \
-c "220,220,220" \
-t "The given directory is the MUSIC root directory. Please create a dedicated subfolder." &
sleep 0.3
pkill -f sdl2imgshow
sleep 1
sleep 2
exit 0
fi

/mnt/SDCARD/System/bin/sdl2imgshow \
-i "/mnt/SDCARD/trimui/res/crossmix-os/bg-info.png" \
-f "/mnt/SDCARD/System/resources/DejaVuSans.ttf" \
-s 25 \
-c "220,220,220" \
-t "Cover extraction. Please wait..." &
sleep 0.3
pkill -f sdl2imgshow

# Directories
# mp3_directory="/mnt/SDCARD/Roms/MUSIC" #debug
png_directory="/mnt/SDCARD/Imgs/MUSIC"

# Create the images directory if it doesn't exist
mkdir -p "$png_directory"

# Find the first MP3 file
first_mp3=""
for file in "$mp3_directory"/*.mp3; do
if [ -f "$file" ]; then
first_mp3="$file"
break
fi
done

if [ -z "$first_mp3" ]; then
echo "No MP3 files found in the directory."
exit 1
fi

# Check for the existence of cover.jpg or cover.png
cover_image="$mp3_directory/cover.png"
cover_jpg="$mp3_directory/cover.jpg"
cover_png_already_existed=false

if [ -f "$cover_image" ]; then
echo "cover.png already exists, using it."
cover_png_already_existed=true
elif [ -f "$cover_jpg" ]; then
echo "cover.jpg already exists, converting to cover.png."
/mnt/SDCARD/Apps/ScreencapTK/bin/ffmpeg -i "$cover_jpg" -vf "scale=400:-1" "$cover_image"
else
echo "Extracting cover from the first MP3."
/mnt/SDCARD/Apps/ScreencapTK/bin/ffmpeg -i "$first_mp3" -an -vcodec copy "$cover_image"
fi

# Create a copy of the extracted image for each MP3 file in the images directory
for file in "$mp3_directory"/*.mp3; do
if [ -f "$file" ]; then
mp3_base_name=$(basename "$file" .mp3)
new_cover_image="$png_directory/$mp3_base_name.png"
cp "$cover_image" "$new_cover_image"
fi
done

# Create a copy of the extracted image for each M3U file in the images directory
for file in "$mp3_directory"/*.m3u; do
if [ -f "$file" ]; then
m3u_base_name=$(basename "$file" .m3u)
new_cover_image="$png_directory/$m3u_base_name.png"
cp "$cover_image" "$new_cover_image"
fi
done

# Remove the cover.png used for copying if it didn't already exist
if [ "$cover_png_already_existed" = false ]; then
rm "$cover_image"
fi

sync
echo "Covers have been created for each MP3 and M3U file in the images directory."
3 changes: 3 additions & 0 deletions Emus/MUSIC/cpufreq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 1008000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
8 changes: 8 additions & 0 deletions Emus/MUSIC/ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
RA_DIR=/mnt/SDCARD/RetroArch
EMU_DIR=/mnt/SDCARD/Emus/VIDEOS
cd $RA_DIR/

$EMU_DIR/cpufreq.sh

HOME=$RA_DIR/ $RA_DIR/ra64.trimui -L $RA_DIR/.retroarch/cores/ffmpeg_libretro.so "$@"
Loading

0 comments on commit 74f23d7

Please sign in to comment.