Extracting thumbnails with mplayer result in grey images - mplayer

I'm trying to extract thumbnails using mplayer with this command:
mplayer -nosound -ss 1 -vf screenshot -frames 1 -vo png:z=9 jump.mpg
The problem is that it results in an almost grey image.
If I now try and execute the command:
mplayer -ss 1 jump.mpg
Then the video plays back skipping the first second (as expected), but the first second of the playback is mostly grey. Technically, I think it displays the diff to the previous frame, until it gets to a key frame, where the whole frame is encoded in the video.
Now the question is:
How do I force mplayer to seek to a key frame, so I avoid this grey image when extracting?
I found the option -hr-seek off, which sounds like it should do the right thing, but it doesn't.

Just use mplayer2, the seek problem is solved. I tested myself:
http://www.mplayer2.org/differences/
on debian/ubuntu just install via apt-get install mplayer2

Related

Mplayer - Change track, play/pause with command line

Mplayer provides shortcuts to change the track and play/pause the music but they only work if the mplayer window has the focus.
Is it possible, for example, to change the track currently played in mplayer with a command line? In that case, I could assign this command to a shortcut and use it even if mplayer does not have the focus.
All I found on google was how to use mplayer to play files or which shortcuts to change track when the window has the focus.
I am actually in the middle of trying to do this exact thing! I am going to share what I have discovered so far in case it helps anyone.
I have not been able to find a way to play/pause tracks. However, I have been able to change tracks, at least in terms of going to the next track.
I have found 2 ways so far: Using /proc/$pid/fd/0 and Named Pipes (FIFOs). Explaining FIFOs is a little harder (I just recently learned of them) so I will do that last.
Modifying STDIN via /proc/$pid/fd/0
We can communicate with a process in a different terminal session by redirecting input to the process' file definitions directory at /proc/$pid/fd/ where $pid is the process' PID.
Firstly, find the process ID using pidof. Make sure mplayer is actually running!
$ pidof mplayer
This will output the PID of mplayer. Using this $PID, we can input what we want to STDIN for mplayer by redirecting it to /proc/$PID/fd/0. (Note, 0 refers to STDIN, 1 to STDOUT, etc.). An example:
$ echo "p" > /proc/$PID/fd/0
This has the effect of changing the tracks for mplayer.
However, even though I used p in my example, I have found that you can echo anything (including nothing) and it will still accomplish the same goal of changing the track no matter what you input.
Named Pipes
Also called FIFOs, named pipes, just like regular pipes (|), redirect output to other processes. The main difference is that these are part of the filesystem and can be used to communicate between different terminal sessions.
To start off, create a new named pipe anywhere in your filesystem. I chose /tmp/.
$ mkfifo /tmp/mp3control.pipe
Then start mplayer redirecting its STDIN to the named pipe.
$ mplayer -playlist brutal_tunez.txt < /tmp/mp3control.pipe
It will look like the process hangs and that's because it is expecting the other side to input something.
Now open up a new terminal and input stuff into the pipe.
$ echo "p" > /tmp/mp3control.pipe
You will hear music start to play from mplayer. Again, just like before, any further inputs to the pipe will just change tracks.
I believe this has something to do with the way mplayer handles STDIN and is not the same thing as entering p to play or pause music.
I will continue looking into this but I would love to hear from someone if I made a mistake somewhere. All in all, this might end up being something where the amount of time spent is not worth it, to be honest. (But we still must!)

Update output to unix in realtime

Im sure this is common but I was having trouble finding anything on google...
I am using Perl and I am running my program in UNIX. At one point in my program I am printing numbers which represent the number of regex matches found. Anyway the output is something like this..
1
2
3
4
5
etc..
It ends up being quite a long list, so if you want to get to the top or bottom of the output you have to do a ton of scrolling...
My question is how can I get the list output to update in realtime, so the list output would stay on one line. so that 1 changes to 2 changes to 3 etc..
Thanks for help!
It depends on a lot of things, but \r in a string should return the cursor to the beginning of the line.
Firstly, don't forget to unbuffer output in your Perl with:
$|=1;
Then try:
$(tput clear);
to put cursor to top of terminal window.
Try typing:
tput clear
into your terminal to see if that clears the screen and puts the cursor at top left. If not, try typing:
clear
to clear the screen and get cursor to "Home" position.

How can I keep my putty scrollback buffer when using emacs -nw and gnu screen?

Here's my problem - hopefully I can explain this well enough:
I use Putty on Windows, and then start a gnu screen session. I may run several shell commands in putty, and then in the same screen, run emacs -nw. The problem is that when I exit emacs, the scrollback buffer (in putty) is messed up. What was on the screen when I started emacs is gone, and if I scroll upward I see various artifacts of screen (e.g. the screen "bar" at the bottom, etc.).
If I don't use screen and just open emacs -nw directly from putty, all my history is still there in the buffer when I exit emacs.
Likewise, if I do use screen, and use vi within a screen instead of emacs, when I exit vi, everything is there.
Is this just some weird interaction with putty and emacs? Is there a way to fix it?
Have you tried setting scrollback buffer size to something else than default? scrollback
In .screenrc put this line:
defscrollback 10000
Here's my config .screenrc. Tried to reproduce this problem but no luck... you can try if it fixes for you:
termcapinfo xterm* ti#:te#
startup_message off
vbell off
autodetach on
altscreen on
shelltitle "$ |bash"
defscrollback 10000
defutf8 on
nonblock on
hardstatus alwayslastline
hardstatus string '%{= kw}[ %{= kb}%H%{= kw} ][%= %{= kw}%?%-Lw%?%{= kW}%n*%f %t%?%?%{= kw}%?%+Lw%?%?%= ][ %{r}%l%{w} ]%{w}[%{r} %d/%m/%y %C %A %{w}]%{w}'
bind 'q' quit
Just at the end I would as well suggest you getting familiar with tmux -> http://tmux.sourceforge.net/
BTW. hopefully you're using newest version of PuTTy right? :) - > http://puttytray.goeswhere.com/
This sounds like Emacs and Screen are stepping on each others toes over the alternate screen feature of your terminal.
I cannot reproduce this issue, but maybe putting the following in your ~/.screenrc would help:
altscreen on
Have you considered using tmux as an alternative to GNU screen?

How do I profile my emacs configuration?

My emacs configuration takes a very long time to load. How can I easily find the offending parts and optimize them?
Very useful package: http://www.emacswiki.org/emacs/ProfileDotEmacs
Just skip loading your init file and let ProfileDotEmacs load/profile it for you:
emacs -Q -l profile-dotemacs.el -f profile-dotemacs
Another solution is ESUP, the Emacs Start Up Profiler. It can profile your config file without leaving Emacs - it accomplishes this by starting a new Emacs as a child process, getting profile information from it.
By using divide and conquer, of course!
Drop the bottom half of your .emacs. See if the speed improves. (If so, the culprit is within the bottom half; otherwise it's in the top half.) Restore the working half. Chop off half of the broken half, and repeat the process until you have isolated the problem.

MPlayer forward/rewind speed

Is it possible to configure how far MPlayer will skips when I press the arrow keys?
In the input.conf file, find the lines for "(UP|DOWN|RIGHT|LEFT) seek" and adjust the values for each one.