Axis Customer Forum

It is currently Sun Feb 17, 2019 8:36 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Wed Oct 07, 2015 12:49 pm 

Joined: Thu Aug 27, 2015 7:48 am
Posts: 5
Hi,
I am using Axis SDK 7.20 on Windows 7 64bit. I developped in Visual C# 2013 a simple GUI for to see and recording a stream video coming from a M7001 video converter. There are only 3 push buttons: Record, Play and Pause.
I am able to recording the frame as asf file and play it back.
Now I want, the first time the user play the video, he can only review the last 10 seconds of the stream.

To do this, I used this code:

bFirstFlag = true;
amc.Stop();
amc.MediaFile = FileName;
amc.Play();

At this point when the first frame is diplayed, in amc_OnNewImage() event:

if(bFirstFlag)
{
bFirstFlag = false;
amc.Stop();
duration = amc.Duration64;
amc.StartPosition64 = 0;
amc.StopPosition64 = duration;
amc.CurrentPosition64 = duration - (10*1000);
amc.Play();
}

I expected the frame video starts from amc.CurrentPosition64, but insted it starts from the beginnig.
What am I wrong?
How can I do in order to load a stream file and play it from a selected point?

Thank you in advance and excuse me for my english,
Rino


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 07, 2015 8:33 pm 

Joined: Tue May 20, 2008 8:35 am
Posts: 238
Works for me, when modifying the "samples\Visual C#\Video" sample code (using a 120 seconds long ASF-file):

Code:

        void amc_OnNewImage(object sender, EventArgs e)
        {
            if (isFirstTime)
            {
                isFirstTime = false;
                amc.Stop();
                ulong duration = amc.Duration64;
                amc.StartPosition64 = 0;
                amc.StopPosition64 = duration;
                amc.CurrentPosition64 = duration - (10 * 1000);
                amc.Play();
            }
        }


Try to put a break-point in your code and verify that the Duration64 value is correct.

Here is a optimized code snippet that still works for me:
Code:

        void amc_OnNewImage(object sender, EventArgs e)
        {
            if (isFirstTime)
            {
                isFirstTime = false;
                ulong playDuration = 10 * 1000;
                if (playDuration < amc.Duration64)
                {
                    amc.StartPosition64 = amc.Duration64 - playDuration;
                }
            }
        }


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 08, 2015 8:48 am 

Joined: Thu Aug 27, 2015 7:48 am
Posts: 5
Hello Anders,
thak you for your reply.

No. It still starts from the beginnig.
I put a breakpoint and I saw that CurrentPosition64 and Duration64 are setted up correctly.

Now I found that if I set a short value of CurrentPosition64, e.g. 5min = 25fps * 60s * 5 = 7500, it works and the stream starts correctly from 5min.
Because the lenght of my stream is 30min, if I increment, in amc_OnNewImage function, the CurrentPosition64 of 5min for every frame displayed I can arrive at the correct point to start to play in less than a second.

Do you know if there is a method to increment the memory buffer of the Play() function or if there is a faster system to set up the CurrentPosition64 when there are big stream files?

Thank you,
Rino


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 08, 2015 9:10 am 

Joined: Tue May 20, 2008 8:35 am
Posts: 238
Rino Valente wrote:

Do you know if there is a method to increment the memory buffer of the Play() function or if there is a faster system to set up the CurrentPosition64 when there are big stream files?


I have no idea.

How are you recording this ASF file? Is the recording still running when you are doing playback?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 08, 2015 12:18 pm 

Joined: Thu Aug 27, 2015 7:48 am
Posts: 5
I use amc.StartRecordMedia/amc.StopRecordMedia functions in order to create the .asf stream file.
The user can play the file, only 5 seconds after the end of the recording step (amc.StopRecordMedia). Actually I'm using an old recording file so I cannot record a new stream every time.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 09, 2015 6:59 am 

Joined: Tue May 20, 2008 8:35 am
Posts: 238
I tested with a larger file as well. Strange.

I would make an ordinary ASF recording from the live-view of the camera (30 min) and try to run it in the sample code with the modifications.

If that works you need to find out what is the difference in your application.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 09, 2015 7:15 am 

Joined: Thu Aug 27, 2015 7:48 am
Posts: 5
Perhaps is my amc initialization wrong?

Here is how I did it:

private: System::Void buttonPlay_Click(System::Object^ sender, System::EventArgs^ e)
{
SetupPlay();
amc->Play();
}

private: void SetupPlay()
{
amc->Stop();
amc->MediaFile = m_PathStream;
amc->EnableOverlays = false;
amc->VideoRenderer = MC_VIDEO_RENDERER.AMC_VIDEO_RENDERER_VMR9;
amc->PlaybackMode = AMC_PM_RECORDING;
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 09, 2015 7:17 am 

Joined: Tue May 20, 2008 8:35 am
Posts: 238
Shouldn't impact this.

Have you tried the sample code with modification?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 09, 2015 8:27 am 

Joined: Thu Aug 27, 2015 7:48 am
Posts: 5
Yes, if I use the Playback window project I have the same problem...and if I move the cursor at the end of the file all freezes for a moment and then the cursor goes back to the start.

This is my recording initialization:

amc->BackgroundColor = RGB(0, 0, 0);
amc->MediaURL = m_sURL;
amc->MediaType = "h264";
amc->H264VideoDecodingMode = AMC_VIDEO_DECODE_ALL_FRAMES;
amc->StretchToFit = true;
amc->MaintainAspectRatio = true;
amc->Mute = true;

When I click the Rec button:

private: System::Void buttonRec_Click(System::Object^ sender, System::EventArgs^ e)
{
...
if( mRecordingFlag )
{
mRecordingFlag = false;
amc->StartRecordMedia(m_PathStream, AMC_RECORD_FLAG::AMC_RECORD_FLAG_VIDEO, "0");
}
else
{
amc->Stop();
}
...
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group