FPCM_GET_TOTALFRAMES fails for FLV files

DLL Edition of the F-IN-BOX
key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

FPCM_GET_TOTALFRAMES fails for FLV files

Postby key88sf » Thu Oct 02, 2008 6:29 pm

I am trying to generate a bitmap of an FLV movie downloaded from YouTube. My code first gets the total frames, then tries to set the frame number to the middle frame (total / 2), and then get a bitmap with FPCM_GET_FRAME_BITMAP.

However, the call to get total frames (using FPCM_GET_TOTALFRAMES) fails with E_FAIL:

SFPCGetTotalFrames.hr == E_FAIL

How can I fix this? Or is there a better way to get a bitmap "snapshot" of an FLV file?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: FPCM_GET_TOTALFRAMES fails for FLV files

Postby Softanics » Thu Oct 02, 2008 7:01 pm

Thank you for your question.

key88sf wrote:I am trying to generate a bitmap of an FLV movie downloaded from YouTube. My code first gets the total frames, then tries to set the frame number to the middle frame (total / 2), and then get a bitmap with FPCM_GET_FRAME_BITMAP.

However, the call to get total frames (using FPCM_GET_TOTALFRAMES) fails with E_FAIL:

SFPCGetTotalFrames.hr == E_FAIL

How can I fix this? Or is there a better way to get a bitmap "snapshot" of an FLV file?


The problem is your flash movie actually does have only one frame.

To set current position and get total duration you should use actionscript and some flv player that provides you this information.

FPCM_GET_FRAME_BITMAP works well with flv files too.

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Thu Oct 02, 2008 8:06 pm

FPCM_GET_FRAME_BITMAP is returning a bitmap which is completely black. How can I have it return a bitmap which is an actual screenshot of the movie?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 03, 2008 10:57 am

key88sf wrote:FPCM_GET_FRAME_BITMAP is returning a bitmap which is completely black. How can I have it return a bitmap which is an actual screenshot of the movie?


I've created a simple example:
http://f-in-box.com/TEMP/B129B38E-C7CE- ... Player.zip

Click on "play swf/flv from file", then select a flv file, then in any time you can click on "make a snapshot" to save the current frame as a bitmap.

Please check it.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Fri Oct 03, 2008 5:26 pm

Hi - your code works, but requires that I play the video up until the point when I take the snapshot.

What I want is: Code that can quickly open an FLV file, take a snapshot of the movie (near halfway point), and close the FLV file. There will be no UI to display the movie to the user...this will be in the background so it should happen fast to only generate a bitmap image.

I have tried in my code:
- load the FLV as you do
- play
- set frame
- take snapshot
- stop

but still just see all-black bitmap. I cannot let the video play halfway before taking the snapshot. Any ideas to help me??

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 03, 2008 5:35 pm

key88sf wrote:Hi - your code works, but requires that I play the video up until the point when I take the snapshot.


Yes, of course. You get a bitmap of the _current_ frame.

key88sf wrote:What I want is: Code that can quickly open an FLV file, take a snapshot of the movie (near halfway point), and close the FLV file. There will be no UI to display the movie to the user...this will be in the background so it should happen fast to only generate a bitmap image.

I have tried in my code:
- load the FLV as you do
- play
- set frame
- take snapshot
- stop

but still just see all-black bitmap. I cannot let the video play halfway before taking the snapshot. Any ideas to help me??


May be you can load a FLV, then wait some time, take a snapshot and close the program?

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Fri Oct 03, 2008 5:43 pm

There is no way other than to wait? If I try to play and then call FPCM_GET_TOTALFRAMES, it is returning 1. So it looks as if I cannot skip to the middle point in the movie? Is it possible to skip using a FlashVars= parameter when playing the FLV?

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Fri Oct 03, 2008 8:48 pm

key88sf wrote:There is no way other than to wait? If I try to play and then call FPCM_GET_TOTALFRAMES, it is returning 1. So it looks as if I cannot skip to the middle point in the movie? Is it possible to skip using a FlashVars= parameter when playing the FLV?


Yes. If you have a good flv player. The player currently included in the f-in-box distrubution is simple. We have new version of the player and I can send you it. It supports changing current position.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Fri Oct 03, 2008 9:26 pm

Yes please! That would be awesome. I will also send you a regular email requesting this. Thanks.

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Sun Oct 05, 2008 4:40 pm

Hi - can you please send me the new FLV player? I also emailed you directly, but have not received a reply. Thank you.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Sun Oct 05, 2008 6:41 pm

I've just sent it. Please check.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Mon Oct 06, 2008 1:29 am

I got it -- but I am not clear now -- If I simply replace the FLVPlayer.swf in my C++ program binary resources with the new one, will all the regular f-in-box functions work?

For example, my code does this right now:

BOOL LoadFLV(LPCTSTR url, int layer = 0)
{
CString strFlashVars = _T("FLVPath=");
strFlashVars += url;
FPC_PutFlashVars(m_hWnd, strFlashVars);
return FPCPutMovieFromResource(m_hWnd, ModuleHelper::GetResourceInstance(), _T("FLVPlayer"), _T("SWF"));
}

How would I call the function playVideo() or seekVideo() ??

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Oct 06, 2008 9:08 am

You should use External API:

CallFunction("<invoke name=\"playVideo\" returntype=\"void\"><arguments><string>flv</string><string>http://PATH_TO_FLV_HERE</string></arguments></invoke>");
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Oct 06, 2008 9:12 am

Change:

key88sf wrote:BOOL LoadFLV(LPCTSTR url, int layer = 0)
{
CString strFlashVars = _T("FLVPath=");
strFlashVars += url;
FPC_PutFlashVars(m_hWnd, strFlashVars);
return FPCPutMovieFromResource(m_hWnd, ModuleHelper::GetResourceInstance(), _T("FLVPlayer"), _T("SWF"));
}


into:

Code: Select all

BOOL LoadFLV(LPCTSTR url, int layer = 0)
{
  CString strFlashVars = _T("type_video=flv&url=");
  strFlashVars += url;
  FPC_PutFlashVars(m_hWnd, strFlashVars);
  return FPCPutMovieFromResource(m_hWnd, ModuleHelper::GetResourceInstance(), _T("FLVPlayer"), _T("SWF"));
}


Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

key88sf
Posts: 17
Joined: Wed Apr 30, 2008 4:48 pm

Postby key88sf » Mon Oct 06, 2008 5:20 pm

Hi - ok one last question :)

After I call LoadFLV() as below, how would I call seekVideo() ??


Return to “DLL Edition”

Who is online

Users browsing this forum: No registered users and 13 guests

cron