JamesHarrison / openob

The Open Outside Broadcast project for radio contribution links and studio-transmitter links.
158 stars 34 forks source link

Upgrade GStreamer to 1.0 #34

Closed jonty-comp closed 6 years ago

jonty-comp commented 6 years ago

NOTE! I have no actual broadcast infrastructure to test this on, just my trusty ThinkPad with Debian and JACK. That being said, it seems to work fine on there.

I don't recommend pushing this as a new version until at least someone else has tested it!

JamesHarrison commented 6 years ago

This looks fantastic - I'll try and get this set up for testing but on the face of it it looks good. Many thanks for breathing new life into the thing!

scottgrobinson commented 6 years ago

Seem to have problems with just firing up the TX side. RX seems happy. I'll start debugging, but posting here in the hope it's something you've come accross!

@jonty-comp @JamesHarrison

pi@ob-ob:~/openob $ openob 10.0.1.192 studio ob1 tx 10.0.1.192 -a test 2018-07-09 16:06:57,311 - openob.link.ob1.config - INFO - Connecting to configuration host 10.0.1.192 2018-07-09 16:06:57,325 - openob.node.studio - INFO - Link ob1 initial setup start on studio 2018-07-09 16:06:57,327 - openob.node.studio.link.ob1 - INFO - Starting up transmitter 2018-07-09 16:06:57,328 - openob.node.studio.link.ob1.tx - INFO - Creating transmission pipeline <openob.rtp.tx.RTPTransmitter object at 0x75ba05f0> Scott <gi.GstAudioTestSrc object at 0x75ba16e8 (GstAudioTestSrc at 0x25e6cd8)> (<gi.GstAudioTestSrc object at 0x75ba16e8 (GstAudioTestSrc at 0x25e6cd8)>,) 2018-07-09 16:06:57,399 - openob.node.studio.link.ob1 - ERROR - Transmitter crashed for some reason! Restarting... Traceback (most recent call last): File "build/bdist.linux-armv7l/egg/openob/node.py", line 45, in run_link transmitter = RTPTransmitter(self.node_name, link_config, audio_interface) File "build/bdist.linux-armv7l/egg/openob/rtp/tx.py", line 21, in init self.build_pipeline() File "build/bdist.linux-armv7l/egg/openob/rtp/tx.py", line 52, in build_pipeline self.source = self.build_audio_interface() File "build/bdist.linux-armv7l/egg/openob/rtp/tx.py", line 102, in build_audio_interface level.set_property('message', True) AttributeError: 'NoneType' object has no attribute 'set_property'

jonty-comp commented 6 years ago

It looks like your GStreamer install is missing the level element - I may have to add a pre-setup check for all the required elements. Do you have the gstreamer-plugins-good package installed? I'm slightly confused because that same plugin set contains pretty much all the other required plugins for OpenOB to function. Could you paste the output of the gst-inspect -a command here please?

scottgrobinson commented 6 years ago

Disregard - I was being really impatient and getting too excited about it possible working, Missing a few packages! "Full" instructions from a base linux image to up and running:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-setuptools git python-gst-1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good gstreamer1.0-tools python-gobject python-gobject-2 gstreamer1.0-alsa python-redis
git clone https://github.com/JamesHarrison/openob.git
cd openob
git fetch origin +refs/pull/34/merge
git checkout FETCH_HEAD
sudo python setup.py install

Can also confirm I can RX & TX correctly with this package using alsa. Having a few issues running two streams at once (RX & TX on both ends) but that's probably local audio config as both 'clients' are running correctly.

Thanks for this PR, much appreciated!

jonty-comp commented 6 years ago

Cool - no worries, gstreamer is a tangled mess of history! I believe you should only need gstreamer1.0-plugins-base and gstreamer1.0-plugins-good nowadays and not all the bad/ugly ones, but it can't hurt to have them. Opus encoder is even in base now, which is exciting!

jonty-comp commented 6 years ago

As you can see from above, i'm whipping up a little Travis build to test the basic functionality - it doesn't really work yet, but i'll hopefully look at it some more tomorrow!

JamesHarrison commented 6 years ago

@jonty-comp I've added Travis to the project, so that should auto-build on future commits.

@scottgrobinson If you could provide some feedback on how this is working for you, that'd be great - once it's looking stable we can merge this into master and roll a new "proper" release.

scottgrobinson commented 6 years ago

@JamesHarrison Will do! I'll be testing over the next few days in the hope it works nicely for an event at beginning of August.

jonty-comp commented 6 years ago

There we go - i've updated the packages required in the documentation, and tested on Dockerized versions of Debian Jessie, Stretch and Buster, and Ubuntu Trusty, Xenial and Bionic. This sounds like a lot of testing but it's very much not real-world - as I said, I don't have any audio equipment here!

Jessie & Trusty require gstreamer1.0-plugins-bad and apparently have a bug where the mono Opus test stream is decoded as stereo, but there's not much I can do about that bar backporting newer versions of gstreamer.

scottgrobinson commented 6 years ago

If I fire up a new Pi, what's the best way of testing this end to end for you? I assume I can't use pip yet until it's released? I could just follow the docs end to end and sub out 'sudo pip install OpenOB' for

git clone, switch to pr, python setup.py install?

jonty-comp commented 6 years ago

That's probably the easiest path, yes. In the most recent versions of pip you can run pip install git+https://github.com/JamesHarrison/openob.git@refs/pull/34/merge directly, but it looks like that's not in my Buster version of pip yet, so I doubt it'll be anywhere else.

e: looks like you can do pip install git+https://github.com/jonty-comp/openob.git@gst1.0, which will install directly from the fork that this PR is against.

scottgrobinson commented 6 years ago

Neither of the above commands worked: pi@ob-studio:~ $ /usr/local/bin/openob 10.0.1.192 studio ob1 rx -a alsa -d hw:1 -bash: /usr/local/bin/openob: No such file or directory

I had to checkout and run it as per previous comment. It's still referencing 3.1 as opposed to 4.0dev when building from git though.

Now having problems running without sudo so I'll start this over again.

Collecting git+https://github.com/jonty-comp/openob.git@gst1.0 Cloning https://github.com/jonty-comp/openob.git (to gst1.0) to /tmp/pip-hwqvxA-build Installing collected packages: OpenOB Running setup.py install for OpenOB ... done Successfully installed OpenOB-3.1.0

jonty-comp commented 6 years ago

That's bizarre...I don't know enough about pip to make any assumptions.

...oh wait, I just noticed that setup.py still references it as version 3.1.0, that'll be why! You should still be getting the latest code.

scottgrobinson commented 6 years ago

Maybe I was just too tired... Worked fine this time!

sudo apt install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gir1.2-gstreamer-1.0 python-gst-1.0 python-redis python-gi python-setuptools git redis-server python-pip sudo sed -i.bak 's/bind 127.*/bind 0.0.0.0/' /etc/redis/redis.conf && sudo service redis-server restart sudo pip install git+https://github.com/jonty-comp/openob.git@gst1.0

I've tested alsa RX and TX, anything else that would want testing before a merge?

EDIT: I forgot. To get alsa working I needed some extra packages. Not sure if it's just the alsa package or all of the below as I just ran this to be on the safe side: sudo apt-get install git python-gst-1.0 gstreamer1.0-plugins-base gstreamer1.0-plugins-base gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good gstreamer1.0-tools python-gobject python-gobject-2 gstreamer1.0-alsa python-redis

jonty-comp commented 6 years ago

Ah right, gstreamer officially lists alsa as being in the base package but I guess debian/ubuntu splits it out. Bizarre, as it seems jack is in the main package! I think if you could just continue to test it in your normal use-case, we can confirm that the stability hasn't been affected by the way I refactored the pipeline.

LyonelB commented 6 years ago

It's works ! With two Raspberry Pi ( 1 RPi 3 B & 1 RPi 3 B+) : $ sudo apt-get install python-gst-1.0 gstreamer1.0-plugins-ugly gstreamer1.0-tools python-gobject python-redis redis-server $ sudo sed -i.bak 's/bind 127.*/bind 0.0.0.0/' /etc/redis/redis.conf && sudo service redis-server restart $ sudo pip install git+https://github.com/jonty-comp/openob.git@gst1.0

scottgrobinson commented 6 years ago

FYI - Latest release is fully working and used in a 'production' environment successfully.

Both ends ran a TX & RX for two way (Only got the commands from studio end, OB end is somewhere in the field...)

RX: /usr/local/bin/openob 10.100.40.53 studio ob1 rx -a alsa -d hw:0 TX: /usr/local/bin/openob 10.100.40.53 studio ob2 tx 10.100.40.77 -a alsa -d hw:1 -p 3002

RX using RapsberryPi onboard TX using Behringer UCA202

JamesHarrison commented 6 years ago

Alright - I'm inclined to merge this into the master branch and cut a new release on PyPi as a new major version, given the positive feedback thus far. Any objections, shout, but if not I'll cut it in a day or two.

jonty-comp commented 6 years ago

Fine by me! I did some random work on another branch off this based on the daemon idea we discussed years ago, but I haven't finished it yet. Hopefully I'll get a chance to pick it up again sometime soon.

whohoho commented 6 years ago

This branch seems to work fine.

I put some patches in the issues to have the help display all options, and 1 to have jack autoconnect (portpattern). Should i submit these as a pull request?

https://github.com/JamesHarrison/openob/issues/36

https://github.com/JamesHarrison/openob/issues/35

JamesHarrison commented 6 years ago

@whohoho Yes, absolutely!

jonty-comp commented 6 years ago

Woo! Hopefully everyone can enjoy the new version without having to juggle old dependencies.

Just a quickie, I noticed setup.py and the documentation still reference old versions.

JamesHarrison commented 6 years ago

@jonty-comp I'm planning to scrap the gh-pages docs and just stick the relevant bits in the wiki in GitHub, tbh. setup.py I'd just forgotten to commit!