Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:27:27+00:00 2026-06-16T11:27:27+00:00

I’m trying to extract metadata from video files by running ffprobe using nativeProcess .

  • 0

I’m trying to extract metadata from video files by running ffprobe using nativeProcess. The code below works just as it should for one file, but causes an error when trying to loop through a series of files.

I know the cause of the problem is that Air tries to start a new nativeProcess before the old one is finished. I know it’s something to do with listening to the air.NativeProcessExitEvent.EXIT. I just can’t get it to work. Any suggestions would be greatly appreciated.

function fileOpen(){
    
  var directory = air.File.userDirectory;
  
  try
  {
      directory.browseForDirectory("Select Directory");
      directory.addEventListener(air.Event.SELECT, directorySelected);
  }
  catch (error)
  {
      air.trace("Failed:", error.message)
  }
  
  function directorySelected(event) 
  {
      directory = event.target ;
      var files = directory.getDirectoryListing();
      for(i=0; i < files.length; i++){
        getMetadata(files[0].nativePath)
                    //wait here for nativeProcess to finish
        }
      }
  } 

function getMetadata(filePathIn){
    
         
        if(air.NativeProcess.isSupported)
        {
            
        }
        else
        {
            air.trace("NativeProcess not supported.");
        }
    
        fileIn = filePathIn.toString()

        var nativeProcessStartupInfo = new air.NativeProcessStartupInfo();
        var file = air.File.applicationStorageDirectory.resolvePath("ffprobe");
        nativeProcessStartupInfo.executable = file;

        args = new air.Vector["<String>"]();
        args.push("-sexagesimal","-show_format","-loglevel","quiet","-show_streams","-print_format","json",filePathIn)
        nativeProcessStartupInfo.arguments = args;

        process = new air.NativeProcess();
        process.start(nativeProcessStartupInfo); 
        process.addEventListener(air.ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
        process.addEventListener(air.ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
        process.addEventListener(air.NativeProcessExitEvent.EXIT, onExit);
        process.addEventListener(air.IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, onIOError);
        process.addEventListener(air.IOErrorEvent.STANDARD_ERROR_IO_ERROR, onIOError);
        
        
    }

    function onOutputData()
    {
      var fileMetadataJSON = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
      air.trace(fileMetadataJSON)
    }
    
    function onErrorData(event)
    {
        air.trace("ERROR -", process.standardError.readUTFBytes(process.standardError.bytesAvailable)); 
    }
    
    function onExit(event)
    {
        air.trace("Process exited with ", event.exitCode);
    
    }
    
    function onIOError(event)
    {
         air.trace(event.toString());
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:27:29+00:00Added an answer on June 16, 2026 at 11:27 am

    Here an outline that should give you an idea of what to do:

    • In your directorySelected() method, promote the local variable files (an Array) to a member variable. This will make the list of files that was selected available so that other methods can access it.
    • Remove the for loop in your directorySelected() method. Instead of running the loop and trying to run the native process here, call a new method, let’s call it dequeueFileAndRunNativeProcess().
    • This new dequeueFileAndRunNativeProcess() method should check the length of the files array, and if it is greater than 0, it should pop() the first file in the files array and execute the native process on it.
    • In your onExit() method, call the dequeueFileAndRunNativeProcess() method again.

    The idea here is to move the code that runs the native process into a method that you can trigger from two places: once immediately after the user finishes browsing for files, and then again after the native process finishes it’s work. The process ends when the files array has no more files in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.