Accessing Quicktime files

  1. 2 weeks ago

    Perry P

    Feb 6 Pre-Release Testers, Xojo Pro Boston, MA

    Working on an application that needs to peek inside a variety of files in a folder and generate a report about those files. Some of them are DPX sequences, some of them are Quicktime movies, some will be MP4 files, or potentially other time-based media like WAV, AIFF, etc. Currently we're using the MBS GraphicsMagick plugin to read DPX and that's working great.

    For other media, It seems to me the best way to do this is to use ffmpeg, since it's a bit of a Swiss Army knife and will handle most of the files we will encounter. And because it does more than Quicktime (and doesn't require that Quicktime be installed, it's going to work on Mac, Windows or Linux, regardless of what Apple does with Quicktime). The only issue I see is that using ffmpeg requires the command line (not the end of the world, but an extra layer of complication, as well as lots of temp files).

    Has anyone made an ffmpeg library we can import that will let us access this functionality more directly than via the command line?

    Here's a list of the kind of information we need to gather:

    • Start timecode (embedded in Quicktime file)
    • frame rate
    • duration
    • resolution
    • codec
    • thumbnails of first, middle and last frames

    I don't care about licensing, so please let's not veer off topic on that! This is an app for in-house use, so none of the usual licensing concerns are applicable.

  2. Tim J

    Feb 6 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    Since using the API directly would require a lot of declares, and you would need to handle the file manipulation to provide the info to the ffmpeg library, you really don't save much - if anything - in going direct versus simply using the CLI app in a Xojo shell. Plus, the shell means that you don't need to worry about memory management.

  3. Perry P

    Feb 6 Pre-Release Testers, Xojo Pro Boston, MA

    Thanks. I've built a simple wrapper app in the past for x264 using the shell, and it was fine when it was working correctly, but setup was a bit of a pain (i recall having issues with paths, especially cross platform, but that may have been user error on my part). I guess what I'm hoping for is either a library or a plugin that lets you do things entirely within Xojo.

    The alternative is going to involve making a bunch of temp text files to store the metadata, then reading all that in and parsing it, as well as having ffmpeg generate thumbnails. Since I already have methods in my app for doing that from DPX using the MBS plugin, I'd prefer to re-use that where possible to keep things simple.

    But it's sounding like that's not really an option, eh?

  4. Tim J

    Feb 6 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    Why write the output to temporary files and later read them? Take the shell output and handle it directly within your app:

    Dim theShell As New Shell
    Dim theResults(-1) As String
    theShell.Mode = 1
    theShell.Execute "/usr/local/bin/ffprobe -hide_banner /Volumes/ArGest\ SSD\ 122113T/GoPro/GP010064.MP4"
    Do
        theShell.Poll
        App.DoEvents(2)
    Loop Until Not theShell.IsRunning
    If theShell.ErrorCode <> 0 Then
        # handle the error
    Else
        theResults = SplitB(theShell.ReadAll, EndOfLine)
    End If

    You will now have an array that you can parse containing the output of the ffprobe command. You can then step through the array using InStrB to check for matching values and separate them out into variables using NthFieldB. No disk I/O outside of the read that ffprobe does to get the info requested.

  5. Perry P

    Feb 6 Pre-Release Testers, Xojo Pro Boston, MA

    True - that'll work for the metadata. Though I'll still need to use ffmpeg to make the image files for the thumbnails.

    I'm not opposed to it, just looking for a more self-contained way of doing it.

  6. Tim J

    Feb 6 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    I'm more a Toyota design kind of guy - If buying a frame and motor from BMW will get me to my new Supra design faster, "Ich spreche Deutsche!"

  7. Perry P

    Feb 6 Pre-Release Testers, Xojo Pro Boston, MA
    Edited 2 weeks ago

    Well, better than ffmpeg is mediainfo, which I didn't realize had a command line tool. Here's the output, which is super easy to parse since everything is set up as key/value pairs. ffmpeg's output is kind of a mess, because individual lines are overloaded. Much less parsing with this:

    perry$ mediainfo /Volumes/SAN_RESOLVE_2/Perry-Dodgers/Source/R1_0000000.mov 
    General
    Complete name                            : /Volumes/SAN_RESOLVE_2/Perry-Dodgers/Source/R1_0000000.mov
    Format                                   : MPEG-4
    Format profile                           : QuickTime
    Codec ID                                 : qt   0000.00 (qt  )
    File size                                : 39.0 GiB
    Duration                                 : 21 min 40 s
    Overall bit rate mode                    : Variable
    Overall bit rate                         : 258 Mb/s
    Encoded date                             : UTC 2014-08-18 22:24:05
    Tagged date                              : UTC 2014-08-18 22:24:05
    Writing application                      : ScanStation V1.2 build 0031 (04/18/14)
    Copyright                                : 2014 Lasergraphics Inc.
    
    Video
    ID                                       : 1
    Format                                   : ProRes
    Format version                           : Version 1
    Format profile                           : 422 HQ
    Codec ID                                 : apch
    Duration                                 : 21 min 40 s
    Bit rate mode                            : Variable
    Bit rate                                 : 258 Mb/s
    Width                                    : 2 048 pixels
    Height                                   : 1 556 pixels
    Display aspect ratio                     : 4:3
    Frame rate mode                          : Constant
    Frame rate                               : 18.000 FPS
    Color space                              : YUV
    Chroma subsampling                       : 4:2:2
    Scan type                                : Progressive
    Bits/(Pixel*Frame)                       : 4.495
    Stream size                              : 39.0 GiB (100%)
    Writing library                          : ffm0
    Language                                 : English
    Encoded date                             : UTC 2014-08-18 22:24:05
    Tagged date                              : UTC 2014-08-18 22:24:05
    Color primaries                          : BT.709
    Transfer characteristics                 : BT.709
    Matrix coefficients                      : BT.709
    
    Other
    ID                                       : 2
    Type                                     : Time code
    Format                                   : QuickTime TC
    Duration                                 : 21 min 40 s
    Time code of first frame                 : 00:00:00:00
    Time code, striped                       : Yes
    Language                                 : English
    Encoded date                             : UTC 2014-08-18 22:24:05
    Tagged date                              : UTC 2014-08-18 22:24:05
    
  8. Perry P

    Feb 6 Pre-Release Testers, Xojo Pro Boston, MA
    Edited 2 weeks ago

    ...and what's nice about this is that if you pass it the first frame of a DPX sequence, it gathers info about the sequence. With MBS and GraphicsMagic, I've been walking through the directory and compiling some of that info myself, since things like total duration aren't embedded in the metadata of a single file. With MediaInfo, this is *so* much cleaner.

    There's also an SDK: https://mediaarea.net/en/MediaInfo/Support/SDK/Quick_Start

  9. Tim J

    Feb 6 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    And, parsing that out is an easy use of InStrB(theArray(x), theStringToMatch) and NthFieldB(theArray(x), " : ", 2).

  10. Michael D

    Feb 7 Pre-Release Testers, Xojo Pro

    I've been able to link in the MediaInfo DLL and/or Dylib - no command-line tools required at all.

or Sign Up to reply!