• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get length of audio/video files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get length of audio/video files


  • Subject: Re: Get length of audio/video files
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 24 Oct 2011 15:14:57 -0500

On Oct 24, 2011, at 13:52, Bob Majors wrote:
Before I dive in, I thought I'd ask if anyone here has AppleScript code (and/or an Automator Workflow) that would walk through a folder of audio or video files (.aif or .mov for audio; .mov for video), get their length (and perhaps other information (encoding?)), then write out the filename and length to a structured text file. Thanks.
______________________________________________________________________

Hey Bob,

I think I'd use the ExifTool for this job.

http://www.sno.phy.queensu.ca/~phil/exiftool/

This script operates on the Finder selection (of movie files), but it'd be simple to change to work with folders.

set movieInfo to ""
try
  tell application "Finder"
    set sel to selection as alias list
    if sel ≠ {} then
      set fSel to first item of sel
    end if

    

    repeat with i in sel
      set movieFile to quoted form of (POSIX path of i)
      set cmd to "exiftool " & movieFile & " | egrep -i '^Duration|File Name|Video Encoding'"
      set movieInfo to movieInfo & (do shell script cmd) & linefeed & linefeed
    end repeat
  end tell

  

  # Write to file...

  

on error errMsg number errNum
  set {cr, sep} to {return, "------------------------------------------"}
  set e to sep & cr & "Error: " & errMsg & cr & sep & cr & "Error Number: " & errNum & cr & sep
  beep
  display dialog e
end try

-->"
File Name                       : Here's to the Crazy Ones.flv
Duration                        : 0:01:00
Video Encoding                  : H.264

File Name                       : Steve Jobs Commencement Address at Stanford 2005.flv
Duration                        : 0:15:04
Video Encoding                  : H.264

File Name                       : The Lost 1984 Video - young Steve Jobs introduces Macintosh.flv
Duration                        : 0:05:10
Video Encoding                  : H.264

"

Here's an example of a full data record:

ExifTool Version Number         : 8.61
File Name                       : The Lost 1984 Video - young Steve Jobs introduces Macintosh.flv
Directory                       : /Users/chris/Movies/Steve Jobs
File Size                       : 11 MB
File Modification Date/Time     : 2010:07:05 04:40:13-05:00
File Permissions                : rw-r-----
File Type                       : FLV
MIME Type                       : video/x-flv
Duration                        : 0:05:10
Start Time                      : 0 s
Total Duration                  : 310.2
Image Width                     : 320
Image Height                    : 240
Video Bitrate                   : 238 kbps
Audio Bitrate                   : 63.2 kbps
Total Data Rate                 : 308678
Frame Rate                      : 25.003
Byte Length                     : 11990298
Can Seek On Time                : Yes
Source Data                     : BADDBA70BHH1317945194139097
URL                             : 
Message                         : 
HTTP Host Header                : o-o.preferred.suddenlink-dfw1.v16.lscache6.c.youtube.com
Video Encoding                  : H.264
Audio Encoding                  : AAC
Audio Sample Rate               : 44100
Audio Bits Per Sample           : 16
Audio Channels                  : 2 (stereo)
Image Size                      : 320x240

* Note that the data record is not fixed-format, so fields may appear/disappear according to the available information.

--
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Get length of audio/video files
      • From: Shane Stanley <email@hidden>
    • Re: Get length of audio/video files
      • From: Alex Zavatone <email@hidden>
References: 
 >RE: Re: (no subject)That (From: email@hidden)
 >Re: (no subject)Thatinteract with alerts (From: Dana Hill <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Alex Zavatone <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Alex Zavatone <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Alex Zavatone <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: Shane Stanley <email@hidden>)
 >Re: (no subject)Thatinteract with alerts (From: email@hidden)
 >Get length of audio/video files (From: Bob Majors <email@hidden>)

  • Prev by Date: Re: Get length of audio/video files
  • Next by Date: Re: Get length of audio/video files
  • Previous by thread: Re: Get length of audio/video files
  • Next by thread: Re: Get length of audio/video files
  • Index(es):
    • Date
    • Thread