Hi all,
REALbasic 2k8r4 (demo)
Mac OS X 10.4.11
PowerBook G4 1.5 GHz Alu
I have troubles trying to edit a movie.
This time, I provide the whole code I used against an avi file.
All you have to do is to add a MoviePlayer (call it MPMain), a button
(where you will paste the code in Action) and two file types (VideoMPEG
and VideoAvi).
Then run, click the button, select an AVI file, see what is missed at
the start of the movie, quit the application, launch the AVi and...
nothing was cut (at last here).
FYI: the code here is taken from a larger project where I have a button
to choose a movie to be edited, another button to get the start and
length, and another button to clear the selection.
TIA for telling me where I am wrong and how I can improve it to save the
changes,
Emile
BTW: on screen, the beginning of the movie is really cleared, but no
change is saved on the disk. [I checked with VLC after closing the
application].
I used a "Cold Case" episode so I know that I cleared the black with
text leading part of the episode (as a test).
Here is the used code:
//
//
// This code is here as a test…
// to remove the first seconds of a movie
//
//
Dim MovieDlg As New OpenDialog
Dim MovieFI As FolderItem
Dim MovieEM As EditableMovie
//
Dim wWidth As Integer
Dim wHeight As Integer
Dim MPWidth As Integer
Dim MPHeight As Integer
Dim DeltaWidth As Integer
Dim DeltaHeight As Integer
// ---------- ---------- ---------- ---------- ---------- ----------
// Some preliminary work
// 1. Get the Window size
wWidth = Self.Width
wHeight = Self.Height
// 2. Get the Movie size
MPWidth = MPMain.Width
MPHeight = MPMain.Height
// 3. The OpenDialog
// a. Set the Dialog properties
#If Not (TargetLinux) Then
MovieDlg.InitialDirectory = GetFolderItem("")
#Else // open Home directory on linux
MovieDlg.InitialDirectory = Volume(0).Child("home")
#EndIf
MovieDlg.Title = "Select an AVI or MPEG video file"
MovieDlg.Filter = FTVideo.VideoAvi + FTVideo.VideoMPEG
// b. Issue the dialog
MovieFI = MovieDlg.ShowModal()
If MovieFI = Nil Or Not MovieFI.Exists Then
MsgBox "An error occured:" + EndOfLine + EndOfLine +_
"Did you click in the Cancel button ?" + EndOfLine + EndOfLine +_
"Sorry, but I cannot load the selected video."
Return
End If
// ---------- ---------- ---------- ---------- ---------- ----------
// Load the movie and set some properties
//
// 1. Open the movie to be editable
MovieEM = MovieFI.OpenEditableMovie
// 2. Assign the Editable Movie to the Movie Player
MPMain.Movie = MovieEM
// 3. Set the window title to the movie name
Self.Title = MovieFI.DisplayName
// 4. Change the window size according to the loaded movie
// a. Get the delta values
DeltaWidth = wWidth - MPWidth
Deltaheight = wHeight - MPHeight
// b. Set the window new width / height
Self.Width = MPMain.Width + DeltaWidth + 20
Self.Height = MPMain.Height + DeltaHeight + 20
// 5. Set the Movie auto save property
MovieEM.SaveOnClose = True
// ---------- ---------- ---------- ---------- ---------- ----------
// This is the part where I clear 12.33333 from the movie [as a test]
//
// 1. Set the Start and Length values
MovieEM.SelStart = 0 // Start of the selection
MovieEM.SelLength = 12.33333 // Length of the selection
// 2. Clear the selection
MovieEM.Clear
// 3. Update the change
call MovieEM.CommitChanges
// 4. Set the new position
MovieEM.Position = 0
// 5. play it again, Sam…
MPMain.Play
// 6. That’s All Folks!
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|