Foobar 2000 Media Player¶
One of the best audio players for organizing, tagging and converting digital music collections.
Foobar 2000 Media Library Database¶
Foobar 2000 media library database can't be opened with 3rd party tools directly. But it's possible to access and even “export” the media library and the playlists content with foo_sqlite.
foo_sqlite is a foobar2000 component for viewing and changing the contents of the media library and the playlists by using SQL statements. Additionally, foo_sqlite provides the possibility to store tag information in a database by defining attributes for each tag individually.
In order to read the foobar 2000 media library with #php oder any other programming language or just a 3rd party database manager the media library table has to be "materialized" (since they are only be accessible as virtual tables through the foo_sqlite interface).
How to materialize the media library in a SQLite database?¶
- File > Preferences > Media Library > SQLite Utilities > MediaLibrary Table and on top add a name how the “Materialized table” will be called, e.g.
library - Go through every database field and check if the field should be materialized
- Go into the foobar 2000 preference folder into configuration and look for foo_sqlite.materialize.db - this will hold all the data from the media library and it gets synced on every change.
Playback statistics¶
How can I adjust "Date Added" for individual tracks/albums as calculated by Playback Statistics?
If importing is not changing the date, it is probably because you can only import dates that are older than the current added date for that track. See here at the * note at the end.
EDIT: If you want to keep current stats (besides ADDED) for these albums, be sure to export to tags first. Quick steps from memory -
- Select problem album - right-click > PS > Write stats to tags
- Find in library / select same amount of tracks with newest possible ADDED date - right-click > PS > Copy stats
- Select problem album - right-click > PS > Paste stats
- Select problem album - right-click > PS > Reset stats (clears every database stat except ADDED)
- Select problem album - right-click > Properties > modify ADDED_TIMESTAMP number to desired date (see link)
- Select problem album - right-click > PS > Import stats from tags
(Finally you can remove the extra tags from right-click > Properties)
https://www.reddit.com/r/foobar2000/comments/12dyfwg/comment/jfc600i/
Sorting Pattern¶
SORT ASCENDING BY $if2(%SINGLETRACK%,2) $cut($if2($meta(added),%added%), 10)-%album artist%-%album%-%discnumber%-%tracknumber%
Foobar2000 REST API¶
Beefweb¶
https://github.com/hyperblast/beefweb
The api call would be:
http://>ip<[:<port>]/api/query?player=true&trcolumns=%25artist%25,%25title%25
result:
{"player":{"activeItem":{"columns":["Asking Alexandria","Dead"],"duration":240.453333333333,"index":9,"playlistId":"p1","playlistIndex":0,"position":37.0565661},"info":{"name":"foobar2000","pluginVersion":"0.4","title":"foobar2000","version":"1.6.1"},"playbackMode":0,"playbackModes":["Default","Repeat (playlist)","Repeat (track)","Random","Shuffle (tracks)","Shuffle (albums)","Shuffle (folders)"],"playbackState":"playing","volume":{"isMuted":false,"max":0.0,"min":-100.0,"type":"db","value":-34.0}}}
See also https://github.com/hyperblast/beefweb/tree/941878620929c1ecff7b8afe48ece382fb651ba6/js/api_tests/src
httpcontrol¶
https://bitbucket.org/oblikoamorale/foo_httpcontrol/downloads/
The api call would be:
http://>ip<[:<port>]/installed_template_name/?cmd=FormatTitles¶m1=%25artist%25|%25title%25¶m3=file.json
result:
["Asking Alexandria","Dead"]
http://127.0.0.1:82/api/?param3=state.json
Search media library: http://127.0.0.1:82/api/?cmd=SearchMediaLibrary¶m1=%25artist%25+HAS+brother%20mc%20queen¶m3=state.json
Command syntax: http://>ip<[:<port>]/<?cmd=Command[¶m1=param 1[¶m2=param 2]][¶m3=param 3]>
Supported commands:¶
Stop playback¶
cmd=Stop
Play or pause playback¶
cmd=PlayOrPause
Start playback in active playlist¶
cmd=Start
param1=playlist item starting from 0
Start playback of random item in active playlist¶
cmd=StartRandom
Start playback of previous item in active playlist¶
cmd=StartPrevious
Start playback of next item in active playlist¶
cmd=StartNext
Volume level¶
cmd=Volume
param1=volume level, 0...100 (%)
Volume level delta¶
cmd=VolumeDelta
param1=signed volume level delta percentage, -N...N (%)
Volume level dB¶
cmd=VolumeDB
param1=volume level, 0...665 (0...-66.5 db), or 1000 to mute
Volume level dB delta¶
cmd=VolumeDBDelta
param1=signed delta, -N...N (-N/10...N/10 db)
Seek playing item by percentage¶
cmd=SeekPercent
param1=position, from 0 to 100 (percent)
Seek playing item by seconds¶
cmd=SeekSecond
param1=seconds (signed integer)
Seek playing item by delta seconds¶
cmd=SeekSecondDelta
param1=seconds (signed integer)
Empty active playlist¶
cmd=EmptyPlaylist
Change playback order¶
cmd=PlaybackOrder
param1=order number, from 0 to 7
Delete one or more playlist items¶
cmd=Del
param1=numbers separated by any delitemeter
param2=optionally specifies playlist
Undo changes made to playlist backed up by restore point¶
cmd=Undo
param1=optionally specifies playlist
Move one or more active playlist items¶
cmd=Move
param1=numbers separated by any delitemeter
param2=signed move delta
Set playlist selection¶
cmd=SetSelection
param1=numbers separated by any delitemeter, empty to remove selection, ~ to select all
param2=optionally specifies playlist
Change stop after current flag¶
cmd=SAC
param1=0 or 1
Switch playlist¶
cmd=SwitchPlaylist
param1=playlist index, from 0
Switch playlist page¶
cmd=SwitchPlaylistPage;P
param1=page index, from 0
Set focus to specific item of active playlist¶
cmd=SetFocus
param1=item starting from 0
Get directory file list¶
cmd=Browse
param1=urlencoded directory path with trailing backslash
Enqueue single file or url¶
cmd=Browse
param1=urlencoded file path / url
Enqueue path¶
cmd=Browse
param1=urlencoded path
param2=EnqueueDir
Enqueue path including subdirectories¶
cmd=Browse
param1=urlencoded path
param2=EnqueueDirSubdirs
Put active playlist items to playback queue¶
cmd=QueueItems
param1=numbers separated by any delitemeter
Remove active playlist items from playback queue¶
cmd=DequeueItems
param1=numbers separated by any delitemeter
Search media library¶
cmd=SearchMediaLibrary;Search
param1=search query
Query media library¶
cmd=QueryAdvance
param1=search query
Query media library¶
cmd=QueryRetrace
Skip generating request response¶
param3=NoResponse
Use different template file¶
param3=template.html
PlaylistItemsPerPage¶
param1=number of playlist items per page, limited to 16384
QueueAlbum¶
param1=item album search starts from (focused item is used if param1 is omitted)
QueueRandomItems¶
param1=item count
FlushQueue¶
Parse¶
param1=string to parse and return
RemovePlaylist¶
param1=playlist index
CreatePlaylist¶
param1=playlist name
param2=insertion point index
RenamePlaylist¶
param1=playlist name
param2=playlist index
FocusOnPlaying¶
Update helper macros¶
cmd=RefreshPlayingInfo
Execute foobar2000 with specific command-line parameters¶
cmd=CmdLine
param1=parameters
Executes context menu command specified in param1 for currently playing item¶
cmd=PlayingCommand
param1=case sensitive context menu path, for example: Playback Statistics/Rating/3
Don't forget to urlencode param1 value.
Executes context menu command specified in param1 for currently selected (or specified list of) items of active playlist¶
cmd=SelectionCommand
param1=case sensitive context menu path, for example: Playback Statistics/Rating/3
param2=numbers separated by any delimeter (optional)
Don't forget to urlencode param1 value. Note that running playlist-specific commands like Remove, Crop, etc is not possible.
Sorts whole active playlist or its specified items using sort pattern in ascending order¶
cmd=SortAscending (deprecated old name Sort)
param1=sort pattern
param2=numbers separated by any delimeter (optional)
Don't forget to urlencode param1 value.
Sorts whole active playlist or its specified items using sort pattern in descending order¶
cmd=SortDescending
param1=sort pattern
param2=numbers separated by any delimeter (optional)
Don't forget to urlencode param1 value.
Tileformats a list of titleformatting string using playing or certain active playlist item and returns result as json array¶
cmd=FormatTitles
param1=list of titleformatting strings (separated by |)
param2=active playlist item index (optional)
param3=file name to guess the resulting content type from, use file.json
Template macro substitutions:¶
- [HELPER{1-9}]
- [HELPER{1-9}X]
- [VOLUME]
- [VOLUME_DB]
- [VOLUME_OPTION]
- [PLAYBACK_ORDER]
- [PLAYBACK_ORDER_OPTION]
- [PLAYLISTS_OPTION]
- [SAC]
- [SAQ]
- [ITEM_PLAYING_POS]
- [ITEM_PLAYING_LEN]
- [QUEUE_TOTAL_TIME]
- [IS_PLAYING]
- [IS_PAUSED]
- [IS_ENQUEUEING]
- [AUTO_REFRESH]
- [LAST_ACTION]
- [ALBUMART]
- [DISCART]
- [PLAYLIST]
- [PLAYLIST_TOTAL_TIME]
- [PLAYLIST_ACTIVE]
- [PLAYLIST_PLAYING]
- [PLAYLIST_PAGE]
- [PLAYLIST_PAGES_COUNT]
- [PLAYLIST_PAGES]
- [PLAYLIST_PAGES_SELECT]
- [PLAYLIST_ITEM_FOCUSED]
- [PLAYLIST_ITEM_PLAYING]
- [PLAYLIST_ITEM_PREV_PLAYED]
- [PLAYLIST_ITEMS_COUNT]
- [PLAYLIST_ITEMS_PER_PAGE]
- [PLAYLIST_PLAYING_ITEMS_COUNT]
- [PLAYLIST_IS_UNDO_AVAILABLE]
- [PLAYLIST_IS_REDO_AVAILABLE]
- [PLAYLIST_IS_LOCKED]
- [PLAYLIST_JS]
- [PLAYLISTS_JS]
- [SEARCH_REQUEST]
- [QUERY]
- [QUERY_JS]
- [QUERY_INFO]
- [QUERY_INFO_JS]
- [PATH]
- [PATH_JS]
- [PATH_PARENT]
- [BROWSER]
- [BROWSER_JS]
- [STATE_CHANGE]
Custom Converter with FFMPEG¶
Remuxing AAC to M4A in Foobar2000¶
The Cli command to wrap raw aac in a mp4 container is:
ffmpeg -i input.aac -c:a copy output.m4a
As a custom converter in foobar 2000 it would look like
ffmpeg -i %s -c:a copy %d
This results in an unplayable file with error moov box not found
The problem with the above is that %s is a temporary .wav file and that's being wrapped into the mp4 container.
The post Using FFmpeg as a custom converter in foobar2000 shows how to use the converter without the %s argument and instead "pipe it" with -i pipe:0 but this didn't work.
Instead, I set up the first FFmpeg command in foo_run and that works
#programming/ffmpeg