> For the complete documentation index, see [llms.txt](https://neuraldefend.gitbook.io/neural-defend/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://neuraldefend.gitbook.io/neural-defend/api-info-for-video-detection.md).

# API Info - For Video Detection

## Neural Defend Video Detection API Examples

**🔗 Endpoint**

```json
https://deepscan.neuraldefend.com/detect/video
```

For **videos**, input must be a video clip ( min 10sec recommended) with a visible face

### Base curl Command Structure

```bash
curl --location 'https://deepscan.neuraldefend.com/detect/video' \
--header 'x-api-key: YOUR_API_KEY_HERE' \
--form 'file=@"path/to/your/video.mp4"'
```

## Video Manipulation Detection API

### Endpoint: `/detect/video`

Comprehensive video manipulation detection combining **Faceswap**, **Deepfake**, and **Audio Spoofing** analysis in a single API call.

> **⚠️ Single-Face Videos Only**\
> This endpoint analyzes frames with a single face. Multi-face frames are automatically skipped.

***

### Quick Start

```bash
curl -X POST "https://api.neuroverify.com/detect/video" \
  -H "x-api-key: YOUR_API_KEY" \
  -F "file=@video.mp4"
```

***

### Request

| Property         | Value                 |
| ---------------- | --------------------- |
| **Method**       | `POST`                |
| **URL**          | `/detect/video`       |
| **Content-Type** | `multipart/form-data` |

#### Headers

| Header      | Type   | Required | Description  |
| ----------- | ------ | -------- | ------------ |
| `x-api-key` | string | ✅ Yes    | Your API key |

#### Parameters

| Parameter    | Type | Required | Default | Description                       |
| ------------ | ---- | -------- | ------- | --------------------------------- |
| `file`       | File | ✅ Yes    | -       | Video file to analyze             |
| `max_frames` | int  | ❌ No     | `30`    | Maximum frames to analyze (1-100) |

#### Supported Formats

```
video/mp4, video/avi, video/mov, video/mkv, video/wmv, video/flv,
video/webm, video/ogg, video/ogv, video/mpeg, video/3gpp, video/quicktime
```

#### Limits

* **Maximum file size**: 1.5 GB

***

### Response

#### Success Response Structure

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_a1b2c3d4e5f6g7h8i9j0",
    "filename": "video.mp4",
    "original_filename": "video.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 1,
    "billable": "Y",
    "message": "Video manipulation analysis completed successfully",
    "inference_time": 8.234,
    "prediction_tag": "GENUINE",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": "Genuine",
        "confidence": 0.92,
        "status": "performed"
      },
      
      "deepfake_check": {
        "prediction": "Genuine",
        "confidence": 0.88,
        "status": "performed"
      }
    },
    
    "audio_check": {
      "prediction": "Genuine",
      "confidence": 0.95,
      "inference_time": 1.2,
      "status": "performed"
    }
  }
}
```

#### Response Fields

| Field            | Type   | Description                              |
| ---------------- | ------ | ---------------------------------------- |
| `unique_trx_id`  | string | Unique transaction ID for tracking       |
| `filename`       | string | Uploaded filename                        |
| `content_type`   | string | MIME type of the video                   |
| `status`         | string | `"success"` or `"failed"`                |
| `status_code`    | int    | Status code for billing                  |
| `billable`       | string | `"Y"` (billable) or `"N"` (not billable) |
| `message`        | string | Human-readable status message            |
| `inference_time` | float  | Total processing time in seconds         |
| `prediction_tag` | string | Final detection result                   |

***

### Prediction Tags

#### `GENUINE`

**Video is authentic** - All detection checks passed successfully. No face manipulation, deepfake content, or audio spoofing detected. The video appears to be an original, unaltered recording.

#### `FACESWAP`

**Face swap detected** - The video contains face replacement or face swap manipulation. This occurs when a person's face has been digitally replaced with another person's face. Detected when >30% of frames OR at least 7 frames show faceswap artifacts.

#### `AI_GENERATED`

**Deepfake/AI-generated content detected** - The video contains AI-generated or synthetically created facial content. This includes deepfakes created using neural networks to generate or manipulate facial features. Detected when >50% of analyzed frames show AI-generated characteristics.

#### `AUDIO_SPOOF`

**Audio spoofing detected** - The video frames are genuine (no faceswap or deepfake), but the audio track is synthetic or AI-generated. This indicates the audio may have been artificially created or cloned using voice synthesis technology.

#### `NO_FACE`

**No analyzable faces found** - The video does not contain any single-face frames suitable for analysis. This may occur when:

* No faces are present in the video
* All frames contain multiple faces (group scenes)
* Faces are too small, blurry, or obscured for detection

#### Error Tags

| Tag                | Description                                   |
| ------------------ | --------------------------------------------- |
| `INVALID_FORMAT`   | Uploaded file is not a supported video format |
| `FILE_TOO_LARGE`   | File exceeds the 1.5GB size limit             |
| `PROCESSING_ERROR` | Internal server error during analysis         |

***

### Status Codes

| Code | Status         | Billable | Description                        |
| ---- | -------------- | -------- | ---------------------------------- |
| `1`  | Success        | ✅ Yes    | Analysis completed successfully    |
| `2`  | Bad Request    | ❌ No     | Invalid file type, size, or format |
| `5`  | Internal Error | ❌ No     | Server error during processing     |
| `6`  | No Face        | ✅ Yes    | No single-face frames detected     |

***

### Response Examples

#### 1. GENUINE Video

All checks pass - video is authentic.

**HTTP Status**: `200 OK`

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_x9k2m4n7p1q3r5s8t0u2",
    "filename": "interview.mp4",
    "original_filename": "interview.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 1,
    "billable": "Y",
    "message": "Video manipulation analysis completed successfully",
    "inference_time": 8.234,
    "prediction_tag": "GENUINE",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": "Genuine",
        "confidence": 0.92,
        "status": "performed"
      },
      
      "deepfake_check": {
        "prediction": "Genuine",
        "confidence": 0.88,
        "status": "performed"
      }
    },
    
    "audio_check": {
      "prediction": "Genuine",
      "confidence": 0.95,
      "inference_time": 1.2,
      "status": "performed"
    }
  }
}
```

***

#### 2. FACESWAP Detected

Face manipulation detected in video frames.

**HTTP Status**: `200 OK`

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_b2c3d4e5f6a7b8c9d0e1",
    "filename": "suspicious_video.mp4",
    "original_filename": "suspicious_video.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 1,
    "billable": "Y",
    "message": "Face manipulation detected in video",
    "inference_time": 6.789,
    "prediction_tag": "FACESWAP",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": "Faceswap detected",
        "confidence": 0.87,
        "status": "performed"
      },
      
      "deepfake_check": {
        "prediction": null,
        "confidence": null,
        "status": "skipped",
        "skip_reason": "Faceswap detected in majority of frames"
      }
    },
    
    "audio_check": {
      "prediction": "Genuine",
      "confidence": 0.91,
      "inference_time": 0.8,
      "status": "performed"
    }
  }
}
```

***

#### 3. AI\_GENERATED (Deepfake) Detected

AI-generated content detected in video.

**HTTP Status**: `200 OK`

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_d4e5f6a7b8c9d0e1f2a3",
    "filename": "deepfake.mp4",
    "original_filename": "deepfake.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 1,
    "billable": "Y",
    "message": "AI-Generated content detected in video",
    "inference_time": 7.5,
    "prediction_tag": "AI_GENERATED",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": "Genuine",
        "confidence": 0.94,
        "status": "performed"
      },
      
      "deepfake_check": {
        "prediction": "AI-Generated",
        "confidence": 0.82,
        "status": "performed"
      }
    },
    
    "audio_check": {
      "prediction": "Genuine",
      "confidence": 0.88,
      "inference_time": 1.1,
      "status": "performed"
    }
  }
}
```

***

#### 4. AUDIO\_SPOOF Detected

Video is genuine but audio is synthetic/AI-generated.

**HTTP Status**: `200 OK`

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_e5f6a7b8c9d0e1f2a3b4",
    "filename": "audio_spoof.mp4",
    "original_filename": "audio_spoof.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 1,
    "billable": "Y",
    "message": "Audio spoofing detected in video",
    "inference_time": 6.2,
    "prediction_tag": "AUDIO_SPOOF",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": "Genuine",
        "confidence": 0.96,
        "status": "performed"
      },
      
      "deepfake_check": {
        "prediction": "Genuine",
        "confidence": 0.91,
        "status": "performed"
      }
    },
    
    "audio_check": {
      "prediction": "AI-Generated",
      "confidence": 0.78,
      "inference_time": 1.3,
      "status": "performed"
    }
  }
}
```

***

#### 5. NO\_FACE (No Analyzable Faces)

No single-face frames found in video.

**HTTP Status**: `200 OK`

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_f6a7b8c9d0e1f2a3b4c5",
    "filename": "group_video.mp4",
    "original_filename": "group_video.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 6,
    "billable": "Y",
    "message": "No single faces detected in video frames",
    "inference_time": 3.5,
    "prediction_tag": "NO_FACE",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": null,
        "confidence": null,
        "status": "skipped",
        "skip_reason": "No single-face frames found"
      },
      
      "deepfake_check": {
        "prediction": null,
        "confidence": null,
        "status": "skipped",
        "skip_reason": "No single-face frames found"
      }
    },
    
    "audio_check": {
      "prediction": "Genuine",
      "confidence": 0.89,
      "inference_time": 1.0,
      "status": "performed"
    }
  }
}
```

***

#### 6. Video Without Audio

Video has no audio track - audio check shows "Not Applicable".

**HTTP Status**: `200 OK`

```json
{
  "video_analysis": {
    "unique_trx_id": "trx_a7b8c9d0e1f2a3b4c5d6",
    "filename": "silent_video.mp4",
    "original_filename": "silent_video.mp4",
    "content_type": "video/mp4",
    "status": "success",
    "status_code": 1,
    "billable": "Y",
    "message": "Video manipulation analysis completed successfully",
    "inference_time": 5.5,
    "prediction_tag": "GENUINE",
    
    "manipulation_video_check": {
      "status": "performed",
      
      "faceswap_check": {
        "prediction": "Genuine",
        "confidence": 0.95,
        "status": "performed"
      },
      
      "deepfake_check": {
        "prediction": "Genuine",
        "confidence": 0.89,
        "status": "performed"
      }
    },
    
    "audio_check": {
      "prediction": "Not Applicable",
      "confidence": null,
      "inference_time": null,
      "status": "no_audio"
    }
  }
}
```

***

### Error Responses

#### Unsupported File Type

**HTTP Status**: `400 Bad Request`

```json
{
  "video_analysis": {
    "status": "failed",
    "status_code": 2,
    "billable": "N",
    "message": "Unsupported file type. Supported types: video/mp4, video/avi, ...",
    "prediction_tag": "INVALID_FORMAT"
  }
}
```

#### File Size Exceeded

**HTTP Status**: `400 Bad Request`

```json
{
  "video_analysis": {
    "status": "failed",
    "status_code": 2,
    "billable": "N",
    "message": "File size too large. Maximum 1.5GB allowed.",
    "prediction_tag": "FILE_TOO_LARGE"
  }
}
```

#### Server Error

**HTTP Status**: `500 Internal Server Error`

```json
{
  "video_analysis": {
    "status": "failed",
    "status_code": 5,
    "billable": "N",
    "message": "Internal server error during video manipulation detection",
    "prediction_tag": "PROCESSING_ERROR"
  }
}
```

***

### Code Examples

#### Python

```python
import requests

API_URL = "https://api.neuroverify.com/detect/video"
API_KEY = "YOUR_API_KEY"


def analyze_video(file_path: str, max_frames: int = 30) -> dict:
    """
    Analyze video for manipulation detection.
    
    Args:
        file_path: Path to video file
        max_frames: Maximum frames to analyze (1-100)
    
    Returns:
        API response dictionary
    """
    headers = {"x-api-key": API_KEY}
    
    with open(file_path, "rb") as f:
        files = {"file": (file_path.split("/")[-1], f, "video/mp4")}
        data = {"max_frames": max_frames}
        response = requests.post(API_URL, headers=headers, files=files, data=data)
    
    return response.json(), response.status_code


def format_confidence(confidence: float) -> str:
    """Convert confidence (0-1) to percentage string."""
    if confidence is None:
        return "N/A"
    return f"{confidence * 100:.1f}%"


def get_check_status(check: dict) -> str:
    """Get formatted status for a check."""
    status = check.get("status", "unknown")
    prediction = check.get("prediction")
    confidence = check.get("confidence")
    skip_reason = check.get("skip_reason")
    
    if status == "skipped":
        return f"Skipped ({skip_reason})" if skip_reason else "Skipped"
    elif status == "performed":
        conf_str = format_confidence(confidence)
        return f"{prediction} ({conf_str} confidence)"
    elif status == "no_audio":
        return "No audio track"
    elif status == "failed":
        return "Failed"
    else:
        return status


def display_results(response: dict, status_code: int):
    """Display formatted analysis results."""
    
    print("\n" + "═" * 50)
    print("       VIDEO MANIPULATION ANALYSIS RESULT")
    print("═" * 50)
    
    # Handle HTTP errors
    if status_code >= 400:
        video = response.get("video_analysis", {})
        print(f"\n❌ ERROR: {video.get('message', 'Unknown error')}")
        print(f"   Status Code: {video.get('status_code')}")
        print(f"   Tag: {video.get('prediction_tag')}")
        print(f"   Billable: {video.get('billable', 'N')}")
        print("═" * 50 + "\n")
        return
    
    video = response.get("video_analysis", {})
    
    # Basic Info
    print(f"\n📁 File: {video.get('filename')}")
    print(f"🔑 Transaction ID: {video.get('unique_trx_id')}")
    print(f"⏱️  Processing Time: {video.get('inference_time', 0):.2f}s")
    
    # Final Verdict
    prediction_tag = video.get("prediction_tag", "UNKNOWN")
    status = video.get("status")
    
    verdict_icons = {
        "GENUINE": "✅",
        "FACESWAP": "⚠️",
        "AI_GENERATED": "⚠️",
        "AUDIO_SPOOF": "🔊",
        "NO_FACE": "👤",
        "INVALID_FORMAT": "❌",
        "FILE_TOO_LARGE": "❌",
        "PROCESSING_ERROR": "❌"
    }
    
    verdict_messages = {
        "GENUINE": "Video is AUTHENTIC - No manipulation detected",
        "FACESWAP": "FACE SWAP DETECTED - Video contains face replacement",
        "AI_GENERATED": "DEEPFAKE DETECTED - AI-generated content found",
        "AUDIO_SPOOF": "AUDIO SPOOF DETECTED - Synthetic audio detected",
        "NO_FACE": "NO ANALYZABLE FACES - Cannot perform analysis",
        "INVALID_FORMAT": "INVALID FORMAT - Unsupported file type",
        "FILE_TOO_LARGE": "FILE TOO LARGE - Exceeds 1.5GB limit",
        "PROCESSING_ERROR": "PROCESSING ERROR - Server error occurred"
    }
    
    icon = verdict_icons.get(prediction_tag, "❓")
    message = verdict_messages.get(prediction_tag, "Unknown result")
    
    print(f"\n{'─' * 50}")
    print(f"  {icon} FINAL VERDICT: {prediction_tag}")
    print(f"     {message}")
    print(f"{'─' * 50}")
    
    # Skip detailed checks for error responses
    if status == "failed" and prediction_tag in ["INVALID_FORMAT", "FILE_TOO_LARGE", "PROCESSING_ERROR"]:
        print(f"\n   Billable: {video.get('billable', 'N')}")
        print("═" * 50 + "\n")
        return
    
    # Detailed Checks
    manipulation = video.get("manipulation_video_check", {})
    faceswap = manipulation.get("faceswap_check", {})
    deepfake = manipulation.get("deepfake_check", {})
    audio = video.get("audio_check", {})
    
    print("\n📊 DETECTION BREAKDOWN:")
    print(f"   ├─ Faceswap Check: {get_check_status(faceswap)}")
    print(f"   ├─ Deepfake Check: {get_check_status(deepfake)}")
    print(f"   └─ Audio Check:    {get_check_status(audio)}")
    
    # Billing Info
    print(f"\n💰 Billable: {video.get('billable', 'N')}")
    print(f"   Status Code: {video.get('status_code')}")
    
    print("═" * 50 + "\n")


# =====================================================
# USAGE EXAMPLE
# =====================================================
if __name__ == "__main__":
    # Analyze a video file
    response, status_code = analyze_video("video.mp4", max_frames=30)
    
    # Display formatted results
    display_results(response, status_code)
    
    # Access specific values programmatically
    video = response.get("video_analysis", {})
    
    # Get final verdict
    verdict = video.get("prediction_tag")
    print(f"Verdict: {verdict}")
    
    # Check if video is safe
    is_safe = verdict == "GENUINE"
    print(f"Is Safe: {is_safe}")
    
    # Get confidence scores
    manipulation = video.get("manipulation_video_check", {})
    faceswap_conf = manipulation.get("faceswap_check", {}).get("confidence")
    deepfake_conf = manipulation.get("deepfake_check", {}).get("confidence")
    audio_conf = video.get("audio_check", {}).get("confidence")
    
    if faceswap_conf:
        print(f"Faceswap Confidence: {faceswap_conf * 100:.1f}%")
    if deepfake_conf:
        print(f"Deepfake Confidence: {deepfake_conf * 100:.1f}%")
    if audio_conf:
        print(f"Audio Confidence: {audio_conf * 100:.1f}%")
```

#### JavaScript (Node.js)

```javascript
const FormData = require('form-data');
const fs = require('fs');
const axios = require('axios');

const API_URL = 'https://api.neuroverify.com/detect/video';
const API_KEY = 'YOUR_API_KEY';

/**
 * Analyze video for manipulation detection
 * @param {string} filePath - Path to video file
 * @param {number} maxFrames - Maximum frames to analyze (1-100)
 * @returns {Promise<{data: object, status: number}>}
 */
async function analyzeVideo(filePath, maxFrames = 30) {
  const form = new FormData();
  form.append('file', fs.createReadStream(filePath));
  form.append('max_frames', maxFrames.toString());

  try {
    const response = await axios.post(API_URL, form, {
      headers: {
        'x-api-key': API_KEY,
        ...form.getHeaders()
      },
      validateStatus: () => true // Don't throw on 4xx/5xx
    });
    return { data: response.data, status: response.status };
  } catch (error) {
    return { 
      data: { video_analysis: { message: error.message, prediction_tag: 'ERROR' } }, 
      status: 500 
    };
  }
}

/**
 * Convert confidence (0-1) to percentage string
 */
function formatConfidence(confidence) {
  if (confidence === null || confidence === undefined) return 'N/A';
  return `${(confidence * 100).toFixed(1)}%`;
}

/**
 * Get formatted status for a check
 */
function getCheckStatus(check) {
  if (!check) return 'Not available';
  
  const { status, prediction, confidence, skip_reason } = check;
  
  switch (status) {
    case 'skipped':
      return skip_reason ? `Skipped (${skip_reason})` : 'Skipped';
    case 'performed':
      return `${prediction} (${formatConfidence(confidence)} confidence)`;
    case 'no_audio':
      return 'No audio track';
    case 'failed':
      return 'Failed';
    default:
      return status || 'Unknown';
  }
}

/**
 * Display formatted analysis results
 */
function displayResults(response, statusCode) {
  console.log('\n' + '═'.repeat(50));
  console.log('       VIDEO MANIPULATION ANALYSIS RESULT');
  console.log('═'.repeat(50));

  const video = response.video_analysis || {};

  // Handle HTTP errors
  if (statusCode >= 400) {
    console.log(`\n❌ ERROR: ${video.message || 'Unknown error'}`);
    console.log(`   Status Code: ${video.status_code}`);
    console.log(`   Tag: ${video.prediction_tag}`);
    console.log(`   Billable: ${video.billable || 'N'}`);
    console.log('═'.repeat(50) + '\n');
    return;
  }

  // Basic Info
  console.log(`\n📁 File: ${video.filename}`);
  console.log(`🔑 Transaction ID: ${video.unique_trx_id}`);
  console.log(`⏱️  Processing Time: ${(video.inference_time || 0).toFixed(2)}s`);

  // Final Verdict
  const predictionTag = video.prediction_tag || 'UNKNOWN';

  const verdictIcons = {
    GENUINE: '✅',
    FACESWAP: '⚠️',
    AI_GENERATED: '⚠️',
    AUDIO_SPOOF: '🔊',
    NO_FACE: '👤',
    INVALID_FORMAT: '❌',
    FILE_TOO_LARGE: '❌',
    PROCESSING_ERROR: '❌'
  };

  const verdictMessages = {
    GENUINE: 'Video is AUTHENTIC - No manipulation detected',
    FACESWAP: 'FACE SWAP DETECTED - Video contains face replacement',
    AI_GENERATED: 'DEEPFAKE DETECTED - AI-generated content found',
    AUDIO_SPOOF: 'AUDIO SPOOF DETECTED - Synthetic audio detected',
    NO_FACE: 'NO ANALYZABLE FACES - Cannot perform analysis',
    INVALID_FORMAT: 'INVALID FORMAT - Unsupported file type',
    FILE_TOO_LARGE: 'FILE TOO LARGE - Exceeds 1.5GB limit',
    PROCESSING_ERROR: 'PROCESSING ERROR - Server error occurred'
  };

  const icon = verdictIcons[predictionTag] || '❓';
  const message = verdictMessages[predictionTag] || 'Unknown result';

  console.log('\n' + '─'.repeat(50));
  console.log(`  ${icon} FINAL VERDICT: ${predictionTag}`);
  console.log(`     ${message}`);
  console.log('─'.repeat(50));

  // Skip detailed checks for error responses
  if (video.status === 'failed' && ['INVALID_FORMAT', 'FILE_TOO_LARGE', 'PROCESSING_ERROR'].includes(predictionTag)) {
    console.log(`\n   Billable: ${video.billable || 'N'}`);
    console.log('═'.repeat(50) + '\n');
    return;
  }

  // Detailed Checks
  const manipulation = video.manipulation_video_check || {};
  const faceswap = manipulation.faceswap_check || {};
  const deepfake = manipulation.deepfake_check || {};
  const audio = video.audio_check || {};

  console.log('\n📊 DETECTION BREAKDOWN:');
  console.log(`   ├─ Faceswap Check: ${getCheckStatus(faceswap)}`);
  console.log(`   ├─ Deepfake Check: ${getCheckStatus(deepfake)}`);
  console.log(`   └─ Audio Check:    ${getCheckStatus(audio)}`);

  // Billing Info
  console.log(`\n💰 Billable: ${video.billable || 'N'}`);
  console.log(`   Status Code: ${video.status_code}`);

  console.log('═'.repeat(50) + '\n');
}

/**
 * Check if video is safe (no manipulation detected)
 */
function isVideoSafe(response) {
  return response.video_analysis?.prediction_tag === 'GENUINE';
}

/**
 * Get confidence scores as percentages
 */
function getConfidenceScores(response) {
  const video = response.video_analysis || {};
  const manipulation = video.manipulation_video_check || {};
  
  return {
    faceswap: manipulation.faceswap_check?.confidence 
      ? (manipulation.faceswap_check.confidence * 100).toFixed(1) + '%' 
      : null,
    deepfake: manipulation.deepfake_check?.confidence 
      ? (manipulation.deepfake_check.confidence * 100).toFixed(1) + '%' 
      : null,
    audio: video.audio_check?.confidence 
      ? (video.audio_check.confidence * 100).toFixed(1) + '%' 
      : null
  };
}


// =====================================================
// USAGE EXAMPLE
// =====================================================
(async () => {
  // Analyze a video file
  const { data: response, status: statusCode } = await analyzeVideo('video.mp4', 30);

  // Display formatted results
  displayResults(response, statusCode);

  // Access specific values programmatically
  const verdict = response.video_analysis?.prediction_tag;
  console.log(`Verdict: ${verdict}`);

  // Check if video is safe
  console.log(`Is Safe: ${isVideoSafe(response)}`);

  // Get confidence scores
  const scores = getConfidenceScores(response);
  if (scores.faceswap) console.log(`Faceswap Confidence: ${scores.faceswap}`);
  if (scores.deepfake) console.log(`Deepfake Confidence: ${scores.deepfake}`);
  if (scores.audio) console.log(`Audio Confidence: ${scores.audio}`);
})();
```

#### cURL

```bash
curl -X POST "https://api.neuroverify.com/detect/video" \
  -H "x-api-key: YOUR_API_KEY" \
  -F "file=@video.mp4" \
  -F "max_frames=30"
```

#### Example Output

```
══════════════════════════════════════════════════
       VIDEO MANIPULATION ANALYSIS RESULT
══════════════════════════════════════════════════

📁 File: interview.mp4
🔑 Transaction ID: trx_x9k2m4n7p1q3r5s8t0u2
⏱️  Processing Time: 8.23s

──────────────────────────────────────────────────
  ✅ FINAL VERDICT: GENUINE
     Video is AUTHENTIC - No manipulation detected
──────────────────────────────────────────────────

📊 DETECTION BREAKDOWN:
   ├─ Faceswap Check: Genuine (92.0% confidence)
   ├─ Deepfake Check: Genuine (88.0% confidence)
   └─ Audio Check:    Genuine (95.0% confidence)

💰 Billable: Y
   Status Code: 1
══════════════════════════════════════════════════
```

***

### Best Practices

1. **Use MP4 format** for fastest processing (WebM files are auto-converted)
2. **Ensure good lighting** in videos for accurate face detection
3. **Single-face videos** work best - group videos may return `NO_FACE`
4. **Keep videos under 1GB** for optimal processing speed
5. **Check `billable` field** to track API usage costs

***

### Support

For API issues or questions, contact: **<sumit@neuraldefend.com>**

### API Response Codes Summary

| HTTP Code                      | Status            | Description                    |
| ------------------------------ | ----------------- | ------------------------------ |
| **200 OK**                     | ✅ Success         | Request processed successfully |
| **400 Bad Request**            | ⚠️ Invalid Input  | Malformed file or parameters   |
| **403 Forbidden**              | 🔒 Access Denied  | Invalid API key                |
| **413 Payload Too Large**      | 📁 File Too Large | File exceeds size limit        |
| **415 Unsupported Media Type** | 🎥 Invalid Format | Unsupported video format       |
| **500 Internal Server Error**  | 🚨 Server Error   | Server-side processing error   |

### Confidence Score Interpretation

* **0.0 - 0.3**: High confidence fake/manipulated
* **0.3 - 0.5**: Moderate confidence fake/manipulated
* **0.5 - 0.7**: Moderate confidence real
* **0.7 - 1.0**: High confidence real

### Best Practices

1. **Video Requirements**:
   * Minimum 10 seconds duration recommended
   * Single face preferred for accuracy
   * Good lighting and resolution
2. **File Specifications**:
   * Format: MP4 (H.264/H.265)
   * Max size: 100MB (default)
   * Resolution: 720p+ recommended
3. **Error Handling**:
   * Always check status field
   * Handle rate limiting with exponential backoff
   * Implement retry logic for 5xx errors


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://neuraldefend.gitbook.io/neural-defend/api-info-for-video-detection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
