Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two videos and need to play them (by mplayer) exactly at the same time. How to do that ?

share|improve this question
Write a bash script? – Cole Johnson Aug 18 '12 at 6:04
can be, but how it looks like ? – marioosh Aug 18 '12 at 6:07
Just put the shebang line followed by the two commands I beleive – Cole Johnson Aug 18 '12 at 6:08
What do you mean by playing at the same time? Do you mean, on the same screen, using the same instance of mplayer, on multiple screens, on multiple workspaces, on different computers on the network?,.... Or do you mean to merge two videos into a single video? – Peter.O Aug 18 '12 at 6:09
I mean two instances of mplayer (two windows) simply. I want to see the difference beetween that videos. – marioosh Aug 18 '12 at 6:10
up vote 8 down vote accepted

Start up multiple background tasks. This means that the second one does not need to wait for the first one to finish loading. The & tell the command to run in the background.

From the command-line: In the first one, the number of . (dots) equals the number of instances.

set "/my/vid/path.mp4"   
for i in . . ;do (mplayer "$1" &) ;done   


set "/my/vid/path.mp4"; ( 
mplayer "$1" &
mplayer "$1" & )


( mplayer "/my/vid/path.mp4" &
  mplayer "/my/vid/path.mp4" & ) 

Or in a script called by play-two "/my/vid/path.mp4"

mplayer "$1" &
mplayer "$1" &
share|improve this answer
I get bash: syntax error near unexpected token ;'` – marioosh Aug 18 '12 at 6:24
You can put the commands on different lines. It is working fine for me.. I have just loaded 2x 4GB matroska vids and the synchronization is perfect... It is an interesing effect, for some clips :) – Peter.O Aug 18 '12 at 6:26
Thanks. Last option works good for me :) – marioosh Aug 18 '12 at 9:10

GNU parallel

In your particular case:

parallel  mplayer ::: file1.avi file2.avi
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .