It is currently 24 Jun 2017, 07:48



CINF doesn't update info

Moderators: Macey, Jonas Hummelstrand, didikunz

CINF doesn't update info

Postby juanidiaz » 09 May 2017, 21:42

Hello everyone, to the best of my possibilities I look for this specific issue on the forum and I found a couple notes about similar cases but not my exact problem. So here it is:

I need to know the duration of five audio files in my media folder every 10 minutes and based on this info I calculate the playout times. The files are updated constantly (overwritten) and the duration varies all the time. The script I'm using (AS in the template) is based in the info from CINF using this line:
Code: Select all
CINF "FileName"


The problem with this method is that the duration returned by CINF does not update with every new version of the audio files. It will return the duration of the very first version. If I restart CasparCG is see the duration info updated, but once again it will not change once the files change.

For example if I request the duration of the file TONE1.MP3 (when the file length is 11s 64 ms) I get this:
Note the command sent was CINF "TONE1"

Code: Select all
[2017-05-09 16:28:56.214] [08DB22A8] [info]    Received message from 127.0.0.1: CINF "TONE1"\r\n
[2017-05-09 16:28:56.224] [07CF5FB0] [warning] [ffmpeg] [mp3 @ 0D190500] max_analyze_duration 50000 reached at 72000
[2017-05-09 16:28:56.233] [07CF5FB0] [warning] [ffmpeg] [mp3 @ 0D190500] Estimating duration from bitrate, this may be inaccurate
[2017-05-09 16:28:56.241] [07CF5FB0] [debug]   Executed command: CinfCommand
[2017-05-09 16:28:56.246] [07CF5FB0] [info]    Sent message to 127.0.0.1: 200 CINF OK\r\n"Tone1"  AUDIO  272513 20170509171123 11 1/1\r\n\r\n\r\n


From this result the last line shows the lenght of the audio file is 11 seconds (CINF omits milliseconds):
"Tone1" AUDIO 272513 20170509171123 11

Then If I update the file TONE1.MP3 with a file longer or shorter and I send the same command. The result is almost the same

Code: Select all
[2017-05-09 16:34:49.948] [08DB22A8] [info]    Received message from 127.0.0.1: CINF "TONE1"\r\n
[2017-05-09 16:34:49.953] [07CF5FB0] [debug]   Executed command: CinfCommand
[2017-05-09 16:34:49.957] [07CF5FB0] [info]    Sent message to 127.0.0.1: 200 CINF OK\r\n"Tone1"  AUDIO  67457 20170509171250 11 1/1\r\n\r\n\r\n


Note the file-size and modify date-time stamp of the file is updated... but the length stays the same; It shows again the file being 11 seconds long: "Tone1" AUDIO 67457 20170509171250 11.


Is there any way around this?
Any idea what gets dumped once CasparCG is restarted? Perhaps there is a way to manually do that?
I've tested this behaviour with versions 2.0.6 and 2.0.7.
User avatar
juanidiaz
 
Posts: 11
Joined: 10 Jul 2016, 23:56

Re: CINF doesn't update info

Postby balte » 10 May 2017, 07:12

There is no way around this.

If bitrates of the files are consistent, use the file-size to calculate a duration in your client.
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: CINF doesn't update info

Postby didikunz » 10 May 2017, 07:53

balte wrote:There is no way around this.

If bitrates of the files are consistent, use the file-size to calculate a duration in your client.


That is kind of a hack. There must be an audio library for your programming langauge, that can give you the information more accurate. (You can get the path to the media folder via INFO PATHS, dependant on your config entries).
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: CINF doesn't update info

Postby juanidiaz » 10 May 2017, 15:47

This sounds like a good approach.. thank you balte.
balte wrote:If bitrates of the files are consistent, use the file-size to calculate a duration in your client.


Now the next step is to correctly calculate the length... or as close as possible.

Has anyone calculate MP3 clip duration based on file size?

I'm working with MP3 files with this settings. This is the information (unsign MediaInfo) of a file 14.256 seconds long:

=== Audio ===
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Mode : Joint stereo
Mode extension : MS Stereo
Duration : 14 s 256 ms
Bit rate mode : Constant
Bit rate : 192 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Compression mode : Lossy
Stream size : 334 KiB (100%)
Writing library : LAME3.99.5


I've found some info online about calculating size file based on duration... just reworked the formula and got to:

CLIP DURATION = ( FILE SIZE in bytes) * (8 to change byte to bits) / ( BIT RATE)

There is a small difference (of about 0.3s) in the calculations... I guess I'll have to live with it.

If anyone has another way to calculate please feel free to share.

Thank you all
User avatar
juanidiaz
 
Posts: 11
Joined: 10 Jul 2016, 23:56

Re: CINF doesn't update info

Postby didikunz » 10 May 2017, 16:33

didikunz wrote:That is kind of a hack. There must be an audio library for your programming langauge, that can give you the information more accurate. (You can get the path to the media folder via INFO PATHS, dependant on your config entries).


...as I said, there must be a better way by inspecting the files directly via an audio programming library.
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: CINF doesn't update info

Postby balte » 10 May 2017, 17:31

I agree that Didi's solution is preferred. This would require access to the files though.

The inaccuracy you have can only be solved by having access to the actual files as well. This is due to the difference in the defined CBR and the active or actual bitrate. Also note, the longer your files are, the more inaccurate the calculation will be.
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: CINF doesn't update info

Postby zbang » 11 May 2017, 06:21

Wasn't there a change in server 2.10 whereby you can give a complete file name on CINF? If so, that might query the file each time; haven't tried this

Otherwise, I think you're stuck with going outside of casper to get the info. If the files are small enough, create them as uncompressed audio; you can fairly accurately calculate the duration from the size then.

Or... I'm guessing that the file info is picked up during thumbnail creation when the server starts. Doesn't the server then watch the media directories for changes so it can create new thumbs? If so, it might be able to pick up changes to non-image files and update the DB. (I don't have time to either try this nor look at the code right now.)

z!
zbang
 
Posts: 44
Joined: 10 Apr 2015, 02:09

Re: CINF doesn't update info

Postby mcdikki » 11 May 2017, 07:52

why don't you load the file to the background of an unused layer with
Code: Select all
loadbg 1-10000
info 1-10000 b

and query the layer info. You should then find the correct values in the returned xml.

The difference between your calculation and the the real file length post probably comes from the file headers.
You should subtract the mp3 file header size before dividing the file size by the bitrate.
Problem there, the file header size may be different for each file depending on the amount of mp3 tags and metadata.

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


Return to General discussions

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests

cron