Using mpv to escape start and end of videos (like in anime, tv shows etc)

Introduction

Sometimes we like to watch cool starting and ends of videos (like the heart touching ending), but after a time those could become repetitive and boring. Also, if you are just starting to watch a series recommended by others, those extra 5 minutes could be saved to watch next video and progress quickly. In this tutorial, I wish to tackle that problem. Since I love mplayer/smplayer for playing most videos, I am not going to deviate from those lines. Therefore, I am going to use mpv (mpv is a fork of mplayer2 and MPlayer) for our purpose.

Commands

a. Start at a specific time

$ mpv --start=80 <file-name>

Here we skipped 80 seconds of the video. Similarly there are options like 01:10:00 to seek 1 hour 10 minutes, 50% to start playing at middle.

b. If you know the length you can use

$ mpv --start=3:20 --length=10 <file-name>

This seeks to 3 minutes 20 seconds and only plays 10 seconds of the video. You can see all of these examples in mpv manual (man mpv).

c. Specifying end

$ mpv --start=30 --end=40 <file-name>

In this case video seeks to 30 seconds and ends at 40 seconds. i.e plays for 10 seconds.

d. Specifying end from end

$ mpv --start=80 --end=-90 <file-name>

In this case video seeks to 80 seconds at the beginning and ends 1 minutes 30 seconds from end. In my opinion this use case is suitable for our purpose. If we can figure out roughly when the videos in the series start and roughly when the videos end, we can specify the section, in the middle which we are going to watch (i.e waste least amount of time for those starting and endings).

Playing a series

One file does not make a series. i.e we need to play a lot of files. Thankfully in most cases most of our videos are listed sequentially in a directory. We can just use wild card character (*) with our extension to play all the videos.

$ mpv --start=80 --end=-90 *.mpv

Or we can also use this command (we are listing each file in this case, but the end result is same)

find . -name "*.mkv" -exec mpv --start=80 --end=-90 {} \;

This command will play all the files in current directory with our start and end time specified on each. However, not always we sit and watch the whole series. Let’s say you have already watched first 20 videos on this directory and you want to watch the rest. In that case, we need to create a playlist and delete the part we have already watched (or don’t want to watch). To create a playlist using files in current directory use this command.

$ find -maxdepth 1 -type f -name \*.\* | sort > playlist.pls

Open up the “playlist.pls” file in your favorite text editor and delete the lines you don’t want to watch. If your use case is little complex (nested directories), search how to create playlist for mplayer (they are just one file name with path per line).

Now to play the files

$ mpv --start=80 --end=-90 --playlist=playlist.pls

Note: If it starts playing at random number (this might be the error only in my case), use the mpv interface to set to the first file. Also make sure to comment save-position-on-quit=”yes” option in ~/.mpv/config file (if you had set one and if videos are not playing at specific time). If it still does not work, make sure to delete all the files inside ~/.mpv/watch_later directory.

Conclusion

I hope you will find these commands useful for watching your favorite shows (of course if you have legal offline copies) :)

 References

  1. http://zuttobenkyou.wordpress.com/2009/01/17/how-to-quickly-make-a-playlist-for-mplayer/
  2. http://mpv.io/

 

About these ads

3 Comments

Filed under Uncategorized

3 responses to “Using mpv to escape start and end of videos (like in anime, tv shows etc)

  1. Thanks this is pretty awesome, much appreciated! If you don’t mind, I’m going to copy this and keep it for future reference, always nice to be able to pass it on to the mates who are interested! And yes, ALL my series are legal!! :-) :-) Thanks again!

  2. Play a interval of a video, this is super cool!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s