3 Replies Latest reply: Jan 3, 2013 9:38 AM by Dan Thomas (DAGWare)
Dan Thomas (DAGWare) Level 1 Level 1 (105 points)

I have an ApleScript script (droplett) that concatenates individual movie files into one movie, and makes chapters markers using the movie file names. The script works great - almost. When I view the file on my Mac, the chapters are spot-on. But when I view the same file on my iPod Touch, the chapter timestamps are off.

 

Here's the truly strange thing: I used Metadata Hootenanny to look at the chapters in the movie, and the timestamps look correct. But if I use MH to save the chapter info to a text file, the timestamps in the text file don't match what the MH GUI says. In fact, the timestamps in the text file appear to be what the iPod Touch uses when viewing the movie.

 

Anyone know how this is possible? I'll include the script below, but I'd like to know how this is even possible, regardless of what I've done wrong in my script.

 

Any help will be apprecitated.

 

Here's the script: CAVEAT: I'm very new to AppleScript, and I know I should be checking for unexpected conditions, etc. Right now I just want to get it working, then I'll deal with that.

 

on open input

 

  repeat with i from 1 to count of input

    set this_item to (item i of input)

 

    -- NOTE: This is a simplified version of how I really get the chapter name.

    -- I didn't want to clutter up the example

    tell application "Finder" to set chapter_name to (name of this_item)

 

    tell application "QuickTime Player 7"

      if i is equal to 1 then

        make new document

      end if

  

      open this_item

      tell document 1

        rewind

        select all

        copy

        set clip_length to the duration

      end tell

      close document 1 saving no

 

      tell document 1

        select none

        set old_movie_length to the duration

        set current time to old_movie_length

        paste

 

     -- NOTE: All the movies I'm concatenating already have one chapter in them.

     -- I don't know if this code will work if that's not true, so if you use

     -- this script and run into problems, that might be the reason.

 

        set time of chapter i to old_movie_length

        set duration of chapter i to clip_length

        set name of chapter i to chapter_name

      end tell

    end tell

  end repeat

 

  quit

end open

 

Thanks for any help!

 

Dan

  • Dan Thomas (DAGWare) Level 1 Level 1 (105 points)

    OK, I was wrong about what the problem is. I misread some numbers. The data exported from Metadata Hootenanny has the correct timestamps.

     

    Unfortunately, this doesn't solve my problem. The chapters work fine when viewing the movie on my Mac, but they jump to the wrong places when viewing the same movie on my iPod.

     

    Dan

  • Jacques Rioux Level 4 Level 4 (2,540 points)

    Hi,

     

    I can not explain it, but if the codecs are not the same type that creates multiple video tracks and multiple "Chapters" tracks in the final document.

     

    In any case, try this.

    --------------

    on open input
    
    set chapter_list to {}
    repeat with i from 1 to count of input
        set this_item to (item i of input)
    
        tell application "Finder" to set chapter_name to (name of this_item)
        set end of chapter_list to chapter_name
    
        tell application "QuickTime Player"
            if i is equal to 1 then make new document
            open this_item
            tell document 1
                stop
                try
                    if i > 1 then
                        delete chapters -- delete all chapters
                    else
                        delete (chapters 2 thru -1) -- keep the first chapter in the first doc
                    end if
                end try
                select all
                copy
                set clip_length to the duration
                close saving no
            end tell
    
            tell document 1
                select none
                set old_movie_length to the duration
                set current time to old_movie_length
                paste
                -- NOTE: All the movies I'm concatenating already have one chapter in them.
                
                set contents of current chapter track to chapter_list
                set time of chapter i to old_movie_length + 1
                set duration of chapter i to clip_length
                set name of chapter i to chapter_name
            end tell
        end tell
    end repeat
    end open
    
  • Dan Thomas (DAGWare) Level 1 Level 1 (105 points)

    Your example is spot-on. This is exactly what I had been working on, after I posted the question. I removed the chapter tracks from the individual movies before pasting them into the new movie.

     

    The thing that had me stumped was that I was deleting the chapter track from even the first movie, and I couldn't figure out how to create a new chapter track from scratch. Your example shows the obvious solution - *don't* delete the chapter track from the first movie. (Duh!)

     

    Thanks so much for your help.

     

    Dan