Question

I need to download a video that I've just recorded, on my PC. I managed to do it with pictures, but for video, I just get an empty file.

I've registred the object event handler

 err = EDSDK.EdsSetObjectEventHandler(cameraDev, EDSDK.ObjectEvent_All, objectEventHandler, new IntPtr(0));

Then,I start recording :

public void StartRecording(int sec)
{
    // set the timer, surement à mettre dans les config, plutot
    System.Timers.Timer aTimer = new System.Timers.Timer(sec * 1000);
    aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
    GC.KeepAlive(aTimer);            

    err = EDSDK.EdsSetPropertyData(cameraDev, EDSDK.PropID_Record, 0, 4, 4);
    aTimer.Start();
}

private void OnTimedEvent(object source, ElapsedEventArgs e)
{
   StopRecording();
}


public void StopRecording()
{           
    err = EDSDK.EdsSetPropertyData(cameraDev, EDSDK.PropID_Record, 0, 4, 0);
}

Object event handler :

public uint objectEventHandler(uint inEvent, IntPtr inRef, IntPtr inContext)
{
    switch (inEvent)
    {
        case EDSDK.ObjectEvent_DirItemCreated:
                DownloadImage(inRef, inContext);
            break;                
    }
    return 0;
}

And finally, the downolad

void DownloadImage(IntPtr DirectoryRef, IntPtr inContext)
{            
    IntPtr stream = IntPtr.Zero;
    IntPtr data = IntPtr.Zero;

    EDSDK.EdsDirectoryItemInfo dirItemInfo;
    uint err;

    try
    {
        err = EDSDK.EdsGetDirectoryItemInfo(DirectoryRef, out dirItemInfo);
        err = EDSDK.EdsCreateFileStream(dirItemInfo.szFileName,
            EDSDK.EdsFileCreateDisposition.CreateAlways, EDSDK.EdsAccess.ReadWrite, out stream);

        // does not work
        err = EDSDK.EdsSetProgressCallback(stream, progressFunc, EDSDK.EdsProgressOption.Periodically, inContext);

        // Fill the stream with the resulting image
        err = EDSDK.EdsDownload(DirectoryRef, dirItemInfo.Size, stream);

        if (err == EDSDK.EDS_ERR_OK)
        {
            err = EDSDK.EdsDownloadComplete(DirectoryRef);
        }
        else
        {
            err = EDSDK.EdsDownloadCancel(DirectoryRef);
        }
        if ((stream == null) == false)
        {
            err = EDSDK.EdsRelease(stream);
            stream = IntPtr.Zero;
        }                 
    }
    catch (Exception ex)
    {
        throw new Exception(String.Format("EDSDK Error : {0}", ex.Message));
    }
    EDSDK.EdsRelease(stream);
}

in debug mode,method EDSDK.EdsDownload never ends, but there is no exception, or return code ...

please help !

No correct solution

OTHER TIPS

Did you make sure to put the kEdsPropID_SaveTo to 1 ("Save on a memory card of a remote camera") because you cannot save it directly to PC as you can with images.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top