As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label MPlayer. Show all posts

Just finished some changes for showing song title and artist of music which played by (S)MPlayer in my dzen.

The modified lf-submit.sh (lf-mplayer-wrapper.sh) doesnt extract time information because it will have to parse MPlayers output, though its not hard, but I just didnt want to do it. Beside, the script couldnt decide the song length, because I might set A-B playing mode. Basically, only song title and artist are available to display and thats what my dzen used to show me the songs played by MPD.

Except the time and players status, my dzen shows me same information as if showing MPD status, including Last.fm playcount and loved status. lf-submit.sh helps save the current song information to /tmp/lf-submit.sh.currentsong and my status.c pick up and show them, then lf-playcount-image.sh helps retrieve data from Last.fm.

I dont feel I really need song to be shown in dzen when I play a music video, you can just watch pictures, why do you want to read text? Anyway, it just got me something to do.

If you have watched the screencast above, you may notice that there are some glitches when rolling the text after 050. I knew someday I would have to fix that, problems with characters other than ASCII. Now, I really have to, but later.

Last few days, I have been watching German music video. I found there are some awesome videos and some funny ones. I will post later hopefully.

Oh, sorry for the last 1 minute and 30 second, seeing me fixing that exclamation mark thing!

Since I started to watch music videos on YouTube, I have always wanted to write a YouTube scrobbler but I never did and probably would never do, because it might be messy in someway. I also have downloaded some from YouTube so I could enjoy better performance in full-screen with MPlayer. A couple of days ago, I started to ponder about a MPlayer a wrapper, which enables users having more controls. Such as a notification capable, or something else. But the main purpose of this wrapper is for being used with a Last.fm scrobbler.

And lf-submit.sh was born, a set of pure Bash scripts including three parts:

  • wrapper: A MPlayer wrapper, it parses outputs of MPlayer. It can be used with MPlayer GUI frontend, such as SMPlayer.
  • scrobbler: A scrobbler, tts invoked by wrapper, it reads metadata of files and invokes lf-submit.sh to send an API request.
  • submitter: Submitter, it can be a standalone script. Its the real script which communication with Last.fm.

The scripts support Now playing and Scrobbling. The dependencies are perl, md5sum, and few common shell scripting programs. The scripts are licensed under the BSD License.

1   How to Install

Download three scripts and make sure scrobbler and submitter is in search path. As for wrapper, you can put it anyway and run it. Before you start the wrapper, you must run submitter to configure your account, you will be asked for your Last.fm username and given a link, which you can authorize the scripts to submit scrobbles.

If you use SMPlayer as frontend, change MPlayer executable in preference dialog to wrapper script.

The configuration files are stored at $XDG_CONFIG_HOME/lf-submit.sh/config. If anything goes wrong, you can run lf-submit.sh -r to re-configure.

2   How it Works?

The first step is to run wrapper. For example:

# Use absolute path
/path/to/lf-mplayer-wrapper.sh foo_video.ogg

# If it's in search path
lf-mplayer-wrapper.sh foo_video.ogg

Calling wrapper directly might not be what you want. My search path, its more like this PATH=/home/username/bin:/usr/bin. My ~/bin is first place to look up for a command. In my case, I use a symbolic link:

ln -s /path/to/lf-mplayer-wrapper.sh ~/bin/mplayer

Therefore, /usr/bin/mplayer is wrapped by the wrapper. The wrapper uses which to find the real MPlayer program.

Once the wrapper brings up the MPlayer and supply all arguments which wrapper is given to the MPlayer, it starts to parse MPlayers output. It can detect file changes, then do proper action with scrobbler:

# When new file played, wrapper runs
lf-scrobble.sh -n - /path/to/file.ogg

# When new file played after the end of another, wrapper runs
lf-scrobble.sh -s <TIMESTAMP> /path/to/file.ogg

-n means now playing and -s means scrobble. When scrobbles a track, timestamp of start time must be sent to Last.fm.

Scrobbler takes over, it firstly checks if there is a file named /path/to/file.lfs. File with extension lfs is the metadata file. The scripts do not use central database, the metadata file must sit next to media file, and there is no automatic way to have metadata. The metadata files should have content like:

track=track name blah blah
artist=the artist's name

These two lines are required, you can put more in, please consult with parameters sections of track.scrobble and track.updateNowPlaying.

If scrobbler has everything it needs to make a request to Last.fm, it then invokes submitter. Submitter accepts similar arguments:

lf-submit.sh <-n|-s> 'key1=value1' 'key2=value2' ...

For a scrobble, it would look like:

lf-submit.sh -s 'track=Track Name' 'artist=Artist Name' 'timestamp=123456789'

The order of key-value pairs is not important, submitter will make them in right order internally.

3   Feedback

The scripts are still in unstable stage. Basically, you wont see any error messages from these scripts and that makes debugging harder. If you encounter problems, please provide information such as file name, metadata, MPlayer and frontend player versions. Its better that you create a bug report.

Its not like that I dont have Flash installed. But every time I click on the black speaker icon (and I have to use mouse to click), Flash gains the focus.

So I modified my ~/.vimperatorrc, I was thinking of using HTML5 Audio, unfortunately, MP3 is not supported.

So, I turned to use MPlayer via io.system(), it does a great job.

Now, after I click on speaker icon, I can continue to type Vimperator commands. If I want to go back to input box, I type gi. I also bind s key to play first pronunciation, of course, I have to press ESC first if the focus is on input box.

I noticed if I leave the page and go back to play, I will see errors. I am not sure whats the problem, I guess I didnt code it exactly right.

SMPlayer is my favorite frontend for MPlayer. There are some other frontends, such as MPlayers own GUI (depreciated), GNOME MPlayer, or KMPlayer. But SMPlayer is the best. You probably use VLC or Totem or something I have never heard, I can say 99% MPlayer is the best. So MPlayer + SMPlayer is the best combination in my opinion.

Weeks ago, I found this Auto zoom Shift+W feature, it fills up the gap of video (and the gap of my life as well). You wont see any blank area if the video doesnt contain blank border. You can use Alt+Arrow keys to pan the zoomed area. There is only a slight problem, the OSD on top-left corner, likely would be cut off. I dont have a resolution for this issue, and I havent tried to ask for one yet.

I usually play a playlist of YouTube videos. Some (indie videos) have introduction part, so I use A-B Section (Repeat) to play only the main part. If a videos sound level is too low or too high, I use Equalizer to adjust.

For what I have done to a video, the changes (not including panning) are memorized by SMPlayer. Thats the most awesome feature, it will always play a video (or audio) in a way you want.

Two things I want to add: 1) Because of SMPlayer, I know there is a hack to boost performance in MPlayer, -vo gl:yuv=2:force-pbo:ati-hack (For ATI cards only). 2) Dont forget to turn off Repeat mode (not the one in Playlist window), it means single track repeat mode when you play a playlist.

Recently I kept playing a MV on my screen, so I decided to turn on Desktop Effects, then I will have alpha channel. I can make video window a little transparent and I can read stuff beneath that window. I have tried to keep system as simple as possible, therefore I didn't install other players besides the default, totem. Funny thing is after turned the Desktop Effects on, I also installed Xine (front-end), MPlayer, and VLC. Why I installed them? because I can't stand with the quality of gstreamer, Xine, or VLC, only MPlayer can satisify my eyes.



I will start to note about how to let each player play with Desktop Effects first:




Totem + gstreamer backend

Make sure you switch to gstreamer (as root)


totem-backend -b gstreamer

Choose video driver


gstreamer-properties

Switch to Video tab, choose X Window System (No XV), Test, then Close.




Xine

Go to Setup, Choose Master of the known universe from Configuration experience level in gui tab, Switch to video tab, Choose driver xshm.




VLC

Tools/Preferences, Video, Display/Output X11 video output.




MPlayer

In Preferences/Video. x11 may work, but the fullscreen doesn't work for me. gl2 is sort of working, but have other issues.



The quality of them, I rank them in this order: MPlayer > VLC >>> Xine = gstreamer. Although VLC seems to be better than Xine or gstreamer, but it gives me few glitches on audio, that is not acceptable to me.



MPlayer is not really fully working with Desktop Effects, I wonder if this is also about open source video driver. I can't recall the status when I still use ATI driver.



Since I only have a small window playing, I will stay with Desktop Effects using Totem + gstreamer, I can accept the quality when window is small. When I need the fullscreen playing, I will turn off Desktop Effects and use MPlayer.