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

  • 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
  • 1
    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

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" &
| 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

GNU parallel

In your particular case:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.