‹ solar cell with loudspeaker f06dof - Wireless Accelerometer+Gyro OSC ›

f0videoplayerOsc

2020-11-15 14:42 visuals

Making use of some old original Raspberry Pi Model A...

Despite having very little RAM (256MB) the Raspberry Pi Model A from 2012 can play video and sound in high resolution via HDMI. So here is how I set up four of them as independent remote-controlled video players. I used the program OMXplayer and the pyliblo and omxplayer-wrapper Python libraries. This setup will also work great with Raspberry Pi Zero and any other low-end model.

To control the players I use SuperCollider and send Open Sound Control messages, but other OSC capable programs or mobile apps will also work. There is a similar system that is controller via physical buttons (GPIO) described in the /f0blog/cheap-4-channel-videoplayer post.

Instructions for installing

This will require at a minimum a 4 GB SD card and a way to connect the Raspberry Pi to the internet.

Prepare the RPi

Copy over files

Autostart

Now the player should launch at boot and start looping a file in the home directory called video.mp4. Send OSC messages to port 9999 to control it (see below).

It is fairly easy to adapt and add new commands to the Python player script. See the omxplayer-wrapper documentation. One can also query and send back information - for example about current position in video.

Test

Here is some SuperCollider code for testing...

n= NetAddr("192.168.1.102", 9999);  //edit IP of your Raspberry Pi
n.sendMsg(\pause);
n.sendMsg(\play);
n.sendMsg(\set_position, 1000);
n.sendMsg(\set_position, 100);
n.sendMsg(\set_position, 10);
n.sendMsg(\hide);
n.sendMsg(\show);
n.sendMsg(\set_dimensions, 100, 100, 200, 200);
n.sendMsg(\set_dimensions, 0, 0, 1920, 1080);  //display dim
n.sendMsg(\set_crop, 100, 100, 200, 200);
n.sendMsg(\set_crop, 0, 0, 640, 360);  //movie dim
n.sendMsg(\set_volume, 0.0);  //0.0-10.0
n.sendMsg(\set_volume, 5.0);
n.sendMsg(\set_volume, 1.0);  //default
n.sendMsg(\set_rate, 1.0);
n.sendMsg(\set_rate, 0.75);
n.sendMsg(\set_rate, 0.5);
n.sendMsg(\set_rate, 0.01);
n.sendMsg(\set_rate, 1.0);  //default

//slow down
(
Routine.run({
  100.do{|i|
    n.sendMsg(\set_rate, i.linlin(0, 99, 1.0, 0.01));
    0.025.wait;
  };
});
)
n.sendMsg(\set_rate, 1.0);

//zoom out
(
Routine.run({
  var num= 100;
  var w= 1920, h= 1080;  //display dim
  num.do{|i|
    n.sendMsg(
      \set_dimensions,
      i.linlin(0, num-1, 0, w/2).asInteger,
      i.linlin(0, num-1, 0, h/2).asInteger,
      i.linlin(0, num-1, w, w/2+1).asInteger,
      i.linlin(0, num-1, h, h/2+1).asInteger
    );
    0.025.wait;
  };
});
)
n.sendMsg(\set_dimensions, 0, 0, 1920, 1080);

//zoom in
(
Routine.run({
  var num= 100;
  var w= 640, h= 360;  //movie dim
  num.do{|i|
    n.sendMsg(
      \set_crop,
      i.linlin(0, num-1, 0, w/2).asInteger,
      i.linlin(0, num-1, 0, h/2).asInteger,
      i.linlin(0, num-1, w, w/2+1).asInteger,
      i.linlin(0, num-1, h, h/2+1).asInteger
    );
    0.025.wait;
  };
});
)
n.sendMsg(\set_crop, 0, 0, 640, 360);

//stop and shut down the Raspberry Pi
n.sendMsg(\shutdown)

References

github.com/redFrik/yetanotheroscmovieplayer

github.com/avilleret/rpi_osc_video_player

Attachments:


‹ solar cell with loudspeaker f06dof - Wireless Accelerometer+Gyro OSC ›