LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-27-2017, 07:23 PM   #1
linux1021
Member
 
Registered: Jun 2016
Location: Washington State, USA
Posts: 78

Rep: Reputation: Disabled
Unhappy How to play a random 1 minute within a video with MPV player?


Hi!

I have an MPV command line that plays random videos, at full screen, at 16:9 scale, with sound off, but I read the MPV man page and did not see a "random time seeker" kind of thing, that allow me to seek and play a random minute of the video playing. Any ideas?

The MPV command that I running right now is:

mpv --shuffle --really-quiet --no-audio --fs --video-aspect=16:9 --no-stop-screensaver
--wid=$XSCREENSAVER_WINDOW $HOME/"ScreenSaver Videos"/*

Thanks in advance for your time and help.
 
Old 10-28-2017, 02:56 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
you need to somewhat modify the above command.
wrap it in a script that
  1. randomly chooses a video from that folder
  2. determines the length of the video
  3. chooses start- and endpoints inside the video's play time, 1 minute apart
  4. use that in your final command

Last edited by ondoho; 10-28-2017 at 02:58 AM.
 
Old 10-28-2017, 06:36 PM   #3
linux1021
Member
 
Registered: Jun 2016
Location: Washington State, USA
Posts: 78

Original Poster
Rep: Reputation: Disabled
Smile

Hi! ondoho

Thanks for the reply. The command line already chooses a file at random with the option --shuffle, the trick is to tell it, to only play a random minute of the video that it is selected by the --shuffle option in command line. Any ideas? Thanks for your time and help.
 
Old 10-29-2017, 03:49 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
you need to disable mpv's --shuffle option because you need to safely determine the length of the video first.
then you can fill --ab-loop-a=<time>, --ab-loop-b=<time> with random values.

of course you can try to set the times randomly and see what mpv makes out of them when they are beyond the video's playing time.
 
Old 10-31-2017, 05:44 PM   #5
linux1021
Member
 
Registered: Jun 2016
Location: Washington State, USA
Posts: 78

Original Poster
Rep: Reputation: Disabled
Hi! ondoho

Thanks for the reply. The command line already chooses a video at random with the option --shuffle from my "Screensaver Videos", folder located in the home folder. The --shuffle command option has to be there. How can I tell mpv to generate the values for your two commands automatically to play 1 minute at random? Is the real problem. Hopefully I explain my self clearly. Thanks for your time and help in advance.
 
Old 11-01-2017, 02:02 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
here's some pseudo code for you:
Code:
#!/bin/bash

file="$(shuf -n1 -e $HOME/"ScreenSaver Videos"/*)" # chooses a random file

filelength=$(do something to get $file's playing time, maybe with mpv, maybe with ffmpeg...)
start=$(( filelength - somerandomvaluethatcannotbelargerthanfilelengthminusoneminute ))
stop=...you get the picture

mpv --really-quiet --no-audio --fs --video-aspect=16:9 --ab-loop-a=$start --ab-loop-b=$stop --no-stop-screensaver
--wid=$XSCREENSAVER_WINDOW "$file"
it needs work - it's not a working script! - but it should give you an overview of what needs to be done.
and you really need to study
Code:
man mpv

Last edited by ondoho; 11-01-2017 at 02:03 AM.
 
1 members found this post helpful.
  


Reply

Tags
mpv, seek, video



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Play any video as a screensaver with mpv and xscreensaver trick/hack linux1021 Linux - Desktop 5 07-20-2022 09:30 AM
LXer: MPlayer-Based MPV 0.20.0 Video Player Released with New Options and Commands LXer Syndicated Linux News 0 08-29-2016 10:27 PM
LXer: MPV 0.17.0 Open-Source Video Player Adds a Direct3D11 Video Acceleration Decoder LXer Syndicated Linux News 0 04-12-2016 05:51 AM
LXer: MPlayer-Based MPV Video Player Reaches Version 0.13.0 with Multivolume Support LXer Syndicated Linux News 0 11-12-2015 01:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration