HDFVR's Video Recording API

Add video recording to any form or web app and control it from Java Script

Getting Started With The HDFVR API

HDFVR's Java Script and PHP/ASPX video recording API allow you to integrate video recording into any form, web page or app. Before using the API you will need a copy of HDFVR. You can download a free 15 day trial of purchase it.

The HDFVR video recording API is comprised of 3 big sets of API functionality:


HDFVR to JS (Callbacks) API Documentation

Introduction

Every time an event happens in HDFVR (a button is pressed, the connection succeeds, etc.) a call is made to a JavaScript function with lots of info about the event.

What you can do with it

You can extend these JS functions to:

  • show a message in the html page,
  • activate a form/button in the html page,
  • redirect the user to another page,
  • etc... .

Actual JS Callbacks API

Here is the list of events and associated JavaScript functions:

Event JavaScript function that is called Parameters passed to the JS function
Triggers after the initial [Record Video] screen is drawn. After this function is called you can safely call document.VideoRecorder.startRecorder(). If skipInitialScreen is turned on in avc_settings.xxx this function is not called. Added in HDFVR 2.2. onRecorderInit(recorderId); recorderId: variable sent via flash vars
HDFVR has reached the recording screen. Wait for this event before using the recording functions. Added in HDFVR 2.2. onRecorderReady(recorderId); recorderId: variable sent via flash vars
DEPRECATED, use onRecorderReady instead. HDFVR is ready to communicate with JavaScript and JavaScript can call functions on HDFVR. onFlashReady(recorderId); recorderId: variable sent via flash vars
HDFVR detects the number of webcams and input devices a user has available. userHasCamMic(cam_number,mic_number, recorderId);

cam_number:number of web cam drivers the user has installed on his computer

mic_number: number of sound card and sound sources the user has installed on his computer

recorderId: variable sent via flash vars

[Record] button is pressed btRecordPressed(recorderId); recorderId: variable sent via flash vars
[Stop Record] button is pressed btStopRecordingPressed(recorderId); recorderId: variable sent via flash vars
[Play] button is pressed btPlayPressed(recorderId); recorderId: variable sent via flash vars
[Pause] busson is pressed btPausePressed(recorderId); recorderId: variable sent via flash vars
Recorded data finishes streaming/uploading to the media server onUploadDone(streamName, streamDuration, userId, recorderId, audioCodec, videoCodec, fileType);

streamName: a string representing the name of the stream recorded on the video server WITHOUT the filename extension (.flv , .f4v or .mp4)

streamDuration: the duration of the recorded video/audio file in seconds but accurate to the millisecond (like this: 4.322)

userId: the userId sent via flash vars or via the avc_settings.XXX file, the value in the avc_settings.XXX file takes precedence

recorderId: variable sent via flash vars

audioCodec: the audio codec used for the recording, Nelly Moser or Speex

videoCodec: the video codec used for the recording, Sorenson or H.264

fileType: the format in which the resulting recording will be saved in: FLV, F4V or MP4

the user pressed the [stop recording] button inside the recorder (that's when jpg_encoder_download.XXX is called) and the jpg_encoder_download.XXX script returned save=ok onSaveJpgOk(streamName,userId, recorderId); streamName and userId take the same values as explained above
the user pressed the [stop recording] button inside the recorder (that's when jpg_encoder_download.XXX is called) and the jpg_encoder_download.XXX script returned save=fail onSaveJpgFailed(streamName,userId, recorderId);

streamName and userId take the same values as explained above

recorderId: variable sent via flash vars

[Save] button is pressed, save_video_to_db.php executes and returns save=ok

 

Note: The actual existence of the .flv file and .jpg snapshot do not depend on the [SAVE] button being pressed.

This button will not be available during or before the recording process OR if hideSaveButton=1 in avc_settings.xxx.

onSaveOk(streamName, streamDuration, userId, cameraName, micName, recorderId, audioCodec, videoCodec, fileType,videoId);

streamName: a string representing the name of the stream recorded on the video server WITHOUT the filename extension (.flv , .f4v or .mp4)

streamDuration: the duration of the recorded video/audio file in seconds but accurate to the millisecond (like this: 4.322)

userId: the userId sent via flash vars or via the avc_settings.XXX file, the value in the avc_settings.XXX file takes precedence

cameraName:the name of the web cam driver the user has selected for capturing video data

micName: the name of the sound card/mic driver the user has selected for capturing audio data

recorderId: variable sent via flash vars

audioCodec: the audio codec used for the recording, Nelly Moser or Speex

videoCodec: the video codec used for the recording, Sorenson or H.264

fileType: the format in which the resulting recording will be saved in: FLV, F4V or MP4

videoId: the videoId sent via flash vars

[Save]
button is pressed and save_video_to_db.php executes and returns save=failed
onSaveFailed(streamName,streamDuration,userId, recorderId);

streamName, streamDuration and userId take the same values as explained above

recorderId: variable sent via flash vars

(New in build 423) HDFVR initializes and requests access to the webcam and microhphone onCamAccess(allowed, recorderId);

allowed is true if: 1) the user clicked the Allow button OR 2) cliked Allow+Remember in a previous session (in which case the Privacy dialog box is not shown) and false if the user clicked the Deny button. If a user clicked Deny+Remeber in a previous session the Privacy dialog box will be shown.

recorderId: variable sent via flash vars

(New in build 440) HDFVR finishes playback of recorded video stream onPlaybackComplete(recorderId); recorderId: variable sent via flash vars
Starting with build 609 HDFVR starts recording onRecordingStarted(recorderId); recorderId: variable sent via flash vars
Starting with build 609 HDFVR looses the connection to the media server onConnectionClosed(recorderId); recorderId: variable sent via flash vars
Starting with build 609 Called by HDFVR every second onFPSChange(recorderId,currentFPS);

recorderId: variable sent via flash vars

currentFPS: the current frames-per-second that HDFVR reports (during recording, playback, uploading or saving) depending of the state of HDFVR

Starting with build 609 [Pause Recording] button is pressed btPauseRecordingPressed(recorderId);

recorderId: variable sent via flash vars

Starting with build 609 [Resume Recording] button is pressed btResumeRecordingPressed(recorderId);

recorderId: variable sent via flash vars

Starting with build 636 Called by HDFVR for every connection event onConnectionStatus(status, recorderId);

status: the actual connection status: (connected, rejected, invalid app, closed, failed)

recorderId: variable sent via flash vars

Starting with build 707 Called by HDFVR every 10th of a second (100 miliseconds) onMicActivityLevel(recorderId, currentActivityLevel);

recorderId: variable sent via flash vars

currentActivityLevel:The amount of sound the microphone is detecting

Starting with build 707 Called by HDFVR after the conversion with FFMPEG has finished server side onFFMPEGConversionFinished(recorderId, status, streamName);

recorderId: variable sent via flash vars

status: the status when the conversion is finished: success or fail

streamName: the name of the stream for which the conversion finished

The snapshot has just been captured by HDFVR. Added in HDFVR 2.2. onSnapshotTaken(recorderId);

recorderId: variable sent via flash vars

 

You can find these JavaScript functions defined and explained in more detail in the HTML files that come with the video recorder.

recorderId has been added to all functions in build 474 .

JavaScript To HDFVR (Control) API Documentation

Introduction

You can control the HDFVR application by making calls from JavaScript. This API has been added in build 349.

How to use it

You can use the JS functions (mentioned below) after the onRecorderReady() ( added in HDFR 2.2, use onFlashReady() in older versions) is called by the HDFVR application by using the following JavaScript syntax:

  • document.NameOfTheObject.nameOfTheCalledFunction();
  • NameOfTheObject is the name property on the EMBED tag and the id property on the OBJECT tag used to embed the HDFVR swf file in the HTML page.
  • Example:document.VideoRecorder.record();

Actual HDFVR Write API

Function Name Event triggered Return Values
record(); This call will trigger HDFVR to record a video stream or to rerecord one if one is already recorded (equivalent to pressing the RECORD button). this function does not return a value
stop(); stopVideo();
For HDFVR versions newer than version 567 stop(); was replaced by stopVideo();
This call will trigger HDFVR to stop the recording of a stream if a recording is in progress this function does not return a value
play(); playVideo()
For HDFVR versions newer than version 567 play(); was replaced by playVideo();
This call will play the recorded stream if there is one. This will not be available during or before the recording process (equivalent to pressing the PLAY button). this function does not return a value
pause(); This call will pause the stream that is currently playing. This will not be available if there is no stream playing(equivalent to pressing the PAUSE button). this function does not return a value

save();

Note: The actual existence of the .flv file and .jpg snapshot do not depend on this call being made.

When the call is made (or when the [SAVE] button is pressed), HDFVR executes save_video_to_db.xxx on the web server and 2 JS READ API functions (onSaveOk and onSaveFailed) are then executed depending on the response.

This call will not be available during or before the recording process OR if hideSaveButton=1 in avc_settings.xxx.

This call is equivalent to pressing the [SAVE] button. this function does not return a value
getStreamName(); This call will return the stream name at any time but beware that the name of the stream might not be set at the time of the call. This is useful when you need the name of the stream during the recording and you do not specify a certain name through the avc_settings.xxx file. a string ,the stream name WITHOUT the filename extension (.flv , .f4v or .mp4). If the stream name is not set it will return an empty string.
getStreamTime(); Will return the length of the recorded video.

HDFVR 2.1 and older: a string with the current length of the recording if called during the recording or playback process and an empty string if called before or after the recording process.

HDFVR 2.2: a number with the current length of the recording.

getPlaybackTime();

Added with HDFVR 2.2

Will return the current time of the video during playback.

a number with the current time of the recording if called during the playback process or 0 if called outside playback

pauseRecording();

Added with build 609

This call will pause the recording if HDFVR is in the recording state. Equivalent to pressing the [PAUSE RECORDING] button. this function does not return a value

resumeRecording();

Added with build 609

This call will resume the recording if HDFVR is in the paused recording state. Equivalent to pressing the [RESUME RECORDING] button. this function does not return a value

startRecorder();

Added in HDFVR 2.0

This call will trigger HDFVR to start the recorder and show the whole interface. Has the same effect as pressing the [Record Video] button in the new pre-recording screen. this function does not return a value

PHP/ASP/.NET(aspx) API Documentation

Introduction

Every time an important event happens in HDFVR (the [SAVE] button is pressed) a php/asp/.NET(aspx) file is executed on the web server. Info about the event is sent (via GET variables) to the php/asp/.NET(aspx) file when it is executed .

What you can do with it

You can extend these files to:

  • insert the info about the movie/event in the database
  • set session variables for later use
  • etc...

Actual PHP/ASP/.NET(aspx) API

Here is the list of events and associated php/asp files that are executed when the event happens:

Event file/script that is executed on the web server variables sent to the script via GET
HDFVR initializes in the browser avc_settings.php or avc_settings.asp or avc_settings.aspx

recorderId: contains the value of the recorderId flash var in the HTML file embedding the videorecorder.swf file (added in build 474)

This script returns variable/value pairs in plain text.

These vars are used by HDFVR for colors, limits, media server info, etc... .

Edit the avc_settings.xxx file with a text editor to change the value of the variables.

Recording process is stopped and all the audio and video data has finished streaming (uploading) to the media server. jpg_encoder_download.php or jpg_encoder_download.asp or jpg_encoder_download.aspx

photoName: a string representing the name of the stream recorded on the video server WITHOUT the filename extension (.flv , .f4v or .mp4)

recorderId: contains the value of the recorderId flash var in the HTML file embedding the videorecorder.swf file (added in build 474)

[Save]
button is pressed
save_video_to_db.php or save_video_to_db.asp or save_video_to_db.aspx

streamName: a string representing the name of the stream recorded on the video server WITHOUT the filename extension (.flv , .f4v or .mp4)

streamDuration: the duration of the recorded video/audio file in seconds but accurate to the millisecond (like this: 4.322)

userId: the userId sent via flash vars or via the avc_settings.XXX file, the value in the avc_settings.XXX file takes precedence

recorderId: contains the value of the recorderId flash var in the HTML file embedding the videorecorder.swf file (added in build 474)

 

Switching between php, asp and .NET(aspx)

See Chapter 5 in the Documentation Area

Cold Fusion, Ruby, etc...

If you manage to port the functionality in the provided asp/php/.NET files to other server side scripting languages you can use the sscode flash var to force the video recorder to use the new server side files. For example if sscode=rb HDFVR will try to execute avc_settings.rb and so on.

Get personalized help

Customers with an active Support & Updates Plan can submit support requests to our knowledgeable techs via the client area.

Enter client area