jaskie / Server

This fork of CasparCG Server contains enhancements used in broadcast play-out system used in TVP.
http://playoutautomation.tvp.pl
GNU General Public License v3.0
20 stars 4 forks source link

Wrong information in INFO command (FFMpeg producer) and broken LOADBG AUTO in 7.3a #5

Closed martastain closed 4 years ago

martastain commented 4 years ago

When INFO 1-1 command is executed while the media file is playing, 7.0a correctly returns information about file position and duration.

7.0A

<layer>
   <status>playing</status>
   <auto_delta>-1</auto_delta>
   <frame-number>45</frame-number>
   <nb_frames>1500</nb_frames>
   <frames-left>1456</frames-left>
   <frame-age>123</frame-age>
   <foreground>
      <producer>
         <type>ffmpeg-producer</type>
         <filename>c:\playout\media.dir\pxd.mxf</filename>
         <width>1920</width>
         <height>1080</height>
         <progressive>false</progressive>
         <fps>25</fps>
         <loop>false</loop>
         <nb-frames>1500</nb-frames>
         <file-frame-number>44</file-frame-number>
         <file-nb-frames>1500</file-nb-frames>
      </producer>
   </foreground>
   <background>
      <producer>
         <type>empty-producer</type>
      </producer>
   </background>
   <index>1</index>
</layer>

With the same configuration, media file and scenario, 7.3a does not return information about position and duration and frame-rate information is wrong.

7.3a

<layer>
   <status>playing</status>
   <auto_delta>-1</auto_delta>
   <frame-number>130</frame-number>
   <nb_frames>0</nb_frames>
   <frames-left>-129</frames-left>
   <frame-age>120</frame-age>
   <foreground>
      <producer>
         <type>ffmpeg-producer</type>
         <filename>c:\playout\media.dir\pxd.mxf</filename>
         <width>1920</width>
         <height>1080</height>
         <progressive>false</progressive>
         <fps>1</fps>
         <loop>false</loop>
         <nb-frames>0</nb-frames>
      </producer>
   </foreground>
   <background>
      <producer>
         <type>empty-producer</type>
      </producer>
   </background>
   <index>1</index>
</layer>

Additionally, when LOADBG 1-1 otherfile AUTO is called, otherfile starts playback immediately and does not wait for the foreground clip end. My guess it is related to the fact that Caspar reads the duration of the foreground clip as 0 frames (and frames-left <= 0) and therefore assumes it is time to switch to the background.

Tested with DNxHD and XDCAM HD media files.

jaskie commented 4 years ago

@martastain, I just fixed the issue. As AMCP INFO command isn't well documented, the format of response will be as follows:

<?xml version="1.0" encoding="utf-8"?>
<layer>
   <status>playing</status>
   <auto_delta>-1</auto_delta>
   <frame-number>38</frame-number>
   <nb_frames>300</nb_frames>
   <frames-left>263</frames-left>
   <frame-age>122</frame-age>
   <foreground>
      <producer>
         <type>ffmpeg-producer</type>
         <filename>media\timecode.mov</filename>
         <file-width>720</file-width>
         <file-height>608</file-height>
         <file-fps>25</file-fps>
         <file-progressive>false</file-progressive>
         <fps>25</fps>
         <loop>false</loop>
         <nb-frames>300</nb-frames>
         <frame-number>37</frame-number>
      </producer>
   </foreground>
   <background>
      <producer>
         <type>empty-producer</type>
      </producer>
   </background>
   <index>0</index>
</layer>

It's important to say that file-fps and channel fps may have distinct, non-integral values, so internal calculations are time, not frame-based. Look it it's OK for your needs. However, I didn't replicated the second issue - with immediate LOADBG AUTO command. Can you share a file that causes the problem (the "first" one, not the "otherfile"), as I work from home this week. Please test with attached executable, as it have many, yet not well tested changes. casparcg.zip

martastain commented 4 years ago

It looks that the LOADBG AUTO issue really was linked to the first one and with this build, it works again. My wild guess is that "foreground_->nb_frames()" in the core/producer/layer.cpp:131 had the same (zero) value as in INFO.

Having both and totally makes sense to me. Thanks.