MediaArea / MediaConch_SourceCode

Media conformance checker
https://MediaArea.net/MediaConch
BSD 2-Clause "Simplified" License
27 stars 18 forks source link

Media Conch Allow comparison between properties #762

Closed joe-sciame-wm closed 4 months ago

joe-sciame-wm commented 1 year ago

Hi Jerome, An interesting use came up this week that we didn't have a good way to solve in media conch. The issue was out of order tracks. In some cases, tracks can get out of order and we wanted to add a check that the audio was after video in the ordering. Because we aren't able to compare different tracks' values, we ended up making sure that the video was the first stream, but we are worried this may be too restrictive across all the formats.

Thoughts on a capability to be able to compare two values across tracks?

General
Complete name                            : /Users/jsciame/Downloads/SAOC3793H_ordered.mov
Format                                   : MPEG-4
Format profile                           : QuickTime
Codec ID                                 : qt   0000.02 (qt  )
File size                                : 555 MiB
Duration                                 : 22 s 23 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 211 Mb/s
Frame rate                               : 29.970 FPS
Writing application                      : Lavf60.3.100

Video
ID                                       : 2
Format                                   : ProRes
Format version                           : Version 0
Format profile                           : 422 HQ
Codec ID                                 : apch
Duration                                 : 22 s 22 ms
Bit rate mode                            : Variable
Bit rate                                 : 202 Mb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 29.970 (30000/1001) FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:2
Scan type                                : Interlaced
Scan type, store method                  : Interleaved fields
Scan order                               : Top Field First
Bits/(Pixel*Frame)                       : 3.254
Stream size                              : 531 MiB (96%)
Writing library                          : apt0
Default                                  : Yes
Alternate group                          : 1
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio #1
ID                                       : 1
Format                                   : PCM
Format settings                          : Little / Signed
Codec ID                                 : in24
Duration                                 : 22 s 23 ms
Bit rate mode                            : Constant
Bit rate                                 : 6 912 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Lb Rb
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 18.1 MiB (3%)

Audio #2
ID                                       : 3
Format                                   : PCM
Format settings                          : Little / Signed
Codec ID                                 : in24
Duration                                 : 22 s 23 ms
Bit rate mode                            : Constant
Bit rate                                 : 2 304 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Bit depth                                : 24 bits
Stream size                              : 6.05 MiB (1%)
Default                                  : Yes
Alternate group                          : 2

Other
ID                                       : 4
Type                                     : Time code
Format                                   : QuickTime TC
Duration                                 : 22 s 22 ms
Frame rate                               : 29.970 (30000/1001) FPS
Time code of first frame                 : 00:00:00;00
Time code of last frame                  : 00:00:21;29
Time code, stripped                      : Yes
Language                                 : English
Default                                  : No
JeromeMartinez commented 1 year ago

Because we aren't able to compare different tracks' values, we ended up making sure that the video was the first stream, but we are worried this may be too restrictive across all the formats.

With first video StreamOrder == 0, right? If you want to catch e.g. also content with time code first, you may add "or (first video StreamOrder == 1 && first audio StreamOrder == 2)".

Thoughts on a capability to be able to compare two values across tracks?

If I understand correctly, the idea is to be able to have a rule e.g. "first video StreamOrder < first audio StreamOrder", right? Not yet implemented but something we could add.

joe-sciame-wm commented 1 year ago

Yes, the idea is a multi stream comparison where "first video StreamOrder < first audio StreamOrder".

JeromeMartinez commented 5 months ago

@joe-sciame-wm you may test this snapshot (for CLI) or this snapshot (JS). GUI is not yet ready, you have to write the policy by hand but the way to write it is not difficult.

With e.g.

p2a.xml (the policy corresponding to your example):

<policy type="and" name="Video before audio">
  <description>Check if video is before audio</description>
    <rule name="StreamOrder" value="StreamOrder" tracktype="Video" occurrence="1" operator="&lt;">
      <source value="StreamOrder" tracktype="Audio"  occurrence="1"/>
    </rule>
</policy>

p2b.xml (the opposite)

<policy type="and" name="Video before audio">
  <description>Check if video is before audio</description>
    <rule name="StreamOrder" value="StreamOrder" tracktype="Video" occurrence="1" operator="&gt;">
      <source value="StreamOrder" tracktype="Audio"  occurrence="1"/>
    </rule>
</policy>
Result is:
> mediaconch example.mkv -p p2a.xml
pass! .\example.mkv
> mediaconch example.mkv -p p2b.xml
fail! .\example.mkv
   --  [fail:Video before audio]
   --   [fail:StreamOrder]
JeromeMartinez commented 4 months ago

@joe-sciame-wm @plondino you may test this GUI snapshot for creating such policy directly from the GUI instead of having to create it manually.