It is currently 22 Jun 2017, 19:20



Suggestion - an alternative to OSC...?

CasparCG Server, Client and development

Moderators: Macey, Jonas Hummelstrand, didikunz

Suggestion - an alternative to OSC...?

Postby bern333 » 28 Aug 2016, 11:05

Having extended my Livecode lower thirds client to include a clip player and multiple outputs (I'm very proud of this, having only started with Livecode a few weeks ago) - I thought it would be really good to have a countdown clock on the running clip, just like the stock client only bigger.

Like lots of others here, I read that there's an OSC output and thought it would be easy. But as it turns out OSC isn't exactly friendly for the amateur coder who's really a TV person in disguise (lots of those here). Like them, I thought OSC would be text.

I couldn't even make the stuff show up. It took me a while to work out, thanks to someone called Ultravibe, that you have to listen on 6250. 5253 gets a mention on the docs, but I don't know what it does. Is that where you send the RegisterMethod command? If only people would write clear documentation. Still, the problems with the CasparCG docs pale into insignificance against those with Livecode.

Anyway - now I can see the OSC bundles and that leads to a suggestion....

I wonder if it would be possible for the people who kindly write CasparcG to maybe provide a different output for simple stuff, like the countdown clock, or any kind of clip timer, for people who can't manage taking apart a varying length binary string. It could be straight text, once every frame. I could work with that. I would have thought it would be fairly straightforward for someone who knows what they are doing, as the info is there being encoded into OSC, and the code is there for making sockets happen. Maybe there's other simple stuff that people need that can be sent in the large gaps.

Here's hoping

Bernard Newnham
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby didikunz » 28 Aug 2016, 13:09

You can try the INFO commands, they also give back some framecounts. It's not simple text but XML. But it's probably easier to interprete.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 28 Aug 2016, 22:48

Ah-ha!

Thanks for that, I'll give it a try. Still somewhat overkill for something you need 25 times a second, but hopefully the system will cope.

This is the result of sending INFO 1 - a lot of stuff.

Do we know what <auto_delta>, <nb_frames> and <frame-age> mean?

Code: Select all
#201 INFO OK
<?xml version="1.0" encoding="utf-8"?>
<channel>
   <video-mode>PAL</video-mode>
   <stage>
      <layers>
         <layer>
            <status>playing</status>
            <auto_delta>-1</auto_delta>
            <frame-number>494</frame-number>
            <nb_frames>11113</nb_frames>
            <frames-left>10620</frames-left>
            <frame-age>41</frame-age>
            <foreground>
               <producer>
                  <type>ffmpeg-producer</type>
                  <filename>media\fish_divx.avi</filename>
                  <width>768</width>
                  <height>576</height>
                  <progressive>true</progressive>
                  <fps>25</fps>
                  <loop>false</loop>
                  <frame-number>494</frame-number>
                  <nb-frames>11113</nb-frames>
                  <file-frame-number>494</file-frame-number>
                  <file-nb-frames>11113</file-nb-frames>
               </producer>
            </foreground>
            <background>
               <producer>
                  <type>empty-producer</type>
               </producer>
            </background>
            <index>0</index>
         </layer>
         <layer>
            <status>playing</status>
            <auto_delta>-1</auto_delta>
            <frame-number>121</frame-number>
            <nb_frames>11113</nb_frames>
            <frames-left>10993</frames-left>
            <frame-age>41</frame-age>
            <foreground>
               <producer>
                  <type>ffmpeg-producer</type>
                  <filename>media\fish_divx.avi</filename>
                  <width>768</width>
                  <height>576</height>
                  <progressive>true</progressive>
                  <fps>25</fps>
                  <loop>false</loop>
                  <frame-number>121</frame-number>
                  <nb-frames>11113</nb-frames>
                  <file-frame-number>121</file-frame-number>
                  <file-nb-frames>11113</file-nb-frames>
               </producer>
            </foreground>
            <background>
               <producer>
                  <type>empty-producer</type>
               </producer>
            </background>
            <index>1</index>
         </layer>
      </layers>
   </stage>
   <mixer>
      <mix-time>1</mix-time>
   </mixer>
   <output>
      <consumers>
         <consumer>
            <type>decklink-consumer</type>
            <key-only>false</key-only>
            <device>1</device>
            <low-latency>false</low-latency>
            <embedded-audio>false</embedded-audio>
            <presentation-frame-age>277</presentation-frame-age>
            <index>301</index>
         </consumer>
         <consumer>
            <type>ogl-consumer</type>
            <key-only>false</key-only>
            <windowed>true</windowed>
            <auto-deinterlace>true</auto-deinterlace>
            <index>600</index>
         </consumer>
      </consumers>
   </output>
   <index>0</index>
</channel>

Thanks again

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 29 Aug 2016, 10:44

Also - thinking about it - I've spent more time than almost anyone in the world of tv - just over fifty years now - most at the BBC, and as a producer /director the only things I ever cared about in a clip are "how long on this?" "what are the out words?" "how does it end?" Perhaps someone out there might want all the other OSC stuff, but I can't imagine who.

CasparCG can't supply me with the out words etc, but it could easily tell me when the piece will end, and it would be really useful to have that accessible to simple people like me, writing code for free.

So my earlier request stands - how about a different socket that just supplies timing info? Meanwhile I shall take apart the INFO command.....

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby didikunz » 29 Aug 2016, 11:03

I like the idea. You could post a feature request on GiHub. Link in my signature. I just wanted to show you a quick solution to your problem.

By the way: I looked up an old code, that I wrote a few years back: /layer/frame-number is the current frame and /layer/nb_frames the total framecount of the playing clip. Subtract one from the other and you get remaining time. But be carefull in writing your code, if I remember right, it was not accurate short after a new clip starts playing, so your code needs to be a bit tolerant... :)
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Suggestion - an alternative to OSC...?

Postby mcdikki » 29 Aug 2016, 11:22

Your problem is not a new one. I came up with it a few years ago (before OSC was introduced for CCG). Getting the timing information of a playing clip is crucial.
I first solved it with the info command as didi suggested you. This works but is far from being elegant or reliable.
Then OSC was introduced and I changed to it. But it has some down sites two. The technology used (UDP) does not guaranty that the OSC messages arrives in order or that they arrive at all. So we could miss frames and receive messages for older frames after newer ones. This makes it not reliable enough for exact timing.
And to add problems, there is also a BUG with the frame count. Somehow, ccg does have two different ways to count the number of frames for a clip. This leads to the problem that the current frame number does not change close to the end of a clip, no matter if you receive it via OSC or the INFO command. It just will never reach the total frame number leaving you in the dark whether the clip has been played completely or not.

So, I really support your wish for a good and easy way of receiving timing information of running clips.

Cheers
mcdikki
sublan.tv - Wir teilen Begeisterung
User avatar
mcdikki
 
Posts: 1059
Joined: 11 Dec 2012, 15:48
Location: Germany

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 29 Aug 2016, 16:51

didikunz wrote:I like the idea. You could post a feature request on GiHub. Link in my signature.

That's much appreciated, but I have no idea how to do it.

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby didikunz » 29 Aug 2016, 19:06

bern333 wrote:
didikunz wrote:I like the idea. You could post a feature request on GiHub. Link in my signature.

That's much appreciated, but I have no idea how to do it.

B


Klick here: https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FCasparCG%2FServer%2Fissues%2Fnew create an account, if you don't already have and then a form appers, where you can post the idea.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 29 Aug 2016, 20:43

Thank you. That's done.

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 31 Aug 2016, 11:37

I don't know how things work on Github. Do the developers read and pronounce on whether they are going to make the addition? There's been several comments from people who don't entirely see the problem -
https://github.com/CasparCG/Server/issues/470

Perhaps a few more TV people could join in and add their voices to mine.

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 01 Sep 2016, 15:23

Having posted my request at Github I now seem to have people sort of acknowledging that its a problem that needs solving -

Of course OSC (over UDP) may and can be used for better timing but there are even many user cases where frame accurate feedback is not required but simple and clear implementation is recommended.

...yes, absolutely.

Maybe they'll be able to sort out something for us tv people who aren't mighty coders.

Meanwhile I've managed to make the INFO command come up with countdown information, but it seems to flood the socket enough that if you send a stop command nothing happens, especially after say 45 seconds. I'm only asking every half second.

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby maurice78 » 01 Sep 2016, 18:30

hi bernie

It makes sense to have a mechanism to have a very simple countdown / progress info mechanism of some sort.
its no problem to be less accurate (it will be used for countdowns on comms, or to background load a clip in a play list)

I'm a livecoder too!
I guess livecode is a perfect solution for people.
1. that have a little or no programming background.
2. need to build something quick and dirty.
3. their daily task is not programming.

OSC is indeed quite a thing inside livecode as there are no lib's to be found except that single one
which is hard to get to work.

the other solution is the bulky info command !
In my workfield i have a lot off layers and or channels in use.
if all layers start to produce time info it can become quite a jungle.

I think it's quite important to have a command to ask ONCE to have info about a specific layer.
and that other layers stay quite !

grt
maurice
maurice78
 
Posts: 122
Joined: 28 May 2013, 21:51

Re: Suggestion - an alternative to OSC...?

Postby didikunz » 01 Sep 2016, 19:52

Hi Maurice, I second this.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Suggestion - an alternative to OSC...?

Postby balte » 08 Sep 2016, 05:51

Hi Bernie333,

In reply to your latest response on Github:

if you do endtime = starttime + frames / framerate and then compare the endtime to the current time it should be accurate. If not you should debug the calculation as time based calculations can be tricky in computer languages.

Try to do a manual calculation to see if the info command returns the right amount of frames as well. And/or perhaps use the official CasparCG Client to see if that gives a correct countdown.
CasparCG enthusiast and broadcast geek - Sometimes, I do get payed for this stuff.
User avatar
balte
 
Posts: 264
Joined: 24 Jan 2015, 16:23
Location: The Netherlands, Goeree Overflakkee

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 08 Sep 2016, 10:25

CasparCG appears to be working correctly. The duration of a clip when played matches the stopwatch, Premiere Pro and VLC. What doesn't work is the Livecode countdown clock loop which seems to run consistently slow.

I'm using this way of doing things because OSC is too complex for my programming skills (and lots of others it seems). Originally I asked on Github - at others recommendation - for a simple method for CasparCG to send time info, maybe down a different socket, and maybe every 25th of a second. Looking around many forums it turns out that I'm far from the first to ask for this, and given that the data is there and the structures for making sockets are there it doesn't seem to be unreachable - though the skills are well beyond me.

Anyway, having not had a "Yes you are right, we should do it immediately" on Github, I loked around for ways to do a lesser job. Getting INFO at the beginning and free running the counter is a fix but as it is currently turning out not a great fix, but it's a problem in Livecode not CasparCG. It wouldn't be a problem at all if there was the appropriate code in CasparCG.

So I'm currently hosting a thread in the Livecode forum where people are trying to help me get the job done.

http://forums.livecode.com/viewtopic.php?f=7&t=27908&sid=cffa7321e8626661ed950f5346d70ad1

Thanks
Bernie
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby bern333 » 11 Sep 2016, 11:22

If anyone is looking for a reasonably accurate countdown clock for a Livecode CasparCG client, I've finally made one.

There are lots of Livecode timer scripts around, but most have the same failing - they use the basic Livecode construct "send xxx to me in yyy milliseconds". This is the only way to run a non-blocking loop in Livecode but the send buffer has varying amounts of messages in it, so the counter isn't accurate - on my 7.44 test clip it could be 20" out.

After I started looking at ways of using Unix time, I found a code snippet kindly provided by someone on Stackoverflow which uses Unix time in the loop to subtract an exact number of milliseconds. Now my countdown is accurate enough for studio use. It can't be exactly accurate because it reads the frame count from datagrid info at the same time as it send the PLAY command, and they can't be exactly in sync.

When CaparCG implements its simple time info, all this will be unnecessary.

Find the Livecode loop code here -
http://forums.livecode.com/viewtopic.php?f=7&t=27908&start=15

Bernie
Last edited by bern333 on 25 Sep 2016, 23:22, edited 1 time in total.
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Suggestion - an alternative to OSC...?

Postby Jesper Stærkær » 11 Sep 2016, 17:57

Cool Bernie! You did it.
Jesper Stærkær
Independent Consultant at SuperFly.tv
User avatar
Jesper Stærkær
 
Posts: 853
Joined: 13 Apr 2010, 18:06
Location: Trondheim, Norway

Re: Suggestion - an alternative to OSC...?

Postby maurice78 » 25 Sep 2016, 20:53

Interesting Bernie
i will ad your code snip in my livecode toolbox :)
will have a quick look at it later this week when i am behind a server.

just for all the code
Code: Select all
    -- @@@@@@@@@@@@@@@@@@@@@@@@@

    local lStartTime, lTimerTime

    on showTime
       put the milliseconds into lStartTime --put current Unix time into a variable
       put lStartTime +  totalsecs * 1000 into lTimerTime -- add to it the start duration of the clip in milliseconds
       runTimer -- run the handler below
    end showTime

    on runTimer
       put lTimerTime - the milliseconds into tTimeLeft
        -- So, subtract the current Unix time which is bigger now,  from the result in showTime above which is lTimerTime.
       -- The difference is smaller - so we're counting down

      -- to keep consistency with the rest of the system I put the current duration in seconds back into totalsecs
       put tTimeLeft/1000 into totalsecs

      then
              -- do the time maths
          set numberformat to "xx"
          put totalsecs div 3600 into xhrs
          put (totalsecs mod 3600) div 60 into xmins
          put trunc((totalsecs mod 3600) mod 60) into xsecs
         
          --put the numbers on the screen
          put xhrs into  field "xHr"  of card "pop1" of stack "pop"
          put xmins into  field "xMin"  of card "pop1" of stack "pop"
          put xsecs into  field "xSec"  of card "pop1" of stack "pop"
         
          --then
          send "runTimer" to me in 100 milliseconds
          -- this loops in a nominal 100mSecs but it doesn't matter if it's inaccurate
       
       else  -- we're done with this
             -- change the button setup
       set the disabled of button "player1"  of card "clipper" of stack "main" to "false"
       --reset everything
       set the cMediaOnFlag of stack "main" to 0        --reset the clip running flag
       set the visible of field "board1"  of card "clipper" of stack "main" to "false"  -- don't show the "clip playing" sign
       put 00 into field "xSec"  of card  "pop1" of stack "pop"  -- put 00s on the screen
       put 00 into field "xMin"  of card  "pop1" of stack "pop"
       put 00 into field "xHr"  of card  "pop1" of stack "pop"
       put 0 into xsecs    -- reset the variables
       put 0 into xmins
       put 0 into xhrs
       end if
    end runTimer
         


soo you will find it in this thread.

grt
maurice
maurice78
 
Posts: 122
Joined: 28 May 2013, 21:51

Re: Suggestion - an alternative to OSC...?

Postby laroca » 19 Mar 2017, 16:03

Hi, i recently made a time module in a client that i stay creating in live code. This module contains three differents timers: a real time clock, a chrono with the capability of show just seconds and minutes or seconds, minutes and hours. And the last option is a countdown. For now im just use a single template that i create one year ago, but the idea is to create a module when i can choose an specific template for any timer. The client is made in spanish becouse i'm from Colombia. I use a rutine to send info to Caspar second by second, for this reason the timer can take a short delay, but for my needs work very good. I can make it in more perfect sync, but then i will need to send the info to caspar in most short intervals of time and I dont know if i send a lot of instructions to the server this can collapse. For now i make some test putting the all timers working at same time for about 3 hours and work fine. This is the view of my module. If someone have a question that how its works please let me know.
Attachments
Timer.jpg
Timer.jpg (24.36 KiB) Viewed 872 times
laroca
 
Posts: 15
Joined: 30 Mar 2016, 19:25


Return to Tech and Development

Who is online

Users browsing this forum: Bing [Bot] and 7 guests