# VisioForge Documentation and Website Content **Author:** VisioForge **License:** CC-BY-4.0 (https://creativecommons.org/licenses/by/4.0/) **Generated:** 2026-06-22 15:53:49 UTC (578e075d5f4) **MCP Server:** https://mcp.visioforge.com/mcp (public, no auth — prefer for structured queries) **Content Sources:** 1296 help documentation pages + 64 website pages --- # Help Documentation ## Delphi ActiveX SDK Setup - Installation and Configuration **URL:** https://www.visioforge.com/help/docs/delphi/general/ **Description:** Install and configure TVFMediaPlayer, TVFVideoCapture, and TVFVideoEdit components in Delphi. Covers 64-bit package setup, .otares errors, and IDE integration. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL # Delphi/ActiveX Libraries for Multimedia Development Welcome to our developer documentation hub for Delphi/ActiveX multimedia libraries. This resource provides in-depth technical information, code examples, and implementation guides for developers working with our specialized components. ## Core Library Benefits Our libraries empower Delphi developers to create sophisticated multimedia applications with minimal coding effort. The components are engineered for maximum performance and reliability in professional development environments. Key advantages include: - Simplified implementation of complex multimedia features - Optimized performance for resource-intensive operations - Cross-version compatibility with multiple Delphi releases - Extensive customization options for specialized requirements ## Documentation Organization ### Technical Reference Materials Each library section contains detailed API references, implementation examples, and recommended practices. Navigate to the specific library documentation for complete information about: - Component properties and attributes - Method signatures and parameters - Event handlers and callback functions - Type definitions and constants ### Code Examples and Tutorials Our documentation includes practical code snippets and complete implementation examples to accelerate your development process. These examples demonstrate effective techniques for common multimedia programming scenarios. ## Installation Troubleshooting Guide When integrating our libraries into your development environment, you might encounter these known technical issues: ### 64-bit Architecture Compatibility Delphi's 64-bit compilation environment requires special configuration in some cases: - [Resolving Delphi 64-bit package installation problems](install-64bit/) - Handling memory alignment requirements in 64-bit environments - Addressing pointer size differences between architectures ### Resource File Management Proper resource handling is essential for stable operation: - [Fixing Delphi package installation issues with .otares files](install-otares/) - Resolving resource locking during development - Managing resource file paths in deployed applications ## Getting Started To begin implementing our libraries in your projects, follow the library-specific installation guides and review the sample applications. Our documentation provides step-by-step instructions to help you achieve optimal results. ---END OF PAGE--- ## Install VisioForge SDK on Delphi 64-bit — Setup Guide **URL:** https://www.visioforge.com/help/docs/delphi/general/install-64bit/ **Description:** Fix 64-bit BPL loading issues in Delphi IDE. Covers design-time vs runtime packages, library path configuration for x86/x64, and common error solutions. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL # Mastering Delphi 64-bit Package Installation ## Introduction to 64-bit Development in Delphi The evolution to 64-bit computing represents a significant advancement for Delphi developers, opening doors to enhanced performance, expanded memory addressing capabilities, and improved resource utilization. Since the introduction of 64-bit support in Delphi XE2, developers have gained the powerful ability to compile native 64-bit Windows applications. This capability enables software to harness modern hardware architectures, access substantially larger memory spaces, and deliver optimized performance for data-intensive operations. However, this technological progression introduces a distinctive set of complexities, particularly regarding the installation and management of component packages (`.bpl` files). Many Delphi developers encounter perplexing obstacles when attempting to integrate 64-bit packages into their development workflow, leading to frustration and lost productivity. This in-depth guide explores these challenges thoroughly and provides meticulously detailed, actionable solutions. The fundamental issue originates from a critical architectural characteristic: **the Delphi Integrated Development Environment (IDE) remains a 32-bit application**, even in the most recent releases. This architectural discrepancy between the 32-bit IDE and the 64-bit compilation target creates numerous misunderstandings and technical difficulties related to package management. Understanding this architectural limitation constitutes the essential first step toward establishing a seamless development experience. We will thoroughly examine why the 32-bit IDE requires 32-bit design-time packages, explore proper project configuration techniques for both 32-bit and 64-bit targets, clarify the critical function of runtime packages, and outline extensive testing methodologies to ensure your applications perform flawlessly across both architectural environments. ## The Architectural Limitation: Why the 32-bit IDE Requires 32-bit Design-Time Packages ### Understanding the IDE's Architecture The Delphi IDE serves as the principal environment for visual component design, code editing, debugging operations, and comprehensive project management. When designers place components onto forms using the Form Designer, modify properties through the Object Inspector, or utilize specialized component editors, the IDE must load and execute code contained within the component's design-time package. Because `bds.exe` (the Delphi IDE executable) operates as a 32-bit process, it functions exclusively within the 32-bit memory address space and must adhere to the constraints of 32-bit execution environments. The IDE physically cannot load or execute 64-bit code directly—this represents a hardware and operating system limitation, not merely a software restriction. Any attempt to load a 64-bit DLL (or in Delphi terminology, a 64-bit `.bpl` package) into a 32-bit process will result in immediate failure, typically manifesting as error messages like "Can't load package %s" or obscure operating system error codes. ### Critical Design-Time Requirements For the IDE to function properly during design activities—enabling visual component manipulation, property configuration, and utilization of design-time features—it *must* load the **32-bit (x86)** version of component packages. This requirement is non-negotiable due to the fundamental architecture of the IDE and operating system memory management principles. This architectural limitation frequently leads to confusion among developers, creating misconceptions that only 32-bit packages are necessary, or generating questions about why separate 64-bit packages exist if the IDE cannot utilize them. The critical distinction lies in understanding the separation between **design time** operations (occurring within the 32-bit IDE) and **compile/run time** processes (where applications can target either 32-bit or 64-bit architectures). ## Step-by-Step Implementation: Installing 32-bit Design-Time Packages ### Essential First Step: Installing 32-bit Components Based on the architectural explanation above, the mandatory initial step always involves installing the 32-bit version of component packages into the Delphi IDE. This process establishes the foundation for all subsequent development activities. 1. **Acquire Necessary Package Files:** Ensure you possess both 32-bit and 64-bit compiled package files (`.bpl` and `.dcp`). The 32-bit files typically carry identifier suffixes such as `_x86`, `_Win32`, or may lack platform specifiers in older Delphi versions. Conversely, 64-bit packages normally include `_x64` or `_Win64` designations. These files typically generate automatically when building component library projects targeting both Win32 and Win64 platforms. When using third-party components, reputable vendors should supply both architectural versions. 2. **Launch Development Environment:** Start the Delphi IDE with appropriate user permissions. 3. **Access Package Installation Interface:** Navigate through the menu system to `Component > Install Packages...`. 4. **Initiate Package Addition:** Click the "Add..." button to begin the installation process. 5. **Locate 32-bit Package Files:** Browse to the directory containing your **32-bit** compiled package files (`.bpl`). Carefully select the 32-bit `.bpl` file and click "Open" to proceed. 6. **Complete Installation Process:** The package should appear in the "Design packages" list, typically enabled by default. Confirm the installation by clicking "OK". ### Verification and Troubleshooting The IDE will attempt to load the 32-bit package. When successful, your components should appear in the Tool Palette, enabling immediate use in the Form Designer. If the IDE fails to load the package, verify that you selected the correct 32-bit `.bpl` file and ensure that all dependency packages required by your target package are properly installed and accessible. **Critical Warning:** Never attempt to install 64-bit `.bpl` files using the `Component > Install Packages...` menu option. Such attempts will invariably fail because the 32-bit IDE architecture cannot load 64-bit code modules. ## Advanced Configuration: Setting Project Library Paths for Dual Platform Development ### Configuring Compiler Search Paths While the IDE utilizes 32-bit packages during design-time operations, the Delphi compiler requires precise information about where to locate appropriate files (`.dcu`, `.dcp`, `.obj`) for your specific target platform during compilation (either 32-bit or 64-bit). These settings are configured through project options, specifically within the library path configuration section. Importantly, these settings must be established separately for each target platform. 1. **Access Project Configuration:** Navigate to `Project > Options...` in the IDE menu. 2. **Select Appropriate Platform:** It is absolutely crucial to configure paths separately for each target platform. Utilize the "Target Platform" dropdown menu located at the top of the Project Options dialog. Begin configuration with the "32-bit Windows" selection. 3. **Navigate to Library Configuration Section:** In the options tree displayed on the left side, select `Delphi Compiler > Library` to access path settings. 4. **Configure 32-bit Library Paths:** Within the "Library path" field, click the ellipsis (...) button to open the path editor. Add the directory containing your compiled **32-bit** units (`.dcu` files) and the **32-bit** package's `.dcp` file for the components you've installed. Ensure this path specifically references the 32-bit output directory of your component library. 5. **Switch to 64-bit Configuration:** Change the "Target Platform" dropdown selection to "64-bit Windows". Notice that the "Library path" field might display different content or appear empty. 6. **Configure 64-bit Library Paths:** Repeat the previous path configuration process, but this time add directories containing your compiled **64-bit** units (`.dcu` files) and the **64-bit** package's `.dcp` file. This path *must* differ from the 32-bit path and correctly reference the 64-bit output directory. 7. **Review Additional Path Settings:** While the Library path configuration is essential for locating `.dcu` and `.dcp` files, also examine the `Browsing path` settings (used by code insight features) and verify the `DCP output directory` location is properly configured if you are building packages yourself. Configure these paths for both 32-bit and 64-bit platforms as well. 8. **Save Configuration Changes:** Click "OK" to preserve the project options settings. ### Avoiding Common Configuration Errors **Frequent Mistake:** Many developers forget to switch the "Target Platform" dropdown *before* setting the path for that platform. Configuring the 64-bit path while "32-bit Windows" remains selected (or vice-versa) represents a common source of compilation errors later in the development process. By correctly establishing these platform-specific library paths, you provide the compiler with precise information about where to locate necessary `.dcu` and `.dcp` files for the architecture currently under construction. ## Runtime Package Management Strategies ### Deciding on Linking Approaches Beyond instructing the compiler where to find units during compilation, you must determine how your final executable will link against component libraries. This critical decision is controlled through the "Runtime Packages" settings section. You have two principal options: 1. **Static Linking Approach:** If you leave the "Link with runtime packages" option unchecked (or remove all packages from the list), the compiler will directly incorporate necessary code and resources from your components into the final `.exe` file. This approach produces larger executable files but eliminates the requirement to distribute separate `.bpl` files alongside your application. 2. **Dynamic Linking (Runtime Packages) Approach:** If you enable "Link with runtime packages" and specify required packages, the compiler will *not* embed component code into your `.exe`. Instead, your application will dynamically load necessary `.bpl` files during execution. This strategy creates smaller executable files but requires deploying corresponding 32-bit or 64-bit `.bpl` files with your application distribution. ### Detailed Configuration Process 1. **Access Project Options:** Navigate to `Project > Options...` in the IDE menu. 2. **Select Target Platform:** Choose either "32-bit Windows" or "64-bit Windows" from the platform dropdown. 3. **Navigate to Package Settings:** Select `Packages > Runtime Packages` in the options navigation tree. 4. **Configure Linking Method:** Enable or disable the "Link with runtime packages" option based on your preferred linking approach determined earlier. 5. **Specify Required Packages:** When utilizing runtime packages, ensure the list contains the correct base names of packages your application requires (e.g., `MyComponentPackage`). Do *not* include platform suffixes or file extensions in these entries. Delphi automatically appends appropriate platform identifiers and loads the correct `_x86.bpl` or `_x64.bpl` files (or equivalent naming based on Delphi version/settings) during runtime. 6. **Configure Secondary Platform:** Switch the "Target Platform" selection and configure runtime package settings identically for the alternative platform. Typically, the decision to use or not use runtime packages remains consistent across both platforms, but package lists might differ if utilizing platform-specific libraries. 7. **Preserve Configuration:** Click "OK" to save the settings. ### Deployment Considerations **Critical Deployment Requirement:** If you choose dynamic linking with runtime packages, remember that you *must* distribute the correct architectural version (32-bit or 64-bit) of those `.bpl` files with your application. The 32-bit executable requires 32-bit `.bpl` files, while the 64-bit executable needs 64-bit `.bpl` files. Place these files either in the same directory as the `.exe` or in locations accessible through the system's PATH environment variable. ## Comprehensive Testing and Verification Methodologies ### Multi-platform Verification Configuration alone cannot guarantee success. Thorough testing becomes essential to confirm that everything functions as expected across both target platforms. 1. **Multi-platform Compilation:** Build your project explicitly for both "32-bit Windows" and "64-bit Windows" target platforms. Address any compiler errors that emerge during this process. Errors occurring during compilation frequently indicate incorrectly configured library paths (detailed in Step 2). 2. **32-bit Execution Testing:** Execute the compiled 32-bit application. Thoroughly test all functionality that depends on the components in question. Specifically look for: 3. Proper visual appearance and interactive behavior of components. 4. Absence of exceptions during component instantiation or method invocation. 5. If using runtime packages, verify the application launches without "Package XYZ not found" error messages. 6. **64-bit Execution Testing:** Execute the compiled 64-bit application. Perform identical tests as conducted with the 32-bit version. Pay particular attention to: 7. Any behavioral differences compared to the 32-bit version. 8. Runtime errors such as Access Violations, which might indicate underlying 64-bit compatibility issues in the component code or application logic (e.g., incorrect pointer arithmetic, integer size assumptions). 9. For runtime packages, check again for missing package errors, ensuring 64-bit `.bpl` files are properly accessible. 10. **Edge Case Evaluation:** Include testing scenarios that explore boundary conditions, particularly regarding memory usage if that represents a motivation for transitioning to 64-bit. Load extensive datasets and perform complex operations involving the components to stress-test the implementation. ### Interpreting Test Results Any discrepancies or errors encountered during runtime on one platform but not the other strongly suggest either a problem in package configuration (Steps 2 or 3) or potential 64-bit compatibility issues within the component or application code itself. Such issues require careful diagnosis and targeted resolution. ## Advanced Troubleshooting Guide ### Resolving Common Installation Issues - **"Package XYZ.bpl can't be installed because it is not a design time package."**: This error typically indicates an attempt to install a package via `Component > Install Packages` that lacks necessary design-time registrations or configuration flags. Verify that the package project is correctly configured as a design-time package or combined design-time & runtime package. - **"Can't load package XYZ.bpl. %1 is not a valid Windows application." / "The specified module could not be found."**: This almost certainly indicates an attempt to install a **64-bit** BPL into the 32-bit IDE via `Component > Install Packages`. Remember to install only 32-bit BPL files through this interface. The "module not found" variant may also occur if the package has dependencies that aren't properly installed or cannot be located. - **[Compiler Error] F1026 File not found: 'ComponentUnit.dcu'**: This error occurs during compilation (not at design time). It indicates the compiler cannot locate the required `.dcu` file for the currently selected target platform. Carefully review your `Project Options > Delphi Compiler > Library > Library path` settings for the *specific platform* you are currently compiling (Step 2). Ensure the path correctly references the appropriate directory (32-bit or 64-bit) containing the necessary `.dcu` files. - **[Linker Error] E2202 Required package 'XYZ' not found**: Similar to F1026, but occurring during the linking phase. This frequently indicates the `.dcp` file for the package cannot be found. Verify the Library Path (Step 2) includes the directory containing the correct platform's `.dcp` file. Additionally, ensure the package name appears correctly in `Project Options > Packages > Runtime Packages` if utilizing dynamic linking (Step 3). - **Runtime Error: "Package XYZ not found"**: This indicates your application was compiled to use runtime packages, but the required `.bpl` file (matching the application's architecture) cannot be located during application startup. Ensure the correct 32-bit or 64-bit `.bpl` files are deployed alongside your `.exe` file (as described in Step 3). - **Runtime Access Violations (AVs) only in 64-bit:** This typically indicates 64-bit compatibility issues in the code (either in your application or the component implementation). Common sources include: - Pointer arithmetic assuming `SizeOf(Pointer)=4` (valid only in 32-bit code). - Incorrect use of `Integer` instead of `NativeInt`/`NativeUInt` for handles or pointer-sized values. - Direct calls to Windows API functions using incorrect data types for 64-bit environments. - Data structure alignment issues. Debugging the 64-bit application becomes necessary to identify the specific cause of these violations. ## Working with Third-Party Component Packages ### Best Practices for External Components The principles outlined throughout this guide apply equally to third-party components. Reputable component vendors typically provide: 1. Detailed instructions for proper installation procedures. 2. Separate 32-bit and 64-bit compiled `.bpl`, `.dcp`, and `.dcu` files. 3. An installation utility that handles file placement in appropriate locations and potentially automates the installation of 32-bit design-time packages into the IDE. If an installer is provided, utilize it as your first approach. However, always validate project options (Library Paths, Runtime Packages) afterward, as installers may not perfectly configure paths for every possible project configuration or Delphi version. If you receive only raw library files without an installer, follow Steps 1-3 manually, carefully identifying and configuring paths for both 32-bit and 64-bit versions supplied by the vendor. When encountering issues, consult the vendor's documentation or contact their technical support team for assistance. ## Summary and Recommendations ### Key Implementation Strategies Successfully managing Delphi packages for both 32-bit and 64-bit development fundamentally depends on understanding the 32-bit nature of the IDE and meticulously configuring project options for each target platform independently. Always install the 32-bit package for design-time use, then carefully establish platform-specific Library Paths and Runtime Package settings to ensure the compiler and your final application can locate and utilize the correct files for the target architecture. While this approach introduces additional complexity compared to purely 32-bit development, the structured methodology enables you to leverage the substantial benefits of 64-bit compilation while maintaining a fully functional design-time experience within the familiar Delphi IDE environment. Consistent testing across both platforms represents the final, crucial verification step to guarantee robust, reliable applications that perform optimally in both 32-bit and 64-bit environments. --- Need additional information? Please [contact support](https://support.visioforge.com/) for assistance with specific scenarios or component issues. ---END OF PAGE--- ## Fix .otares File Errors in Delphi SDK Packages Guide **URL:** https://www.visioforge.com/help/docs/delphi/general/install-otares/ **Description:** Resolve missing .otares file errors in Delphi - troubleshoot resource issues, fix compilation errors, and restore package functionality. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL # Fixing .otares File Errors in Delphi Packages ## How to Solve the .otares File Not Found Error in Delphi When working with Delphi packages, developers frequently encounter the frustrating .otares file not found error that can completely halt your development workflow. This practical guide explains the problem, identifies common causes, and provides tested solutions to get your projects back on track. ### What is an .otares File? To effectively troubleshoot this issue, you need to understand the role of .otares files in Delphi: - Resource files specific to Delphi development environments - Contain compiled resources including images, icons, and binary assets - Generated during package compilation processes - Critical for packages with visual components or resource-dependent features ### Typical Error Messages You'll likely encounter these errors during compilation or installation: ``` [dcc32 Error] E1026 File not found: 'Package_Name.otares' [dcc32 Error] E1026 Could not locate resource file 'Component_Package.otares' [dcc32 Error] Package compilation failed due to missing .otares file ``` ### When This Issue Typically Occurs These errors commonly appear when: 1. Installing third-party component packages 2. Upgrading to newer Delphi versions 3. Moving projects between development machines 4. Collaborating with team members on shared projects ### Why .otares File Errors Happen Several factors can trigger these errors: 1. **Missing Resource Files**: The .otares file isn't in the expected location 2. **Incorrect Path References**: Package configuration references wrong location 3. **Version Compatibility Issues**: Resource file compiled for different Delphi version 4. **Corrupted Resources**: The file exists but is damaged 5. **Permission Problems**: Environment lacks access rights to the resource location ### Step-by-Step Solution Guide Follow these practical steps to resolve .otares-related issues: 1. **Find and Examine the .dpk File** 2. Navigate to your package's source directory 3. Open the .dpk file in Delphi IDE or text editor 4. Review all resource references 5. Focus on `$R` directives 6. **Identify Problematic Resource Directives** 7. Search for lines starting with `$R` or `{$R}` 8. These lines specify resource file inclusions 9. Example of problematic directives: ``` {$R 'Component_Package.otares'} {$R '.\resources\ComponentResources.otares'} ``` 1. **Apply the Fix** **Comment out the problematic resource reference:** ``` // Original line {$R 'Component_Package.otares'} // Modified version // {$R 'Component_Package.otares'} ``` 1. **Rebuild the Package** 2. Save all changes to the .dpk file 3. Restart the Delphi IDE to ensure changes are recognized 4. Clean the project (Project → Clean) 5. Rebuild the package (Project → Build) 6. If successful, install the package ### Advanced Solutions for Persistent Issues When basic fixes don't work, try these advanced approaches: 1. **Recreate Resource Files** 2. Locate the original source files 3. Use Resource Compiler to rebuild the .otares file 4. Update package references to the new file 5. **Check Package Dependencies** 6. Look for circular dependencies 7. Verify installation order is correct 8. Ensure version compatibility 9. **Verify Environment Configuration** 10. Check BDSCOMMONDIR setting 11. Verify PATH variables for resource locations 12. Confirm library paths in IDE options --- For personalized assistance with this issue, [contact our support team](https://support.visioforge.com/) and our technical experts will guide you through resolving your specific package installation problems. ---END OF PAGE--- ## Delphi and ActiveX Video SDK - Playback, Capture, Editing **URL:** https://www.visioforge.com/help/docs/delphi/ **Description:** VCL components and ActiveX controls for video playback, capture, screen recording, and editing in Delphi and C++ Builder. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Streaming, Editing **API:** TVFMediaPlayer, TVFVideoCapture, TVFVideoEdit # All-in-One Media Framework A set of Delphi/ActiveX libraries for video processing, playback, and capture called All-in-One Media Framework. These libraries help developers create professional video editing, playback, and capture applications with minimal effort and maximum performance. The framework provides a comprehensive solution for media handling in Delphi applications, offering high-performance video processing capabilities that would otherwise require extensive low-level programming. Developers can implement complex video workflows with simple component-based architecture. You can find the following library documentation here: ## Libraries - [TVFMediaPlayer](mediaplayer/) - Full-featured media player component with playlist support, frame-accurate seeking, and advanced playback controls - [TVFVideoCapture](videocapture/) - Powerful video capture component supporting webcams, capture cards, IP cameras, and screen recording - [TVFVideoEdit](videoedit/) - Professional video editing component with timeline support, transitions, filters, and output to multiple formats ## Implementation Examples The framework includes numerous examples demonstrating how to implement common media tasks: - Video players with custom controls and visualizations - Multi-camera recording applications - Video editing software with timeline support - Format conversion utilities - Streaming media applications ## General Information ActiveX packages can be used in multiple programming languages and development environments including Visual C++, Visual Basic, and C++ Builder. These components extend your software capabilities, accelerating development and improving performance. With ActiveX integration, you can incorporate existing software components into your projects, boosting efficiency and functionality. Our framework is compatible with all Delphi versions from Delphi 6 to Delphi 11 and beyond, making it suitable for both legacy projects and new development. The components maintain a consistent API across different Delphi versions, simplifying migration between different IDE versions. ## Technical Specifications - **Supported Media Formats**: MP4, AVI, MOV, MKV, MPEG, WMV and many others - **Audio Support**: AAC, MP3, PCM, WMA and other popular audio codecs - **Video Codecs**: H.264, H.265/HEVC, MPEG-4, VP9, AV1 and more - **Capture Sources**: Webcams, HDMI capture cards, IP cameras, screen capture - **Hardware Acceleration**: NVIDIA NVENC, Intel Quick Sync, AMD AMF ## x64 Support Limitations With Delphi XE2 and later, you can develop 64-bit applications. Our framework fully supports these 64-bit applications, allowing you to leverage modern computing power and handle larger memory requirements. 64-bit support enables processing of higher resolution videos and more complex editing operations that would be impossible in 32-bit environments. Microsoft Visual Basic 6 does not support 64-bit applications. If you're using Visual Basic 6, you'll need to use the 32-bit version of our framework due to VB6's inherent limitations. While 32-bit applications can access up to 4GB of memory with proper configuration, for demanding video applications, we recommend using Delphi or other development environments with 64-bit support. ## Development Best Practices When integrating the framework into your applications, consider these best practices: - Initialize components at design time when possible for better IDE integration - Use hardware acceleration for demanding operations like encoding and decoding - Implement proper error handling for media operations - Consider memory management for large media files - Test with various media sources to ensure compatibility --- For more information about the framework, visit the [All-in-One Media Framework (Delphi/ActiveX)](https://www.visioforge.com/all-in-one-media-framework) product page. ---END OF PAGE--- ## TVFMediaPlayer Delphi Changelog - Version History v3 to v10 **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/changelog/ **Description:** TVFMediaPlayer changelog - track version history from 3.0 to 10.0 with 4K support, encryption, effects, streaming, and performance updates. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Playback, Streaming **API:** TVFMediaPlayer # TVFMediaPlayer Library Changelog This document details the evolution of the TVFMediaPlayer library, chronicling the significant features, enhancements, optimizations, and bug fixes introduced across various versions. It serves as a comprehensive reference for developers tracking the library's progress and understanding the capabilities added over time. ## Version 10.0: Enhanced Media Handling and Customization Version 10.0 represents a significant step forward, focusing on improved media introspection, logging, customization, and compatibility. ### Core Enhancements - **Enhanced Media Information Reader:** This version significantly boosts the capabilities of the media information reader. It enables faster, more accurate extraction of metadata from an extensive array of media file types. Developers gain reliable access to critical details like duration, resolution, codec specifics, bitrates, and embedded tags, which streamlines media management and enhances the display capabilities within applications. - **Improved Logging Capabilities:** Logging has been substantially refined, offering developers more granular control. Configuration options now include distinct log levels (Debug, Info, Warning, Error) and flexible output destinations such as files, the console, or custom endpoints. This facilitates more effective issue diagnosis during development and robust monitoring of application behavior in production, ultimately leading to quicker troubleshooting and increased application stability. - **Standard Metadata Tag Support:** A cornerstone of this release is the introduction of comprehensive support for reading standard metadata tags embedded within popular video and audio containers. This includes formats like MP4, WMV, MP3, AAC, M4A, and Ogg Vorbis. Applications utilizing TVFMediaPlayer can now seamlessly extract and leverage common tags such as title, artist, album, genre, year, and cover art, thereby enriching the user experience by providing valuable context for the media being played. ### Capture and Effects Improvements - **Configurable Auto-Split Filenames:** The new `SeparateCapture_Filename_Mask` property provides fine-grained control over filenames when using the auto-split capture feature based on duration or size. This allows for customized naming conventions, improving organization and workflow for segmented recordings. - **JSON Settings Serialization:** Configuration settings for the media player can now be easily serialized to and deserialized from the widely-used JSON format. This simplifies saving and loading player configurations, enabling persistent settings and easier integration with configuration management systems. - **Custom Video Effects Pipeline:** Flexibility in video processing is enhanced with the ability to insert custom video effects using third-party filters identified by their CLSID. These filters can be strategically placed either before or after the main effects filter or sample grabber, allowing for sophisticated, tailored video manipulation pipelines. - **Optimized Video Effects:** Video effects processing has been optimized to take full advantage of the latest generations of Intel CPUs, resulting in smoother playback and lower resource consumption when applying effects. ### Source and Compatibility Fixes - **MP3 Splitter for Playback Issues:** An MP3 splitter has been integrated to specifically address and resolve playback inconsistencies encountered with certain non-standard or problematic MP3 files, ensuring broader compatibility. - **Updated VLC Source Filter:** The underlying VLC source filter has been updated to libVLC version 2.2.2.0. This update brings notable improvements, particularly in handling RTMP and HTTPS streams, and resolves previously identified memory leaks, contributing to enhanced stability and broader streaming protocol support. - **Pan and Blur Effect Fixes:** Specific issues related to the Pan effect in x64 builds and the Blur effect have been addressed and resolved, ensuring consistent visual effect behavior across different architectures. - **FFMPEG Source Memory Leak Resolved:** A memory leak associated with the FFMPEG source component has been identified and fixed, improving long-term stability and resource management during playback. ## Version 9.2: Engine Updates and Reader Enhancements This interim release focused on updating core components and further refining the media information capabilities. - **Updated VLC Engine:** The integrated VLC engine was updated to libVLC version 2.2.1.0, incorporating upstream fixes and improvements from the VLC project for better stability and format compatibility. - **Enhanced Media Information Reader:** Building upon previous improvements, the media information reader received further enhancements for broader file support and more accurate metadata extraction. - **Updated FFMPEG Engine:** The FFMPEG engine components were updated, ensuring compatibility with newer codecs and formats while incorporating performance optimizations. ## Version 9.1: Advanced Security Integration Version 9.1 introduced robust security features through integration with the Video Encryption SDK. - **Video Encryption SDK v9 Support:** This version added compatibility with the Video Encryption SDK v9. This enables developers to implement strong AES-256 encryption for their video content, using either separate key files or embedded binary data as keys, significantly enhancing content protection capabilities. ## Version 9.0: Audio Enhancements and Logo Flexibility Version 9.0 brought significant improvements to audio handling and visual branding options. - **Animated GIF Logo Support:** The capability to use image logos was expanded to include support for animated GIFs, allowing for more dynamic and engaging visual branding within the video playback interface. - **Audio Enhancements:** A suite of audio enhancement features was introduced, including audio normalization to ensure consistent volume levels, automatic gain control (AGC) to dynamically adjust volume, and manual gain controls for precise audio level adjustments. - **Percentage-Based Audio Volume:** The API for controlling audio volume was modernized to use a percentage-based system (0-100%), providing a more intuitive and standardized way to manage audio levels compared to previous methods. ## Version 8.6: Decoder Expansion and API Additions This release focused on expanding codec support, adding flexibility through custom filters, and refining the API. - **H264 CPU/Intel QuickSync Decoder:** A highly optimized H264 video decoder was added, leveraging both CPU resources and Intel QuickSync hardware acceleration where available. This significantly improves performance for decoding one of the most common video codecs. - **Custom DirectShow Video Filter Support:** Developers gained the ability to integrate their own custom DirectShow video filters into the playback graph, allowing for highly specialized video processing tasks. - **`OnNewFilePlaybackStarted` Event:** A new event, `OnNewFilePlaybackStarted`, was introduced. This event fires specifically when a new file begins playing within a playlist context, enabling applications to react precisely to transitions between media items. - **Updated Decoders:** The Ogg Vorbis audio decoder and WebM video decoders were updated to their latest versions, ensuring compatibility and performance improvements. - **Frame Grabber API Update:** The API for grabbing individual video frames was updated, potentially offering improved performance or flexibility. - **Bug Fixes:** Various unspecified bug fixes were implemented to improve overall stability and reliability. ## Version 8.5: Rotation, 4K Readiness, and Rendering Options Version 8.5 introduced innovative video manipulation features and prepared the engine for ultra-high-definition content. - **On-the-Fly Video Rotation:** A new video effect was added, enabling real-time rotation of the video stream during playback (e.g., 90, 180, 270 degrees). - **Updated FFMPEG Source:** The FFMPEG source component was updated, likely incorporating support for newer formats or improving performance. - **4K-Ready Video Effects:** Existing video effects were optimized and tested to ensure they perform efficiently with 4K resolution video content. - **VMR-9/EVR Zoom Shift Bug Fix:** A specific bug related to unexpected image shifting when using zoom with the VMR-9 or EVR video renderers was corrected. - **Direct2D Video Renderer (Beta):** A new video renderer based on Direct2D was introduced as a beta feature. This renderer included support for live video rotation and aimed to leverage modern graphics APIs for potentially improved performance and quality. - **Bug Fixes:** Included various general bug fixes to enhance stability. ## Version 8.4: Decoder Updates and Stability This was primarily a maintenance release focused on updating core components. - **Updated FFMPEG Decoder:** The FFMPEG decoder components were updated, likely incorporating fixes and improvements from the FFMPEG project. - **Bug Fixes:** Addressed various unspecified bugs for improved stability. ## Version 8.3: Stability Release This release focused solely on addressing bugs identified in previous versions. - **Bug Fixes:** Implemented various fixes to enhance the overall reliability and stability of the library. ## Version 8.0: Introducing the VLC Engine Version 8.0 marked a significant architectural addition by integrating the powerful VLC engine. - **VLC Engine Integration:** The renowned VLC engine was integrated as an alternative playback backend for video and audio files. This brought VLC's extensive format support and robust streaming capabilities to TVFMediaPlayer applications. - **Bug Fixes:** Included various general bug fixes. ## Version 7.x Series: Effects, Encryption, and Playlists The Version 7 series introduced key features related to playback control, security, and visual effects. ### Version 7.20 - **Reverse Playback:** Added the capability to play video files in reverse, opening up creative possibilities and specialized application use cases. - **Bug Fixes:** Addressed various bugs. ### Version 7.12 - **Video Encryption Support:** Initial support for video encryption was added, providing basic content protection mechanisms. - **Bug Fixes:** Included general stability improvements. ### Version 7.7 - **Fade-In/Fade-Out Effect:** A common and useful video transition effect, fade-in/fade-out, was added to the available video effects. - **Playlist Support:** Functionality for creating and managing playlists was introduced, allowing sequences of media files to be played automatically. - **Bug Fixes:** Addressed various issues. ### Version 7.5 - **Improved Chroma Key:** The chroma key (green screen) effect was enhanced for better quality and more precise control. - **Enhanced Text Logo:** The feature for overlaying text logos onto the video was improved. - **Modified Video Effects API:** The API for applying video effects underwent modifications, potentially for improved usability or to accommodate new features. - **Bug Fixes:** Included various stability fixes. ### Version 7.0 - **Windows 8 RTM Support:** Ensured compatibility with the release version of Windows 8. - **Enhanced Video Effects:** Further improvements were made to the quality and performance of existing video effects. - **New FFMPEG Playback Engine:** Introduced a new playback engine based on FFMPEG components, offering an alternative to the default DirectShow-based playback and expanding format compatibility. ## Version 6.x Series: Windows 8 Compatibility and Optimizations The Version 6 series focused on adapting to the then-new Windows 8 operating system and improving performance. ### Version 6.3 - **Windows 8 Customer Preview Support:** Added compatibility for the pre-release Customer Preview version of Windows 8. - **Improved Video Effects:** Continued refinement of video effect performance and quality. ### Version 6.0 - **Enhanced OpenCL Support:** Improved utilization of OpenCL for GPU acceleration tasks, potentially boosting performance for effects or decoding on compatible hardware. - **Windows 8 Developer Preview Support:** Added early support for the Developer Preview version of Windows 8. - **Improved Video Effects:** General enhancements to the video effects subsystem. ## Version 3.x Series: Early Features and Optimizations The Version 3 series laid groundwork features and focused on CPU-specific optimizations. ### Version 3.9 - **New Installers:** Introduced a new main installer and separate redistributable installers for easier deployment. - **Minor Bug Fixes:** Addressed minor outstanding issues. ### Version 3.7 - **Improved Video Effects:** Enhancements made to the video effects features. - **New Demo Applications:** Added new demo applications to showcase library capabilities. - **Netbook CPU Optimizations:** Included specific performance optimizations tailored for Intel Core II/Atom and AMD netbook processors. - **Minor Bug Fixes:** General stability improvements. ### Version 3.5 - **Improved Video Effects:** Continued work on enhancing video effects. - **Intel Core i7 Optimizations:** Added new performance optimizations specifically for the then-new Intel Core i7 CPU architecture. ### Version 3.0 - **Motion Detection:** Introduced a motion detection feature, enabling applications to react to changes within the video stream. - **Chroma Key:** Added initial chroma key (green screen) functionality. - **MMS/WMV Source Support:** Included support for streaming using the MMS protocol and playing WMV (Windows Media Video) files. - **CPU Optimizations:** Added performance optimizations targeted at Intel Atom and Core i3/i5/i7 processors. - **Direct Stream Processing:** Enabled the capability to directly access and process decoded video and audio stream data, offering advanced manipulation possibilities. ---END OF PAGE--- ## TVFMediaPlayer Deployment Guide — Delphi and ActiveX **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/deployment/ **Description:** Deploy TVFMediaPlayer apps with silent installers or manual setup. Covers codec packages, DirectShow filters, VC++ redistributables, and dependencies. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Playback, IP Camera **API:** TVFMediaPlayer # Deployment Guide for TVFMediaPlayer Deploying applications built with the TVFMediaPlayer library requires ensuring that all necessary components are correctly installed and configured on the target machine. This guide provides detailed instructions for both automated and manual deployment methods, catering to different scenarios and technical requirements. Whether you prefer the simplicity of silent installers or the granular control of manual setup, this document covers the essential steps to successfully deploy your Delphi or ActiveX media player application. ## Understanding Deployment Requirements Before deploying your application, it's crucial to understand the dependencies of the TVFMediaPlayer library. The library relies on several core components, including base runtimes, specific codecs (like FFMPEG or VLC for certain sources), and Microsoft Visual C++ Redistributables. The deployment method you choose will determine how these dependencies are handled. ### Core Components - **Base Library:** Contains the essential engine and DirectShow filters for basic playback functionality. - **Codec Packages:** Optional but often necessary for supporting a wide range of media formats and network streams (e.g., IP cameras). FFMPEG and VLC are common choices provided. - **Runtime Dependencies:** Microsoft Visual C++ Redistributable packages are required for the core library components to function correctly. Choosing the right deployment strategy depends on factors like user privileges on the target machine, the need for unattended installation, and the specific features of your application (e.g., which media sources it needs to support). ## Method 1: Automated Installation (Admin Rights Required) Using the provided silent installers is the most straightforward method for deploying the TVFMediaPlayer library components. These installers handle the registration of necessary files and ensure all dependencies are correctly placed. This method requires administrative privileges on the target machine as it involves system-level changes like registering COM components and potentially modifying the system PATH. ### Available Installers VisioForge provides separate installers for the base library and optional codec packages, with versions for both Delphi and ActiveX, and for x86 and x64 architectures. #### Base Package (Mandatory) This package installs the core TVFMediaPlayer components and essential DirectShow filters. It's always required, regardless of the media sources your application uses. Choose the installer corresponding to your development environment (Delphi or ActiveX) and target architecture (x86 or x64). - **Delphi:** - [x86 Installer](https://files.visioforge.com/redists_delphi/redist_media_player_base_delphi.exe) - [x64 Installer](https://files.visioforge.com/redists_delphi/redist_media_player_base_delphi_x64.exe) - **ActiveX:** - [x86 Installer](https://files.visioforge.com/redists_delphi/redist_media_player_base_ax.exe) - [x64 Installer](https://files.visioforge.com/redists_delphi/redist_media_player_base_ax_x64.exe) #### FFMPEG Package (Optional - For File/IP Camera Sources) If your application needs to play local files or stream from IP cameras using the FFMPEG engine, you must deploy this package. FFMPEG provides a wide range of codec support. - **FFMPEG:** - [x86 Installer](https://files.visioforge.com/redists_delphi/redist_media_player_ffmpeg.exe) - *Note: An x64 FFMPEG installer link was not explicitly provided in the original source; assume x86 covers most needs or consult VisioForge documentation for x64 specifics if required.* #### VLC Source Package (Optional - For File/IP Camera Sources) As an alternative or addition to FFMPEG, you can use the VLC engine for file and IP camera sources. This requires deploying the VLC package. Ensure you select the correct architecture. - **VLC:** - [x86 Installer](https://files.visioforge.com/redists_net/redist_dotnet_vlc_x86.exe) - [x64 Installer](https://files.visioforge.com/redists_net/redist_dotnet_vlc_x64.exe) ### Installer Usage These installers are designed for silent execution, making them suitable for inclusion in larger application setup routines or for deployment via scripts. Run the executable(s) with administrator privileges on the target machine. ``` # Example: Running the base Delphi x86 installer silently redist_media_player_base_delphi.exe /S ``` *(Note: The exact silent switch might vary; consult the installer documentation or use standard switches like `/S`, `/silent`, or `/q` if `/S` doesn't work).* ## Method 2: Manual Installation (Admin Rights Recommended) Manual installation offers more control but requires careful execution of each step. This method is suitable when automated installers cannot be used, or when deploying to environments with specific restrictions. While some steps might be achievable without full admin rights, registering COM components typically requires elevation. ### Prerequisites Before copying library files, ensure the necessary runtime dependencies are present on the target system. #### Install VC++ 2010 SP1 Redistributable The TVFMediaPlayer library relies on the Microsoft Visual C++ 2010 SP1 runtime. Install the appropriate version (x86 or x64) for your application's target architecture. - **VC++ 2010 SP1:** - [x86 Redistributable](https://files.visioforge.com/shared/vcredist_2010_x86.exe) - [x64 Redistributable](https://files.visioforge.com/shared/vcredist_2010_x64.exe) Run these installers before proceeding with the library file deployment. ### Deploying Core Library Files Follow these steps to manually install the base library components: 1. **Copy Core DLLs:** Locate the `Redist\Filters` folder within your TVFMediaPlayer installation directory. Copy all the DLL files from this folder to a deployment directory on the target machine. A common practice is to place these DLLs in the same folder as your application's executable. 2. **Register DirectShow Filters:** The core functionality relies on several DirectShow filters (`.ax` files). These must be registered with the Windows operating system using Component Object Model (COM) registration. - **Identify Filters:** The key filters to register are: - `VisioForge_Audio_Effects_4.ax` - `VisioForge_Dump.ax` - `VisioForge_RGB2YUV.ax` - `VisioForge_Video_Effects_Pro.ax` - `VisioForge_YUV2RGB.ax` - *(Note: Other `.ax` files might be present; register all `.ax` files found in the `Redist\Filters` directory).* - **Registration Method:** Use the `regsvr32.exe` command-line tool, which is part of Windows. Open an Command Prompt **as Administrator** and run the command for each `.ax` file. ``` # Example: Registering a filter (run from the directory containing the .ax file) regsvr32.exe VisioForge_Video_Effects_Pro.ax ``` Alternatively, VisioForge provides a utility `reg_special.exe` in the redistributables. Copy this utility to the folder containing the `.ax` files and run it with administrator privileges to register all filters in that directory automatically. Refer to Microsoft's documentation for troubleshooting `regsvr32.exe` errors: [How to use the Regsvr32 tool](https://support.microsoft.com/en-us/topic/how-to-use-the-regsvr32-tool-and-troubleshoot-regsvr32-error-messages-a98d960a-7392-e6fe-d90a-3f4e0cb543e5). 3. **Update System PATH (Optional but Recommended):** If the filter DLLs and `.ax` files are placed in a directory separate from your application's executable, you must add the path to this directory to the system's `PATH` environment variable. This allows the operating system and your application to locate these essential files. Failure to do this can result in "DLL not found" or filter registration errors. ### Deploying Optional Packages Manually #### FFMPEG Deployment 1. **Copy Files:** Copy the entire contents of the `Redist\FFMPEG` folder from your TVFMediaPlayer installation to a deployment directory on the target machine (e.g., a subfolder within your application's installation directory). 2. **Update System PATH:** Add the full path to the folder where you copied the FFMPEG files to the Windows system `PATH` environment variable. This is crucial for the library to find and load the FFMPEG components. #### VLC Deployment (Example: x86) 1. **Copy Files:** Copy the entire contents of the `Redist\VLC` folder (specifically the x86 version if applicable) to a deployment directory. 2. **Register VLC Filter:** Locate the `.ax` file within the copied VLC files (e.g., `axvlc.dll` or similar, though the original text only generically mentions ".ax file") and register it using `regsvr32.exe` with administrator privileges. 3. **Set Environment Variable:** Create a new system environment variable named `VLC_PLUGIN_PATH`. Set its value to the full path of the `plugins` subfolder within the directory where you copied the VLC files (e.g., `C:\YourApp\VLC\plugins`). This tells the VLC engine where to find its necessary plugin modules. ## Verification and Troubleshooting After deployment, thoroughly test your application on the target machine. - Check basic playback functionality. - Test any specific features that rely on optional packages (FFMPEG or VLC), such as playing various file formats or connecting to IP cameras. - If errors occur, double-check: - Admin rights during installation/registration. - Correct installation of VC++ Redistributables. - Successful registration of all `.ax` files (check `regsvr32.exe` output). - Accurate configuration of `PATH` and `VLC_PLUGIN_PATH` environment variables. - Correct architecture (x86/x64) match between your application, the library components, and runtime dependencies. --- Need further assistance? Contact [VisioForge Support](https://support.visioforge.com/). Explore more examples on our [GitHub](https://github.com/visioforge/). ---END OF PAGE--- ## Play Multiple Video Streams with Delphi SDK Player **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/file-multiple-video-streams/ **Description:** Handle multiple video streams in files - select camera angles, switch resolutions, and manage tracks with code examples for Delphi, C++, and VB6. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, C++, Windows, VCL, Playback, MKV **API:** TVFMediaPlayer, CVFMediaPlayer # Playing Video Files with Multiple Video Streams ## Understanding Multiple Video Streams ### What Are Multiple Video Streams? Multiple video streams refer to different video tracks contained within a single media file. These streams can vary in several ways: - Different camera angles of the same scene - Alternate versions with varying resolutions or bitrates - Primary and secondary content (such as picture-in-picture) - Different aspect ratios or formats of the same content - Versions with or without special effects or graphics ### Supported File Formats Many popular container formats support multiple video streams, including: - **Matroska (MKV)**: Widely recognized for its flexibility and robust support for multiple streams - **MP4/MPEG-4**: Common in both professional and consumer applications - **AVI**: Although older, still widely used in some contexts - **WebM**: Popular for web-based applications - **TS/MTS**: Used in broadcast applications and consumer video cameras Each format has its own characteristics and limitations regarding how it handles multiple video streams, but the `TVFMediaPlayer` component provides a unified approach to working with them. ## Implementing Multiple Video Stream Playback ### Setting Up the Media Player The first step is to properly initialize the `TVFMediaPlayer` object. This involves creating the instance, configuring basic properties, and preparing it for playback. Snippets are fragments of one procedure The Pascal snippets in the three sub-sections below are excerpts from a single procedure (`TForm1.SetupAndPlayMultiStream`), split for narrative clarity. The full pasteable listing is at the [end of this section](#complete-pascal-listing). ``` // Excerpt — see "Complete Pascal listing" below for the full procedure. procedure TForm1.SetupAndPlayMultiStream; var MediaPlayer1: TVFMediaPlayer; begin MediaPlayer1 := TVFMediaPlayer.Create(Self); // Set container size and position if needed MediaPlayer1.Parent := Panel1; // Assuming Panel1 is your container MediaPlayer1.Align := alClient; // Configure initial state MediaPlayer1.DoubleBuffered := True; MediaPlayer1.AutoPlay := False; // We'll control playback explicitly // ... continued below end; ``` ### Configuring the Media Source Next, we need to specify the media file and configure how it should be loaded: ``` // Excerpt — body of TForm1.SetupAndPlayMultiStream (continued). // Set the file name - use full path for reliability MediaPlayer1.FilenameOrURL := 'C:\Videos\multistream-video.mkv'; // Enable audio playback (default DirectSound audio renderer will be used) MediaPlayer1.Audio_Play := True; // Configure audio settings if needed MediaPlayer1.Audio_Volume := 85; // Set volume to 85% // Set the source mode to DirectShow // Other options include SM_File_FFMPEG or SM_File_VLC MediaPlayer1.Source_Mode := SM_File_DS; ``` ### Selecting and Switching Video Streams The key to working with multiple video streams is the `Source_VideoStreamIndex` property. This zero-based index allows you to select which video stream should be rendered: ``` // Excerpt — body of TForm1.SetupAndPlayMultiStream (final part). // Set video stream index to 1 (second stream, as index is zero-based) MediaPlayer1.Source_VideoStreamIndex := 1; // Start playback MediaPlayer1.Play(); end; ``` ### Complete Pascal listing The three excerpts above merged into one self-contained, copy-pasteable procedure: ``` procedure TForm1.SetupAndPlayMultiStream; var MediaPlayer1: TVFMediaPlayer; begin MediaPlayer1 := TVFMediaPlayer.Create(Self); // Container + initial state MediaPlayer1.Parent := Panel1; MediaPlayer1.Align := alClient; MediaPlayer1.DoubleBuffered := True; MediaPlayer1.AutoPlay := False; // Source + audio configuration MediaPlayer1.FilenameOrURL := 'C:\Videos\multistream-video.mkv'; MediaPlayer1.Audio_Play := True; MediaPlayer1.Audio_Volume := 85; MediaPlayer1.Source_Mode := SM_File_DS; // Pick a non-default video stream and start playback MediaPlayer1.Source_VideoStreamIndex := 1; MediaPlayer1.Play(); end; ``` ## C++ MFC Implementation ### Setting Up the Media Player Here's how to implement multiple video stream playback using C++ with MFC: ``` // In your header file (MyDlg.h) private: CVFMediaPlayer* m_pMediaPlayer; // In your implementation file (MyDlg.cpp) BOOL CMyDlg::OnInitDialog() { CDialog::OnInitDialog(); // Create the MediaPlayer instance m_pMediaPlayer = new CVFMediaPlayer(); // Initialize the control CWnd* pContainer = GetDlgItem(IDC_PLAYER_CONTAINER); // Your container control m_pMediaPlayer->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), pContainer, 1001); // Configure display settings — CWnd::GetClientRect(LPRECT) returns void // and fills the rect by reference, so we must declare a CRect first. CRect rc; pContainer->GetClientRect(&rc); m_pMediaPlayer->SetWindowPos(NULL, 0, 0, rc.Width(), rc.Height(), SWP_NOZORDER); m_pMediaPlayer->PutDoubleBuffered(TRUE); m_pMediaPlayer->PutAutoPlay(FALSE); return TRUE; } ``` ### Configuring the Media Source ``` void CMyDlg::PlayMultiStreamVideo() { // Set the file path and configure source m_pMediaPlayer->PutFilenameOrURL(_T("C:\\Videos\\multistream-video.mkv")); // Configure audio m_pMediaPlayer->PutAudio_Play(TRUE); m_pMediaPlayer->PutAudio_Volume(85); // Set source mode to DirectShow m_pMediaPlayer->PutSource_Mode(SM_File_DS); // Select the second video stream (index 1) m_pMediaPlayer->PutSource_VideoStreamIndex(1); // Start playback m_pMediaPlayer->Play(); } // Don't forget to clean up void CMyDlg::OnDestroy() { if (m_pMediaPlayer != NULL) { m_pMediaPlayer->DestroyWindow(); delete m_pMediaPlayer; m_pMediaPlayer = NULL; } CDialog::OnDestroy(); } ``` ## VB6 Implementation Here's how to implement multiple video stream playback in Visual Basic 6: ``` ' Declare the MediaPlayer object at form level Private WithEvents MediaPlayer1 As TVFMediaPlayer Private Sub Form_Load() ' Create the MediaPlayer instance Set MediaPlayer1 = New TVFMediaPlayer ' Set container properties MediaPlayer1.CreateControl MediaPlayer1.Parent = Frame1 ' Assuming Frame1 is your container MediaPlayer1.Left = 0 MediaPlayer1.Top = 0 MediaPlayer1.Width = Frame1.ScaleWidth MediaPlayer1.Height = Frame1.ScaleHeight ' Configure initial state MediaPlayer1.DoubleBuffered = True MediaPlayer1.AutoPlay = False End Sub Private Sub btnPlay_Click() ' Set the file name - use full path for reliability MediaPlayer1.FilenameOrURL = "C:\Videos\multistream-video.mkv" ' Enable audio playback MediaPlayer1.Audio_Play = True MediaPlayer1.Audio_Volume = 85 ' Set volume to 85% ' Set the source mode to DirectShow MediaPlayer1.Source_Mode = SM_File_DS ' Select the second video stream (index 1) MediaPlayer1.Source_VideoStreamIndex = 1 ' Start playback MediaPlayer1.Play End Sub Private Sub Form_Unload(Cancel As Integer) ' Clean up resources Set MediaPlayer1 = Nothing End Sub ``` ## Conclusion The ability to play video files with multiple streams opens up numerous possibilities for creating rich, interactive multimedia experiences. The `TVFMediaPlayer` component provides a straightforward approach to implementing this functionality, with flexible options to suit different application requirements. By following the techniques outlined in this guide, you can effectively incorporate multiple video stream support into your applications, enhancing user experience and expanding the capabilities of your multimedia projects. --- Please get in touch with [support](https://support.visioforge.com/) if you need assistance with this functionality. Visit our [GitHub](https://github.com/visioforge/) page for additional code samples and implementation examples. ---END OF PAGE--- ## Media Player SDK for Delphi - TVFMediaPlayer Guide **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/ **Description:** Embed video and audio playback in Delphi apps with TVFMediaPlayer, including playback controls, seeking, volume, frame capture, audio tracks, and fullscreen. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Playback, Streaming **API:** TVFMediaPlayer # Media Player SDK for Delphi [Media Player SDK Delphi](https://www.visioforge.com/all-in-one-media-framework) This page covers using Media Player SDK with Delphi to build multimedia playback applications around the `TVFMediaPlayer` VCL component. ## Main Component ### TVFMediaPlayer `TVFMediaPlayer` is a `TCustomPanel` descendant that exposes the full playback API. Drop it on a form at design time, or create it programmatically and attach it to a host panel. ``` var MediaPlayer1: TVFMediaPlayer; begin MediaPlayer1 := TVFMediaPlayer.Create(Self); MediaPlayer1.Parent := Panel1; MediaPlayer1.Align := alClient; end; ``` ## Basic Playback ### Play a File Set `FilenameOrURL` to the input path (or network URL), pick a source engine via `Source_Mode`, then call `Play`. ``` procedure TForm1.PlayFile(const Filename: WideString); begin MediaPlayer1.FilenameOrURL := Filename; MediaPlayer1.Source_Mode := SM_File_FFMPEG; // SM_File_DS, SM_File_VLC, SM_File_LAV MediaPlayer1.Audio_Play := True; MediaPlayer1.Play; end; ``` ### Playback Controls `Play` returns `True` on success. `Pause`, `Resume`, and `Stop` are procedures. ``` procedure TForm1.btnPlayClick(Sender: TObject); begin MediaPlayer1.Play; end; procedure TForm1.btnPauseClick(Sender: TObject); begin MediaPlayer1.Pause; end; procedure TForm1.btnResumeClick(Sender: TObject); begin MediaPlayer1.Resume; end; procedure TForm1.btnStopClick(Sender: TObject); begin MediaPlayer1.Stop; end; ``` The current state is exposed by the read-only `Status` property (`ST_PLAY`, `ST_PAUSE`, `ST_FREE`). ``` if MediaPlayer1.Status = ST_PLAY then StatusBar1.SimpleText := 'Playing'; ``` ## Seeking Position is expressed in milliseconds. `Position_Get_Time` returns the current position, `Position_Set_Time` seeks to an absolute position, and `Info_Video_DurationMSec(0)` returns the total duration of the first video stream. ``` procedure TForm1.SeekTo(PositionMs: Integer); begin MediaPlayer1.Position_Set_Time(PositionMs); end; function TForm1.GetDurationMs: Integer; begin Result := MediaPlayer1.Info_Video_DurationMSec(0); end; function TForm1.GetPositionMs: Integer; begin Result := MediaPlayer1.Position_Get_Time; end; ``` Frame-accurate seeking is also available via `Position_Get_Frame` and `Position_Set_Frame`. ## Audio Control `TVFMediaPlayer` supports up to eight independent audio output streams. Volume and balance are addressed by zero-based stream index. ``` procedure TForm1.SetVolume(StreamIndex, Volume: Integer); begin // Volume range: 0..100 (SDK scales internally) MediaPlayer1.Audio_Volume_Set(StreamIndex, Volume); end; function TForm1.GetVolume(StreamIndex: Integer): Integer; begin Result := MediaPlayer1.Audio_Volume_Get(StreamIndex); end; procedure TForm1.SetBalance(StreamIndex, Balance: Integer); begin // Balance range: -100 (left) to +100 (right) MediaPlayer1.Audio_Balance_Set(StreamIndex, Balance); end; ``` To mute audio, set the volume to zero and restore the previous value on unmute, or toggle `Audio_Play` before starting playback. ``` procedure TForm1.Mute; begin FSavedVolume := MediaPlayer1.Audio_Volume_Get(0); MediaPlayer1.Audio_Volume_Set(0, 0); end; procedure TForm1.Unmute; begin MediaPlayer1.Audio_Volume_Set(0, FSavedVolume); end; ``` ## Playback Speed `SetSpeed` accepts a multiplier between 0.01 and 100.0. ``` procedure TForm1.SetPlaybackSpeed(Rate: Double); begin // Rate: 0.5 (half speed) to 2.0 (double speed) MediaPlayer1.SetSpeed(Rate); end; ``` ## Network URL Playback The same `FilenameOrURL` property accepts network URLs. Pick the engine that best supports the protocol — `SM_File_VLC` and `SM_File_FFMPEG` cover the broadest set of streaming sources; `SM_MMS_WMV_DS` is dedicated to MMS/WMV streams. ``` procedure TForm1.PlayURL(const URL: WideString); begin MediaPlayer1.FilenameOrURL := URL; MediaPlayer1.Source_Mode := SM_File_FFMPEG; MediaPlayer1.Play; end; procedure TForm1.PlayRTSP; begin MediaPlayer1.FilenameOrURL := 'rtsp://192.168.1.100:554/stream'; MediaPlayer1.Source_Mode := SM_File_FFMPEG; MediaPlayer1.Play; end; procedure TForm1.PlayHLS; begin MediaPlayer1.FilenameOrURL := 'https://server.example.com/playlist.m3u8'; MediaPlayer1.Source_Mode := SM_File_FFMPEG; MediaPlayer1.Play; end; ``` ## Frame Capture `Frame_Save` writes the current frame to disk in the chosen image format. `Frame_GetCurrent` fills a `TBitmap` you supply. ``` procedure TForm1.CaptureFrame; begin // Frame_Save(Filename, Format, Quality) MediaPlayer1.Frame_Save('C:\Snapshots\frame.jpg', IM_JPEG, 85); end; procedure TForm1.CaptureFrameToBitmap; var Bitmap: TBitmap; begin Bitmap := TBitmap.Create; try MediaPlayer1.Frame_GetCurrent(Bitmap); Image1.Picture.Assign(Bitmap); finally Bitmap.Free; end; end; ``` Optionally resize the saved frame by configuring `Frame_Save_Resize`, `Frame_Save_Resize_Width`, and `Frame_Save_Resize_Height` before the call. ## Audio and Subtitle Tracks The `Info_Audio_*` and `Info_Text_*` helpers enumerate streams discovered inside the source file. Audio streams are enabled or disabled individually with `Audio_SetStream`. ``` procedure TForm1.PopulateAudioTracks; var i: Integer; begin cbAudioTracks.Items.Clear; for i := 0 to MediaPlayer1.Info_Audio_Streams_Count - 1 do cbAudioTracks.Items.Add(MediaPlayer1.Info_Audio_Codec(i)); end; procedure TForm1.SelectAudioTrack(Index: Integer); var i: Integer; begin // Enable the chosen track and disable the others for i := 0 to MediaPlayer1.Info_Audio_Streams_Count - 1 do MediaPlayer1.Audio_SetStream(i, i = Index); end; procedure TForm1.PopulateSubtitles; var i: Integer; begin cbSubtitles.Items.Clear; for i := 0 to MediaPlayer1.Info_Text_Streams_Count - 1 do cbSubtitles.Items.Add(MediaPlayer1.Info_Text_Name(i)); end; ``` `Info_Text_Language(i)` and `Info_Text_Codec(i)` are also available for richer subtitle metadata. ## Fullscreen Mode Toggle fullscreen via the `Screen_VR_FullScreen` property. This works with the configured video renderer. ``` procedure TForm1.ToggleFullscreen; begin MediaPlayer1.Screen_VR_FullScreen := not MediaPlayer1.Screen_VR_FullScreen; end; ``` ## Events `TVFMediaPlayer` exposes three core playback events. `OnStart` and `OnStop` take no parameters; `OnError` receives the error text. ``` procedure TForm1.MediaPlayer1Start; begin StatusBar1.SimpleText := 'Playing'; end; procedure TForm1.MediaPlayer1Stop; begin StatusBar1.SimpleText := 'Stopped'; end; procedure TForm1.MediaPlayer1Error(ErrorText: WideString); begin ShowMessage('Error: ' + ErrorText); end; ``` To track position updates, poll `Position_Get_Time` from a `TTimer` while `Status = ST_PLAY`: ``` procedure TForm1.PositionTimerTick(Sender: TObject); var Position, Duration: Integer; begin if MediaPlayer1.Status <> ST_PLAY then Exit; Position := MediaPlayer1.Position_Get_Time; Duration := MediaPlayer1.Info_Video_DurationMSec(0); if Duration > 0 then begin TrackBar1.Max := Duration; TrackBar1.Position := Position; end; LabelPosition.Caption := Format('%d:%.2d / %d:%.2d', [Position div 60000, (Position div 1000) mod 60, Duration div 60000, (Duration div 1000) mod 60]); end; ``` ## Supported Formats | Type | Formats | | --- | --- | | Video | MP4, AVI, MKV, MOV, WMV, FLV, WebM | | Audio | MP3, AAC, FLAC, WAV, OGG, WMA | | Streaming | RTSP, RTMP, HTTP, HLS, DASH | Format coverage depends on the selected `Source_Mode` — the FFmpeg and VLC engines cover the broadest range out of the box; DirectShow (`SM_File_DS`) relies on the codecs installed on the system. ## Resources and Further Information To explore the capabilities and usage of the `TVFMediaPlayer` library in more depth, see the following official resources: - **Product page:** [VisioForge Media Player SDK](https://www.visioforge.com/all-in-one-media-framework) - **API reference:** [Delphi Media Player API Reference](https://api.visioforge.org/delphi/media_player_sdk/index.html) - **Changelog:** [Recent updates and fixes](changelog/) - **Installation guide:** [Setting up the library](install/) - **Deployment:** [Distributing your application](deployment/) - **License agreement:** [End User License Agreement](../../eula/) ## Tutorials and Code Samples Practical examples demonstrating how to implement specific features: - [How to play a video file with multiple video streams?](file-multiple-video-streams/) - *(More tutorials will be added here as they become available)* ---END OF PAGE--- ## Install TVFMediaPlayer ActiveX Control in C++ Builder **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/install/builder/ **Description:** Install TVFMediaPlayer in C++ Builder - step-by-step guide for versions 5, 6, 2006, and later with prerequisites, setup, and troubleshooting. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Playback, Streaming, MP4 **API:** TVFMediaPlayer # Installing TVFMediaPlayer in C++ Builder Welcome to the detailed guide for integrating the powerful TVFMediaPlayer library into your Embarcadero C++ Builder development environment. This document covers the installation process for legacy versions like C++ Builder 5 and 6, as well as modern versions from 2006 onwards. We will explore the necessary prerequisites, step-by-step installation procedures for different IDE versions, considerations for 32-bit (x86) and 64-bit (x64) architectures, and common troubleshooting steps. ## Introduction to TVFMediaPlayer and VisioForge Media Framework TVFMediaPlayer is a versatile multimedia component developed by VisioForge. It's part of the larger VisioForge Media Framework, designed to provide developers with a robust set of tools for handling audio and video playback, capture, processing, and streaming within their applications. TVFMediaPlayer specifically focuses on playback capabilities, supporting a wide array of formats and offering extensive control over media rendering. The component is delivered as an ActiveX control, making it easily integrable into environments that support COM technology, such as C++ Builder. Utilizing ActiveX allows for visual design-time integration and straightforward programmatic access to the player's features. ## Prerequisites Before proceeding with the installation, ensure your development environment meets the following requirements: 1. **Supported C++ Builder Version:** You need a working installation of Embarcadero C++ Builder. This guide covers: - C++ Builder 5 - C++ Builder 6 - C++ Builder 2006 - C++ Builder 2007, 2009, 2010, XE series (XE to XE8), 10.x series (Seattle, Berlin, Tokyo, Rio, Sydney), 11.x (Alexandria), and later versions. While the core process remains similar for newer versions, minor UI variations might exist. 2. **Operating System:** A compatible Windows operating system (Windows 7 or later, including Windows 8, 10, 11, and corresponding Server versions). Ensure your OS matches the target architecture (32-bit or 64-bit) of your C++ Builder projects. 3. **Administrative Privileges:** The installation of the VisioForge Media Framework and the registration of ActiveX controls typically require administrative privileges on your machine. Ensure you are running the installer and C++ Builder with sufficient permissions, especially if User Account Control (UAC) is enabled. 4. **Dependencies:** The VisioForge installer usually bundles necessary runtime dependencies (like specific DirectX or Media Foundation components). However, keeping your Windows system updated is generally recommended. ## Step 1: Download the All-in-One Media Framework The TVFMediaPlayer component is distributed as part of the VisioForge All-in-One Media Framework SDK. You must download the correct version: - **Target:** Download the **ActiveX** version of the SDK. Do not download the .NET or VCL versions, as they are intended for different development environments. - **Source:** Obtain the installer directly from the official VisioForge website. Navigate to the [product page](https://www.visioforge.com/all-in-one-media-framework) and locate the download link for the ActiveX SDK. Ensure you are downloading the latest stable release unless you have specific requirements for an older version. ## Step 2: Install the VisioForge Media Framework Once the download is complete, proceed with the installation: 1. **Locate the Installer:** Find the downloaded executable file. 2. **Run as Administrator:** Right-click the installer file and select "Run as administrator". This is crucial for ensuring the ActiveX controls are correctly registered in the Windows Registry. 3. **Follow the Wizard:** The installation wizard will guide you through the process. - Accept the license agreement. - Choose the installation directory (the default location is usually suitable). - Select the components to install. Ensure that the core framework and the MediaPlayer components are selected. Typically, the default selection is sufficient. - The installer will copy the necessary files (DLLs, AX files, etc.) and register the ActiveX controls on your system. 4. **Completion:** Once the installation finishes, click "Finish". The TVFMediaPlayer ActiveX control is now available on your system, ready to be imported into the C++ Builder IDE. ## Step 3: Import the TVFMediaPlayer ActiveX Control into C++ Builder The method for importing the ActiveX control differs slightly between older and newer versions of C++ Builder. ### A. For C++ Builder 5 and 6 These classic versions have a straightforward import mechanism: 1. **Launch C++ Builder:** Open your C++ Builder 5 or 6 IDE. 2. **Open or Create a Project:** You can import the control into an existing project or a new one. The import process adds the component to the IDE's palette, making it available for all projects. 3. **Import ActiveX Control:** Navigate to the main menu and select `Component` → `Import ActiveX Controls...`. 4. **Select the Control:** A dialog box will appear listing all registered ActiveX controls on your system. Scroll through the list and find `VisioForge Media Player` (it might also be listed as `VFMediaPlayer Class` or similar, depending on registry details). Check the box next to it. 5. **Install:** Click the `Install...` button. 6. **Package Creation/Selection:** C++ Builder will prompt you to install the component into a package. You can choose an existing package (like `dclusr.dpk`) or create a new one. For simplicity, adding it to the default user package is often sufficient. Click `OK`. 7. **Confirmation:** A confirmation dialog will ask if you want to rebuild the package. Click `Yes`. 8. **Compilation and Installation:** C++ Builder will compile the package containing the wrapper code for the ActiveX control. Upon successful compilation, a message will confirm the installation. Click `OK`. 9. **Component Palette:** The TVFMediaPlayer component should now appear on the C++ Builder Component Palette, likely under a tab named `ActiveX` or `VisioForge`. You can now drag and drop it onto your forms like any other standard VCL component. ### B. For C++ Builder 2006 and Later (including XE, 10.x, 11.x) Modern C++ Builder versions use a more structured component import process, typically involving creating or using a dedicated design-time package: 1. **Launch C++ Builder:** Open your C++ Builder IDE (2006 or newer). 2. **Create a New Package:** It's generally best practice to install third-party components into their own package. - Go to `File` → `New` → `Other...`. - In the `New Items` dialog, navigate to `C++Builder Projects` (or similar category) and select `Package`. Click `OK`. 3. **Import Component:** With the new package project active (e.g., `Package1.cbproj`), go to the main menu and select `Component` → `Import Component...`. 4. **Select Import Type:** In the `Import Component` wizard, choose the `Import ActiveX Control` option and click `Next >`. 5. **Select the Control:** Similar to the older versions, find `VisioForge Media Player` in the list of registered controls, select it, and click `Next >`. 6. **Component Details:** The wizard will display details about the control. You can typically accept the defaults for `Palette Page` (e.g., `ActiveX`), `Unit Dir Name`, and `Search Path`. Click `Next >`. *Note: Some developers prefer to create a dedicated "VisioForge" palette page.* 7. **Package Selection:** Choose the action `Add unit to .cbproj` (where `` is the name of the package you created in step 2). Click `Finish`. *Self-Correction: The screenshot reference 'mpbcb2006\_5.webp' seems misplaced in the original document's flow. It likely referred to saving or build options, which are handled next.* 8. **Save the Package:** C++ Builder will generate the necessary wrapper unit (e.g., `VFMediaPlayerLib_TLB.cpp` / `.h`). Save the package project (`.cbproj`) and the associated files when prompted. Choose a meaningful name and location for your package (e.g., `VisioForgeMediaPlayerPkg`). 9. **Compile and Install the Package:** - In the `Project Manager` pane, right-click on the package project's `.bpl` file (e.g., `VisioForgeMediaPlayerPkg.bpl`). - Select `Compile` to ensure the wrapper code builds correctly. - After a successful compilation, right-click the `.bpl` file again and select `Install`. 10. **Confirmation:** The IDE will install the package, making the TVFMediaPlayer component available on the specified Component Palette page (e.g., `ActiveX`). ## Step 4: Using the TVFMediaPlayer Component After successful installation, you can use the component in your C++ Builder applications: 1. **Design-Time:** Open a form in the Form Designer. Locate the `TVFMediaPlayer` component on the Component Palette (usually on the `ActiveX` or `VisioForge` tab). Click and drop it onto your form. You can resize and position it as needed. Use the Object Inspector to configure its basic properties. 2. **Run-Time:** Access the component's methods and properties programmatically in your C++ code. For example, to load and play a file: ``` // Assuming MediaPlayer1 is the name of the TVFMediaPlayer component on your form MediaPlayer1->FilenameOrURL = "C:\\path\\to\\your\\video.mp4"; MediaPlayer1->Play(); ``` 3. **Event Handling:** Use the Object Inspector's `Events` tab to assign handlers to various player events (e.g., `OnPlay`, `OnStop`, `OnError`). ## Architecture Considerations (x86 vs. x64) The VisioForge Media Framework provides both 32-bit (x86) and 64-bit (x64) versions of its libraries and ActiveX controls. It's crucial to match the component architecture with your C++ Builder project's target platform: - **32-bit Projects (Win32 Target Platform):** Use the x86 version of the TVFMediaPlayer ActiveX control. The standard installation typically registers the x86 version correctly. When importing/installing the component package (especially in modern IDEs), ensure you are building and installing the package for the Win32 platform. - **64-bit Projects (Win64 Target Platform):** Use the x64 version of the TVFMediaPlayer ActiveX control. The VisioForge installer should register both versions. - **IDE Design-Time:** Importantly, the C++ Builder IDE itself is often a 32-bit application (even in recent versions). This means that for visual form design, the IDE needs to load the **x86** version of the ActiveX control. - **Compilation/Runtime:** When you compile your project for the Win64 target platform, the application will require the **x64** version of the control at runtime. - **Package Management:** In modern C++ Builder versions, you might need to: 1. Create and install a design-time package targeting Win32 (using the x86 control) for use in the IDE. 2. Ensure the corresponding runtime package (or necessary library files) for Win64 are correctly configured in your project's build settings and deployed with your 64-bit application. Consult the VisioForge documentation and C++ Builder's platform management features for specifics. Some developers manage separate packages for Win32 and Win64 targets. **Recommendation:** While legacy C++ Builder versions are covered, VisioForge strongly recommends using modern versions of C++ Builder (XE series or later). These versions offer better support for 64-bit development, improved IDE features, and compatibility with current Windows operating systems and VisioForge SDK updates. Support for C++ Builder 5/6 might be limited. ## Troubleshooting Common Issues - **Control Not Found in Import List:** Ensure the VisioForge Media Framework (ActiveX version) was installed correctly with administrative privileges. Try reinstalling the framework. Manually registering the `.ocx` or `.ax` file using `regsvr32` (run from an Administrator command prompt) might be necessary in rare cases (e.g., `regsvr32 "C:\Program Files (x86)\VisioForge\Media Framework\VFMediaPlayer.ax"` - adjust path as needed). - **Package Installation Fails:** Check the build output for errors. Ensure the package project settings (paths, target platform) are correct. Verify you have write permissions to the C++ Builder library/package directories. - **Component Works in IDE but Fails at Runtime (or vice-versa):** This often points to an architecture mismatch (x86 vs. x64). Review the "Architecture Considerations" section carefully. Ensure the correct version (32-bit or 64-bit) of the VisioForge runtime files is accessible to your compiled application. Deploy the required VisioForge redistributables with your application if necessary. - **Errors During Playback (`CreateObject` fails, etc.):** Double-check that the `FilenameOrURL` property points to a valid, accessible media file. Ensure the necessary codecs for the media format are installed on the system (though VisioForge often includes internal decoders or utilizes Media Foundation/DirectShow). Check the VisioForge `OnError` event for specific error codes or messages. ## Conclusion Integrating TVFMediaPlayer into C++ Builder provides a powerful solution for adding media playback to your applications. By following the appropriate steps for your IDE version, carefully managing x86/x64 architectures, and understanding the package system, you can successfully incorporate this component. Remember to consult the official VisioForge documentation and examples for more advanced usage and API details. --- For further assistance or specific issues not covered here, please contact VisioForge [support](https://support.visioforge.com/). Explore more advanced examples and source code on the VisioForge [GitHub](https://github.com/visioforge/) repository. ---END OF PAGE--- ## Install Media Player SDK in Delphi — 32/64-bit Setup **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/install/delphi/ **Description:** Install VisioForge Media Player SDK in Delphi 10.x-12.x — VCL/FMX components, package registration, library paths. Windows 32/64-bit supported. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Playback, MP4 **API:** TVFMediaPlayer # Installing TVFMediaPlayer in Delphi Welcome to the detailed guide for installing the VisioForge Media Player SDK, specifically the `TVFMediaPlayer` component, into your Delphi development environment. This guide covers installations for classic Delphi versions like Delphi 6 and 7, as well as modern versions from Delphi 2005 onwards, including the latest releases supporting 64-bit development. ## Understanding TVFMediaPlayer `TVFMediaPlayer` is a powerful VCL component from VisioForge designed for seamless integration of video and audio playback capabilities into Delphi applications. It simplifies tasks such as playing various media formats, capturing snapshots, controlling playback speed, managing audio streams, and much more. Built upon a robust media engine, it offers high performance and extensive format support, making it a versatile choice for multimedia application development in Delphi. This guide assumes you have a working installation of Embarcadero Delphi or a compatible older version (Borland Delphi). ## Step 1: Prerequisites and Downloading the Framework Before proceeding with the installation, ensure your development environment meets the necessary prerequisites. Primarily, you need a licensed or trial version of Delphi installed on your Windows machine. The `TVFMediaPlayer` component is distributed as part of the VisioForge All-in-One Media Framework. This framework bundles various VisioForge SDKs, providing a comprehensive toolkit for media handling. 1. **Navigate to the Product Page:** Open your web browser and go to the official VisioForge [All-in-One Media Framework product page](https://www.visioforge.com/all-in-one-media-framework). 2. **Select the Delphi Version:** Locate the download section specifically for Delphi. VisioForge typically offers versions tailored for different development platforms. 3. **Download:** Click the download link to obtain the installer executable (`.exe`) file. Save this file to a known location on your computer, such as your Downloads folder. The downloaded file contains not only the `TVFMediaPlayer` component but also other related libraries, source code (if applicable based on licensing), necessary runtime files, and documentation. ## Step 2: Running the Installer Once the download is complete, you need to run the installer to place the necessary SDK files onto your system. 1. **Locate the Installer:** Navigate to the folder where you saved the downloaded `.exe` file. 2. **Run as Administrator:** Right-click the installer file and select "Run as administrator". This is crucial because the installer needs to register components and potentially write to system directories, requiring elevated privileges. 3. **Follow On-Screen Instructions:** The installer wizard will guide you through the process. Typically, this involves: - Accepting the license agreement. - Choosing the installation directory (the default location is usually appropriate, e.g., within `C:\Program Files (x86)\VisioForge\` or similar). Note this path, as you'll need it later. - Selecting components to install (ensure the Media Player SDK is selected). - Confirming the installation. 4. **Complete Installation:** Allow the installer to finish copying files and performing necessary setup tasks. This process unpacks the SDK, including source files (`.pas`), pre-compiled units (`.dcu`), package files (`.dpk`, `.bpl`), and potentially required DLLs. ## Step 3: Integrating with the Delphi IDE After running the main installer, the next critical step is integrating the `TVFMediaPlayer` component into the Delphi IDE so you can use it visually in the form designer and reference its units in your code. The process differs slightly between older (Delphi 6/7) and newer (Delphi 2005+) versions. **Important:** For all Delphi versions, it's recommended to run the Delphi IDE itself **as administrator** during the package installation process. This helps avoid potential permission issues when compiling and registering the component package. ### Installation in Delphi 6 / Delphi 7 These older versions require manual configuration of paths and package installation. 1. **Launch Delphi (as Administrator):** Start your Delphi 6 or Delphi 7 IDE with administrative privileges. 2. **Open IDE Options:** Go to the `Tools` menu and select `Environment Options`. 3. **Configure Library Path:** - Navigate to the `Library` tab. - In the `Library path` field, click the ellipsis (`...`) button. - Click the `Add` or `New` button (icon might vary) and browse to the `Source` directory within the VisioForge installation path you noted earlier (e.g., `C:\Program Files (x86)\VisioForge\Media Player SDK\Source`). Add this path. This tells Delphi where to find the `.pas` source files if needed during compilation or debugging. - Click `OK` to close the path editor. 4. **Configure Browsing Path:** - While still in the `Library` tab, locate the `Browsing path` field (it might be combined or separate depending on the exact Delphi version/update). - Add the same `Source` directory path here as well. This helps the IDE locate files for features like code completion and navigation. - Click `OK` to save the Environment Options. 5. **Open the Package File:** - Go to the `File` menu and select `Open...`. - Navigate to the `Packages\Delphi7` (or `Delphi6`) subfolder within the VisioForge installation directory (e.g., `C:\Program Files (x86)\VisioForge\Media Player SDK\Packages\Delphi7`). - Locate the runtime package file, often named something like `VFMediaPlayerD7_R.dpk` (the 'R' usually denotes runtime). Open it. - Repeat the process to open the design-time package, often named `VFMediaPlayerD7_D.dpk` (the 'D' denotes design-time). 6. **Compile the Runtime Package:** - Ensure the runtime package (`*_R.dpk`) is the active project in the Project Manager. - Click the `Compile` button in the Project Manager window (or use the corresponding menu option, e.g., `Project -> Compile`). Resolve any compilation errors if they occur (though typically unnecessary with official packages). 7. **Compile and Install the Design-Time Package:** - Make the design-time package (`*_D.dpk`) the active project. - Click the `Compile` button. - Once compiled successfully, click the `Install` button in the Project Manager. 8. **Confirmation:** You should see a confirmation message indicating that the package(s) were installed. The `TVFMediaPlayer` component (and potentially others from the SDK) should now appear on the Delphi component palette, likely under a "VisioForge" or similar category tab. *Note on Architecture:* Delphi 6/7 are strictly 32-bit (x86) environments. Therefore, you will only be installing and using the 32-bit version of the `TVFMediaPlayer` component. The SDK might contain 64-bit files, but they are not applicable here. ### Installation in Delphi 2005 and Later (XE, 10.x, 11.x, 12.x) Modern Delphi versions offer a more streamlined process and robust support for multiple platforms (Win32, Win64). 1. **Launch Delphi (as Administrator):** Start your Delphi IDE (e.g., Delphi 11 Alexandria, Delphi 12 Athens) with administrative privileges. 2. **Open IDE Options:** Go to `Tools -> Options`. 3. **Configure Library Path:** - In the Options dialog, navigate to `Language -> Delphi -> Library` (the exact path might slightly vary between versions). - Select the target platform for which you want to configure the path (e.g., `Windows 32-bit`, `Windows 64-bit`). It's recommended to configure both if you plan to build for both architectures. - Click the ellipsis (`...`) button next to the `Library path` field. - Add the path to the appropriate `Source` directory within the VisioForge installation (e.g., `C:\Program Files (x86)\VisioForge\Media Player SDK\Source`). - Click `Add` and then `OK`. Repeat for the other platform if desired. 4. **Configure Browsing Path (Optional but Recommended):** - Under the same `Library` section, add the `Source` path to the `Browsing path` field as well. - Click `OK` to save the Options. 5. **Open the Package File:** - Go to `File -> Open Project...`. - Navigate to the `Packages` directory within the VisioForge installation. Find the subfolder corresponding to your Delphi version (e.g., `Delphi11`, `Delphi12`). - Open the appropriate design-time package file (e.g., `VFMediaPlayerD11_D.dpk`). Modern Delphi often manages runtime/design-time dependencies more automatically, so you might only need to explicitly open the design-time package. 6. **Compile and Install:** - In the Project Manager, right-click on the package project (`.dpk` file). - Select `Compile` from the context menu. - Once compiled successfully, right-click again and select `Install`. 7. **Confirmation:** Delphi will confirm the installation, and the components will appear on the palette. *Note on Architecture:* Modern Delphi supports both 32-bit (Win32) and 64-bit (Win64) targets. The VisioForge SDK typically provides pre-compiled units (`.dcu`) for both. When you compile and install the package, Delphi usually handles registering it for the currently active platform. You can switch platforms in the Project Manager and rebuild/reinstall if necessary, although often the IDE handles this association correctly after the initial install. ## Step 4: Project Configuration After installing the component package into the IDE, you need to ensure your individual *projects* can find the necessary VisioForge files at compile and runtime. 1. **Project Options:** Open your Delphi project (`.dpr` file). Go to `Project -> Options`. 2. **Library Path:** Navigate to `Delphi Compiler -> Search path` (or similar depending on version). 3. **Add SDK Path:** For each target platform (`Windows 32-bit`, `Windows 64-bit`) you intend to use: - Add the path to the VisioForge `Source` directory (e.g., `C:\Program Files (x86)\VisioForge\Media Player SDK\Source`). This ensures the compiler can find the `.pas` files or required `.dcu` files. Sometimes, pre-compiled `.dcu` files are provided in platform-specific subdirectories (e.g., `DCU\Win32`, `DCU\Win64`); if so, add those specific paths instead of or in addition to the main `Source` path. Check the VisioForge documentation or installation structure for specifics. 4. **Save Changes:** Click `OK` or `Save` to apply the project options. Setting the project search path correctly is crucial. If the compiler complains about not finding units like `VisioForge_MediaPlayer_Engine` or similar, incorrect or missing search paths are the most common cause. ## Step 5: Verification To confirm the installation was successful: 1. **Check Component Palette:** Look for the "VisioForge" tab (or similar) on the component palette in the Delphi IDE. You should see the `TVFMediaPlayer` icon. 2. **Create a Test Application:** - Create a new VCL Forms Application (`File -> New -> VCL Forms Application - Delphi`). - Drag and drop the `TVFMediaPlayer` component from the palette onto the main form. - If the component appears on the form without errors, the design-time installation is likely correct. - Add a simple button. In its `OnClick` event handler, add a basic line of code to interact with the player, for example: ``` procedure TForm1.Button1Click(Sender: TObject); begin // Ensure VFMediaPlayer1 is the name of your component instance VFMediaPlayer1.FilenameOrURL := 'C:\path\to\your\test_video.mp4'; // Replace with an actual media file path VFMediaPlayer1.Play(); end; ``` - Compile the project (`Project -> Compile`). If it compiles without "File not found" errors related to VisioForge units, the path configuration is likely correct. - Run the application. If it runs and you can play the media file using the button, the runtime setup is working. ## Common Installation Problems and Troubleshooting While the process is generally straightforward, occasional issues can arise: - **IDE Permissions:** Forgetting to run the Delphi IDE as administrator during package installation can lead to errors writing to registry or system folders, preventing component registration. **Solution:** Close Delphi, restart it as administrator, and try the package installation steps again. - **Path Configuration Errors:** Incorrect paths in either the IDE `Library Path` or the project's `Search Path` are common. **Solution:** Double-check that the paths point *exactly* to the VisioForge SDK's `Source` (or relevant `DCU`) directory. Ensure paths are correct for the specific target platform (Win32/Win64). - **Package Compilation Errors:** Sometimes, conflicts with other installed packages or issues within the package source itself can cause compilation failures. **Solution:** Ensure you are using the correct package version for your specific Delphi version. Consult VisioForge support or forums if errors persist. - **64-bit Specific Issues:** Installing packages for the 64-bit platform can sometimes present unique challenges, especially in older Delphi versions that first introduced Win64 support. Refer to the linked article [Delphi 64-bit package installation problem](../../../general/install-64bit/) for specific known issues and workarounds. - **`.otares` File Issues:** Some Delphi versions utilize `.otares` files for resources. Problems during package installation related to these files can occur. See the linked article [Delphi package installation problem with .otares](../../../general/install-otares/). - **Missing Runtime DLLs:** The `TVFMediaPlayer` often relies on underlying DLLs (e.g., FFmpeg components) for its functionality. While the main installer usually handles these, ensure they are correctly placed either in your application's output directory, a directory in the system PATH, or the System32/SysWOW64 folders as appropriate. Deployment requires distributing these necessary DLLs with your application. Check the VisioForge documentation for a list of required runtime files. ## Further Steps and Resources With `TVFMediaPlayer` successfully installed, you can now explore its extensive features. - **Explore Properties and Events:** Use the Delphi Object Inspector to examine the numerous properties and events available for the `TVFMediaPlayer` component. - **Consult Documentation:** Refer to the official VisioForge documentation installed with the SDK or available online for detailed API references and usage examples. - **Code Samples:** Visit the VisioForge [GitHub repository](https://github.com/visioforge/) to find demo projects and code snippets showcasing various functionalities. - **Seek Support:** If you encounter persistent issues or have specific questions not covered here, contact [VisioForge support](https://support.visioforge.com/) for assistance. --- Please get in touch with [support](https://support.visioforge.com/) to get help with this tutorial. Visit our [GitHub](https://github.com/visioforge/) page to get more code samples. ---END OF PAGE--- ## TVFMediaPlayer Installation Guide for Delphi and ActiveX **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/install/ **Description:** Install TVFMediaPlayer in Delphi, C++ Builder, Visual Basic 6, Visual Studio, and ActiveX environments with detailed setup instructions. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Playback, Streaming **API:** TVFMediaPlayer # Install the TVFMediaPlayer Library Welcome to the detailed installation guide for the VisioForge TVFMediaPlayer library, a core component of the powerful All-in-One Media Framework. This guide provides comprehensive steps for installing the library across various Integrated Development Environments (IDEs), ensuring you can leverage its rich media playback capabilities effectively in your projects. The TVFMediaPlayer library offers developers robust tools for integrating audio and video playback, processing, and streaming functionalities into their applications. It is available in two primary forms to cater to different development ecosystems: 1. **Native Delphi Package:** Optimized specifically for Embarcadero Delphi developers, offering seamless integration, design-time support, and leveraging the full potential of the VCL framework. 2. **ActiveX Control (OCX):** Designed for broad compatibility, allowing integration into environments that support ActiveX technology, such as C++ Builder, Microsoft Visual Basic 6 (VB6), Microsoft Visual Studio (for C#, VB.NET, C++ MFC projects), and other ActiveX containers. This dual availability ensures that whether you are working within the Delphi ecosystem or utilizing other popular development tools, you can harness the power of TVFMediaPlayer. ## Before You Begin: System Requirements and Prerequisites Before proceeding with the installation, ensure your development environment meets the necessary requirements: - **Operating System:** Windows 7, 8, 8.1, 10, 11, or Windows Server 2012 R2 and newer (both x86 and x64 versions are supported). - **Development Environment:** A compatible IDE such as: - Embarcadero Delphi (refer to specific framework version for compatible Delphi releases, typically XE2 or newer). - Embarcadero C++ Builder (refer to specific framework version for compatibility). - Microsoft Visual Studio 2010 or newer (for C#, VB.NET, C++ MFC development using ActiveX). - Microsoft Visual Basic 6 (requires the IDE installed). - Any other IDE or development tool capable of hosting ActiveX controls. - **Dependencies:** - **DirectX:** Microsoft DirectX 9 or later is generally required. While modern Windows versions include compatible DirectX runtimes, ensure they are up-to-date. - **.NET Framework (for .NET usage):** If using the ActiveX control within .NET applications (C#, VB.NET), ensure the appropriate .NET Framework version targeted by your project is installed. - **Administrator Privileges:** Running the installer typically requires administrator rights to register components and write to system directories. ## Step-by-Step General Installation Process The core installation process involves downloading the All-in-One Media Framework installer and running it. Follow these steps carefully: 1. **Download the Framework:** - Navigate to the official [All-in-One Media Framework product page](https://www.visioforge.com/all-in-one-media-framework) on the VisioForge website. - Locate the downloads section. You might find different versions (e.g., Trial, Full) or builds. Download the latest stable release suitable for your needs. Pay attention to whether you need the Delphi-specific package installer or the general ActiveX installer if they are provided separately (often, one installer contains both). - Save the installer executable (`.exe`) file to a convenient location on your computer. 2. **Run the Installer:** - Locate the downloaded setup file (e.g., `visioforge_media_framework_setup.exe`). - Right-click the file and select "Run as administrator" to ensure necessary permissions. - If prompted by User Account Control (UAC), confirm that you want to allow the installer to make changes to your device. 3. **Follow the Installation Wizard:** - **Welcome Screen:** The installer will launch, typically starting with a welcome message. Click "Next" to proceed. - **License Agreement:** Read the End-User License Agreement (EULA) carefully. You must accept the terms to continue the installation. Select the appropriate option and click "Next". - **Select Destination Location:** Choose the directory where the framework files, examples, and documentation will be installed. The default location is usually within `C:\Program Files (x86)\VisioForge\` or similar. You can browse for a different path if needed. Click "Next". - **Select Components (If Applicable):** Some installers might allow you to choose which components to install (e.g., specific framework features, documentation, examples for different languages). Ensure the core Media Player components and any relevant examples (Delphi, C#, VB.NET, C++, VB6) are selected. Click "Next". - **Select Start Menu Folder:** Choose the name for the Start Menu folder where shortcuts will be created. Click "Next". - **Ready to Install:** Review your selected options. If everything is correct, click "Install" to begin the file copying and system registration process. - **Installation Progress:** The wizard will show the progress of the installation. This may take a few minutes. During this phase, the necessary DLLs and OCX files are copied, and the ActiveX control is registered in the Windows Registry. - **Completion:** Once the installation is finished, you will see a completion screen. It might offer options to view documentation or launch an example project. Click "Finish" to exit the wizard. 4. **Post-Installation Verification:** - Navigate to the installation directory you selected (e.g., `C:\Program Files (x86)\VisioForge\Media Framework\`). - Verify that the core library files (`.dll`, `.ocx`), documentation (`.chm` or `Docs` folder), and example projects (`Examples` folder) are present. - Check the Start Menu folder for shortcuts to documentation and examples. - It's highly recommended to try compiling and running one of the provided sample projects for your specific IDE to confirm the installation was successful and the components are correctly registered and accessible. ## IDE-Specific Integration After the general installation, you need to integrate the TVFMediaPlayer library into your chosen development environment. ### Delphi (Native Packages) Using the native Delphi packages provides the best experience for Delphi developers, including design-time component integration. - **Detailed Guide:** For comprehensive instructions specific to Delphi, including adding the library path and installing the design-time and runtime packages (`.dpk` files), please refer to the dedicated **[Delphi Installation Guide](delphi/)**. - **Key Benefits:** Direct component palette access, property inspectors, event handlers integrated within the IDE, and optimized performance for VCL applications. ### ActiveX Integration (C++ Builder, VB6, Visual Studio, etc.) If you are not using Delphi or prefer the ActiveX approach, you'll need to add the `TVFMediaPlayer.ocx` control to your project. #### C++ Builder Integrating the ActiveX control in C++ Builder involves importing it into the IDE. - **Detailed Guide:** Refer to the **[C++ Builder Installation Guide](builder/)** for step-by-step instructions on importing the ActiveX control, which typically involves using the IDE's "Import Component" or "Import ActiveX Control" feature to generate necessary wrapper code. - **Process Overview:** This usually involves navigating `Component -> Import Component...`, selecting "Import ActiveX Control", finding the "VisioForge Media Player SDK" (or similar name) in the list of registered controls, and letting the IDE generate the corresponding C++ wrapper classes that allow you to interact with the control. #### Visual Basic 6 (VB6) VB6 relies heavily on ActiveX technology, making integration straightforward. 1. **Open Project:** Launch Visual Basic 6 and open your existing project or create a new one. 2. **Access Components Dialog:** Go to the main menu and select `Project -> Components...`. This will open the Components dialog box, listing registered controls. 3. **Locate and Select Control:** Scroll through the list under the "Controls" tab. Look for an entry like "VisioForge Media Player SDK Control" or similar (the exact name might vary slightly depending on the version). Check the box next to it. 4. **Add via Browse (If Not Listed):** If the control is not listed (perhaps due to a registration issue), click the "Browse..." button. Navigate to the VisioForge installation directory (specifically the `Redist\AnyCPU` or similar subfolder containing `TVFMediaPlayer.ocx`) and select the `.ocx` file. Click "Open". This should register and add the control to the list. Ensure its checkbox is ticked. 5. **Confirm:** Click "OK" or "Apply" in the Components dialog. 6. **Use Control:** The TVFMediaPlayer icon should now appear in your VB6 Toolbox. You can click and drag it onto your forms to use it visually. You can then interact with its properties and methods via code. #### Visual Studio (C#, VB.NET, C++ MFC) Visual Studio manages ActiveX controls through the COM Interoperability layer. 1. **Open Project:** Launch Visual Studio and open your Windows Forms (C# or VB.NET), WPF, or MFC project. 2. **Open Toolbox:** Ensure the Toolbox is visible (`View -> Toolbox`). 3. **Add Control to Toolbox:** - Right-click inside the Toolbox, preferably within a relevant tab like "General" or "All Windows Forms", or create a new tab (e.g., "VisioForge"). - Select "Choose Items...". - Wait for the "Choose Toolbox Items" dialog to load. This can sometimes take a moment as it scans registered components. - Navigate to the "COM Components" tab. - Scroll through the list and look for "VisioForge Media Player SDK Control" or a similar name. Check the box next to it. - **Add via Browse (If Not Listed):** If you cannot find it, click the "Browse..." button. Navigate to the VisioForge installation directory (usually the `Redist\AnyCPU` subfolder) and select the `TVFMediaPlayer.ocx` file. Click "Open". This should add it to the list; make sure its checkbox is now selected. - Click "OK". 4. **Use Control:** The TVFMediaPlayer control icon will now be available in your Visual Studio Toolbox. Drag and drop it onto your form (Windows Forms) or use it programmatically (WPF, MFC). Visual Studio will automatically generate the necessary Interop assemblies (wrappers) to allow managed code (.NET) or C++ to interact with the COM-based ActiveX control. ## Troubleshooting Common Installation Issues Encountering problems during installation? Here are some common issues and solutions: - **Control Not Registered / Not Appearing in IDE:** - Ensure the installer was run with administrator privileges. - Try manually registering the OCX file. Open an **Administrator Command Prompt**, navigate to the directory containing `TVFMediaPlayer.ocx` (e.g., `cd "C:\Program Files (x86)\VisioForge\Media Framework\Redist\AnyCPU"`), and run `regsvr32 TVFMediaPlayer.ocx`. A success message should appear. - Check for conflicts with other media libraries or older VisioForge versions. Consider uninstalling previous versions first. - **Installation Fails or Rolls Back:** - Ensure you meet all system requirements, including DirectX and .NET versions. - Temporarily disable antivirus software, which might interfere with the registration process. Remember to re-enable it afterward. - Check for sufficient disk space on the target drive. - **Issues in Specific IDEs:** - **Delphi:** Ensure the library path is correctly added in `Tools -> Options -> Library Path` and that the correct `BPL` files are installed. Rebuilding packages might help. - **Visual Studio:** Delete the `obj` and `bin` folders in your project, delete any existing Interop assemblies related to VisioForge, remove the control reference, restart Visual Studio, and try adding the control again. Ensure your project targets a compatible .NET Framework version if applicable. ## Updating the Framework To update to a newer version of the All-in-One Media Framework: 1. **Check for Compatibility:** Review the release notes for the new version to understand changes and potential compatibility issues with your existing projects. 2. **Backup Projects:** Always back up your projects before updating a major library dependency. 3. **Uninstall Existing Version (Recommended):** It's generally best practice to uninstall the current version via the Windows Control Panel ("Add or Remove Programs" or "Apps & features") before installing the new one. This helps prevent file conflicts or registration issues. 4. **Download and Install:** Download the new version's installer and follow the standard installation procedure outlined earlier in this guide. 5. **Recompile Projects:** Open your projects in their respective IDEs. You may need to remove and re-add references or components if the underlying interfaces have changed significantly (though this is less common with minor updates). Recompile your entire project. 6. **Test Thoroughly:** Test your application extensively to ensure all media functionalities work as expected with the updated library. ## Uninstallation To remove the TVFMediaPlayer library and the All-in-One Media Framework: 1. **Close IDEs:** Ensure all development environments that might be using the library files are closed. 2. **Use Windows Uninstaller:** - Go to the Windows Control Panel or Settings app. - Navigate to "Programs and Features" or "Apps & features". - Locate "VisioForge Media Framework" (or similar name) in the list of installed programs. - Select it and click "Uninstall". - Follow the prompts in the uninstallation wizard. This process should remove the installed files and attempt to unregister the ActiveX control. 3. **Manual Cleanup (Optional):** In some rare cases, or if you want to ensure a complete removal, you might manually check and delete: - The main installation directory (e.g., `C:\Program Files (x86)\VisioForge\`). - Any remaining configuration files or registry entries (advanced users only, proceed with caution). - Interop assemblies generated within your project folders (`obj`, `bin`). ## Licensing and Activation The All-in-One Media Framework typically operates under a commercial license, often with a trial period. - **Trial Version:** The downloaded installer might initially function as a trial, which may have limitations (e.g., nag screens, time limits, restricted features). - **Purchasing a License:** To unlock the full capabilities and use the framework in production applications, you must purchase a license from the VisioForge website. - **Activation:** After purchase, you will usually receive a license key or instructions on how to activate the software. This might involve entering the key into a specific property of the control at runtime or using a license activation tool provided by VisioForge. Refer to the documentation accompanying your purchased license for exact details. ## Getting Support If you encounter issues not covered here or need further assistance: - **Official Documentation:** Check the `Docs` folder in your installation directory or the online documentation on the VisioForge website. The `CHM` help file often contains detailed API references and usage examples. - **Sample Projects:** Explore the example projects provided for your IDE. They demonstrate common use cases and correct implementation techniques. - **VisioForge Support:** Visit the support section on the VisioForge website. This may include forums, a knowledge base, or direct contact options for licensed users. ## Conclusion Installing the TVFMediaPlayer library, whether as a native Delphi package or an ActiveX control, is a straightforward process when following these detailed steps. By ensuring system requirements are met, carefully executing the installation wizard, and correctly integrating the components into your chosen IDE, you can quickly begin developing powerful multimedia applications. Remember to consult the specific IDE guides (Delphi, C++ Builder) linked herein and the official documentation for deeper insights and advanced configurations. With the framework successfully installed, you are well-equipped to explore the extensive features of the VisioForge All-in-One Media Framework. ---END OF PAGE--- ## Installing TVFMediaPlayer Library in Visual Basic 6 **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/install/visual-basic-6/ **Description:** Install and integrate TVFMediaPlayer in VB6 - ActiveX setup, 32-bit considerations, basic playback implementation, and deployment practices. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Playback, Streaming, Screen Capture **API:** TVFMediaPlayer # Integrating TVFMediaPlayer with Visual Basic 6: A Comprehensive Guide Microsoft Visual Basic 6 (VB6), despite its age, remains a relevant platform for many legacy applications. Its simplicity and rapid application development (RAD) capabilities made it incredibly popular. One way to extend the functionality of VB6 applications, particularly in multimedia processing, is by leveraging ActiveX controls. The TVFMediaPlayer library, developed by VisioForge, offers a powerful suite of multimedia features accessible to VB6 developers through its ActiveX interface. This guide provides a comprehensive walkthrough for installing, configuring, and utilizing the TVFMediaPlayer library within a Visual Basic 6 project. We will cover the nuances of working with ActiveX in VB6, address the inherent 32-bit limitations, and provide practical steps for integration and basic usage. ## Understanding ActiveX and VB6 Compatibility ActiveX controls are reusable software components based on Microsoft's Component Object Model (COM) technology. They allow developers to add specific functionalities to applications without writing the underlying code from scratch. Visual Basic 6 has excellent built-in support for ActiveX, enabling developers to easily incorporate third-party controls like TVFMediaPlayer into their projects via a graphical interface. This seamless integration means that VB6 developers can access the advanced multimedia capabilities of the VisioForge library—such as video playback, audio manipulation, screen capture, and network streaming—directly within the familiar VB6 IDE. ### The 32-bit Constraint A crucial point to understand is that Visual Basic 6 is strictly a 32-bit development environment. It was created during an era when 64-bit computing was not mainstream for desktop applications. Consequently, VB6 cannot create or directly interact with 64-bit components or processes. This limitation dictates that only the 32-bit (x86) version of the TVFMediaPlayer ActiveX control can be used with VB6. While modern systems are predominantly 64-bit, Windows maintains compatibility layers (WoW64 - Windows 32-bit on Windows 64-bit) that allow 32-bit applications like those built with VB6, and the 32-bit ActiveX controls they use, to run correctly on 64-bit operating systems. Despite being confined to a 32-bit architecture, the TVFMediaPlayer library is optimized to deliver robust and reliable performance. Developers can confidently build sophisticated multimedia applications in VB6, leveraging the full feature set provided by the 32-bit control. ## Prerequisites Before you begin the installation process, ensure you have the following: 1. **Microsoft Visual Basic 6:** A working installation of the VB6 IDE is required. This includes the necessary service packs (typically SP6). 2. **SDK:** Download the latest version of the SDK that includes the ActiveX components. Ensure you download the installer appropriate for your needs (often a combined x86/x64 installer, but only the x86 components will be registered for VB6 use). 3. **Administrator Privileges:** Installing the SDK and registering the ActiveX control typically requires administrator rights on the development machine. ## Step-by-Step Installation and Integration Follow these steps to integrate the TVFMediaPlayer control into your Visual Basic 6 project: ### **Step 1: Install the TVFMediaPlayer control** Run the downloaded VisioForge SDK installer. Follow the on-screen prompts. The installer will copy the necessary library files (`.ocx`, `.dll`) to your system and attempt to register the ActiveX control in the Windows Registry. Pay attention to the installation directory, though typically the registration process makes the control available system-wide. ### **Step 2: Create or Open a VB6 Project** Launch the Visual Basic 6 IDE. You can either start a new Standard EXE project or open an existing one where you wish to add multimedia capabilities. *Caption: Creating a new Standard EXE project in Visual Basic 6.* ### **Step 3: Add the TVFMediaPlayer Component** To make the ActiveX control available in your project's Toolbox, you need to add it through the "Components" dialog. - Go to the `Project` menu and select `Components...`. Alternatively, right-click on the Toolbox and choose `Components...`. *Caption: Accessing the Components dialog from the Project menu.* - The "Components" dialog lists all registered ActiveX controls on your system. Scroll down the list under the "Controls" tab. - Locate and check the box next to "VisioForge Media Player" (the exact name might vary slightly depending on the installed version). *Caption: Selecting the 'VisioForge Media Player' control in the Components dialog.* - Click `OK` or `Apply`. ### **Step 4: Use the Control in Your Project** After adding the component, its icon will appear in the VB6 Toolbox. *Caption: The TVFMediaPlayer control added to the Visual Basic 6 Toolbox.* You can now select the TVFMediaPlayer icon from the Toolbox and draw it onto any form in your project, just like any standard VB6 control (e.g., Button, TextBox). This creates an instance of the media player object on your form. You can resize and position it as needed using the form designer. #### **Basic Usage: Controlling the Player** Once the TVFMediaPlayer control (`VFMediaPlayer1` by default, if it's the first one added) is on your form, you can interact with it programmatically using VB6 code. ## Deployment Considerations When you distribute your VB6 application that uses the TVFMediaPlayer control, you must ensure the necessary runtime files are included and correctly registered on the target user's machine. 1. **Required Files:** Identify the specific `.ocx` file for the TVFMediaPlayer control and any dependent `.dll` files provided by the VisioForge SDK. These files need to be shipped with your application installer. 2. **Registration:** The ActiveX control (`.ocx` file) must be registered in the Windows Registry on the target machine. Standard installer tools (like Inno Setup, InstallShield, or even older VB6 packaging tools) usually provide mechanisms to register ActiveX controls during installation. Alternatively, the `regsvr32.exe` command-line utility can be used manually or via a script: ``` regsvr32.exe "C:\\Program Files (x86)\\YourApp\\VFMediaPlayer.ocx" ``` Remember to use the correct path and run the command with administrator privileges. Since it's a 32-bit control, even on a 64-bit system, you typically use the `regsvr32.exe` found in the `C:\Windows\SysWOW64` directory, although the system often handles this redirection automatically. 3. **Licensing:** Ensure you comply with the VisioForge licensing terms for deployment. Some versions might require a runtime license key to be set programmatically within your application. ## Troubleshooting Common Issues - **Control Not Appearing in Components:** - Ensure the VisioForge SDK was installed correctly with administrator rights. - Try manually registering the `.ocx` file using `regsvr32.exe` from an elevated command prompt. - Verify you are looking for the correct name in the Components list. - **"Runtime Error '429': ActiveX component can't create object":** - This usually indicates the control is not properly registered on the machine where the application is running. Re-register the `.ocx` file. - Ensure all dependent DLLs are present in the application's directory or a system path. - **Playback Issues (No Video/Audio, Errors):** - Verify the path to the media file is correct and accessible. - Ensure necessary codecs are installed on the system (though TVFMediaPlayer often includes internal decoders or uses DirectShow/Media Foundation). - Check the VisioForge documentation for specific error codes or properties that might give more detail. - Implement proper error handling around player methods (`Play`, `Stop`, property setting) to diagnose issues. ## Beyond VB6: Modernization While TVFMediaPlayer provides a bridge for adding modern multimedia features to legacy VB6 applications, organizations should also consider long-term strategies. Migrating VB6 applications to newer platforms like .NET (using C# or VB.NET) or web-based technologies can offer significant advantages in terms of performance, security, maintainability, and access to the latest development tools and libraries. VisioForge also offers .NET-native versions of its libraries, which would be the preferred choice in a modernized application. ## Conclusion The TVFMediaPlayer library, through its ActiveX control, offers a powerful and accessible way for Visual Basic 6 developers to incorporate advanced multimedia functionalities into their applications. By understanding the installation process, the 32-bit limitations, basic control usage, and deployment requirements outlined in this guide, developers can effectively leverage VisioForge technology to enhance their VB6 projects. While VB6 is a legacy platform, tools like TVFMediaPlayer help extend its useful life for specific application needs. --- For further assistance or more complex scenarios, please get in touch with [VisioForge support](https://support.visioforge.com/). Explore the extensive code samples available on the VisioForge [GitHub repository](https://github.com/visioforge/) for more advanced examples and techniques. ---END OF PAGE--- ## Add ActiveX Media Player to Visual Studio C++/C#/VB.NET **URL:** https://www.visioforge.com/help/docs/delphi/mediaplayer/install/visual-studio/ **Description:** Import TVFMediaPlayer ActiveX control into Visual Studio 2010+ projects. Step-by-step COM wrapper generation, toolbox setup, and .NET SDK migration guide. **Tags:** Media Player SDK, All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Playback, MP4, AVI, MOV, WMV, C# **API:** TVFMediaPlayer # Installing TVFMediaPlayer ActiveX in Visual Studio 2010 and Later This guide provides detailed instructions for integrating the VisioForge Media Player (`TVFMediaPlayer`) ActiveX control into your Microsoft Visual Studio projects (version 2010 and newer). We will cover the necessary steps for C++, C#, and Visual Basic .NET environments, explain the underlying mechanisms, and discuss important considerations, including why migrating to the native .NET SDK is highly recommended for modern development. ## Understanding ActiveX and its Role in Modern Development ActiveX, a technology developed by Microsoft, allows software components (controls) to interact with one another regardless of the language they were originally written in. It's based on the Component Object Model (COM). In the context of Visual Studio, ActiveX controls can be embedded within application forms to provide specific functionalities, such as media playback in the case of `TVFMediaPlayer`. While historically significant, ActiveX usage has declined, especially within the .NET ecosystem. Modern .NET frameworks offer more integrated, robust, and secure ways to incorporate UI components and functionality. However, legacy applications or specific interoperability scenarios might still necessitate the use of ActiveX controls. When you use an ActiveX control in a .NET project (C# or VB.Net), Visual Studio doesn't interact with it directly. Instead, it automatically generates **Runtime Callable Wrappers (RCW)**. These wrappers are essentially .NET assemblies that act as intermediaries, translating .NET calls into COM calls that the ActiveX control understands, and vice versa. This process allows managed (.NET) code to utilize unmanaged (COM/ActiveX) components. ## Prerequisites Before you begin, ensure you have the following: 1. **Microsoft Visual Studio:** Version 2010 or a later edition installed. 2. **TVFMediaPlayer ActiveX Control:** The VisioForge Media Player ActiveX control must be properly installed and registered on your development machine. You can typically download this from the VisioForge website or distributor. **Crucially**, you might need both the 32-bit (x86) and 64-bit (x64) versions registered, even if you are only developing a 64-bit application. Visual Studio's designer often runs as a 32-bit process and requires the x86 version to display the control visually during design time. The runtime will use the version corresponding to your project's target architecture (x86 or x64). 3. **Project:** An existing or new C++, C#, or VB.NET project where you intend to use the media player. ## Step-by-Step Installation in Visual Studio The process involves adding the `TVFMediaPlayer` control to the Visual Studio Toolbox, which then allows you to drag and drop it onto your application's forms or windows. ### **Step 1: Create or Open Your Project** Launch Visual Studio and create a new project or open an existing one. The example screenshots below use a C# Windows Forms application, but the steps are analogous for C++ (MFC, perhaps) and VB.NET WinForms. - For C# WinForms: `File -> New -> Project -> Visual C# -> Windows Forms App (.NET Framework)` - For VB.NET WinForms: `File -> New -> Project -> Visual Basic -> Windows Forms App (.NET Framework)` - For C++ MFC: `File -> New -> Project -> Visual C++ -> MFC/ATL -> MFC App` ### **Step 2: Open the Toolbox** If the Toolbox is not visible, you can open it via the `View` menu (`View -> Toolbox` or `Ctrl+Alt+X`). The Toolbox contains standard UI controls and components. ### **Step 3: Add the ActiveX Control to the Toolbox** To make the `TVFMediaPlayer` control available, you need to add it to the Toolbox: 1. Right-click within an empty area of the Toolbox (e.g., under the "General" tab or create a new tab). 2. Select "Choose Items..." from the context menu. ### **Step 4: Select the TVFMediaPlayer Control** 1. The "Choose Toolbox Items" dialog will appear. Navigate to the "COM Components" tab. This tab lists all registered ActiveX controls on your system. 2. Scroll through the list or use the filter box to find the "VisioForge Media Player" control (the exact name might vary slightly based on the installed version). 3. Check the checkbox next to the control's name. 4. Click "OK". Visual Studio will now add the control to your Toolbox and, if you are in a C# or VB.Net project, it will generate the necessary RCW assemblies (often named `AxInterop.VisioForgeMediaPlayerLib.dll` and `Interop.VisioForgeMediaPlayerLib.dll`) and add references to them in your project. ### **Step 5: Add the Control to Your Form** 1. Locate the newly added "VisioForge Media Player" icon in the Toolbox. 2. Click and drag the icon onto your application's form or design surface. An instance of the `TVFMediaPlayer` control will appear on your form. You can resize and position it as needed using the designer. ### **Step 6: Interacting with the Control (Code)** You can now interact with the media player control programmatically through its properties, methods, and events. Select the control in the designer, and use the Properties window (`F4`) to configure its appearance and basic behavior. To control playback, handle events, etc., you'll write code. Here's a simple C# example to load and play a video file when a button is clicked: ``` // Assuming your TVFMediaPlayer control is named 'axMediaPlayer1' // and you have a button named 'buttonPlay' private void buttonPlay_Click(object sender, EventArgs e) { // Prompt user to select a video file OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Media Files|*.mp4;*.avi;*.mov;*.wmv|All Files|*.*"; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { // Set the filename for the ActiveX control axMediaPlayer1.FilenameOrURL = openFileDialog.FileName; // Start playback axMediaPlayer1.Play(); } catch (Exception ex) { MessageBox.Show($"Error playing file: {ex.Message}"); } } } // Example of handling an event (e.g., playback completed) private void axMediaPlayer1_OnStop(object sender, EventArgs e) { MessageBox.Show("Playback stopped or finished."); } // Remember to attach the event handler, usually in the Form's Load event or constructor public Form1() { InitializeComponent(); axMediaPlayer1.OnStop += axMediaPlayer1_OnStop; // Attach the event handler } ``` Similar code can be written in VB.NET, accessing the same properties (`FilenameOrURL`, `Play()`) and events (`OnStop`). In C++, you would typically use COM interfaces directly or MFC wrappers if using that framework. ## Important: The Case for the Native .NET SDK While the steps above show how to use the ActiveX control, **for all new .NET development (C#, VB.NET), we strongly recommend using the native VisioForge Media Player SDK for .NET.** The ActiveX approach, while functional, carries several significant disadvantages in the modern .NET world: 1. **Complexity:** Relies on COM Interop and RCW generation, adding layers of abstraction that can sometimes be fragile or lead to unexpected behavior. 2. **Performance:** COM Interop can introduce performance overhead compared to native .NET code. 3. **Deployment:** Requires proper registration of the ActiveX control (x86 and potentially x64) on the end-user's machine using `regsvr32`, which can complicate deployment and require administrative privileges. Native .NET libraries are typically deployed just by copying files (XCopy deployment) or via NuGet. 4. **Limited Integration:** ActiveX controls don't integrate as seamlessly with modern .NET UI frameworks like WPF or MAUI. While they can sometimes be hosted, it's often awkward and limited compared to native controls. 5. **Bitness Mismatches:** Managing x86/x64 versions and ensuring the correct one is used by the application and the VS designer can be error-prone. 6. **Technology Age:** ActiveX is a legacy technology with limited ongoing evolution compared to the rapidly advancing .NET platform. **Advantages of the Native .NET SDK:** - **Native Controls:** Provides dedicated, optimized controls for WinForms, WPF, and MAUI. - **Full .NET Integration:** Leverages the full power of the .NET framework, including async/await, LINQ, modern event patterns, and easier data binding. - **Simplified Deployment:** Usually involves just referencing the SDK assemblies or NuGet packages. No COM registration needed. - **Enhanced Features:** Often includes more features, better performance, and more granular control than the corresponding ActiveX version. - **Improved Stability & Maintainability:** Native code is generally easier to debug, maintain, and less prone to interop issues. - **Future-Proofing:** Aligns your application with modern .NET development practices. You can find the native [.Net version of the SDK here](https://www.visioforge.com/media-player-sdk-net). It offers a significantly superior development experience and results for .NET applications. ## Troubleshooting Common Issues - **Control Not Appearing in "COM Components":** Ensure the `TVFMediaPlayer` ActiveX control is correctly installed and registered. Try running the registration command (`regsvr32 `) manually as an administrator. Remember to register both x86 and x64 versions if available and needed. - **Error Adding Control to Form:** This often points to a mismatch between the Visual Studio designer process (usually x86) and the registered control version. Make sure the x86 version is registered. - **Runtime Errors (File Not Found, Class Not Registered):** Verify the control (correct bitness for your app's target) is registered on the target machine where the application is run. Check project references to ensure the Interop assemblies are correctly included. - **Events Not Firing:** Double-check that event handlers are correctly attached to the control's events in your code. ## Conclusion Integrating the `TVFMediaPlayer` ActiveX control into Visual Studio 2010+ is achievable by adding it via the "Choose Toolbox Items" dialog. Visual Studio handles the generation of wrapper assemblies for .NET projects, allowing interaction via standard properties, methods, and events. However, due to the complexities, limitations, and deployment challenges associated with ActiveX/COM Interop in the .NET environment, **it is strongly advised to use the native VisioForge Media Player SDK for .NET for any new WinForms, WPF, or MAUI development.** The native SDK provides a more robust, performant, and developer-friendly experience aligned with modern application development practices. --- Need further assistance? Please contact [VisioForge Support](https://support.visioforge.com/) or explore more examples on our [GitHub](https://github.com/visioforge/) page. ---END OF PAGE--- ## Audio Capture to MP3 Files in Delphi, C++ MFC & VB6 **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/audio-capture-mp3/ **Description:** Implement MP3 audio capture in Delphi, C++, and VB6 - configure LAME encoder, manage bitrates, and create high-quality audio recordings. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Encoding, MP3 # Audio Capture to MP3 Files in Delphi, C++ MFC & VB6 ## Introduction Audio capture capabilities are essential for many modern applications, from voice recording tools to multimedia creation software. This guide walks through the implementation of MP3 audio capture functionality in Delphi, C++ MFC, and VB6 applications using the VideoCapture component. MP3 remains one of the most widely used audio formats due to its excellent compression and broad compatibility. By implementing proper MP3 audio capture in your applications, you can provide users with efficient, high-quality audio recording capabilities. ## Prerequisites Before implementing MP3 audio capture, ensure you have: - Development environment with Delphi, Visual C++ (for MFC), or Visual Basic 6 - VideoCapture component properly installed and referenced in your project - Basic understanding of audio encoding concepts - Required permissions for audio device access in your application ## LAME Encoder Configuration The LAME MP3 encoder provides extensive customization options for audio quality, bitrate management, and channel configuration. Properly configuring these settings is crucial for achieving the desired audio quality while managing file size. ### Configuring Basic Encoding Parameters The following code snippets demonstrate how to configure basic LAME encoding parameters: ``` // Delphi VideoCapture1.Audio_LAME_CBR_Bitrate := StrToInt(cbLameCBRBitrate.Items[cbLameCBRBitrate.ItemIndex]); VideoCapture1.Audio_LAME_VBR_Min_Bitrate := StrToInt(cbLameVBRMin.Items[cbLameVBRMin.ItemIndex]); VideoCapture1.Audio_LAME_VBR_Max_Bitrate := StrToInt(cbLameVBRMax.Items[cbLameVBRMax.ItemIndex]); VideoCapture1.Audio_LAME_Sample_Rate := StrToInt(cbLameSampleRate.Items[cbLameSampleRate.ItemIndex]); VideoCapture1.Audio_LAME_VBR_Quality := tbLameVBRQuality.Position; VideoCapture1.Audio_LAME_Encoding_Quality := tbLameEncodingQuality.Position; ``` ``` // C++ MFC // CComboBox::GetCurSel returns CB_ERR (-1) when nothing is selected — skip the // assignment in that case so the property keeps its previously configured value. int nIndex; nIndex = m_cbLameCBRBitrate.GetCurSel(); if (nIndex != CB_ERR) m_VideoCapture.Audio_LAME_CBR_Bitrate = (int)m_cbLameCBRBitrate.GetItemData(nIndex); nIndex = m_cbLameVBRMin.GetCurSel(); if (nIndex != CB_ERR) m_VideoCapture.Audio_LAME_VBR_Min_Bitrate = (int)m_cbLameVBRMin.GetItemData(nIndex); nIndex = m_cbLameVBRMax.GetCurSel(); if (nIndex != CB_ERR) m_VideoCapture.Audio_LAME_VBR_Max_Bitrate = (int)m_cbLameVBRMax.GetItemData(nIndex); nIndex = m_cbLameSampleRate.GetCurSel(); if (nIndex != CB_ERR) m_VideoCapture.Audio_LAME_Sample_Rate = (int)m_cbLameSampleRate.GetItemData(nIndex); m_VideoCapture.Audio_LAME_VBR_Quality = m_tbLameVBRQuality.GetPos(); m_VideoCapture.Audio_LAME_Encoding_Quality = m_tbLameEncodingQuality.GetPos(); ``` ``` ' VB6 VideoCapture1.Audio_LAME_CBR_Bitrate = CInt(cbLameCBRBitrate.List(cbLameCBRBitrate.ListIndex)) VideoCapture1.Audio_LAME_VBR_Min_Bitrate = CInt(cbLameVBRMin.List(cbLameVBRMin.ListIndex)) VideoCapture1.Audio_LAME_VBR_Max_Bitrate = CInt(cbLameVBRMax.List(cbLameVBRMax.ListIndex)) VideoCapture1.Audio_LAME_Sample_Rate = CInt(cbLameSampleRate.List(cbLameSampleRate.ListIndex)) VideoCapture1.Audio_LAME_VBR_Quality = tbLameVBRQuality.Value VideoCapture1.Audio_LAME_Encoding_Quality = tbLameEncodingQuality.Value ``` ### Setting Audio Channel Modes Channel configuration affects both sound quality and file size. The following code demonstrates how to set the channel mode: ``` // Delphi if rbLameStandardStereo.Checked then VideoCapture1.Audio_LAME_Channels_Mode := CH_Standard_Stereo else if rbLameJointStereo.Checked then VideoCapture1.Audio_LAME_Channels_Mode := CH_Joint_Stereo else if rbLameDualChannels.Checked then VideoCapture1.Audio_LAME_Channels_Mode := CH_Dual_Stereo else VideoCapture1.Audio_LAME_Channels_Mode := CH_Mono; ``` ``` // C++ MFC if (m_rbLameStandardStereo.GetCheck()) m_VideoCapture.Audio_LAME_Channels_Mode = VisioForge_Video_Capture::CH_Standard_Stereo; else if (m_rbLameJointStereo.GetCheck()) m_VideoCapture.Audio_LAME_Channels_Mode = VisioForge_Video_Capture::CH_Joint_Stereo; else if (m_rbLameDualChannels.GetCheck()) m_VideoCapture.Audio_LAME_Channels_Mode = VisioForge_Video_Capture::CH_Dual_Stereo; else m_VideoCapture.Audio_LAME_Channels_Mode = VisioForge_Video_Capture::CH_Mono; ``` ``` ' VB6 If rbLameStandardStereo.Value Then VideoCapture1.Audio_LAME_Channels_Mode = CH_Standard_Stereo ElseIf rbLameJointStereo.Value Then VideoCapture1.Audio_LAME_Channels_Mode = CH_Joint_Stereo ElseIf rbLameDualChannels.Value Then VideoCapture1.Audio_LAME_Channels_Mode = CH_Dual_Stereo Else VideoCapture1.Audio_LAME_Channels_Mode = CH_Mono End If ``` ### Advanced LAME Configuration Options For more precise control over the encoding process, configure these advanced LAME options: ``` // Delphi VideoCapture1.Audio_LAME_VBR_Mode := rbLameVBR.Checked; VideoCapture1.Audio_LAME_Copyright := cbLameCopyright.Checked; VideoCapture1.Audio_LAME_Original := cbLameOriginalCopy.Checked; VideoCapture1.Audio_LAME_CRC_Protected := cbLameCRCProtected.Checked; VideoCapture1.Audio_LAME_Force_Mono := cbLameForceMono.Checked; VideoCapture1.Audio_LAME_Strictly_Enforce_VBR_Min_Bitrate := cbLameStrictlyEnforceVBRMinBitrate.Checked; VideoCapture1.Audio_LAME_Voice_Encoding_Mode := cbLameVoiceEncodingMode.Checked; VideoCapture1.Audio_LAME_Keep_All_Frequencies := cbLameKeepAllFrequencies.Checked; VideoCapture1.Audio_LAME_Strict_ISO_Compilance := cbLameStrictISOCompilance.Checked; VideoCapture1.Audio_LAME_Disable_Short_Blocks := cbLameDisableShortBlocks.Checked; VideoCapture1.Audio_LAME_Enable_Xing_VBR_Tag := cbLameEnableXingVBRTag.Checked; VideoCapture1.Audio_LAME_Mode_Fixed := cbLameModeFixed.Checked; ``` ``` // C++ MFC m_VideoCapture.Audio_LAME_VBR_Mode = m_rbLameVBR.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Copyright = m_cbLameCopyright.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Original = m_cbLameOriginalCopy.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_CRC_Protected = m_cbLameCRCProtected.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Force_Mono = m_cbLameForceMono.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Strictly_Enforce_VBR_Min_Bitrate = m_cbLameStrictlyEnforceVBRMinBitrate.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Voice_Encoding_Mode = m_cbLameVoiceEncodingMode.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Keep_All_Frequencies = m_cbLameKeepAllFrequencies.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Strict_ISO_Compilance = m_cbLameStrictISOCompilance.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Disable_Short_Blocks = m_cbLameDisableShortBlocks.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Enable_Xing_VBR_Tag = m_cbLameEnableXingVBRTag.GetCheck() ? true : false; m_VideoCapture.Audio_LAME_Mode_Fixed = m_cbLameModeFixed.GetCheck() ? true : false; ``` ``` ' VB6 VideoCapture1.Audio_LAME_VBR_Mode = rbLameVBR.Value VideoCapture1.Audio_LAME_Copyright = cbLameCopyright.Value VideoCapture1.Audio_LAME_Original = cbLameOriginalCopy.Value VideoCapture1.Audio_LAME_CRC_Protected = cbLameCRCProtected.Value VideoCapture1.Audio_LAME_Force_Mono = cbLameForceMono.Value VideoCapture1.Audio_LAME_Strictly_Enforce_VBR_Min_Bitrate = cbLameStrictlyEnforceVBRMinBitrate.Value VideoCapture1.Audio_LAME_Voice_Encoding_Mode = cbLameVoiceEncodingMode.Value VideoCapture1.Audio_LAME_Keep_All_Frequencies = cbLameKeepAllFrequencies.Value VideoCapture1.Audio_LAME_Strict_ISO_Compilance = cbLameStrictISOCompilance.Value VideoCapture1.Audio_LAME_Disable_Short_Blocks = cbLameDisableShortBlocks.Value VideoCapture1.Audio_LAME_Enable_Xing_VBR_Tag = cbLameEnableXingVBRTag.Value VideoCapture1.Audio_LAME_Mode_Fixed = cbLameModeFixed.Value ``` ## Understanding LAME Configuration Options ### Bitrate Settings - **CBR (Constant Bitrate)**: Maintains the same bitrate throughout the entire recording - **VBR (Variable Bitrate)**: Adjusts bitrate based on audio complexity - **Min/Max Bitrate**: Sets boundaries for VBR encoding - **VBR Quality**: Controls the quality/file size balance in VBR mode ### Channel Modes - **Standard Stereo**: Completely separate left and right channels - **Joint Stereo**: Combines redundant information between channels to save space - **Dual Stereo**: Two completely independent mono channels - **Mono**: Single audio channel ### Special Encoding Options - **Voice Encoding Mode**: Optimizes encoding for voice frequencies - **Force Mono**: Converts stereo input to mono output - **CRC Protection**: Adds error detection data - **Strict ISO Compliance**: Ensures maximum compatibility with all MP3 players ## Configuring Output Format After setting up LAME encoding parameters, specify MP3 as the output format: ``` // Delphi VideoCapture1.OutputFormat := Format_LAME; ``` ``` // C++ MFC m_VideoCapture.OutputFormat = VisioForge_Video_Capture::Format_LAME; ``` ``` ' VB6 VideoCapture1.OutputFormat = Format_LAME ``` ## Setting Audio Capture Mode Set the VideoCapture component to audio-only capture mode: ``` // Delphi VideoCapture1.Mode := Mode_Audio_Capture; ``` ``` // C++ MFC m_VideoCapture.Mode = VisioForge_Video_Capture::Mode_Audio_Capture; ``` ``` ' VB6 VideoCapture1.Mode = Mode_Audio_Capture ``` ## Starting the Audio Capture Once all parameters are configured, initiate the recording process: ``` // Delphi VideoCapture1.Start; ``` ``` // C++ MFC m_VideoCapture.Start(); ``` ``` ' VB6 VideoCapture1.Start ``` ## Best Practices for MP3 Audio Capture - **Quality vs. Size**: For voice recordings, lower bitrates (64-128 kbps) are usually sufficient. For music, use 192 kbps or higher. - **Sample Rate Selection**: 44.1 kHz is standard for most audio. Lower rates can be used for voice-only recordings. - **VBR vs. CBR**: VBR generally provides better quality-to-size ratio but might have compatibility issues with some players. - **Error Handling**: Always implement proper error handling around the recording process. - **User Feedback**: Provide visual feedback during recording (level meters, time elapsed). ## Conclusion Implementing MP3 audio capture in your applications provides users with a widely compatible and efficient recording solution. By properly configuring LAME encoder settings, you can balance audio quality and file size based on your application's specific requirements. The VideoCapture component makes this implementation straightforward in Delphi, C++ MFC, and VB6 applications, allowing you to focus on creating a great user experience around the audio capture functionality. --- For additional code samples and advanced implementation techniques, visit our GitHub repository. If you encounter any issues during implementation, contact our technical support team for assistance. ---END OF PAGE--- ## Delphi Video Capture SDK WAV Audio Recording Guide **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/audio-capture-wav/ **Description:** Capture audio to WAV files in Delphi with codec selection, compression options, and stereo recording using TVFVideoCapture code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, WAV # Audio Capture to WAV Files: Developer Implementation Guide ## Introduction Capturing audio to WAV files is a fundamental requirement for many multimedia applications. This guide provides detailed instructions for implementing audio capture functionality with or without compression in your applications. Whether you're developing in Delphi, C++ MFC, or VB6 using our ActiveX controls, this guide will walk you through the entire process from initial setup to final implementation. ## Setting Up Your Development Environment Before you begin implementing audio capture, ensure you have: 1. Installed the SDK in your development environment 2. Added the VideoCapture component to your form/project 3. Set up basic error handling to manage capture exceptions 4. Configured your application to access audio hardware ## Audio Codec Management ### Retrieving Available Audio Codecs The first step in implementing audio capture is to retrieve a list of available audio codecs on the system. This allows you to present users with codec options or to programmatically select the most appropriate codec for your application's needs. #### Delphi Implementation ``` // Iterate through all available audio codecs for i := 0 to VideoCapture1.Audio_Codecs_GetCount - 1 do cbAudioCodec.Items.Add(VideoCapture1.Audio_Codecs_GetItem(i)); ``` #### C++ MFC Implementation ``` // Get all available audio codecs and populate combo box for (int i = 0; i < m_VideoCapture.Audio_Codecs_GetCount(); i++) { CString codec = m_VideoCapture.Audio_Codecs_GetItem(i); m_AudioCodecCombo.AddString(codec); } ``` #### VB6 Implementation ``` ' Iterate through all available audio codecs For i = 0 To VideoCapture1.Audio_Codecs_GetCount - 1 cboAudioCodec.AddItem VideoCapture1.Audio_Codecs_GetItem(i) Next i ``` ### Selecting an Audio Codec Once you've populated the list of available codecs, you'll need to provide a way to select the desired codec for the audio capture operation. This can be done programmatically or via user selection. #### Delphi Implementation ``` // Set the codec based on user selection from combo box VideoCapture1.Audio_Codec := cbAudioCodec.Items[cbAudioCodec.ItemIndex]; ``` #### C++ MFC Implementation ``` // Get the selected codec from the combo box int selectedIndex = m_AudioCodecCombo.GetCurSel(); CString selectedCodec; m_AudioCodecCombo.GetLBText(selectedIndex, selectedCodec); // Set the codec m_VideoCapture.SetAudio_Codec(selectedCodec); ``` #### VB6 Implementation ``` ' Set the codec based on user selection VideoCapture1.Audio_Codec = cboAudioCodec.Text ``` ## Configuring Audio Parameters Proper audio parameter configuration is crucial for achieving the desired quality and file size balance. The three primary parameters to configure are channels, bits per sample (BPS), and sample rate. ### Setting Audio Channels Audio channels determine whether the captured audio is mono (1 channel) or stereo (2 channels). Stereo provides better spatial audio representation but requires more storage space. #### Delphi Implementation ``` // Set the number of audio channels (1 for mono, 2 for stereo) VideoCapture1.Audio_Channels := StrToInt(cbChannels2.Items[cbChannels2.ItemIndex]); ``` #### C++ MFC Implementation ``` // Set audio channels (1 for mono, 2 for stereo) int nIndex = m_ChannelsCombo.GetCurSel(); if (nIndex == CB_ERR) return; // No selection — leave the current value untouched CString strChannels; m_ChannelsCombo.GetLBText(nIndex, strChannels); int channels = _ttoi(strChannels); m_VideoCapture.SetAudio_Channels(channels); ``` #### VB6 Implementation ``` ' Set audio channels (1 for mono, 2 for stereo) VideoCapture1.Audio_Channels = CInt(cboChannels.Text) ``` ### Configuring Bits Per Sample (BPS) The bits per sample (BPS) setting affects the dynamic range and quality of the audio. Common values include 8, 16, and 24 bits, with higher values providing better quality at the cost of larger file sizes. #### Delphi Implementation ``` // Set bits per sample (typically 8, 16, or 24) VideoCapture1.Audio_BPS := StrToInt(cbBPS2.Items[cbBPS2.ItemIndex]); ``` #### C++ MFC Implementation ``` // Set bits per sample int nIndex = m_BPSCombo.GetCurSel(); if (nIndex == CB_ERR) return; // No selection — leave the current value untouched CString strBPS; m_BPSCombo.GetLBText(nIndex, strBPS); int bps = _ttoi(strBPS); m_VideoCapture.SetAudio_BPS(bps); ``` #### VB6 Implementation ``` ' Set bits per sample VideoCapture1.Audio_BPS = CInt(cboBPS.Text) ``` ### Setting Sample Rate The sample rate determines how many audio samples are captured per second. Common values include 8000 Hz, 44100 Hz (CD quality), and 48000 Hz (professional audio). Higher sample rates capture more high-frequency detail but increase file size. #### Delphi Implementation ``` // Set audio sample rate in Hz (common values: 8000, 44100, 48000) VideoCapture1.Audio_SampleRate := StrToInt(cbSamplerate.Items[cbSamplerate.ItemIndex]); ``` #### C++ MFC Implementation ``` // Set sample rate int nIndex = m_SampleRateCombo.GetCurSel(); if (nIndex == CB_ERR) return; // No selection — leave the current value untouched CString strSampleRate; m_SampleRateCombo.GetLBText(nIndex, strSampleRate); int sampleRate = _ttoi(strSampleRate); m_VideoCapture.SetAudio_SampleRate(sampleRate); ``` #### VB6 Implementation ``` ' Set sample rate VideoCapture1.Audio_SampleRate = CInt(cboSampleRate.Text) ``` ## Configuring Output Format ### Selecting PCM/ACM Format The Windows Audio Compression Manager (ACM) supports various audio formats including PCM (uncompressed) and compressed formats. Setting the output format to PCM/ACM enables codec-based compression when a codec other than PCM is selected. #### Delphi Implementation ``` // Set output to PCM/ACM format to enable codec-based compression VideoCapture1.OutputFormat := Format_PCM_ACM; ``` #### C++ MFC Implementation ``` // Set output format to PCM/ACM m_VideoCapture.SetOutputFormat(Format_PCM_ACM); ``` #### VB6 Implementation ``` ' Set output format to PCM/ACM VideoCapture1.OutputFormat = Format_PCM_ACM ``` ## Setting the Audio Capture Mode Before starting the capture operation, you need to set the component to audio capture mode. This ensures that only audio is captured without any video streams. ### Delphi Implementation ``` // Set to audio-only capture mode VideoCapture1.Mode := Mode_Audio_Capture; ``` ### C++ MFC Implementation ``` // Set to audio-only capture mode m_VideoCapture.SetMode(Mode_Audio_Capture); ``` ### VB6 Implementation ``` ' Set to audio-only capture mode VideoCapture1.Mode = Mode_Audio_Capture ``` ## Starting the Audio Capture With all parameters configured, you can now start the audio capture process. This initializes the audio hardware, applies the selected codec and settings, and begins capturing audio to the specified output file. ### Delphi Implementation ``` // Begin audio capture process VideoCapture1.Start; ``` ### C++ MFC Implementation ``` // Begin audio capture process m_VideoCapture.Start(); ``` ### VB6 Implementation ``` ' Begin audio capture process VideoCapture1.Start ``` ## Advanced Implementation Considerations ### User Interface Integration To provide a better user experience, consider implementing: 1. Real-time audio level metering 2. Elapsed time display 3. File size estimation 4. Pause/resume functionality ### Performance Optimization For optimal performance when capturing extended audio sessions: 1. Monitor system memory usage 2. Implement file splitting for long recordings 3. Consider buffering strategies for high-quality captures ## Troubleshooting Common Issues When implementing audio capture, you might encounter these common issues: 1. **No audio devices detected**: Ensure proper hardware connections and drivers 2. **Poor audio quality**: Verify sample rate and bits per sample settings 3. **Codec compatibility issues**: Test with standard codecs like PCM or MP3 4. **High CPU usage**: Consider reducing sample rate or using hardware acceleration ## Conclusion Implementing audio capture to WAV files in your applications requires careful configuration of codecs, audio parameters, and output settings. By following this guide, you can create robust audio capture functionality that balances quality and file size requirements. For complex implementations or specific technical challenges, our support team is available to assist with custom solutions tailored to your application requirements. ## Additional Resources Visit our GitHub page for more code samples and implementation examples that demonstrate advanced audio capture techniques and integration patterns. --- For technical assistance with this implementation, please contact our support team. Additional code samples are available on our GitHub page. ---END OF PAGE--- ## Delphi Audio Output Device Selection | VideoCapture **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/audio-output/ **Description:** Select audio output devices in Delphi - enumerate devices, control volume, adjust balance with code examples for Delphi, C++, and VB6. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture # Audio Output Device Selection in Delphi This guide provides detailed instructions and code examples for implementing audio output device selection in your video capture applications. Delphi, C++ MFC, and VB6 implementations are covered to help you integrate this functionality into your projects efficiently. ## Available Audio Output Device Enumeration The first step in implementing audio output device selection is retrieving the complete list of available audio output devices on the system. This allows users to choose their preferred audio output device. ### Delphi Implementation ``` // Iterate through all available audio output devices for i := 0 to VideoCapture1.Audio_OutputDevices_GetCount - 1 do // Add each device to the dropdown list cbAudioOutputDevice.Items.Add(VideoCapture1.Audio_OutputDevices_GetItem(i)); ``` ### C++ MFC Implementation ``` // Populate the combobox with all available audio output devices for (int i = 0; i < m_VideoCapture.Audio_OutputDevices_GetCount(); i++) { CString deviceName = m_VideoCapture.Audio_OutputDevices_GetItem(i); m_AudioOutputDeviceCombo.AddString(deviceName); } ``` ### VB6 Implementation ``` ' Iterate through all available audio output devices For i = 0 To VideoCapture1.Audio_OutputDevices_GetCount - 1 ' Add each device to the dropdown list cboAudioOutputDevice.AddItem VideoCapture1.Audio_OutputDevices_GetItem(i) Next i ``` ## Setting the Active Audio Output Device After retrieving the available devices, the next step is to set the selected device as the active audio output device for your application. ### Delphi Implementation ``` // Set the selected device as the active audio output device VideoCapture1.Audio_OutputDevice := cbAudioOutputDevice.Items[cbAudioOutputDevice.ItemIndex]; ``` ### C++ MFC Implementation ``` // Get the selected index from the combobox int selectedIndex = m_AudioOutputDeviceCombo.GetCurSel(); CString selectedDevice; m_AudioOutputDeviceCombo.GetLBText(selectedIndex, selectedDevice); // Set the selected device as the active audio output device. // COM property setters in MFC use the put_ wrapper, not direct assignment. m_VideoCapture.put_Audio_OutputDevice(selectedDevice); ``` ### VB6 Implementation ``` ' Set the selected device as the active audio output device VideoCapture1.Audio_OutputDevice = cboAudioOutputDevice.Text ``` ## Enabling Audio Playback Once the output device is selected, you need to enable audio playback to hear the audio through the selected device. ### Delphi Implementation ``` // Enable audio playback through the selected device VideoCapture1.Audio_PlayAudio := true; ``` ### C++ MFC Implementation ``` // Enable audio playback through the selected device m_VideoCapture.Audio_PlayAudio = TRUE; ``` ### VB6 Implementation ``` ' Enable audio playback through the selected device VideoCapture1.Audio_PlayAudio = True ``` ## Adjusting Audio Volume Levels Providing volume control gives users the ability to customize their audio experience. This section shows how to implement volume adjustment. ### Delphi Implementation ``` // Set the volume level based on trackbar position VideoCapture1.Audio_OutputDevice_SetVolume(tbAudioVolume.Position); ``` ### C++ MFC Implementation ``` // Get the current position of the volume slider int volumeLevel = m_VolumeSlider.GetPos(); // Set the volume level based on slider position m_VideoCapture.Audio_OutputDevice_SetVolume(volumeLevel); ``` ### VB6 Implementation ``` ' Set the volume level based on slider position VideoCapture1.Audio_OutputDevice_SetVolume sldVolume.Value ``` ## Controlling Audio Balance For stereo output, balance control allows users to adjust the relative volume between left and right channels. ### Delphi Implementation ``` // Set the balance level based on trackbar position VideoCapture1.Audio_OutputDevice_SetBalance(tbAudioBalance.Position); ``` ### C++ MFC Implementation ``` // Get the current position of the balance slider int balanceLevel = m_BalanceSlider.GetPos(); // Set the balance level based on slider position m_VideoCapture.Audio_OutputDevice_SetBalance(balanceLevel); ``` ### VB6 Implementation ``` ' Set the balance level based on slider position VideoCapture1.Audio_OutputDevice_SetBalance sldBalance.Value ``` ## Best Practices for Audio Device Implementation - Always check if the audio device is valid before attempting to use it - Provide fallback mechanisms when the selected device becomes unavailable - Consider saving user preferences for audio device selection between sessions - Implement visual feedback when volume or balance settings are changed --- Please contact our [support team](https://support.visioforge.com/) if you need assistance with this implementation. Visit our [GitHub repository](https://github.com/visioforge/) for additional code samples and resources. ---END OF PAGE--- ## Delphi Video Capture SDK Version Changelog and Notes **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/changelog/ **Description:** TVFVideoCapture version history - GPU acceleration, streaming capabilities, format updates from version 4.1 to 11.0 with detailed release notes. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Streaming **API:** TVFVideoCapture, TVFMediaPlayer # TVFVideoCapture Version History ## Release 11.00 - Enhanced GPU Encoding & Modern Delphi Support - **Expanded Framework Compatibility**: Added support for Delphi 10.4 and 11.0 development environments - **Advanced AMD GPU Acceleration**: Implemented MP4 (H264/AAC) video encoding utilizing AMD graphics processing units - **Intel GPU Hardware Encoding**: Added MP4 (H264/AAC) video encoding through Intel integrated and discrete GPUs - **NVIDIA CUDA Acceleration**: Introduced MP4 (H264/AAC) video encoding powered by NVIDIA graphics hardware - **Container Format Improvements**: Enhanced MKV output with optimized performance and reliability - **New Output Format**: Added MOV container format support for Apple ecosystem compatibility ## Release 10.0 - Performance Optimizations & Multi-Platform Support - **MP4 Enhancement**: Thoroughly updated and improved MP4 output capabilities - **Streaming Improvements**: Updated VLC source filter with enhanced RTMP and HTTPS support - **Memory Management**: Fixed critical CUDA encoder memory leak for stable long-duration encoding - **Resource Optimization**: Resolved FFMPEG source memory leak for improved application stability - **Audio Capture**: Enhanced What You Hear filter for superior system audio recording - **64-bit Architecture**: Added x64 VLC source for TVFMediaPlayer and TVFVideoCapture (both Delphi and ActiveX) - **Extended Format Support**: Enhanced YUV2RGB filter with HDYC format support - **Audio Encoding**: Updated LAME encoder with fix for low bitrate mono audio issues - **Development Environment**: Added Delphi 10, 10.1 support for modern development workflows ## Release 8.7 - Core Engine Updates - **VLC Integration**: Updated VLC engine to libVLC 2.2.1.0 for improved streaming capabilities - **Decoder Enhancement**: Updated FFMPEG engine for better format compatibility and performance ## Release 8.6 - Reliability Improvements & Format Support - **Resource Management**: Fixed critical memory leak for improved application stability - **File Handling**: Resolved issues with improperly closed input and output files - **New Format Support**: Added custom WebM filters based on the WebM project specifications ## Release 8.4 - Architecture Expansion - **Modern Delphi**: Added Delphi XE8 support for latest development environments - **64-bit Architecture**: Introduced Delphi and ActiveX x64 versions for performance on modern systems ## Release 8.31 - Development Environment Update - **Framework Compatibility**: Added Delphi XE7 support for expanded development options ## Release 8.3 - API and Performance Improvements - **Interface Enhancement**: Updated ActiveX API for improved developer experience - **Decoder Optimization**: Enhanced FFMPEG decoder for better performance and format support - **Stability**: Implemented several critical bug fixes and performance improvements ## Release 8.0 - Streaming Capabilities - **Network Streaming**: Introduced VLC engine for IP video capture capabilities - **Reliability**: Fixed several bugs for improved stability across all components ## Release 7.15 - Advanced Output Options & Security - **Network Capture**: Improved IP capture engine for better connection stability and performance - **Modern Format Support**: Added MP4 with H264/AAC output for industry-standard compatibility - **Security Feature**: Implemented video encryption for protected content workflows - **System Integration**: Added Virtual Camera output for software integration scenarios - **Stability**: Multiple small bug fixes for improved reliability ## Release 7.0 - Capture Engine Improvements - **Network Performance**: Enhanced IP capture engine with improved throughput and reliability - **Desktop Capture**: Updated screen capture engine for better performance and quality - **Output Options**: Enhanced FFMPEG output for expanded format support - **Visual Effects**: Added Pan/zoom video effect for advanced video manipulation - **Reliability**: Implemented multiple small bug fixes for improved stability ## Release 6.0 - Multi-Source & Windows 8 Compatibility - **Advanced Compositing**: Improved Picture-In-Picture with support for any video source including screen capture and IP cameras - **Streaming Protocol**: Enhanced RTSP sources support for better network video integration - **Special Capture Mode**: Added layered windows screen capture support for complex UI recording - **Hardware Support**: Implemented iCube cameras support for specialized imaging applications - **OS Compatibility**: Added Windows 8 Developer Preview support for forward compatibility - **Visual Processing**: Enhanced video effects with new options and improved performance - **Audio Management**: Introduced multiple audio stream support for AVI and WMV outputs ## Release 5.5 - Stability & Feature Enhancements - **Visual Processing**: Enhanced video effects with improved quality and performance - **Network Video**: Improved IP cameras support for better connectivity and compatibility - **Reliability**: Fixed several bugs for improved overall stability ## Release 5.4 - Modern Delphi Support - **Development Environment**: Added Delphi XE2 support for modern application development - **Stability**: Implemented several bug fixes for improved reliability ## Release 5.3 - Video Processing Improvements - **Visual Effects**: Enhanced video effects with additional options and better performance - **Network Video**: Improved IP cameras support for wider device compatibility - **Reliability**: Fixed multiple bugs for more stable operation ## Release 5.2 - Frame Processing Enhancements - **Visual Effects**: Improved video effects and video frame grabber functionality - **Stability**: Fixed several bugs for enhanced reliability ## Release 5.1 - Network Video & Effects Improvements - **IP Camera Integration**: Enhanced IP camera support for improved connectivity - **Visual Processing**: Improved video effect quality and performance - **Reliability**: Fixed various issues for better stability ## Release 5.0 - Major Format Support Expansion - **Network Video**: Added RTSP/HTTP IP camera support (MJPEG/MPEG-4/H264 with or without audio) - **Modern Format**: Implemented WebM output for open web standards compatibility - **Format Flexibility**: Added MPEG-1/2/4 and FLV output using FFMPEG integration ## Release 4.22 - Screen Capture Improvements - **Desktop Recording**: Fixed bugs in screen capture filter for improved recording quality ## Release 4.21 - Screen Capture Enhancements - **Desktop Recording**: Implemented multiple bug fixes and improvements in screen capture filter ## Release 4.2 - Audio Processing Improvement - **Sound Effects**: Enhanced audio effects filter with improved quality and performance ## Release 4.1 - Modern Delphi Integration - **Development Environment**: Added Delphi 2010 support for the Delphi edition - **Stability**: Fixed several bugs for improved reliability ---END OF PAGE--- ## DirectShow Output Formats in Delphi - Complete Guide **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/custom-output/ **Description:** Implement DirectShow custom output formats in Delphi, C++, VB6 - integrate third-party filters, codecs, and multiplexers with code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Capture, Encoding # Code sample - Custom output formats Delphi, C++ MFC, and VB6 sample code. Currently, there are several options for connecting third-party DirectShow filters to get the necessary format. ## The first option - 3 different DirectShow filters An audio codec, a video codec, and a multiplexer – different filter. You can use both DirectShow filters and regular codecs as codecs. ## The second option - an all-in-one DirectShow filter A multiplexer, a video codec, and an audio codec – the same filter. Another difference is whether the filter can write to a file itself, whether you should use the standard File Writer filter, or whether you need another special filter. In the first two cases, VisioForge Video Capture will detect it automatically and set the necessary parameters, but you have to specify the necessary filter yourself in the third case. Now, let us see what the code for different options looks like. ## First option Get lists of audio and video codecs ``` for I := 0 to VideoCapture1.Video_Codecs_GetCount - 1 do cbCustomVideoCodec.Items.Add(VideoCapture1.Video_Codecs_GetItem(i)); for I := 0 to VideoCapture1.Audio_Codecs_GetCount - 1 do cbCustomAudioCodec.Items.Add(VideoCapture1.Audio_Codecs_GetItem(i)); ``` ``` // C++ MFC for (int i = 0; i < m_VideoCapture.Video_Codecs_GetCount(); i++) m_CustomVideoCodecCombo.AddString(m_VideoCapture.Video_Codecs_GetItem(i)); for (int i = 0; i < m_VideoCapture.Audio_Codecs_GetCount(); i++) m_CustomAudioCodecCombo.AddString(m_VideoCapture.Audio_Codecs_GetItem(i)); ``` ``` ' VB6 For i = 0 To VideoCapture1.Video_Codecs_GetCount - 1 cbCustomVideoCodec.AddItem VideoCapture1.Video_Codecs_GetItem(i) Next i For i = 0 To VideoCapture1.Audio_Codecs_GetCount - 1 cbCustomAudioCodec.AddItem VideoCapture1.Audio_Codecs_GetItem(i) Next i ``` Get the list of DirectShow filters ``` for I := 0 to VideoCapture1.DirectShow_Filters_GetCount - 1 do begin cbCustomDSFilterV.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); cbCustomDSFilterA.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); cbCustomMuxer.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); cbCustomFilewriter.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); end; ``` ``` // C++ MFC for (int i = 0; i < m_VideoCapture.DirectShow_Filters_GetCount(); i++) { m_CustomDSFilterVCombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); m_CustomDSFilterACombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); m_CustomMuxerCombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); m_CustomFilewriterCombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); } ``` ``` ' VB6 For i = 0 To VideoCapture1.DirectShow_Filters_GetCount - 1 cbCustomDSFilterV.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) cbCustomDSFilterA.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) cbCustomMuxer.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) cbCustomFilewriter.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) Next i ``` Select filters and codecs ``` if rbCustomUseVideoCodecsCat.Checked then begin VideoCapture1.Custom_Output_Video_Codec := cbCustomVideoCodec.Items[cbCustomVideoCodec.ItemIndex]; VideoCapture1.Custom_Output_Video_Codec_Use_Filters_Category := false; end else begin VideoCapture1.Custom_Output_Video_Codec := cbCustomDSFilterV.Items[cbCustomDSFilterV.ItemIndex]; VideoCapture1.Custom_Output_Video_Codec_Use_Filters_Category := true; end; if rbCustomUseAudioCodecsCat.Checked then begin VideoCapture1.Custom_Output_Audio_Codec := cbCustomAudioCodec.Items[cbCustomAudioCodec.ItemIndex]; VideoCapture1.Custom_Output_Audio_Codec_Use_Filters_Category := false; end else begin VideoCapture1.Custom_Output_Audio_Codec := cbCustomDSFilterA.Items[cbCustomDSFilterA.ItemIndex]; VideoCapture1.Custom_Output_Audio_Codec_Use_Filters_Category := true; end; VideoCapture1.Custom_Output_Mux_Filter_Name := cbCustomMuxer.Items[cbCustomMuxer.ItemIndex]; ``` ``` // C++ MFC // CComboBox::GetCurSel returns CB_ERR (-1) when no item is selected; guard each // read so GetLBText is never called with -1. int nIndex; if (m_CustomUseVideoCodecsCat.GetCheck()) { nIndex = m_CustomVideoCodecCombo.GetCurSel(); if (nIndex != CB_ERR) { CString videoCodec; m_CustomVideoCodecCombo.GetLBText(nIndex, videoCodec); m_VideoCapture.Custom_Output_Video_Codec = videoCodec; m_VideoCapture.Custom_Output_Video_Codec_Use_Filters_Category = false; } } else { nIndex = m_CustomDSFilterVCombo.GetCurSel(); if (nIndex != CB_ERR) { CString videoCodec; m_CustomDSFilterVCombo.GetLBText(nIndex, videoCodec); m_VideoCapture.Custom_Output_Video_Codec = videoCodec; m_VideoCapture.Custom_Output_Video_Codec_Use_Filters_Category = true; } } if (m_CustomUseAudioCodecsCat.GetCheck()) { nIndex = m_CustomAudioCodecCombo.GetCurSel(); if (nIndex != CB_ERR) { CString audioCodec; m_CustomAudioCodecCombo.GetLBText(nIndex, audioCodec); m_VideoCapture.Custom_Output_Audio_Codec = audioCodec; m_VideoCapture.Custom_Output_Audio_Codec_Use_Filters_Category = false; } } else { nIndex = m_CustomDSFilterACombo.GetCurSel(); if (nIndex != CB_ERR) { CString audioCodec; m_CustomDSFilterACombo.GetLBText(nIndex, audioCodec); m_VideoCapture.Custom_Output_Audio_Codec = audioCodec; m_VideoCapture.Custom_Output_Audio_Codec_Use_Filters_Category = true; } } nIndex = m_CustomMuxerCombo.GetCurSel(); if (nIndex != CB_ERR) { CString muxerName; m_CustomMuxerCombo.GetLBText(nIndex, muxerName); m_VideoCapture.Custom_Output_Mux_Filter_Name = muxerName; } ``` ``` ' VB6 If rbCustomUseVideoCodecsCat.Value Then VideoCapture1.Custom_Output_Video_Codec = cbCustomVideoCodec.List(cbCustomVideoCodec.ListIndex) VideoCapture1.Custom_Output_Video_Codec_Use_Filters_Category = False Else VideoCapture1.Custom_Output_Video_Codec = cbCustomDSFilterV.List(cbCustomDSFilterV.ListIndex) VideoCapture1.Custom_Output_Video_Codec_Use_Filters_Category = True End If If rbCustomUseAudioCodecsCat.Value Then VideoCapture1.Custom_Output_Audio_Codec = cbCustomAudioCodec.List(cbCustomAudioCodec.ListIndex) VideoCapture1.Custom_Output_Audio_Codec_Use_Filters_Category = False Else VideoCapture1.Custom_Output_Audio_Codec = cbCustomDSFilterA.List(cbCustomDSFilterA.ListIndex) VideoCapture1.Custom_Output_Audio_Codec_Use_Filters_Category = True End If VideoCapture1.Custom_Output_Mux_Filter_Name = cbCustomMuxer.List(cbCustomMuxer.ListIndex) ``` ## Second option Get lists of DirectShow filters. ``` for I := 0 to VideoCapture1.DirectShow_Filters_GetCount - 1 do begin cbCustomDSFilterV.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); cbCustomDSFilterA.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); cbCustomMuxer.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); cbCustomFilewriter.Items.Add(VideoCapture1.DirectShow_Filters_GetItem(i)); end; ``` ``` // C++ MFC for (int i = 0; i < m_VideoCapture.DirectShow_Filters_GetCount(); i++) { m_CustomDSFilterVCombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); m_CustomDSFilterACombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); m_CustomMuxerCombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); m_CustomFilewriterCombo.AddString(m_VideoCapture.DirectShow_Filters_GetItem(i)); } ``` ``` ' VB6 For i = 0 To VideoCapture1.DirectShow_Filters_GetCount - 1 cbCustomDSFilterV.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) cbCustomDSFilterA.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) cbCustomMuxer.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) cbCustomFilewriter.AddItem VideoCapture1.DirectShow_Filters_GetItem(i) Next i ``` Select multiplexer (mux) filter ``` VideoCapture1.Custom_Output_Mux_Filter_Name := cbCustomMuxer.Items[cbCustomMuxer.ItemIndex]; VideoCapture1.Custom_Output_Mux_Filter_Is_Encoder := cbCustomMuxFilterIsEncoder.Checked; ``` ``` // C++ MFC CString muxerName; m_CustomMuxerCombo.GetLBText(m_CustomMuxerCombo.GetCurSel(), muxerName); m_VideoCapture.Custom_Output_Mux_Filter_Name = muxerName; m_VideoCapture.Custom_Output_Mux_Filter_Is_Encoder = m_CustomMuxFilterIsEncoder.GetCheck(); ``` ``` ' VB6 VideoCapture1.Custom_Output_Mux_Filter_Name = cbCustomMuxer.List(cbCustomMuxer.ListIndex) VideoCapture1.Custom_Output_Mux_Filter_Is_Encoder = cbCustomMuxFilterIsEncoder.Value ``` If you need a special File Writer filter, you should specify it. This is true for both options described above. ``` VideoCapture1.Custom_Output_Special_FileWriter_Needed := cbUseSpecialFilewriter.Checked; VideoCapture1.Custom_Output_Special_FileWriter_Filter_Name := cbCustomFilewriter.Items[cbCustomFilewriter.ItemIndex]; ``` ``` // C++ MFC m_VideoCapture.Custom_Output_Special_FileWriter_Needed = m_UseSpecialFilewriter.GetCheck(); CString fileWriterName; m_CustomFilewriterCombo.GetLBText(m_CustomFilewriterCombo.GetCurSel(), fileWriterName); m_VideoCapture.Custom_Output_Special_FileWriter_Filter_Name = fileWriterName; ``` ``` ' VB6 VideoCapture1.Custom_Output_Special_FileWriter_Needed = cbUseSpecialFilewriter.Value VideoCapture1.Custom_Output_Special_FileWriter_Filter_Name = cbCustomFilewriter.List(cbCustomFilewriter.ListIndex) ``` Start capture ``` VideoCapture1.Start; ``` ``` // C++ MFC m_VideoCapture.Start(); ``` ``` ' VB6 VideoCapture1.Start ``` --- Please get in touch with [support](https://support.visioforge.com/) to get help with this tutorial. Visit our [GitHub](https://github.com/visioforge/) page to get more code samples. ---END OF PAGE--- ## Deploying TVFVideoCapture Library in Delphi Projects **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/deployment/ **Description:** Deploy TVFVideoCapture in Delphi - install components, register DirectShow filters, configure environment for successful application deployment. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Capture, Encoding, IP Camera, MP4, MP3 **API:** TVFVideoCapture # Complete TVFVideoCapture Library Deployment Guide When distributing applications built with the TVFVideoCapture library, you'll need to deploy several framework components to ensure proper functionality on end-user systems. This guide covers all deployment scenarios to help you create reliable installations. ## Deployment Options Overview You have two primary approaches for deploying the necessary components: automatic installers for simpler deployment or manual installation for more customized setups. ## Automatic Silent Installers (Requires Admin Rights) These pre-configured installers handle dependencies automatically and can be integrated into your application's installation process: ### Essential Components - **Base Package** (mandatory for all deployments) - [Delphi Version](https://files.visioforge.com/redists_delphi/redist_video_capture_base_delphi.exe) - [ActiveX Version](https://files.visioforge.com/redists_delphi/redist_video_capture_base_ax.exe) ### Optional Feature Components - **FFMPEG Package** (required for file or IP camera sources) - [x86 Architecture](https://files.visioforge.com/redists_delphi/redist_video_capture_ffmpeg.exe) - **MP4 Output Support** - [x86 Architecture](https://files.visioforge.com/redists_delphi/redist_video_capture_mp4.exe) - **VLC Source Package** (alternative option for file or IP camera sources) - [x86 Architecture](https://files.visioforge.com/redists_delphi/redist_video_capture_vlc.exe) ## Manual Installation Process (Requires Admin Rights) For more control over the deployment process, follow these detailed steps: ### Step 1: Install Required Dependencies 1. Deploy Visual C++ 2010 SP1 redistributables: 2. [x86 Architecture](https://files.visioforge.com/shared/vcredist_2010_x86.exe) 3. [x64 Architecture](https://files.visioforge.com/shared/vcredist_2010_x64.exe) ### Step 2: Deploy Core Components 1. Copy all Media Foundation Platform (MFP) DLLs from the `Redist\Filters` directory to your application folder 2. For ActiveX implementations: copy and register the OCX file using [regsvr32.exe](https://support.microsoft.com/en-us/topic/how-to-use-the-regsvr32-tool-and-troubleshoot-regsvr32-error-messages-a98d960a-7392-e6fe-d90a-3f4e0cb543e5) ### Step 3: Register DirectShow Filters Using [regsvr32.exe](https://support.microsoft.com/en-us/topic/how-to-use-the-regsvr32-tool-and-troubleshoot-regsvr32-error-messages-a98d960a-7392-e6fe-d90a-3f4e0cb543e5), register these essential DirectShow filters: - `VisioForge_Audio_Effects_4.ax` - `VisioForge_Dump.ax` - `VisioForge_RGB2YUV.ax` - `VisioForge_Screen_Capture.ax` - `VisioForge_Video_Effects_Pro.ax` - `VisioForge_Video_Mixer.ax` - `VisioForge_Video_Resize.ax` - `VisioForge_WavDest.ax` - `VisioForge_YUV2RGB.ax` - `VisioForge_FFMPEG_Source.ax` > **Important:** Add the filter directory to the system PATH environment variable if your application executable resides in a different folder. ## Advanced Component Installation ### FFMPEG Integration 1. Copy all files from `Redist\FFMPEG` folder to your deployment 2. Add the FFMPEG folder to the Windows system PATH variable 3. Register all .ax files from the FFMPEG folder ### VLC Integration 1. Copy all files from the `Redist\VLC` folder 2. Register the included .ax file using regsvr32.exe 3. Create an environment variable named `VLC_PLUGIN_PATH` pointing to the `VLC\plugins` directory ### Audio Output Support (LAME) 1. Copy `lame.ax` from the `Redist\Formats` folder 2. Register the `lame.ax` file using regsvr32.exe ### Container Format Support - **WebM Support:** Install free codecs from [xiph.org](https://www.xiph.org) - **Matroska Support:** Deploy `Haali Matroska Splitter` ### MP4 Output Configuration #### Modern Encoder Setup 1. Copy appropriate library files: 2. `libmfxsw32.dll` (for 32-bit deployments) 3. `libmfxsw64.dll` (for 64-bit deployments) 4. Register required components: 5. `VisioForge_H264_Encoder.ax` 6. `VisioForge_MP4_Muxer.ax` 7. `VisioForge_AAC_Encoder.ax` 8. `VisioForge_Video_Resize.ax` #### Legacy Encoder Setup (for older systems) 1. Copy appropriate library files: 2. `libmfxxp32.dll` (for 32-bit deployments) 3. `libmfxxp64.dll` (for 64-bit deployments) 4. Register required components: 5. `VisioForge_H264_Encoder_XP.ax` 6. `VisioForge_MP4_Muxer_XP.ax` 7. `VisioForge_AAC_Encoder_XP.ax` 8. `VisioForge_Video_Resize.ax` ## Bulk Registration Utility To simplify DirectShow filter registration, you can use the `reg_special.exe` utility from the framework setup. Place this executable in your filter directory and run it with administrator privileges to register all filters at once. --- For additional code samples and implementation examples, visit our [GitHub repository](https://github.com/visioforge/). If you encounter any difficulties with deployment, please contact [technical support](https://support.visioforge.com/) for personalized assistance. ---END OF PAGE--- ## DV Camcorder Control in Delphi with TVFVideoCapture **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/dv-camcorder/ **Description:** Control DV camcorders in Delphi with TVFVideoCapture - playback, navigation, transport controls with code examples for Delphi, C++, and VB6. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, DV Camera **API:** TVFVideoCapture # Complete Guide to DV Camcorder Control This developer guide demonstrates how to effectively integrate and control Digital Video (DV) camcorders in your applications using the TVFVideoCapture component. The examples below include implementations for Delphi, C++ MFC, and Visual Basic 6, allowing you to choose the development environment that best suits your project requirements. ## Prerequisites for Implementation Before using any of the DV control commands, you must initialize your video capture system by starting either the video preview or capture process. This establishes the necessary connection between your application and the DV device. ## DV Transport Control Commands The following sections provide detailed implementation examples for each of the essential DV transport control functions, allowing you to create professional video manipulation applications. ### Starting Playback Initiate standard playback of your DV content with the `DV_PLAY` command. This command starts playback at normal speed and is essential for basic video viewing functionality. ``` VideoCapture1.DV_SendCommand(DV_PLAY); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_PLAY); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_PLAY ``` ### Pausing Video Playback Temporarily suspend video playback while maintaining the current position with the `DV_PAUSE` command. This is useful for implementing frame analysis or allowing users to examine specific content. ``` VideoCapture1.DV_SendCommand(DV_PAUSE); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_PAUSE); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_PAUSE ``` ### Stopping Playback Completely halt playback and reset the DV device to a ready state using the `DV_STOP` command. This typically returns the playback position to the beginning of the current section. ``` VideoCapture1.DV_SendCommand(DV_STOP); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_STOP); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_STOP ``` ### Advanced Navigation Controls #### Fast Forward Operation Rapidly advance through content with the `DV_FF` command. This allows users to quickly navigate to specific sections of the video. ``` VideoCapture1.DV_SendCommand(DV_FF); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_FF); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_FF ``` #### Rewind Operation Move backward through content at high speed with the `DV_REW` command. This function enables efficient navigation to previous sections of video. ``` VideoCapture1.DV_SendCommand(DV_REW); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_REW); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_REW ``` ## Frame-by-Frame Navigation For precision video analysis and editing applications, these commands enable frame-accurate navigation. ### Forward Frame Step Advance exactly one frame forward with the `DV_STEP_FW` command. This enables precise frame analysis and is essential for detailed video editing applications. ``` VideoCapture1.DV_SendCommand(DV_STEP_FW); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_STEP_FW); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_STEP_FW ``` ### Backward Frame Step Move exactly one frame backward with the `DV_STEP_REV` command. This complements the forward step function and allows for bidirectional frame-accurate navigation. ``` VideoCapture1.DV_SendCommand(DV_STEP_REV); ``` ``` // C++ MFC m_VideoCapture.DV_SendCommand(DV_STEP_REV); ``` ``` ' VB6 VideoCapture1.DV_SendCommand DV_STEP_REV ``` ## Implementation Best Practices When integrating DV control functionality into your applications, consider the following practices: 1. Always verify device connectivity before sending commands 2. Implement proper error handling for cases when commands fail 3. Provide visual feedback to users when transport control states change 4. Consider implementing keyboard shortcuts for common DV control operations ## Additional Resources For more detailed information and advanced implementation techniques, explore our additional documentation and code repositories. Please contact our support team if you need assistance with implementation. Visit our GitHub repository for additional code samples and example projects. ---END OF PAGE--- ## FM Radio and TV Tuning in Delphi — Channel Scanning Guide **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/fm-radio-tv-tuning/ **Description:** Implement FM radio and TV tuning in Delphi - channel scanning, frequency management, signal detection with code examples for Delphi, C++, VB6. **Tags:** All-in-One Media Framework, Delphi, ActiveX, C++, Windows, VCL, Capture, TV Tuner # Implementing FM Radio and TV Tuning in Delphi Applications ## Introduction to TV and Radio Tuning This guide provides detailed implementation examples for Delphi developers working with FM radio and TV tuning functionality. We've included equivalent code samples for C++ MFC and VB6 to support cross-platform development needs. ## Device Management ### Retrieving Available TV Tuners The first step in implementing tuner functionality is identifying available hardware devices: ``` // Iterate through all connected TV Tuner devices and populate dropdown for I := 0 to VideoCapture1.TVTuner_Devices_GetCount - 1 do cbTVTuner.Items.Add(VideoCapture1.TVTuner_Devices_GetItem(i)); ``` ``` // C++ MFC implementation for retrieving TV Tuner devices for (int i = 0; i < m_VideoCapture.TVTuner_Devices_GetCount(); i++) m_cbTVTuner.AddString(m_VideoCapture.TVTuner_Devices_GetItem(i)); ``` ``` ' VB6 implementation for device enumeration For i = 0 To VideoCapture1.TVTuner_Devices_GetCount - 1 cbTVTuner.AddItem VideoCapture1.TVTuner_Devices_GetItem(i) Next i ``` ### Enumerating TV Format Support Different regions use different broadcast standards. Your application should detect and handle these formats: ``` // Load available TV formats (PAL, NTSC, SECAM, etc.) for I := 0 to VideoCapture1.TVTuner_TVFormats_GetCount - 1 do cbTVSystem.Items.Add(VideoCapture1.TVTuner_TVFormats_GetItem(i)); ``` ``` // C++ MFC - Populate TV format dropdown with available standards for (int i = 0; i < m_VideoCapture.TVTuner_TVFormats_GetCount(); i++) m_cbTVSystem.AddString(m_VideoCapture.TVTuner_TVFormats_GetItem(i)); ``` ``` ' VB6 - Get supported TV formats for the selected tuner For i = 0 To VideoCapture1.TVTuner_TVFormats_GetCount - 1 cbTVSystem.AddItem VideoCapture1.TVTuner_TVFormats_GetItem(i) Next i ``` ### Country-Specific Configuration Broadcasting standards vary by country, so your application should provide appropriate region selection: ``` // Load country/region list for localized tuning parameters for I := 0 to VideoCapture1.TVTuner_Countries_GetCount - 1 do cbTVCountry.Items.Add(VideoCapture1.TVTuner_Countries_GetItem(i)); ``` ``` // C++ MFC - Build country selection list for regional settings for (int i = 0; i < m_VideoCapture.TVTuner_Countries_GetCount(); i++) m_cbTVCountry.AddString(m_VideoCapture.TVTuner_Countries_GetItem(i)); ``` ``` ' VB6 - Populate country dropdown for regional broadcast settings For i = 0 To VideoCapture1.TVTuner_Countries_GetCount - 1 cbTVCountry.AddItem VideoCapture1.TVTuner_Countries_GetItem(i) Next i ``` ## Device Configuration ### Selecting a TV Tuner Device Once you've enumerated the available devices, users can select their preferred tuner: ``` // Set the active tuner device based on user selection VideoCapture1.TVTuner_Name := cbTVTuner.Items[cbTVTuner.ItemIndex]; ``` ``` // C++ MFC - Apply user's tuner device selection CString strText; m_cbTVTuner.GetLBText(m_cbTVTuner.GetCurSel(), strText); m_VideoCapture.put_TVTuner_Name(strText); ``` ``` ' VB6 - Set selected tuner as active device VideoCapture1.TVTuner_Name = cbTVTuner.Text ``` ### Reading Current Tuner Configuration After selecting a device, you'll need to read its current settings: ``` // Initialize tuner and read current configuration VideoCapture1.TVTuner_Read; ``` ``` // C++ MFC - Load current tuner settings into application m_VideoCapture.TVTuner_Read(); ``` ``` ' VB6 - Read tuner configuration after device selection VideoCapture1.TVTuner_Read ``` ### Available Operation Modes Tuners support different modes like TV, FM Radio, etc: ``` // Populate operation mode dropdown with available options for I := 0 to VideoCapture1.TVTuner_Modes_GetCount - 1 do cbTVMode.Items.Add(VideoCapture1.TVTuner_Modes_GetItem(i)); ``` ``` // C++ MFC - Get supported operational modes for this device for (int i = 0; i < m_VideoCapture.TVTuner_Modes_GetCount(); i++) m_cbTVMode.AddString(m_VideoCapture.TVTuner_Modes_GetItem(i)); ``` ``` ' VB6 - List available tuner modes (TV, FM Radio, etc) For i = 0 To VideoCapture1.TVTuner_Modes_GetCount - 1 cbTVMode.AddItem VideoCapture1.TVTuner_Modes_GetItem(i) Next i ``` ## Frequency Management ### Reading Current Frequencies Display the current audio and video frequencies to provide user feedback: ``` // Display current video and audio frequencies in Hz edVideoFreq.Text := IntToStr(VideoCapture1.TVTuner_VideoFrequency); edAudiofreq.Text := IntToStr(VideoCapture1.TVTuner_AudioFrequency); ``` ``` // C++ MFC - Show current frequency values in the interface CString strFreq; strFreq.Format(_T("%d"), m_VideoCapture.get_TVTuner_VideoFrequency()); m_edVideoFreq.SetWindowText(strFreq); strFreq.Format(_T("%d"), m_VideoCapture.get_TVTuner_AudioFrequency()); m_edAudioFreq.SetWindowText(strFreq); ``` ``` ' VB6 - Update frequency display fields with current values edVideoFreq.Text = CStr(VideoCapture1.TVTuner_VideoFrequency) edAudioFreq.Text = CStr(VideoCapture1.TVTuner_AudioFrequency) ``` ## Input and Mode Configuration ### Setting Signal Input Source Tuners may support multiple input sources that should be configurable: ``` // Select the appropriate input source based on current configuration cbTVInput.ItemIndex := cbTVInput.Items.IndexOf(VideoCapture1.TVTuner_InputType); ``` ``` // C++ MFC - Update input source selection in UI CString strInputType = m_VideoCapture.get_TVTuner_InputType(); m_cbTVInput.SetCurSel(m_cbTVInput.FindStringExact(-1, strInputType)); ``` ``` ' VB6 - Set input source dropdown to match current configuration cbTVInput.ListIndex = cbTVInput.FindItem(VideoCapture1.TVTuner_InputType) ``` ### Configuring Operation Mode Different tuner modes require specific UI and parameter adjustments: ``` // Set operation mode dropdown to current mode (TV, FM Radio, etc) cbTVMode.ItemIndex := cbTVMode.Items.IndexOf(VideoCapture1.TVTuner_Mode); ``` ``` // C++ MFC - Update mode selector to match current tuner configuration CString strMode = m_VideoCapture.get_TVTuner_Mode(); m_cbTVMode.SetCurSel(m_cbTVMode.FindStringExact(-1, strMode)); ``` ``` ' VB6 - Select current operating mode in dropdown cbTVMode.ListIndex = cbTVMode.FindItem(VideoCapture1.TVTuner_Mode) ``` ### TV Format Configuration Set the appropriate broadcast standard for the region: ``` // Configure the appropriate TV standard (PAL, NTSC, SECAM, etc) cbTVSystem.ItemIndex := cbTVSystem.Items.IndexOf(VideoCapture1.TVTuner_TVFormat); ``` ``` // C++ MFC - Set TV format dropdown to current broadcast standard CString strTVFormat = m_VideoCapture.get_TVTuner_TVFormat(); m_cbTVSystem.SetCurSel(m_cbTVSystem.FindStringExact(-1, strTVFormat)); ``` ``` ' VB6 - Update TV system format selection cbTVSystem.ListIndex = cbTVSystem.FindItem(VideoCapture1.TVTuner_TVFormat) ``` ### Regional Settings Configure region-specific broadcast parameters: ``` // Set country/region for appropriate frequency tables and standards cbTVCountry.ItemIndex := cbTVCountry.Items.IndexOf(VideoCapture1.TVTuner_Country); ``` ``` // C++ MFC - Update country selection to match current setting CString strCountry = m_VideoCapture.get_TVTuner_Country(); m_cbTVCountry.SetCurSel(m_cbTVCountry.FindStringExact(-1, strCountry)); ``` ``` ' VB6 - Set country dropdown to current regional setting cbTVCountry.ListIndex = cbTVCountry.FindItem(VideoCapture1.TVTuner_Country) ``` ## Channel Scanning ### Handling Channel Scan Events Implement the event handler for channel scanning process: ``` // Event handler for channel scanning process // Tracks progress and collects found channels procedure TForm1.VideoCapture1TVTunerTuneChannels(SignalPresent: Boolean; Channel, Frequency, Progress: Integer); begin // Update progress bar with current scan progress pbChannels.Position := Progress; // Add channel to list if signal is detected if SignalPresent then cbTVChannel.Items.Add(IntToStr(Channel)); // Scan complete when Channel = -1 if Channel = -1 then begin pbChannels.Position := 0; ShowMessage('AutoTune complete'); end; end; ``` ``` // C++ MFC - Channel scan event handler implementation // In header file (.h) BEGIN_EVENTSINK_MAP(CMainDlg, CDialog) ON_EVENT(CMainDlg, IDC_VIDEOCAPTURE, 1, OnTVTunerTuneChannels, VTS_BOOL VTS_I4 VTS_I4 VTS_I4) END_EVENTSINK_MAP() // In implementation file (.cpp) void CMainDlg::OnTVTunerTuneChannels(BOOL SignalPresent, long Channel, long Frequency, long Progress) { // Update scan progress indicator m_pbChannels.SetPos(Progress); // Add found channels to the selection list if (SignalPresent) { CString strChannel; strChannel.Format(_T("%d"), Channel); m_cbTVChannel.AddString(strChannel); } // Handle scan completion if (Channel == -1) { m_pbChannels.SetPos(0); MessageBox(_T("AutoTune complete"), _T("Information"), MB_OK | MB_ICONINFORMATION); } } ``` ``` ' VB6 - Channel scan event handler Private Sub VideoCapture1_TVTunerTuneChannels(ByVal SignalPresent As Boolean, ByVal Channel As Long, ByVal Frequency As Long, ByVal Progress As Long) ' Update scan progress display pbChannels.Value = Progress ' Add channel to list when signal is found If SignalPresent Then cbTVChannel.AddItem CStr(Channel) End If ' Handle scan completion If Channel = -1 Then pbChannels.Value = 0 MsgBox "AutoTune complete", vbInformation End If End Sub ``` ### Initiating Channel Scan Start the automatic channel scanning process: ``` // Define frequency constants for clarity const KHz = 1000; const MHz = 1000000; // Initialize tuner with current settings VideoCapture1.TVTuner_Read; // Clear previous channel list cbTVChannel.Items.Clear; // Configure special parameters for FM Radio scanning if ( (cbTVMode.ItemIndex <> -1) and (cbTVMode.Items[cbTVMode.ItemIndex] = 'FM Radio') ) then begin // Set frequency range for FM scanning (100-110MHz) VideoCapture1.TVTuner_FM_Tuning_StartFrequency := 100 * MHz; VideoCapture1.TVTuner_FM_Tuning_StopFrequency := 110 * MHz; // Set 100KHz increments for FM scanning VideoCapture1.TVTuner_FM_Tuning_Step := 100 * KHz; end; // Begin automatic channel scan VideoCapture1.TVTuner_TuneChannels_Start; ``` ``` // C++ MFC - Initiate channel scan with appropriate parameters const int KHz = 1000; const int MHz = 1000000; // Update tuner configuration m_VideoCapture.TVTuner_Read(); // Reset channel list before scanning m_cbTVChannel.ResetContent(); // Configure FM-specific parameters if in radio mode CString strMode; m_cbTVMode.GetLBText(m_cbTVMode.GetCurSel(), strMode); if (strMode == _T("FM Radio")) { // Set FM scan range (100-110MHz) m_VideoCapture.put_TVTuner_FM_Tuning_StartFrequency(100 * MHz); m_VideoCapture.put_TVTuner_FM_Tuning_StopFrequency(110 * MHz); // Use 100KHz steps for FM scanning m_VideoCapture.put_TVTuner_FM_Tuning_Step(100 * KHz); } // Start the channel scanning process m_VideoCapture.TVTuner_TuneChannels_Start(); ``` ``` ' VB6 - Begin channel scanning process Const KHz = 1000 Const MHz = 1000000 ' Read current tuner configuration VideoCapture1.TVTuner_Read ' Clear existing channel list cbTVChannel.Clear ' Special configuration for FM Radio scanning If (cbTVMode.ListIndex <> -1) And (cbTVMode.Text = "FM Radio") Then ' Set FM band scan parameters (100-110MHz) VideoCapture1.TVTuner_FM_Tuning_StartFrequency = 100 * MHz VideoCapture1.TVTuner_FM_Tuning_StopFrequency = 110 * MHz ' Use 100KHz step size for FM scanning VideoCapture1.TVTuner_FM_Tuning_Step = 100 * KHz End If ' Initiate automatic channel scan VideoCapture1.TVTuner_TuneChannels_Start ``` ## Manual Tuning Operations ### Setting Channel by Number Allow direct channel selection by number: ``` // Change to specified channel number VideoCapture1.TVTuner_Channel := StrToInt(edChannel.Text); // Apply tuning changes VideoCapture1.TVTuner_Apply; ``` ``` // C++ MFC - Set tuner to specified channel number CString strChannel; m_edChannel.GetWindowText(strChannel); m_VideoCapture.put_TVTuner_Channel(_ttoi(strChannel)); m_VideoCapture.TVTuner_Apply(); ``` ``` ' VB6 - Tune to specific channel number VideoCapture1.TVTuner_Channel = CInt(edChannel.Text) VideoCapture1.TVTuner_Apply ``` ### Setting Radio Frequency Directly For FM radio, direct frequency tuning is often required: ``` // Set channel to -1 for frequency-based tuning VideoCapture1.TVTuner_Channel := -1; // must be -1 to use frequency // Set specific frequency from input field VideoCapture1.TVTuner_Frequency := StrToInt(edChannel.Text); // Apply frequency change VideoCapture1.TVTuner_Apply; ``` ``` // C++ MFC - Direct frequency tuning implementation CString strFrequency; m_edChannel.GetWindowText(strFrequency); // Set channel to -1 to enable frequency-based tuning m_VideoCapture.put_TVTuner_Channel(-1); // must be -1 to use frequency // Apply the specified frequency m_VideoCapture.put_TVTuner_Frequency(_ttoi(strFrequency)); m_VideoCapture.TVTuner_Apply(); ``` ``` ' VB6 - Manual frequency tuning for radio VideoCapture1.TVTuner_Channel = -1 ' must be -1 to use frequency VideoCapture1.TVTuner_Frequency = CInt(edChannel.Text) VideoCapture1.TVTuner_Apply ``` ## Conclusion This guide covers the essential aspects of implementing FM radio and TV tuning functionality in your Delphi applications. By following these examples, you can create robust tuning interfaces with proper channel scanning, frequency management, and signal detection. For optimal integration into your projects, remember to handle error conditions and provide appropriate user feedback during lengthy operations such as channel scanning. --- Please visit our [GitHub](https://github.com/visioforge/) page for additional code samples and implementation examples. ---END OF PAGE--- ## Camera Brightness, Contrast and Saturation Control in Delphi **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/hardware-adjustments/ **Description:** Adjust camera brightness, contrast, and saturation in Delphi with TVFVideoCapture hardware controls and parameter configuration examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture # Implementing Hardware Video Adjustments in Delphi Applications ## Overview Modern video capture devices offer powerful hardware-level adjustments that can significantly enhance the quality of your video applications. By leveraging these capabilities in your Delphi applications, you can provide users with professional-grade video control features without complex software-based image processing. ## Supported Adjustment Types Most webcams and video capture devices support several adjustment parameters: - Brightness - Contrast - Saturation - Hue - Sharpness - Gamma - White balance - Gain ## Retrieving Available Adjustment Ranges Before setting adjustments, you'll need to determine what ranges are supported by the connected device. The `Video_CaptureDevice_VideoAdjust_GetRanges` method provides this information. ### Delphi Implementation ``` // Retrieve the available range for brightness adjustment // Returns minimum, maximum, step size, default value, and auto-adjustment capability VideoCapture1.Video_CaptureDevice_VideoAdjust_GetRanges(adj_Brightness, min, max, step, default, auto); ``` ### C++ MFC Implementation ``` // C++ MFC implementation for getting brightness adjustment ranges // Store results in integer variables for UI configuration int min, max, step, default_value; BOOL auto_value; m_VideoCapture.Video_CaptureDevice_VideoAdjust_GetRanges( TxVFVideoCapAdjust::adj_Brightness, &min, &max, &step, &default_value, &auto_value); ``` ### VB6 Implementation ``` ' VB6 implementation for retrieving brightness adjustment parameters ' Use these values to configure slider controls and checkboxes Dim min As Integer, max As Integer, step As Integer, default_val As Integer Dim auto_val As Boolean VideoCapture1.Video_CaptureDevice_VideoAdjust_GetRanges adj_Brightness, min, max, step, default_val, auto_val ``` ## Setting Adjustment Values Once you've determined the available ranges, you can use the `Video_CaptureDevice_VideoAdjust_SetValue` method to apply specific settings to the video stream. ### Delphi Implementation ``` // Set the brightness level based on trackbar position // The third parameter enables/disables automatic brightness adjustment VideoCapture1.Video_CaptureDevice_VideoAdjust_SetValue( adj_Brightness, tbAdjBrightness.Position, cbAdjBrightnessAuto.Checked); ``` ### C++ MFC Implementation ``` // C++ MFC implementation for setting brightness value // Uses slider position for manual adjustment value // Checkbox state determines if auto-adjustment is enabled m_VideoCapture.Video_CaptureDevice_VideoAdjust_SetValue( TxVFVideoCapAdjust::adj_Brightness, m_sliderBrightness.GetPos(), m_checkBrightnessAuto.GetCheck() == BST_CHECKED); ``` ### VB6 Implementation ``` ' VB6 implementation for applying brightness settings ' Uses trackbar value for adjustment level ' Checkbox value determines automatic adjustment mode VideoCapture1.Video_CaptureDevice_VideoAdjust_SetValue _ adj_Brightness, _ tbAdjBrightness.Value, _ cbAdjBrightnessAuto.Value = vbChecked ``` ## Best Practices for Video Adjustment Implementation When implementing video adjustments in your applications: 1. Always check device capabilities first, as not all devices support all adjustment types 2. Provide intuitive UI controls like sliders with appropriate min/max values 3. Include auto-adjustment options when available 4. Consider saving user preferences for future sessions 5. Implement real-time preview so users can see the effects of their adjustments ## Additional Resources Please contact our support team for assistance with implementing these features in your application. Visit our GitHub repository for additional code samples and implementation examples. ---END OF PAGE--- ## Delphi Video Capture SDK - TVFVideoCapture Full Guide **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/ **Description:** Build Delphi video and audio capture apps with TVFVideoCapture, including device enumeration, preview, MP4/AVI recording, screen capture, and IP cameras. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Streaming **API:** TVFVideoCapture # Video Capture SDK for Delphi [Video Capture SDK Delphi](https://www.visioforge.com/all-in-one-media-framework) This section covers using the Video Capture SDK with Delphi to build video and audio capture applications. The `TVFVideoCapture` component (declared in `VideoCaptureMain.pas`) is a `TCustomPanel` descendant, so it both renders the preview surface and exposes the full capture API as published properties, methods, and events. ## Main Component ### TVFVideoCapture `TVFVideoCapture` provides complete video and audio capture functionality. You can drop it on a form from the IDE palette or create it at runtime. As it descends from `TCustomPanel`, set `Parent` and `Align` like any other VCL container. ``` var VideoCapture1: TVFVideoCapture; begin VideoCapture1 := TVFVideoCapture.Create(Self); VideoCapture1.Parent := Panel1; VideoCapture1.Align := alClient; end; ``` ## Device Enumeration Populate combo boxes with the video and audio capture devices discovered on the host. The SDK exposes `_GetCount` / `_GetItem(Index)` pairs for every device list. ``` procedure TForm1.EnumerateDevices; var i: Integer; begin // Video capture devices cbVideoDevices.Clear; for i := 0 to VideoCapture1.Video_CaptureDevices_GetCount - 1 do cbVideoDevices.Items.Add(VideoCapture1.Video_CaptureDevices_GetItem(i)); // Audio capture devices cbAudioDevices.Clear; for i := 0 to VideoCapture1.Audio_CaptureDevices_GetCount - 1 do cbAudioDevices.Items.Add(VideoCapture1.Audio_CaptureDevices_GetItem(i)); end; ``` ## Preview Switch the component to `Mode_Video_Preview` to render live video to the panel without writing anything to disk. Audio monitoring is controlled by `Audio_PlayAudio`. ``` procedure TForm1.StartPreview; begin // Select devices by display name VideoCapture1.Video_CaptureDevice := cbVideoDevices.Text; VideoCapture1.Audio_CaptureDevice := cbAudioDevices.Text; // Preview mode (no file output) VideoCapture1.Mode := Mode_Video_Preview; VideoCapture1.Audio_PlayAudio := True; VideoCapture1.Start; end; procedure TForm1.StopPreview; begin VideoCapture1.Stop; end; ``` ## Capturing to a File Switch to `Mode_Video_Capture` and assign `Output_Filename` and `Output_Format`. The `TVFOutputFormat` enum lists every container the component can write (`Format_MP4`, `Format_AVI`, `Format_WMV`, `Format_DV`, `Format_WebM`, `Format_FFMPEG`, `Format_FFMPEGX`, and so on). ``` procedure TForm1.StartCapture; begin VideoCapture1.Video_CaptureDevice := cbVideoDevices.Text; VideoCapture1.Audio_CaptureDevice := cbAudioDevices.Text; VideoCapture1.Audio_RecordAudio := True; // Output file and container VideoCapture1.Output_Filename := 'C:\Videos\capture.mp4'; VideoCapture1.Output_Format := Format_MP4; // Switch to capture mode VideoCapture1.Mode := Mode_Video_Capture; VideoCapture1.Start; end; ``` You can change the output file on the fly without stopping the graph by calling `OutputFilename_ChangeOnTheFly`. ## Snapshots Save the current preview frame to disk in any of the supported `TVFImageFormat` values (`IM_BMP`, `IM_JPEG`, `IM_PNG`, `IM_GIF`, `IM_TIFF`). The third parameter is the JPEG quality (ignored for other formats). ``` procedure TForm1.TakeSnapshot; begin VideoCapture1.Frame_Save('C:\Photos\snapshot.jpg', IM_JPEG, 85); end; ``` To pull the frame straight into a `TBitmap` (for example to display in a `TImage`), use `Frame_GetCurrent`: ``` procedure TForm1.TakeSnapshotToMemory; var Bitmap: TBitmap; begin Bitmap := TBitmap.Create; try VideoCapture1.Frame_GetCurrent(Bitmap); Image1.Picture.Assign(Bitmap); finally Bitmap.Free; end; end; ``` ## IP Cameras (RTSP / HTTP) Switch the mode to `Mode_IP_Preview` or `Mode_IP_Capture` and set `IP_Camera_URL`. Use `IP_Camera_Type` to pick the engine and protocol — for example `IP_RTSP_TCP` for RTSP over TCP via the FFmpeg engine, or `IP_Auto_VLC` to fall back to the bundled VLC source. ``` procedure TForm1.ConnectIPCamera; begin VideoCapture1.IP_Camera_URL := 'rtsp://user:password@192.168.1.100:554/stream'; VideoCapture1.IP_Camera_Type := IP_RTSP_TCP; VideoCapture1.Mode := Mode_IP_Preview; VideoCapture1.Start; end; ``` ## Screen Capture The component records the desktop, an individual display, a region, or a window. Set the capture rectangle (or enable full-screen), choose a frame rate, then switch to `Mode_Screen_Capture`. ``` procedure TForm1.StartScreenCapture; begin // Full-screen capture at 30 fps with the mouse cursor included VideoCapture1.Screen_Capture_FullScreen := True; VideoCapture1.Screen_Capture_FrameRate := 30.0; VideoCapture1.Screen_Capture_Grab_Mouse_Cursor := True; VideoCapture1.Output_Filename := 'C:\Videos\screen.mp4'; VideoCapture1.Output_Format := Format_MP4; VideoCapture1.Mode := Mode_Screen_Capture; VideoCapture1.Start; end; ``` For region capture, disable `Screen_Capture_FullScreen` and supply `Screen_Capture_Left`, `Screen_Capture_Top`, `Screen_Capture_Right`, and `Screen_Capture_Bottom` (all in pixels). See [Screen Capture Implementation](screen-capture/) for the full set of options. ## Video Effects Effects (brightness, contrast, saturation, flip, blur, grayscale, sepia, and many more) are managed with `Video_Effect_Ex`. Enable the effects pipeline first with `Video_Effects_Enabled := True`, then add each effect by `TVFEffectType`. The `Amount` argument is the strength of the effect — for `ef_contrast` it shifts contrast, for `ef_flip_right` it acts as an on/off flag, and so on. ``` procedure TForm1.ApplyVideoEffects; begin VideoCapture1.Video_Effects_Enabled := True; // ID=1, applied for the full graph (StartTime=0, StopTime=0), enabled, // contrast effect with amount = 20 VideoCapture1.Video_Effect_Ex(1, 0, 0, True, ef_contrast, 20.0, ''); // ID=2, horizontal flip VideoCapture1.Video_Effect_Ex(2, 0, 0, True, ef_flip_right, 0.0, ''); end; ``` Remove individual effects with `Video_Effects_Remove(ID)` or clear them all with `Video_Effects_Clear`. ## Text Overlay Use `Video_Effects_Text_Logo` (legacy GDI overlay) or `Video_Effects_Text_Logo_Plus` (modern GDI+ overlay with gradients, rotation, and outline effects) to burn text into the video stream. The example below uses `Video_Effects_Text_Logo_Plus`. ``` procedure TForm1.AddTextOverlay; begin VideoCapture1.Video_Effects_Enabled := True; // ID=10, full duration (0..0), enabled, "My Video" at (10, 10), // Arial 24, not bold/italic/underline/strike-out, white color VideoCapture1.Video_Effects_Text_Logo_Plus( 10, 0, 0, True, 'My Video', 10, 10, 'Arial', 24, False, False, False, False, clWhite); end; ``` ## Events `TVFVideoCapture` raises three core lifecycle events: `OnStart`, `OnStop`, and `OnError`. None of them carry a `Sender` parameter — `OnError` receives the error message as a `WideString`. ``` procedure TForm1.VideoCapture1Start; begin Button1.Caption := 'Stop'; end; procedure TForm1.VideoCapture1Stop; begin Button1.Caption := 'Start'; end; procedure TForm1.VideoCapture1Error(ErrorText: WideString); begin ShowMessage('Capture error: ' + ErrorText); end; ``` Additional events cover live frame access (`OnVideoFrame`, `OnAudioFrame`), motion detection (`OnMotion`), mouse and keyboard activity on the preview surface, VU-meter values, DV transport events, and TV-tuner channel scanning. ## Development Resources For detailed implementation guidance, explore these essential resources: - [Complete Changelog and Version History](changelog/) - [Installation and Configuration Guide](install/) - [Deployment Best Practices](deployment/) - [Licensing Information and EULA](../../eula/) - [Comprehensive API Documentation](https://api.visioforge.org/delphi/video_capture_sdk/index.html) ## Implementation Tutorials ### Audio Recording and Processing Master audio capture with these step-by-step guides: - [MP3 Audio Capture Implementation](audio-capture-mp3/) - Learn how to capture audio streams and encode them directly to MP3 format with configurable bitrates and quality settings. - [WAV Audio Recording with Compression Options](audio-capture-wav/) - Implement high-quality WAV audio recording with optional compression codecs and format configurations. - [Configuring Audio Output Devices](audio-output/) - Guide to selecting and configuring audio output devices for monitoring and playback in your applications. ### Video Capture and Device Control Learn essential video handling techniques: - [AVI Video Capture Implementation](video-capture-avi/) - Develop applications that capture video streams to AVI format with customizable codecs and container settings. - [DV Camcorder Control and Integration](dv-camcorder/) - Connect and control DV camcorders through FireWire/IEEE-1394 with transport controls and metadata handling. - [Device Selection for Video and Audio Sources](video-audio-sources/) - Techniques for enumerating, selecting, and managing multiple capture devices in your applications. - [Hardware Video Adjustment Parameters](hardware-adjustments/) - Access and modify device-level parameters including brightness, contrast, saturation, and white balance. - [Video Input Configuration via Crossbar](video-input-crossbar/) - Learn to configure video input routing through crossbar interfaces for multi-input capture devices. - [Video Renderer Selection and Configuration](video-renderer/) - Choose and configure the optimal video rendering engine for your capture application. ### Advanced Media Techniques Explore sophisticated implementation scenarios: - [Custom Output Format Configuration](custom-output/) - Create specialized output formats with custom compression settings and container configurations. - [FM Radio and TV Tuner Integration](fm-radio-tv-tuning/) - Implement FM radio reception and TV channel tuning in applications with supported hardware. - [Network Streaming with WMV Format](network-streaming-wmv/) - Stream captured video over networks using Windows Media Video format with bandwidth optimization. - [Resolution Management with Resize and Crop](resize-crop/) - Process video frames with dynamic resizing and cropping to achieve custom output dimensions. - [Screen Capture Implementation](screen-capture/) - Capture on-screen content with configurable frame rates and region selection capabilities. - [DV File Capture with Compression Options](video-capture-dv/) - Save video directly to DV format or with recompression for optimized storage requirements. - [MPEG-2 Capture with TV Tuner Integration](mpeg2-capture/) - Utilize hardware MPEG-2 encoders in TV tuners for efficient high-quality broadcast capture. - [Windows Media Video Capture with External Profiles](video-capture-wmv/) - Implement Windows Media Video encoding with external profile configurations for optimized quality and size. ---END OF PAGE--- ## Install TVFVideoCapture ActiveX Control in C++ Builder **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/install/builder/ **Description:** Import and configure TVFVideoCapture ActiveX control in C++ Builder 5/6, 2006, and newer versions with detailed installation steps. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture **API:** TVFVideoCapture # TVFVideoCapture Integration Guide for C++ Builder This detailed installation guide walks you through the process of integrating the powerful TVFVideoCapture ActiveX control with your C++ Builder projects. We've provided separate instructions for different C++ Builder versions to ensure seamless implementation regardless of your development environment. > Related products: [All-in-One Media Framework (Delphi / ActiveX)](https://www.visioforge.com/all-in-one-media-framework) ## Installation in Borland C++ Builder 5/6 Follow these detailed steps to properly install the TVFVideoCapture control in Borland C++ Builder 5/6: 1. Navigate to the main menu and select **Component → Import ActiveX Controls** 1. From the available controls list, locate and select the **VisioForge Video Capture** item 2. Click the **Install** button to begin importing the ActiveX control 1. When prompted for confirmation, click the **Yes** button to proceed 1. Once the installation process completes successfully, you'll see a confirmation message 2. Click the **OK** button to finalize the installation ## Installation in C++ Builder 2006 and Later Versions For more recent versions of C++ Builder (2006 and newer), follow this expanded installation process: ### Step 1: Create a New Package Begin by creating a new package that will contain the TVFVideoCapture control ### Step 2: Import the ActiveX Component 1. From the main menu, select **Component → Import Component** 1. In the dialog that appears, select the **Import ActiveX Control** radio button 2. Click the **Next** button to continue ### Step 3: Select the TVFVideoCapture Control 1. Browse through the available ActiveX controls 2. Locate and select the **VisioForge Video Capture** item from the list 3. Click the **Next** button to proceed ### Step 4: Configure Output Settings 1. Specify the desired package output folder for the component files 2. Click the **Next** button after selecting an appropriate location ### Step 5: Add Component to Package 1. Ensure the **Add unit to…** radio button is selected 2. Click the **Finish** button to complete the import process ### Step 6: Save and Install the Package 1. Save your project when prompted 1. Install the package to make the component available in your development environment 1. Verify that the TVFVideoCapture ActiveX control has been successfully installed ## Additional Resources and Support After completing the installation, you can begin using the TVFVideoCapture control in your applications. The component provides extensive functionality for video capture and processing operations. For developers looking to explore additional implementation examples and techniques: - Access our [GitHub repository](https://github.com/visioforge/) for code samples and example projects - Contact our [technical support team](https://support.visioforge.com/) for personalized assistance with integration challenges - Review our documentation for detailed API references and advanced usage scenarios By following this installation guide, you'll have successfully integrated the TVFVideoCapture ActiveX control into your C++ Builder development environment, enabling powerful video capture capabilities in your applications. ---END OF PAGE--- ## TVFVideoCapture Installation Guide for Delphi 6 to 11 **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/install/delphi/ **Description:** Install TVFVideoCapture packages in Delphi 6/7 through Delphi 11+ with complete setup instructions, library paths, and configuration. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture **API:** TVFVideoCapture # Comprehensive TVFVideoCapture Installation Guide for Delphi Developers > Related products: [All-in-One Media Framework (Delphi / ActiveX)](https://www.visioforge.com/all-in-one-media-framework) ## Installation in Borland Delphi 6/7 The installation process for legacy Delphi 6/7 environments requires several specific steps to ensure proper integration of the TVFVideoCapture library. ### Step 1: Create a New Package Begin by creating a new package in your Delphi 6/7 development environment. ### Step 2: Configure Library Paths Add the TVFVideoCapture source directory to both the library and browser path settings. This allows Delphi to locate the necessary component files. ### Step 3: Open the Library Package Navigate to and open the library package file to prepare for installation. ### Step 4: Install the Component Package Complete the installation by selecting the install option within the package interface. ### Architecture Limitations While TVFVideoCapture offers both x86 and x64 architecture support, Delphi 6/7 only supports x86 due to platform limitations. Developers using these versions will need to utilize the 32-bit implementation exclusively. ## Installation Process for Delphi 2005 and Later Versions Modern Delphi versions offer an improved installation workflow with enhanced capabilities. ### Step 1: Launch Delphi with Administrative Privileges Ensure you run your Delphi IDE with administrative rights to prevent permission-related installation issues. ### Step 2: Access Options Dialog Navigate to the Options menu to configure essential library settings. ### Step 3: Configure Source Directory Paths Add the TVFVideoCapture source directory to both the library and browser path settings to ensure proper component discovery. ### Step 4: Open the Component Library Package Locate and open the library package file included with TVFVideoCapture. ### Step 5: Complete Package Installation Install the package through the IDE's package installation interface. ## Advanced Installation for Delphi 11 and Newer Releases The latest Delphi versions require a slightly different approach that leverages modern project structures. ### Step 1: Locate and Open the Package Project After installing the framework, navigate to the installation folder and open the `.dproj` package file. ### Step 2: Select the Appropriate Build Configuration Choose the Release build configuration to ensure optimal component performance. ### Step 3: Install the Component Package Complete the installation process through the IDE's package installation interface. ### Step 4: Verify Installation Success Confirm that the installation completed successfully before proceeding with development. ## Project Configuration Requirements and Best Practices ### Multi-Architecture Support TVFVideoCapture supports both x86 and x64 architectures, allowing you to develop applications for different platform targets. You can install both package versions simultaneously to support flexible deployment scenarios. ### Library Path Configuration For proper component functionality, ensure that you've configured the correct library folder path in your application project settings. This path should point to the location containing the `.dcu` files for your target architecture. To set this up: 1. Open your project options dialog 2. Navigate to the Library path section 3. Add the appropriate TVFVideoCapture library path 4. Save your project settings This configuration ensures that your application can locate all required component resources during both development and runtime. ## Troubleshooting Common Installation Issues When installing TVFVideoCapture, developers might encounter several known issues. Here are solutions to the most frequent problems: ### 64-bit Package Installation Problems If you're having difficulties installing the 64-bit package version, refer to our [detailed guide for resolving Delphi 64-bit package installation issues](../../../general/install-64bit/). ### Resource File (.otares) Installation Issues Some developers encounter problems related to `.otares` files during package installation. For a step-by-step resolution process, see our [troubleshooting guide for .otares installation problems](../../../general/install-otares/). ## Technical Support and Additional Resources For developers requiring additional assistance with the installation process or component implementation: - Contact our [technical support team](https://support.visioforge.com/) for personalized installation assistance - Visit our [GitHub repository](https://github.com/visioforge/) for additional code samples and implementation examples - Check our documentation for advanced usage scenarios and integration patterns Following this installation guide will ensure that you have a properly configured development environment for creating powerful multimedia applications with TVFVideoCapture in your Delphi projects. ---END OF PAGE--- ## Install TVFVideoCapture in Delphi, VB6, and C++ Builder **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/install/ **Description:** Install TVFVideoCapture library in Delphi, Visual Studio, C++ Builder, and VB6 with step-by-step IDE setup and ActiveX integration. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture **API:** TVFVideoCapture # TVFVideoCapture Installation Guide ## Installation 1. **Download the latest version of the VisioForge All-in-One Media Framework**: Navigate to the [product page](https://www.visioforge.com/all-in-one-media-framework) on our official website and download the most up-to-date version of the TVFVideoCapture library. Ensure that you select the appropriate version that matches your development environment requirements. 2. **Run the setup file**: After the download completes, locate the setup file in your download directory and execute it. This will launch the installation process. 3. **Follow the installation wizard instructions**: The setup wizard will guide you through the installation steps. Carefully read each prompt, accept the license agreement, choose the installation directory, and proceed by clicking "Next". 4. **Completion**: Upon successful installation, go to the installation folder. Here, you will find a variety of framework samples and detailed documentation designed to assist you in integrating and utilizing the library effectively within your projects. ### Delphi packages installation For detailed instructions on installing the TVFVideoCapture packages in your Delphi IDE, please refer to the following [Delphi installation guide](delphi/). ### ActiveX installation #### C++ Builder For [C++ Builder](builder/), the installation process involves importing the ActiveX control into your project. This straightforward process ensures that you can quickly start using the TVFVideoCapture library in your C++ Builder projects. #### Visual Basic 6 In [Visual Basic 6](visual-basic-6/), open your project and go to the "Project" menu. Select "Components" and click "Browse". Find the ActiveX .ocx file in the installation folder and add it to your project. The components will now be available in the toolbox for your VB6 applications. ### Visual Studio 2010 and later For [Visual Studio 2010 and newer](visual-studio/) versions, open your project in the IDE, right-click on the toolbox, and select "Choose Items". Navigate to the COM components tab, click "Browse", and select the ActiveX .ocx file from the framework installation directory. This will add the components to your toolbox, allowing you to use them in your Visual Studio projects. ## Conclusion By following this comprehensive guide, you should be able to smoothly install and integrate the TVFVideoCapture library into your chosen development environment. Should you encounter any issues or require further assistance, please refer to the detailed documentation included in the framework or contact our support team. ---END OF PAGE--- ## Installing TVFVideoCapture in VB6 for Delphi Users **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/install/visual-basic-6/ **Description:** Integrate TVFVideoCapture ActiveX control in Visual Basic 6 with x86 compatibility and full video capture feature access. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture **API:** TVFVideoCapture # Integrating TVFVideoCapture with Visual Basic 6 ## Overview and Compatibility Microsoft Visual Basic 6 offers excellent compatibility with our TVFVideoCapture library through its ActiveX control interface. This integration empowers developers to significantly enhance their applications with advanced video capture capabilities while maintaining optimal performance characteristics. Due to the architecture of Visual Basic 6, which was developed during the early stages of Windows programming frameworks, the platform exclusively supports 32-bit applications. Consequently, only the x86 version of our TVFVideoCapture library is compatible with VB6 development environments. Despite this architectural limitation, our framework delivers exceptional performance within the 32-bit environment. The library provides full access to our comprehensive feature set, ensuring developers can implement sophisticated video capture solutions regardless of the 32-bit constraint. ## Detailed Installation Process The following step-by-step guide will walk you through the complete process of installing and configuring the TVFVideoCapture ActiveX control in your Visual Basic 6 development environment. ### Step 1: Create a New Project Environment Begin by launching Visual Basic 6 and creating a new standard project that will serve as the foundation for your video capture implementation. ### Step 2: Access the Components Dialog Navigate to the Project menu and select the "Components" option to open the component selection dialog. This interface allows you to browse and select from available ActiveX controls. ### Step 3: Select the TVFVideoCapture Component In the Components dialog, scroll through the available controls and locate the "VisioForge Video Capture" item. Check the box next to it to include this component in your toolbox. ### Step 4: Verify Successful Integration After adding the component, you should notice the new TVFVideoCapture control appearing in your VB6 toolbox. This confirms that the ActiveX control has been successfully integrated into your development environment. ## Implementation Considerations When implementing the TVFVideoCapture control in your VB6 application, consider the following best practices: - Initialize the control early in your application lifecycle - Configure capture parameters before starting the capture process - Implement proper error handling for device connectivity issues - Release resources when they are no longer needed ## Technical Support and Additional Resources --- For technical questions or implementation challenges, please contact our [support team](https://support.visioforge.com/) who specialize in assisting developers with integration requirements. For additional code examples and implementation patterns, visit our [GitHub repository](https://github.com/visioforge/) which contains numerous samples demonstrating optimal usage patterns. ---END OF PAGE--- ## Install TVFVideoCapture ActiveX Control in Visual Studio **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/install/visual-studio/ **Description:** Install TVFVideoCapture ActiveX controls in Visual Studio 2010+ with C++ and managed code integration for video capture projects. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture **API:** TVFVideoCapture # Installing TVFVideoCapture in Visual Studio 2010 and Later ## Overview of TVFVideoCapture Integration The TVFVideoCapture ActiveX control provides powerful video capture capabilities for your development projects. This guide walks you through the installation process in Visual Studio environments, with special considerations for Delphi developers. ## Installation Requirements Before beginning the installation process, ensure you have: - Visual Studio 2010 or a later version installed - Administrator rights on your development machine - Both x86 and x64 ActiveX controls registered (if applicable) ## Installation Process for Different Project Types You can implement the TVFVideoCapture ActiveX control directly in various project types. The integration approach differs slightly depending on your development environment: ### For C++ Projects In C++ projects, you can use the ActiveX control directly without additional wrappers or interfaces. ### For C#/VB.Net Projects When working with C# or Visual Basic .NET projects, Visual Studio automatically generates a custom wrapper assembly. This wrapper exposes the ActiveX API through managed code, making integration seamless. ## Step-by-Step Installation Guide Follow these detailed steps to install the TVFVideoCapture control in your Visual Studio environment: 1. Create a new project in your preferred language (C++, C#, or Visual Basic .NET) 2. Access the toolbox panel in your Visual Studio interface 1. Right-click on the toolbox and select "Choose toolbox items" from the context menu 1. In the dialog box that appears, locate and select the "VisioForge Video Capture" component 1. After selection, the control will be added to your toolbox for easy access 1. Add the control to your form by dragging it from the toolbox 2. For .NET projects, Visual Studio will automatically generate the necessary wrapper assembly ## Framework Samples and Resources For practical implementation examples, refer to the framework samples included with your installation package. These samples cover all supported programming languages and demonstrate various integration scenarios. ## Recommendations for .NET Developers While ActiveX integration is fully supported, .NET developers may benefit from using the native .NET version of the SDK. The native implementation offers: - Enhanced performance and stability - Direct integration with WinForms and WPF - MAUI control support for cross-platform development - More intuitive API design for .NET environments ## Additional Resources and Support Explore our extensive documentation for advanced configuration options and optimization techniques. Our development team continuously updates resources to address common implementation challenges. --- For technical assistance with this installation process, please contact our [support team](https://support.visioforge.com/). Additional code samples and implementation examples are available on our [GitHub repository](https://github.com/visioforge/). ---END OF PAGE--- ## Delphi MPEG-2 Video Capture with TV Tuner Hardware **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/mpeg2-capture/ **Description:** Implement MPEG-2 capture in Delphi using TV tuner hardware encoders - device enumeration, format configuration, and optimized code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Capture, Encoding, TV Tuner, MPEG-2 # MPEG-2 Video Capture in Delphi Using TV Tuner Hardware Encoders This comprehensive tutorial demonstrates how to implement high-quality MPEG-2 video capture functionality in your Delphi applications by leveraging TV tuners with built-in hardware encoding capabilities. Hardware encoding significantly reduces CPU usage while maintaining excellent video quality. ## Overview of MPEG-2 Hardware Encoding MPEG-2 hardware encoders provide superior performance compared to software-based encoding solutions. They're particularly useful for developing professional video capture applications that require efficient processing and high-quality output. ## Enumerating Available MPEG-2 Hardware Encoders The first step is to identify all available MPEG-2 hardware encoders in the system. This code demonstrates how to populate a dropdown with detected devices: ``` // List all available MPEG-2 hardware encoders in the system // This helps users select the appropriate encoding device VideoCapture1.Special_Filters_Fill; for I := 0 to VideoCapture1.Special_Filters_GetCount(SF_Hardware_Video_Encoder) - 1 do cbMPEGEncoder.Items.Add(VideoCapture1.Special_Filters_GetItem(SF_Hardware_Video_Encoder, i)); ``` ``` // C++ MFC implementation for MPEG-2 encoder enumeration // Populates a combobox with all detected hardware encoders m_VideoCapture.Special_Filters_Fill(); for (int i = 0; i < m_VideoCapture.Special_Filters_GetCount(SF_Hardware_Video_Encoder); i++) { CString encoderName = m_VideoCapture.Special_Filters_GetItem(SF_Hardware_Video_Encoder, i); m_cbMPEGEncoder.AddString(encoderName); } ``` ``` ' VB6 implementation for finding hardware MPEG-2 encoders ' Lists all available encoders in a combobox control VideoCapture1.Special_Filters_Fill For i = 0 To VideoCapture1.Special_Filters_GetCount(SF_Hardware_Video_Encoder) - 1 cbMPEGEncoder.AddItem VideoCapture1.Special_Filters_GetItem(SF_Hardware_Video_Encoder, i) Next i ``` ## Selecting a Specific MPEG-2 Encoder After enumerating the available encoders, the next step is to select a specific encoder for use: ``` // Configure the component to use the selected MPEG-2 hardware encoder // This must be done before starting the capture process VideoCapture1.Video_CaptureDevice_InternalMPEGEncoder_Name := cbMPEGEncoder.Items[cbMPEGEncoder.ItemIndex]; ``` ``` // C++ MFC: Select and configure the chosen MPEG-2 hardware encoder // Retrieves the selected encoder name from the combobox int nIndex = m_cbMPEGEncoder.GetCurSel(); CString encoderName; m_cbMPEGEncoder.GetLBText(nIndex, encoderName); m_VideoCapture.Video_CaptureDevice_InternalMPEGEncoder_Name = encoderName; ``` ``` ' VB6: Set the selected encoder as the active MPEG-2 hardware encoder ' Must be called before initializing the capture graph VideoCapture1.Video_CaptureDevice_InternalMPEGEncoder_Name = cbMPEGEncoder.List(cbMPEGEncoder.ListIndex) ``` ## Configuring DirectStream MPEG Format for Output To properly capture MPEG-2 encoded video, you need to set the appropriate output format: ``` // Set the output format to DirectStream MPEG // This enables proper handling of hardware-encoded MPEG-2 streams VideoCapture1.OutputFormat := Format_DirectStream_MPEG; ``` ``` // C++ MFC: Configure the output format for MPEG-2 encoded content // DirectStream MPEG format preserves the hardware-encoded stream m_VideoCapture.OutputFormat = Format_DirectStream_MPEG; ``` ``` ' VB6: Set the proper output format for MPEG-2 hardware encoding ' DirectStream format ensures the encoded data is properly handled VideoCapture1.OutputFormat = Format_DirectStream_MPEG ``` ## Establishing Video Capture Mode Before starting the capture process, set the component to video capture mode: ``` // Configure the component for video capture operation // This prepares the internal DirectShow graph for recording VideoCapture1.Mode := Mode_Video_Capture; ``` ``` // C++ MFC: Set the component to video capture mode // Required before starting the MPEG-2 capture process m_VideoCapture.Mode = Mode_Video_Capture; ``` ``` ' VB6: Set video capture mode before starting recording ' This initializes the appropriate DirectShow filters VideoCapture1.Mode = Mode_Video_Capture ``` ## Initiating the MPEG-2 Capture Process Finally, start the capture process to begin recording MPEG-2 video: ``` // Begin the video capture process with the configured settings // The component will now start recording to the specified output VideoCapture1.Start; ``` ``` // C++ MFC: Start the MPEG-2 video capture process // Recording begins with the previously configured settings m_VideoCapture.Start(); ``` ``` ' VB6: Start the video capture with the current configuration ' The hardware encoder will now begin processing video data VideoCapture1.Start ``` ## Advanced MPEG-2 Capture Considerations When implementing MPEG-2 capture with hardware encoders, consider these additional factors: 1. Hardware encoders typically offer better performance than software-based solutions 2. Some TV tuners provide additional encoding parameters that can be customized 3. Buffer sizes may need adjustment for higher quality captures 4. Hardware encoders often handle video scaling and frame rate conversion internally ## Troubleshooting Common Issues If you encounter problems with MPEG-2 hardware encoding: 1. Verify that your TV tuner device supports hardware MPEG-2 encoding 2. Ensure proper driver installation for the capture device 3. Check that DirectX is properly installed and updated 4. Consider system resource availability, as some encoders require specific resources Please contact our dedicated support team for assistance with implementing this tutorial in your specific application. Visit our GitHub repository for additional code samples and implementation examples. ---END OF PAGE--- ## Implement WMV Network Streaming in Delphi and ActiveX **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/network-streaming-wmv/ **Description:** Implement WMV network streaming in Delphi - configure profiles, manage client connections, set ports, and broadcast video with code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Streaming, Encoding, WMV # WMV Network Streaming Implementation Guide ## Overview This guide demonstrates how to implement network-based video broadcasting using Windows Media Video (WMV) format in your Delphi applications. The techniques shown here allow you to stream video content over networks while simultaneously capturing and saving the video to a file for archival purposes. ## Requirements Before implementing WMV network streaming, ensure that you have: - A supported video capture device connected to your system - Proper network access and permissions - A valid WMV profile file with encoder settings ## Implementation Steps ### Basic Configuration To enable WMV network streaming in your application, you'll need to configure several essential parameters: 1. Enable network streaming functionality 2. Specify a WMV profile file containing video encoding parameters 3. Set the maximum number of concurrent client connections 4. Define the network port for client connections ### Delphi Implementation Code ``` // Delphi code for configuring WMV network streaming // Enable the network streaming functionality VideoCapture1.Network_Streaming_Enabled := true; // Set the path to the WMV profile file containing encoder settings // This file defines video quality, bitrate, resolution, etc. VideoCapture1.Network_Streaming_WMV_Profile_FileName := edNetworkStreamingWMVProfile.Text; // Define maximum number of concurrent clients that can connect VideoCapture1.Network_Streaming_Maximum_Clients := StrToInt(edMaximumClients.Text); // Specify the network port that clients will use to connect VideoCapture1.Network_Streaming_Network_Port := StrToInt(edNetworkPort.Text); ``` ### C++ MFC Implementation ``` // C++ MFC implementation for WMV network streaming. // CEdit::GetWindowText takes a CString reference and writes into it (returns void), // so capture the value via a local CString and pass that to the COM setter. CString profile, maxClients, port; edNetworkStreamingWMVProfile.GetWindowText(profile); edMaximumClients.GetWindowText(maxClients); edNetworkPort.GetWindowText(port); // Enable streaming functionality m_VideoCapture.SetNetwork_Streaming_Enabled(true); // Set WMV profile path - contains encoding parameters m_VideoCapture.SetNetwork_Streaming_WMV_Profile_FileName(profile); // Define maximum concurrent client connections m_VideoCapture.SetNetwork_Streaming_Maximum_Clients(_ttoi(maxClients)); // Set the network port for client connections m_VideoCapture.SetNetwork_Streaming_Network_Port(_ttoi(port)); ``` ### VB6 Implementation ``` ' VB6 (ActiveX) implementation for WMV network streaming ' Enable network streaming capabilities VideoCapture1.Network_Streaming_Enabled = True ' Set the profile file containing video encoder settings VideoCapture1.Network_Streaming_WMV_Profile_FileName = txtNetworkStreamingWMVProfile.Text ' Define maximum number of clients allowed to connect simultaneously VideoCapture1.Network_Streaming_Maximum_Clients = CInt(txtMaximumClients.Text) ' Specify the network port for client connections VideoCapture1.Network_Streaming_Network_Port = CInt(txtNetworkPort.Text) ``` ## Client Connection Information After configuring the streaming parameters, your application can obtain the connection URL that clients will use to access the video stream: ``` // Get the URL that clients will use to connect to the stream // This URL can be shared with users who need to view the stream strStreamURL := VideoCapture1.Network_Streaming_URL; ``` This URL can be used with Windows Media Player or any other application that supports Windows Media streaming protocols. ## Best Practices For optimal streaming performance, consider the following recommendations: - Use appropriate bitrates based on your network capabilities - Monitor client connections to ensure system stability - Test your streaming configuration with various client applications - Consider network bandwidth limitations when setting quality parameters ## Troubleshooting If you encounter issues with your streaming implementation: - Verify network firewall settings allow traffic on your selected port - Ensure the WMV profile file exists and contains valid settings - Check that the maximum client count is appropriate for your server resources - Validate network connectivity between the server and potential clients --- Please get in touch with [support](https://support.visioforge.com/) if you have questions about this implementation. Visit our [GitHub](https://github.com/visioforge/) page for additional code samples and resources. ---END OF PAGE--- ## Resize and Crop Video in Delphi with TVFVideoCapture **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/resize-crop/ **Description:** Implement video resizing and cropping in Delphi - real-time processing, aspect ratio handling, and performance optimization with code samples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Streaming **API:** TVFVideoCapture # Video Resizing and Cropping in Delphi TVFVideoCapture Video manipulation is a critical component of many modern applications. This guide provides detailed instructions for implementing real-time video resizing and cropping in your Delphi applications with minimal performance impact. ## Why Resize or Crop Video? Video resizing and cropping serve multiple purposes in development: - Optimize video for different display sizes - Reduce bandwidth requirements for streaming - Focus on specific regions of interest - Create uniform video dimensions across your application - Improve performance on resource-constrained devices ## Enabling Resize and Crop Functionality Before applying any transformations, you must enable the resize/crop functionality in the TVFVideoCapture component. ### Step 1: Enable the Feature ``` // Enable video resizing or cropping functionality VideoCapture1.Video_ResizeOrCrop_Enabled := true; ``` ``` // C++ MFC - Enable video transformation capabilities m_VideoCapture.SetVideo_ResizeOrCrop_Enabled(TRUE); ``` ``` ' VB6 - Activate resize/crop features VideoCapture1.Video_ResizeOrCrop_Enabled = True ``` ## Video Resizing Implementation Resizing allows you to change the dimensions of your video stream while maintaining visual quality. ### Setting New Dimensions ``` // Set the desired width and height for the resized video output VideoCapture1.Video_Resize_NewWidth := StrToInt(edResizeWidth.Text); VideoCapture1.Video_Resize_NewHeight := StrToInt(edResizeHeight.Text); ``` ``` // C++ MFC - Configure target dimensions for video resize m_VideoCapture.SetVideo_Resize_NewWidth(_ttoi(m_strResizeWidth)); m_VideoCapture.SetVideo_Resize_NewHeight(_ttoi(m_strResizeHeight)); ``` ``` ' VB6 - Define new video dimensions VideoCapture1.Video_Resize_NewWidth = CInt(txtResizeWidth.Text) VideoCapture1.Video_Resize_NewHeight = CInt(txtResizeHeight.Text) ``` ### Handling Aspect Ratio Changes When resizing video, you can choose between preserving the original aspect ratio (letterbox) or stretching the content to fit the new dimensions. ``` // Letterbox mode adds black borders to preserve aspect ratio // When false, the video will stretch to fit the new dimensions VideoCapture1.Video_Resize_LetterBox := cbResizeLetterbox.Checked; ``` ``` // C++ MFC - Configure aspect ratio handling method m_VideoCapture.SetVideo_Resize_LetterBox(m_bResizeLetterbox); ``` ``` ' VB6 - Set letterbox mode for aspect ratio preservation VideoCapture1.Video_Resize_LetterBox = chkResizeLetterbox.Value ``` ### Selecting Resize Algorithms Choose from multiple resize algorithms based on your quality requirements and performance constraints: ``` // Select the appropriate resize algorithm: // - NearestNeighbor: Fastest but lowest quality // - Bilinear: Good balance between speed and quality // - Bilinear_HQ: Enhanced bilinear with improved quality // - Bicubic: Better quality with moderate performance impact // - Bicubic_HQ: Highest quality with highest CPU usage case cbResizeMode.ItemIndex of 0: VideoCapture1.Video_Resize_Mode := rm_NearestNeighbor; 1: VideoCapture1.Video_Resize_Mode := rm_Bilinear; 2: VideoCapture1.Video_Resize_Mode := rm_Bilinear_HQ; 3: VideoCapture1.Video_Resize_Mode := rm_Bicubic; 4: VideoCapture1.Video_Resize_Mode := rm_Bicubic_HQ; end; ``` ``` // C++ MFC - Set the resize algorithm based on quality/performance needs switch(m_nResizeMode) { case 0: m_VideoCapture.SetVideo_Resize_Mode(rm_NearestNeighbor); break; // Fastest case 1: m_VideoCapture.SetVideo_Resize_Mode(rm_Bilinear); break; // Standard case 2: m_VideoCapture.SetVideo_Resize_Mode(rm_Bilinear_HQ); break; // Enhanced case 3: m_VideoCapture.SetVideo_Resize_Mode(rm_Bicubic); break; // High quality case 4: m_VideoCapture.SetVideo_Resize_Mode(rm_Bicubic_HQ); break; // Maximum quality } ``` ``` ' VB6 - Choose resize algorithm based on quality and performance needs Select Case cboResizeMode.ListIndex Case 0: VideoCapture1.Video_Resize_Mode = rm_NearestNeighbor ' Fastest, lower quality Case 1: VideoCapture1.Video_Resize_Mode = rm_Bilinear ' Balanced option Case 2: VideoCapture1.Video_Resize_Mode = rm_Bilinear_HQ ' Enhanced bilinear Case 3: VideoCapture1.Video_Resize_Mode = rm_Bicubic ' Better quality Case 4: VideoCapture1.Video_Resize_Mode = rm_Bicubic_HQ ' Highest quality End Select ``` ## Video Cropping Implementation Cropping allows you to select a specific region of interest from your video stream. ### Step 1: Enable Cropping As with resizing, you must first enable the feature: ``` // Enable video transformation capabilities before applying crop VideoCapture1.Video_ResizeOrCrop_Enabled := true; ``` ``` // C++ MFC - Activate video manipulation features m_VideoCapture.SetVideo_ResizeOrCrop_Enabled(TRUE); ``` ``` ' VB6 - Enable video transformation functionality VideoCapture1.Video_ResizeOrCrop_Enabled = True ``` ### Step 2: Define Crop Region Specify the boundaries of your crop region by defining the left, top, right, and bottom coordinates: ``` // Define the crop region coordinates in pixels // These values represent the distance from each edge of the original video VideoCapture1.Video_Crop_Left := StrToInt(edCropLeft.Text); VideoCapture1.Video_Crop_Top := StrToInt(edCropTop.Text); VideoCapture1.Video_Crop_Right := StrToInt(edCropRight.Text); VideoCapture1.Video_Crop_Bottom := StrToInt(edCropBottom.Text); ``` ``` // C++ MFC - Set the crop boundaries in pixels // Each value defines how many pixels to crop from the respective edge m_VideoCapture.SetVideo_Crop_Left(_ttoi(m_strCropLeft)); m_VideoCapture.SetVideo_Crop_Top(_ttoi(m_strCropTop)); m_VideoCapture.SetVideo_Crop_Right(_ttoi(m_strCropRight)); m_VideoCapture.SetVideo_Crop_Bottom(_ttoi(m_strCropBottom)); ``` ``` ' VB6 - Configure crop region boundaries ' Values represent pixel counts from each edge to exclude VideoCapture1.Video_Crop_Left = CInt(txtCropLeft.Text) VideoCapture1.Video_Crop_Top = CInt(txtCropTop.Text) VideoCapture1.Video_Crop_Right = CInt(txtCropRight.Text) VideoCapture1.Video_Crop_Bottom = CInt(txtCropBottom.Text) ``` ## Best Practices for Video Manipulation For optimal results when implementing video resizing and cropping: 1. **Test on target hardware** - Different resize algorithms have varying CPU requirements 2. **Consider your use case** - For real-time applications, favor performance over quality 3. **Maintain aspect ratios** - Unless specifically needed, preserve original proportions 4. **Combine operations judiciously** - Applying both resize and crop increases processing overhead 5. **Cache settings** - Avoid changing parameters frequently during capture ## Troubleshooting Common Issues - If performance is poor, try a faster resize algorithm - Ensure crop values don't exceed the dimensions of your video stream - When using letterbox mode, account for the black borders in your UI design - For best results, resize to dimensions that are multiples of 8 or 16 --- For additional code samples and implementation examples, visit our [GitHub](https://github.com/visioforge/) repository. Need technical assistance? Contact our support team for personalized guidance. ---END OF PAGE--- ## Delphi Screen Capture and Recording with TVFVideoCapture **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/screen-capture/ **Description:** Implement screen recording in Delphi with TVFVideoCapture - capture regions, full screen, customize frame rates, track cursor with code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Screen Capture **API:** TVFVideoCapture # Screen Recording Implementation in Delphi ## Introduction to Screen Capture Functionality TVFVideoCapture provides powerful screen recording capabilities for Delphi developers. This guide walks through the implementation of screen capture features in your applications, allowing you to record specific regions or the entire screen with customizable settings. ## Configuring Screen Capture Area You can precisely control which portion of the screen to record by setting coordinate parameters. This is particularly useful when you want to focus on specific application windows or screen regions. ### Setting Specific Screen Coordinates Use these parameters to define the exact boundaries of your capture area: ``` // Define the top edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Top := StrToInt(edScreenTop.Text); // Define the bottom edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Bottom := StrToInt(edScreenBottom.Text); // Define the left edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Left := StrToInt(edScreenLeft.Text); // Define the right edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Right := StrToInt(edScreenRight.Text); ``` ``` // CEdit::GetWindowText(CString&) returns void and fills the buffer by reference, // so we must declare a CString first and then convert it to int via _ttoi // (the TCHAR-aware variant — required because CString is wide in Unicode MFC builds). CString sTop, sBottom, sLeft, sRight; m_edScreenTop.GetWindowText(sTop); m_edScreenBottom.GetWindowText(sBottom); m_edScreenLeft.GetWindowText(sLeft); m_edScreenRight.GetWindowText(sRight); // Define the top edge position of the capture rectangle (in pixels) m_VideoCapture.SetScreen_Capture_Top(_ttoi(sTop)); // Define the bottom edge position of the capture rectangle (in pixels) m_VideoCapture.SetScreen_Capture_Bottom(_ttoi(sBottom)); // Define the left edge position of the capture rectangle (in pixels) m_VideoCapture.SetScreen_Capture_Left(_ttoi(sLeft)); // Define the right edge position of the capture rectangle (in pixels) m_VideoCapture.SetScreen_Capture_Right(_ttoi(sRight)); ``` ``` ' Define the top edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Top = CInt(edScreenTop.Text) ' Define the bottom edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Bottom = CInt(edScreenBottom.Text) ' Define the left edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Left = CInt(edScreenLeft.Text) ' Define the right edge position of the capture rectangle (in pixels) VideoCapture1.Screen_Capture_Right = CInt(edScreenRight.Text) ``` ### Capturing the Full Screen For complete screen recording, simply enable the full screen capture option: ``` // Enable full screen capture mode - will record the entire display VideoCapture1.Screen_Capture_FullScreen := true; ``` ``` // Enable full screen capture mode - will record the entire display m_VideoCapture.SetScreen_Capture_FullScreen(true); ``` ``` ' Enable full screen capture mode - will record the entire display VideoCapture1.Screen_Capture_FullScreen = True ``` ## Optimizing Frame Rate Settings The frame rate directly impacts both the quality and file size of your screen recordings. Higher frame rates produce smoother video but generate larger files. ``` // Set capture frame rate to 10 frames per second // Adjust this value based on your performance requirements VideoCapture1.Screen_Capture_FrameRate := 10; ``` ``` // Set capture frame rate to 10 frames per second // Adjust this value based on your performance requirements m_VideoCapture.SetScreen_Capture_FrameRate(10); ``` ``` ' Set capture frame rate to 10 frames per second ' Adjust this value based on your performance requirements VideoCapture1.Screen_Capture_FrameRate = 10 ``` ## Cursor Tracking Configuration For instructional videos or demonstrations, capturing the mouse cursor movement is essential: ``` // Enable mouse cursor capture in the recording // Set to false to hide cursor in the output video VideoCapture1.Screen_Capture_Grab_Mouse_Cursor := true; ``` ``` // Enable mouse cursor capture in the recording // Set to false to hide cursor in the output video m_VideoCapture.SetScreen_Capture_Grab_Mouse_Cursor(true); ``` ``` ' Enable mouse cursor capture in the recording ' Set to false to hide cursor in the output video VideoCapture1.Screen_Capture_Grab_Mouse_Cursor = True ``` ## Activating Screen Capture Mode After configuring all settings, set the component to screen capture mode to begin recording: ``` // Set component to screen capture operational mode // This activates all screen recording functionality VideoCapture1.Mode := Mode_Screen_Capture; ``` ``` // Set component to screen capture operational mode // This activates all screen recording functionality m_VideoCapture.SetMode(Mode_Screen_Capture); ``` ``` ' Set component to screen capture operational mode ' This activates all screen recording functionality VideoCapture1.Mode = Mode_Screen_Capture ``` ## Advanced Implementation Tips For optimal screen recording performance: - Consider system resources when selecting frame rates - Use region capture when possible to minimize processing load - Test different quality settings to balance file size and visual quality - Remember that cursor capture adds slight processing overhead --- For additional code samples and implementation examples, visit our [GitHub](https://github.com/visioforge/) repository. For technical assistance with implementation, please contact our [support team](https://support.visioforge.com/). ---END OF PAGE--- ## Select Video and Audio Capture Devices in Delphi and VB6 **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/video-audio-sources/ **Description:** Select video and audio devices in Delphi - enumerate devices, configure formats, set frame rates with code examples for Delphi, C++, and VB6. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture # Code sample - How to select video and audio capture devices? Delphi, C++ MFC and VB6 sample code ## Select video source ### Get a list of available video capture devices ``` for i := 0 to VideoCapture1.Video_CaptureDevices_GetCount - 1 do cbVideoInputDevice.Items.Add(VideoCapture1.Video_CaptureDevices_GetItem(i)); ``` ``` // C++ MFC for (int i = 0; i < m_VideoCapture.Video_CaptureDevices_GetCount(); i++) m_cbVideoInputDevice.AddString(m_VideoCapture.Video_CaptureDevices_GetItem(i)); ``` ``` ' VB6 For i = 0 To VideoCapture1.Video_CaptureDevices_GetCount - 1 cbVideoInputDevice.AddItem VideoCapture1.Video_CaptureDevices_GetItem(i) Next i ``` ### Select the video input device ``` VideoCapture1.Video_CaptureDevice := cbVideoInputDevice.Items[cbVideoInputDevice.ItemIndex]; ``` ``` // C++ MFC CString strDevice; m_cbVideoInputDevice.GetLBText(m_cbVideoInputDevice.GetCurSel(), strDevice); m_VideoCapture.put_Video_CaptureDevice(strDevice); ``` ``` ' VB6 VideoCapture1.Video_CaptureDevice = cbVideoInputDevice.Text ``` ### Get a list of available video formats ``` VideoCapture1.Video_CaptureDevice_Formats_Fill; for I := 0 to VideoCapture1.Video_CaptureDevice_Formats_GetCount - 1 do cbVideoInputFormat.Items.Add(VideoCapture1.Video_CaptureDevice_Formats_GetItem(i)); ``` ``` // C++ MFC m_VideoCapture.Video_CaptureDevice_Formats_Fill(); for (int i = 0; i < m_VideoCapture.Video_CaptureDevice_Formats_GetCount(); i++) m_cbVideoInputFormat.AddString(m_VideoCapture.Video_CaptureDevice_Formats_GetItem(i)); ``` ``` ' VB6 VideoCapture1.Video_CaptureDevice_Formats_Fill For i = 0 To VideoCapture1.Video_CaptureDevice_Formats_GetCount - 1 cbVideoInputFormat.AddItem VideoCapture1.Video_CaptureDevice_Formats_GetItem(i) Next i ``` ### Select video format ``` VideoCapture1.Video_CaptureFormat := cbVideoInputFormat.Items[cbVideoInputFormat.ItemIndex]; ``` ``` // C++ MFC CString strFormat; m_cbVideoInputFormat.GetLBText(m_cbVideoInputFormat.GetCurSel(), strFormat); m_VideoCapture.put_Video_CaptureFormat(strFormat); ``` ``` ' VB6 VideoCapture1.Video_CaptureFormat = cbVideoInputFormat.Text ``` or ### Automatically choose the best video format ``` VideoCapture1.Video_CaptureFormat_UseBest := cbUseBestVideoInputFormat.Checked; ``` ``` // C++ MFC m_VideoCapture.put_Video_CaptureFormat_UseBest(m_cbUseBestVideoInputFormat.GetCheck() == BST_CHECKED); ``` ``` ' VB6 VideoCapture1.Video_CaptureFormat_UseBest = cbUseBestVideoInputFormat.Value ``` ### Get a list of available frame rates ``` VideoCapture1.Video_CaptureDevice_FrameRates_Fill; for I := 0 to VideoCapture1.Video_CaptureDevice_FrameRates_GetCount - 1 do cbFrameRate.Items.Add(VideoCapture1.Video_CaptureDevice_FrameRates_GetItem(i)); ``` ``` // C++ MFC m_VideoCapture.Video_CaptureDevice_FrameRates_Fill(); for (int i = 0; i < m_VideoCapture.Video_CaptureDevice_FrameRates_GetCount(); i++) m_cbFrameRate.AddString(m_VideoCapture.Video_CaptureDevice_FrameRates_GetItem(i)); ``` ``` ' VB6 VideoCapture1.Video_CaptureDevice_FrameRates_Fill For i = 0 To VideoCapture1.Video_CaptureDevice_FrameRates_GetCount - 1 cbFrameRate.AddItem VideoCapture1.Video_CaptureDevice_FrameRates_GetItem(i) Next i ``` ### Select frame rate ``` VideoCapture1.Video_FrameRate := StrToFloat(cbFrameRate.Items[cbFrameRate.ItemIndex]); ``` ``` // C++ MFC CString strFrameRate; m_cbFrameRate.GetLBText(m_cbFrameRate.GetCurSel(), strFrameRate); m_VideoCapture.put_Video_FrameRate(_wtof(strFrameRate)); ``` ``` ' VB6 VideoCapture1.Video_FrameRate = CDbl(cbFrameRate.Text) ``` Select needed video input (configure crossbar) if needed. ## Select audio source ### Use video capture device as audio source ``` VideoCapture1.Video_CaptureDevice_IsAudioSource := true; ``` ``` // C++ MFC m_VideoCapture.put_Video_CaptureDevice_IsAudioSource(true); ``` ``` ' VB6 VideoCapture1.Video_CaptureDevice_IsAudioSource = True ``` or ### Get a list of available audio capture devices ``` for I := 0 to VideoCapture1.Audio_CaptureDevices_GetCount - 1 do cbAudioInputDevice.Items.Add(VideoCapture1.Audio_CaptureDevices_GetItem(i)); ``` ``` // C++ MFC for (int i = 0; i < m_VideoCapture.Audio_CaptureDevices_GetCount(); i++) m_cbAudioInputDevice.AddString(m_VideoCapture.Audio_CaptureDevices_GetItem(i)); ``` ``` ' VB6 For i = 0 To VideoCapture1.Audio_CaptureDevices_GetCount - 1 cbAudioInputDevice.AddItem VideoCapture1.Audio_CaptureDevices_GetItem(i) Next i ``` ### Select the audio input device ``` VideoCapture1.Audio_CaptureDevice := cbAudioInputDevice.Items[cbAudioInputDevice.ItemIndex]; ``` ``` // C++ MFC CString strAudioDevice; m_cbAudioInputDevice.GetLBText(m_cbAudioInputDevice.GetCurSel(), strAudioDevice); m_VideoCapture.put_Audio_CaptureDevice(strAudioDevice); ``` ``` ' VB6 VideoCapture1.Audio_CaptureDevice = cbAudioInputDevice.Text ``` ### Get a list of available audio formats ``` VideoCapture1.Audio_CaptureDevice_Formats_Fill; for I := 0 to VideoCapture1.Audio_CaptureDevice_Formats_GetCount - 1 do cbAudioInputFormat.Items.Add(VideoCapture1.Audio_CaptureDevice_Formats_GetItem(i)); ``` ``` // C++ MFC m_VideoCapture.Audio_CaptureDevice_Formats_Fill(); for (int i = 0; i < m_VideoCapture.Audio_CaptureDevice_Formats_GetCount(); i++) m_cbAudioInputFormat.AddString(m_VideoCapture.Audio_CaptureDevice_Formats_GetItem(i)); ``` ``` ' VB6 VideoCapture1.Audio_CaptureDevice_Formats_Fill For i = 0 To VideoCapture1.Audio_CaptureDevice_Formats_GetCount - 1 cbAudioInputFormat.AddItem VideoCapture1.Audio_CaptureDevice_Formats_GetItem(i) Next i ``` ### Select the format ``` VideoCapture1.Audio_CaptureFormat := cbAudioInputFormat.Items[cbAudioInputFormat.ItemIndex]; ``` ``` // C++ MFC CString strAudioFormat; m_cbAudioInputFormat.GetLBText(m_cbAudioInputFormat.GetCurSel(), strAudioFormat); m_VideoCapture.put_Audio_CaptureFormat(strAudioFormat); ``` ``` ' VB6 VideoCapture1.Audio_CaptureFormat = cbAudioInputFormat.Text ``` or ### Automatically choose the best audio format ``` VideoCapture1.Audio_CaptureFormat_UseBest := cbUseBestAudioInputFormat.Checked; ``` ``` // C++ MFC m_VideoCapture.put_Audio_CaptureFormat_UseBest(m_cbUseBestAudioInputFormat.GetCheck() == BST_CHECKED); ``` ``` ' VB6 VideoCapture1.Audio_CaptureFormat_UseBest = cbUseBestAudioInputFormat.Value ``` ### Get a list of available audio inputs (lines) ``` VideoCapture1.Audio_CaptureDevice_Lines_Fill; for I := 0 to VideoCapture1.Audio_CaptureDevice_Lines_GetCount - 1 do cbAudioInputLine.Items.Add(VideoCapture1.Audio_CaptureDevice_Lines_GetItem(i)); ``` ``` // C++ MFC m_VideoCapture.Audio_CaptureDevice_Lines_Fill(); for (int i = 0; i < m_VideoCapture.Audio_CaptureDevice_Lines_GetCount(); i++) m_cbAudioInputLine.AddString(m_VideoCapture.Audio_CaptureDevice_Lines_GetItem(i)); ``` ``` ' VB6 VideoCapture1.Audio_CaptureDevice_Lines_Fill For i = 0 To VideoCapture1.Audio_CaptureDevice_Lines_GetCount - 1 cbAudioInputLine.AddItem VideoCapture1.Audio_CaptureDevice_Lines_GetItem(i) Next i ``` ### Select audio input ``` VideoCapture1.Audio_CaptureLine := cbAudioInputLine.Items[cbAudioInputLine.ItemIndex]; ``` ``` // C++ MFC CString strAudioLine; m_cbAudioInputLine.GetLBText(m_cbAudioInputLine.GetCurSel(), strAudioLine); m_VideoCapture.put_Audio_CaptureLine(strAudioLine); ``` ``` ' VB6 VideoCapture1.Audio_CaptureLine = cbAudioInputLine.Text ``` --- Please get in touch with [support](https://support.visioforge.com/) to get help with this tutorial. Visit our [GitHub](https://github.com/visioforge/) page to get more code samples. ---END OF PAGE--- ## AVI Video Capture in Delphi Using TVFVideoCapture SDK **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/video-capture-avi/ **Description:** Record video to AVI format in Delphi with TVFVideoCapture using codec selection, audio configuration, and complete implementation examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, C++, Windows, VCL, Capture, AVI **API:** TVFVideoCapture # Complete Guide to Video Capture to AVI Files in Delphi When developing multimedia applications in Delphi, video capture functionality is often a critical requirement. This guide explores how to implement high-quality video capture to AVI files using the TVFVideoCapture component in Delphi applications. We'll cover everything from setting up codecs to configuring audio parameters and starting the capture process. ## Understanding AVI Video Capture in Delphi The TVFVideoCapture component provides a powerful and flexible way to capture video directly to AVI format in Delphi applications. AVI (Audio Video Interleave) remains a popular video container format due to its broad compatibility and reliability for recording purposes. When implementing video capture in your Delphi application, you'll need to consider several key aspects: 1. Selecting appropriate video and audio codecs 2. Configuring audio parameters 3. Setting the output format and capture mode 4. Managing the capture process This guide provides detailed explanations and code samples for each of these steps. ## Working with Video and Audio Codecs ### Retrieving Available Codecs Before capturing video, you'll need to populate your application with the available video and audio codecs. The TVFVideoCapture component makes this straightforward: ``` procedure TMyForm.PopulateCodecLists; var I: Integer; begin // Clear existing items cbVideoCodecs.Items.Clear; cbAudioCodecs.Items.Clear; // Populate video codecs for I := 0 to VideoCapture1.Video_Codecs_GetCount - 1 do cbVideoCodecs.Items.Add(VideoCapture1.Video_Codecs_GetItem(i)); // Populate audio codecs for I := 0 to VideoCapture1.Audio_Codecs_GetCount - 1 do cbAudioCodecs.Items.Add(VideoCapture1.Audio_Codecs_GetItem(i)); end; ``` For developers using C++ MFC, the equivalent code would be: ``` void CMyDialog::PopulateCodecLists() { // Clear existing items m_VideoCodecsCombo.ResetContent(); m_AudioCodecsCombo.ResetContent(); // Populate video codecs for (int i = 0; i < m_VideoCapture.Video_Codecs_GetCount(); i++) { CString codecName = m_VideoCapture.Video_Codecs_GetItem(i); m_VideoCodecsCombo.AddString(codecName); } // Populate audio codecs for (int i = 0; i < m_VideoCapture.Audio_Codecs_GetCount(); i++) { CString codecName = m_VideoCapture.Audio_Codecs_GetItem(i); m_AudioCodecsCombo.AddString(codecName); } } ``` For VB6 developers, here's how to implement the same functionality: ``` Private Sub PopulateCodecLists() ' Clear existing items cboVideoCodecs.Clear cboAudioCodecs.Clear ' Populate video codecs Dim i As Integer For i = 0 To VideoCapture1.Video_Codecs_GetCount - 1 cboVideoCodecs.AddItem VideoCapture1.Video_Codecs_GetItem(i) Next i ' Populate audio codecs For i = 0 To VideoCapture1.Audio_Codecs_GetCount - 1 cboAudioCodecs.AddItem VideoCapture1.Audio_Codecs_GetItem(i) Next i End Sub ``` ### Selecting Codecs for Capture Once you've populated the lists, you'll need to let users select their preferred codecs and apply those selections to the capture component: ``` procedure TMyForm.ApplyCodecSelections; begin if cbVideoCodecs.ItemIndex >= 0 then VideoCapture1.Video_Codec := cbVideoCodecs.Items[cbVideoCodecs.ItemIndex]; if cbAudioCodecs.ItemIndex >= 0 then VideoCapture1.Audio_Codec := cbAudioCodecs.Items[cbAudioCodecs.ItemIndex]; end; ``` C++ MFC implementation: ``` void CMyDialog::ApplyCodecSelections() { int videoIndex = m_VideoCodecsCombo.GetCurSel(); if (videoIndex >= 0) { CString videoCodec; m_VideoCodecsCombo.GetLBText(videoIndex, videoCodec); m_VideoCapture.Video_Codec = videoCodec; } int audioIndex = m_AudioCodecsCombo.GetCurSel(); if (audioIndex >= 0) { CString audioCodec; m_AudioCodecsCombo.GetLBText(audioIndex, audioCodec); m_VideoCapture.Audio_Codec = audioCodec; } } ``` VB6 implementation: ``` Private Sub ApplyCodecSelections() If cboVideoCodecs.ListIndex >= 0 Then VideoCapture1.Video_Codec = cboVideoCodecs.Text End If If cboAudioCodecs.ListIndex >= 0 Then VideoCapture1.Audio_Codec = cboAudioCodecs.Text End If End Sub ``` ## Configuring Audio Parameters Quality audio capture requires proper configuration of three key parameters: 1. **Audio Channels**: Typically 1 (mono) or 2 (stereo) 2. **Bits Per Sample (BPS)**: Common values include 8, 16, or 24 bits 3. **Sample Rate**: Standard rates include 44100 Hz (CD quality) or 48000 Hz Here's how to apply these settings in Delphi: ``` procedure TMyForm.ConfigureAudioSettings; begin // Apply audio channel configuration (mono/stereo) VideoCapture1.Audio_Channels := StrToInt(cbChannels.Items[cbChannels.ItemIndex]); // Set bits per sample for audio quality VideoCapture1.Audio_BPS := StrToInt(cbBPS.Items[cbBPS.ItemIndex]); // Configure sample rate VideoCapture1.Audio_SampleRate := StrToInt(cbSampleRate.Items[cbSampleRate.ItemIndex]); end; ``` C++ MFC implementation: ``` void CMyDialog::ConfigureAudioSettings() { CString channelStr, bpsStr, sampleRateStr; // Get selected values from combo boxes m_ChannelsCombo.GetLBText(m_ChannelsCombo.GetCurSel(), channelStr); m_BpsCombo.GetLBText(m_BpsCombo.GetCurSel(), bpsStr); m_SampleRateCombo.GetLBText(m_SampleRateCombo.GetCurSel(), sampleRateStr); // Apply audio channel configuration m_VideoCapture.Audio_Channels = _ttoi(channelStr); // Set bits per sample m_VideoCapture.Audio_BPS = _ttoi(bpsStr); // Configure sample rate m_VideoCapture.Audio_SampleRate = _ttoi(sampleRateStr); } ``` VB6 implementation: ``` Private Sub ConfigureAudioSettings() ' Apply audio channel configuration VideoCapture1.Audio_Channels = CInt(cboChannels.Text) ' Set bits per sample VideoCapture1.Audio_BPS = CInt(cboBPS.Text) ' Configure sample rate VideoCapture1.Audio_SampleRate = CInt(cboSampleRate.Text) End Sub ``` ## Configuring Output Format and Capture Mode The next step is to configure the output format as AVI and set the appropriate capture mode: ``` procedure TMyForm.PrepareForCapture; begin // Set AVI as the output format VideoCapture1.OutputFormat := Format_AVI; // Configure video capture mode VideoCapture1.Mode := Mode_Video_Capture; end; ``` C++ MFC implementation: ``` void CMyDialog::PrepareForCapture() { // Set AVI as the output format m_VideoCapture.OutputFormat = Format_AVI; // Configure video capture mode m_VideoCapture.Mode = Mode_Video_Capture; } ``` VB6 implementation: ``` Private Sub PrepareForCapture() ' Set AVI as the output format VideoCapture1.OutputFormat = Format_AVI ' Configure video capture mode VideoCapture1.Mode = Mode_Video_Capture End Sub ``` ## Starting and Managing the Capture Process Once everything is configured, you can start the capture process: ``` procedure TMyForm.StartCapture; begin try // Set output filename VideoCapture1.Output_Filename := ExtractFilePath(Application.ExeName) + 'CapturedVideo.avi'; // Begin capture process VideoCapture1.Start; // Update UI to show capture in progress btnStart.Enabled := False; btnStop.Enabled := True; lblStatus.Caption := 'Recording...'; except on E: Exception do ShowMessage('Error starting capture: ' + E.Message); end; end; ``` C++ MFC implementation: ``` void CMyDialog::StartCapture() { try { TCHAR appPath[MAX_PATH]; GetModuleFileName(NULL, appPath, MAX_PATH); CString appDir = appPath; int pos = appDir.ReverseFind('\\'); if (pos != -1) { appDir = appDir.Left(pos + 1); } // Set output filename m_VideoCapture.Output_Filename = appDir + _T("CapturedVideo.avi"); // Begin capture process m_VideoCapture.Start(); // Update UI GetDlgItem(IDC_START_BUTTON)->EnableWindow(FALSE); GetDlgItem(IDC_STOP_BUTTON)->EnableWindow(TRUE); SetDlgItemText(IDC_STATUS_STATIC, _T("Recording...")); } catch (COleDispatchException* e) { CString errorMsg = _T("Error starting capture: "); errorMsg += e->m_strDescription; MessageBox(errorMsg, _T("Error"), MB_ICONERROR); e->Delete(); } } ``` VB6 implementation: ``` Private Sub StartCapture() On Error GoTo ErrorHandler ' Set output filename VideoCapture1.Output_Filename = App.Path & "\CapturedVideo.avi" ' Begin capture process VideoCapture1.Start ' Update UI btnStart.Enabled = False btnStop.Enabled = True lblStatus.Caption = "Recording..." Exit Sub ErrorHandler: MsgBox "Error starting capture: " & Err.Description, vbExclamation End Sub ``` ## Handling Capture Completion It's important to provide functionality to stop the capture process: ``` procedure TMyForm.StopCapture; begin try // Stop the capture process VideoCapture1.Stop; // Update UI btnStart.Enabled := True; btnStop.Enabled := False; lblStatus.Caption := 'Capture completed'; // Optionally open the captured file if FileExists(VideoCapture1.Output_Filename) and (MessageDlg('Open captured video?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then ShellExecute(0, 'open', PChar(VideoCapture1.Output_Filename), nil, nil, SW_SHOW); except on E: Exception do ShowMessage('Error stopping capture: ' + E.Message); end; end; ``` C++ MFC implementation: ``` void CMyDialog::StopCapture() { try { // Stop the capture process m_VideoCapture.Stop(); // Update UI GetDlgItem(IDC_START_BUTTON)->EnableWindow(TRUE); GetDlgItem(IDC_STOP_BUTTON)->EnableWindow(FALSE); SetDlgItemText(IDC_STATUS_STATIC, _T("Capture completed")); // Optionally open the captured file CString outputFile = m_VideoCapture.Output_Filename; if (PathFileExists(outputFile) && MessageBox(_T("Open captured video?"), _T("Confirmation"), MB_YESNO | MB_ICONQUESTION) == IDYES) { ShellExecute(NULL, _T("open"), outputFile, NULL, NULL, SW_SHOW); } } catch (COleDispatchException* e) { CString errorMsg = _T("Error stopping capture: "); errorMsg += e->m_strDescription; MessageBox(errorMsg, _T("Error"), MB_ICONERROR); e->Delete(); } } ``` VB6 implementation: ``` Private Sub StopCapture() On Error GoTo ErrorHandler ' Stop the capture process VideoCapture1.Stop ' Update UI btnStart.Enabled = True btnStop.Enabled = False lblStatus.Caption = "Capture completed" ' Optionally open the captured file If Dir(VideoCapture1.Output_Filename) <> "" Then If MsgBox("Open captured video?", vbQuestion + vbYesNo) = vbYes Then Shell "explorer.exe """ & VideoCapture1.Output_Filename & """", vbNormalFocus End If End If Exit Sub ErrorHandler: MsgBox "Error stopping capture: " & Err.Description, vbExclamation End Sub ``` ## Conclusion Implementing video capture to AVI files in Delphi applications using the TVFVideoCapture component is a straightforward process when you understand the key concepts. By following this guide, you can create robust multimedia applications with professional video capture functionality. The TVFVideoCapture component provides a wide range of additional features and customization options beyond what's covered in this guide, including video effects, overlays, and device property configuration. Remember to test your video capture implementation thoroughly with different codecs and audio configurations to ensure the best quality for your specific use case. --- For additional code samples and implementation guidance, visit our GitHub repository. If you need further assistance with this tutorial, our support team is available to help. ---END OF PAGE--- ## DV Video Capture in Delphi — Direct Stream and Recompressed **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/video-capture-dv/ **Description:** Implement DV video capture in Delphi - compressed and uncompressed formats with step-by-step implementation and working code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Streaming # Video Capture to DV File Format: Implementation Guide Digital Video (DV) remains a reliable format for video capture applications, particularly when working with legacy systems or specific professional requirements. This guide explores how to implement DV video capture functionality in your Delphi applications, with additional C++ MFC and VB6 examples for cross-platform reference. ## Understanding DV Format Options DV format offers several advantages for video capture applications: - Consistent quality with minimal generation loss - Efficient storage for professional video content - Support for both PAL and NTSC standards - Compatibility with professional video editing software - Reliable audio synchronization When implementing DV video capture, developers have two primary approaches: 1. **Direct Stream Capture** - Raw DV data without recompression 2. **Recompressed DV** - Processed video with customizable settings Each approach serves different use cases depending on your application requirements. ## Direct Stream Capture Implementation Direct stream capture provides the highest quality by avoiding any recompression of the video signal. This method is ideal for archival purposes and professional video production where maintaining the original signal integrity is crucial. ### Configuring DV Type Settings The first step in implementing direct stream capture is setting the appropriate DV type configuration: #### Delphi ``` VideoCapture1.DV_Capture_Type2 := rbDVType2.Checked; ``` #### C++ MFC ``` m_videoCapture.put_DV_Capture_Type2(m_rbDVType2.GetCheck() == BST_CHECKED); ``` #### VB6 ``` VideoCapture1.DV_Capture_Type2 = rbDVType2.Value ``` The DV Type setting determines the specific format variation used for capture. Most modern applications use Type 2, which offers better compatibility with editing software. ### Setting Output Format for Direct Stream For direct stream capture, you must specify the DirectStream\_DV format: #### Delphi ``` VideoCapture1.OutputFormat := Format_DirectStream_DV; ``` #### C++ MFC ``` m_videoCapture.SetOutputFormat(Format_DirectStream_DV); ``` #### VB6 ``` VideoCapture1.OutputFormat = Format_DirectStream_DV ``` This ensures the video data is stored without additional processing or compression. ### Configuring Capture Mode Next, set the component to video capture mode: #### Delphi ``` VideoCapture1.Mode := Mode_Video_Capture; ``` #### C++ MFC ``` m_videoCapture.SetMode(Mode_Video_Capture); ``` #### VB6 ``` VideoCapture1.Mode = Mode_Video_Capture ``` This prepares the component for continuous video acquisition rather than single-frame capture. ### Initiating Direct Stream Capture With all settings in place, you can begin the capture process: #### Delphi ``` VideoCapture1.Start; ``` #### C++ MFC ``` m_videoCapture.Start(); ``` #### VB6 ``` VideoCapture1.Start ``` The component will now capture the video stream directly to the specified output location in DV format. ## Implementing DV Capture with Recompression In some scenarios, you may need to modify the DV stream during capture. This approach allows for customization of audio parameters and video format standards. ### Configuring Audio Parameters DV format supports multiple audio configurations. Set the channels and sample rate to match your requirements: #### Delphi ``` VideoCapture1.DV_Capture_Audio_Channels := StrToInt(cbDVChannels.Items[cbDVChannels.ItemIndex]); VideoCapture1.DV_Capture_Audio_SampleRate := StrToInt(cbDVSampleRate.Items[cbDVSampleRate.ItemIndex]); ``` #### C++ MFC ``` CString channelStr, sampleRateStr; m_cbDVChannels.GetLBText(m_cbDVChannels.GetCurSel(), channelStr); m_cbDVSampleRate.GetLBText(m_cbDVSampleRate.GetCurSel(), sampleRateStr); m_videoCapture.put_DV_Capture_Audio_Channels(_ttoi(channelStr)); m_videoCapture.put_DV_Capture_Audio_SampleRate(_ttoi(sampleRateStr)); ``` #### VB6 ``` VideoCapture1.DV_Capture_Audio_Channels = CInt(cbDVChannels.List(cbDVChannels.ListIndex)) VideoCapture1.DV_Capture_Audio_SampleRate = CInt(cbDVSampleRate.List(cbDVSampleRate.ListIndex)) ``` Standard DV audio options include: - Channels: 1 (mono) or 2 (stereo) - Sample rates: 32000 Hz, 44100 Hz, or 48000 Hz ### Setting Video Format Standard DV supports both PAL and NTSC standards. Select the appropriate standard for your target region: #### Delphi ``` if rbDVPAL.Checked then VideoCapture1.DV_Capture_Video_Format := DVF_PAL else VideoCapture1.DV_Capture_Video_Format := DVF_NTSC; ``` #### C++ MFC ``` if (m_rbDVPAL.GetCheck() == BST_CHECKED) m_videoCapture.put_DV_Capture_Video_Format(DVF_PAL); else m_videoCapture.put_DV_Capture_Video_Format(DVF_NTSC); ``` #### VB6 ``` If rbDVPAL.Value Then VideoCapture1.DV_Capture_Video_Format = DVF_PAL Else VideoCapture1.DV_Capture_Video_Format = DVF_NTSC End If ``` Remember that: - PAL: 720×576 resolution at 25 fps (used in Europe, Australia, parts of Asia) - NTSC: 720×480 resolution at 29.97 fps (used in North America, Japan, parts of South America) ### DV Type Selection As with direct streaming, specify the DV type for recompressed capture: #### Delphi ``` VideoCapture1.DV_Capture_Type2 := rbDVType2.Checked; ``` #### C++ MFC ``` m_videoCapture.put_DV_Capture_Type2(m_rbDVType2.GetCheck() == BST_CHECKED); ``` #### VB6 ``` VideoCapture1.DV_Capture_Type2 = rbDVType2.Value ``` ### Setting Output Format for Recompression For recompressed DV capture, specify the DV format rather than DirectStream\_DV: #### Delphi ``` VideoCapture1.OutputFormat := Format_DV; VideoCapture1.Mode := Mode_Video_Capture; ``` #### C++ MFC ``` m_videoCapture.SetOutputFormat(Format_DV); m_videoCapture.SetMode(Mode_Video_Capture); ``` #### VB6 ``` VideoCapture1.OutputFormat = Format_DV VideoCapture1.Mode = Mode_Video_Capture ``` This tells the component to process the stream through the DV codec during capture. ### Starting Recompressed Capture With all parameters configured, begin the capture process: #### Delphi ``` VideoCapture1.Start; ``` #### C++ MFC ``` m_videoCapture.Start(); ``` #### VB6 ``` VideoCapture1.Start ``` ## Best Practices for DV Capture Implementation When implementing DV capture in your applications, consider these recommendations: 1. **Pre-allocate sufficient disk space** - DV format requires approximately 13 GB per hour of footage 2. **Implement capture time limits** - DV files have a 4 GB size limit on some file systems 3. **Monitor system resources** - DV capture requires consistent CPU and disk performance 4. **Provide format selection UI** - Let users choose between direct stream and recompressed options 5. **Test with various camera models** - DV implementation can vary between manufacturers ## Error Handling Considerations Robust DV capture implementations should include error handling for these common scenarios: - Device disconnection during capture - Disk space exhaustion - Buffer overrun conditions - Invalid format settings - Codec compatibility issues ## Conclusion Implementing DV video capture in your Delphi, C++ MFC, or VB6 applications provides a solid foundation for professional video acquisition workflows. Whether you choose direct stream capture for maximum quality or recompressed capture for additional flexibility, the DV format offers reliable performance for specialized video applications. By following the implementation examples in this guide, you can integrate professional-grade video capture capabilities into your custom software solutions. --- Need additional assistance with your video capture implementation? Visit our [GitHub](https://github.com/visioforge/) page for more code samples or contact our [support team](https://support.visioforge.com/) for personalized guidance. ---END OF PAGE--- ## Video Capture to WMV Format in Delphi, C++ MFC and VB6 **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/video-capture-wmv/ **Description:** Capture video to WMV format - external profiles, output configuration, and implementation for Delphi, C++ MFC, and VB6 with code examples. **Tags:** All-in-One Media Framework, Delphi, ActiveX, C++, Windows, VCL, Capture, Streaming, Encoding, WMV # Video Capture to Windows Media Video (WMV) Using External Profiles ## Introduction Capturing video to Windows Media Video (WMV) format is a common requirement in many software applications. This guide provides a detailed walkthrough of implementing video capture functionality using external WMV profiles in Delphi, C++ MFC, and VB6 applications. The WMV format remains popular due to its compatibility with Windows platforms and efficient compression algorithms that balance quality and file size. ## Understanding WMV and External Profiles Windows Media Video (WMV) is a compressed video file format developed by Microsoft as part of the Windows Media framework. When capturing video to WMV format, using external profiles allows for greater flexibility and customization of the output. External profiles contain pre-configured settings that define: - Video resolution - Bitrate - Frame rate - Compression quality - Audio settings - Other encoding parameters By leveraging external profiles, developers can quickly implement different quality presets without having to manually configure each parameter in code. ## Implementation Steps ### Step 1: Setting Up Your Environment Before implementing video capture functionality, ensure your development environment is properly configured: 1. Install the necessary video capture component 2. Add the component reference to your project 3. Design your user interface to include: 4. A file selector for choosing the WMV profile 5. Output file location selector 6. Video capture preview window 7. Start/Stop capture controls ### Step 2: Selecting a WMV Profile The first step in the implementation is to specify which WMV profile to use for encoding. This profile contains all the encoding parameters that will be applied to the captured video. > `WMV_Profile_Filename` expects the path to a `.prx` Windows Media profile (the encoding-parameters template) — NOT the path to the captured `.wmv` output file. Set the captured filename via `Output_Filename` (or the project's standard filename property). #### Delphi ``` // Pascal string literals use single quotes. VideoCapture1.WMV_Profile_Filename := 'C:\Profiles\HighQuality.prx'; ``` #### C++ MFC ``` m_videoCapture.SetWMVProfileFilename(_T("C:\\Profiles\\HighQuality.prx")); ``` #### VB6 ``` VideoCapture1.WMV_Profile_Filename = "C:\Profiles\HighQuality.prx" ``` ### Step 3: Configuring the Output Format Once the profile is selected, you need to configure the component to use WMV as the output format. This tells the capture component which encoder to use for processing the video stream. #### Delphi ``` VideoCapture1.OutputFormat := Format_WMV; ``` #### C++ MFC ``` m_videoCapture.SetOutputFormat(FORMAT_WMV); ``` #### VB6 ``` VideoCapture1.OutputFormat = FORMAT_WMV ``` ### Step 4: Setting the Capture Mode The capture component can operate in various modes, so it's important to explicitly set it to video capture mode. #### Delphi ``` VideoCapture1.Mode := Mode_Video_Capture; ``` #### C++ MFC ``` m_videoCapture.SetMode(MODE_VIDEO_CAPTURE); ``` #### VB6 ``` VideoCapture1.Mode = MODE_VIDEO_CAPTURE ``` This ensures that the component is configured for continuous video recording rather than other modes like snapshot capture or streaming. ### Step 5: Starting the Video Capture With all the configuration in place, the final step is to start the actual capture process. #### Delphi ``` VideoCapture1.Start; ``` #### C++ MFC ``` m_videoCapture.Start(); ``` #### VB6 ``` VideoCapture1.Start ``` This command begins the capture process using all the previously configured settings. ## Advanced Configuration Options ### Custom Output File Naming You can implement custom file naming for your captured video files: #### Delphi ``` VideoCapture1.Output_Filename := 'C:\Captures\Video_' + FormatDateTime('yyyymmdd_hhnnss', Now) + '.wmv'; ``` #### C++ MFC ``` CTime currentTime = CTime::GetCurrentTime(); CString fileName; fileName.Format(_T("C:\\Captures\\Video_%04d%02d%02d_%02d%02d%02d.wmv"), currentTime.GetYear(), currentTime.GetMonth(), currentTime.GetDay(), currentTime.GetHour(), currentTime.GetMinute(), currentTime.GetSecond()); m_videoCapture.SetOutputFilename(fileName); ``` #### VB6 ``` VideoCapture1.Output_Filename = "C:\Captures\Video_" & Format(Now, "yyyymmdd_hhnnss") & ".wmv" ``` These examples create a timestamped filename to ensure each captured file has a unique name. When designing your application, consider these best practices: 1. Always verify device availability before attempting capture 2. Provide feedback during long encoding operations 3. Include a preview window so users can see what's being captured 4. Implement a file size monitor for long recordings 5. Test with various WMV profiles to ensure compatibility ## Conclusion Implementing video capture to WMV format using external profiles provides flexibility and control over the capture process. The approach outlined in this guide works effectively in Delphi, C++ MFC, and VB6 development environments, allowing you to integrate professional-grade video capture capabilities into your applications. By using external profiles, you can quickly switch between different quality settings without changing your code, which is ideal for applications that need to adapt to different use cases or hardware capabilities. --- For additional code samples, visit our GitHub repository. If you need technical assistance with implementation, our support team is available to help. ---END OF PAGE--- ## Video Input Crossbar Selection in Delphi Applications **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/video-input-crossbar/ **Description:** Select video input sources in Delphi with crossbar - configure composite, S-Video, HDMI inputs with step-by-step code examples for Delphi. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture, Decoding, TV Tuner # Selecting Video Input Sources with Crossbar Technology ## Introduction to Video Input Selection When developing applications that capture video from external devices, you'll often need to handle multiple input sources. The crossbar is a crucial component in video capture systems that allows you to route different physical inputs (like composite, S-Video, HDMI) to your application. This guide walks you through the process of detecting, configuring, and selecting video inputs using the crossbar interface in Delphi, C++ MFC, and Visual Basic 6 applications. ## Understanding Crossbar Technology Crossbar technology functions as a routing matrix in video capture devices, enabling the connection between various inputs and outputs. Modern capture cards and TV tuners frequently incorporate crossbar functionality to facilitate switching between different video sources such as: - Composite video inputs - S-Video connections - Component video - HDMI inputs - TV tuner inputs - Digital video interfaces Properly configuring these connections programmatically is essential for applications that need to dynamically switch between different video sources. ## Implementation Steps Overview The implementation process for configuring crossbar connections in your application involves three main steps: 1. Initializing the crossbar interface and verifying its availability 2. Enumerating available video inputs for selection 3. Connecting the selected input to the video decoder output Let's examine each step in detail with sample code for Delphi, C++ MFC, and VB6 environments. ## Detailed Implementation Guide ### Step 1: Initialize the Crossbar Interface Before you can work with input selection, you need to initialize the crossbar interface and verify it's available on the current capture device. #### Delphi Implementation ``` // Initialize the crossbar interface CrossBarFound := VideoCapture1.Video_CaptureDevice_CrossBar_Init; // Check if crossbar functionality is available if CrossBarFound then ShowMessage('Crossbar functionality detected and initialized') else ShowMessage('No crossbar available on this capture device'); ``` #### C++ MFC Implementation ``` // Initialize the crossbar interface BOOL bCrossBarFound = m_videoCapture.Video_CaptureDevice_CrossBar_Init(); // Check if crossbar functionality is available if (bCrossBarFound) { AfxMessageBox(_T("Crossbar functionality detected and initialized")); } else { AfxMessageBox(_T("No crossbar available on this capture device")); } ``` #### VB6 Implementation ``` ' Initialize the crossbar interface Dim CrossBarFound As Boolean CrossBarFound = VideoCapture1.Video_CaptureDevice_CrossBar_Init() ' Check if crossbar functionality is available If CrossBarFound Then MsgBox "Crossbar functionality detected and initialized" Else MsgBox "No crossbar available on this capture device" End If ``` The initialization function returns a boolean value indicating whether the crossbar functionality is available on the current capture device. Not all capture devices support crossbar functionality, so this check is crucial. ### Step 2: Enumerate Available Video Inputs Once you've confirmed that the crossbar is available, the next step is to retrieve a list of available inputs for the "Video Decoder" output. This allows users to select from available physical connections. #### Delphi Implementation ``` // Variables declared at the procedure level so the snippet compiles on any Delphi 6+ IDE // (inline `var name: T := ...` requires Delphi 10.3 Rio or later). procedure TForm1.PopulateCrossBarInputs; var inputCount: Integer; inputName: String; i: Integer; begin // Clear any existing connections and UI elements VideoCapture1.Video_CaptureDevice_CrossBar_ClearConnections; cbCrossbarVideoInput.Clear; // Get count of available inputs for the "Video Decoder" output inputCount := VideoCapture1.Video_CaptureDevice_CrossBar_GetInputsForOutput_GetCount('Video Decoder'); // Populate UI with available inputs for i := 0 to inputCount - 1 do begin inputName := VideoCapture1.Video_CaptureDevice_CrossBar_GetInputsForOutput_GetItem('Video Decoder', i); cbCrossbarVideoInput.Items.Add(inputName); end; // Select the first item by default if available if cbCrossbarVideoInput.Items.Count > 0 then cbCrossbarVideoInput.ItemIndex := 0; end; ``` #### C++ MFC Implementation ``` // Clear any existing connections and UI elements m_videoCapture.Video_CaptureDevice_CrossBar_ClearConnections(); m_comboVideoInputs.ResetContent(); // Get count of available inputs for the "Video Decoder" output int inputCount = m_videoCapture.Video_CaptureDevice_CrossBar_GetInputsForOutput_GetCount(_T("Video Decoder")); // Populate UI with available inputs for (int i = 0; i < inputCount; i++) { CString inputName = m_videoCapture.Video_CaptureDevice_CrossBar_GetInputsForOutput_GetItem(_T("Video Decoder"), i); m_comboVideoInputs.AddString(inputName); } // Select the first item by default if available if (m_comboVideoInputs.GetCount() > 0) { m_comboVideoInputs.SetCurSel(0); } ``` #### VB6 Implementation ``` ' Clear any existing connections and UI elements VideoCapture1.Video_CaptureDevice_CrossBar_ClearConnections cboVideoInputs.Clear ' Get count of available inputs for the "Video Decoder" output Dim inputCount As Integer inputCount = VideoCapture1.Video_CaptureDevice_CrossBar_GetInputsForOutput_GetCount("Video Decoder") ' Populate UI with available inputs Dim i As Integer Dim inputName As String For i = 0 To inputCount - 1 inputName = VideoCapture1.Video_CaptureDevice_CrossBar_GetInputsForOutput_GetItem("Video Decoder", i) cboVideoInputs.AddItem inputName Next i ' Select the first item by default if available If cboVideoInputs.ListCount > 0 Then cboVideoInputs.ListIndex = 0 End If ``` Common input types you might encounter include: - Composite - S-Video - HDMI - Component - TV Tuner The exact list depends on your specific capture hardware capabilities. ### Step 3: Apply the Selected Input After the user selects their desired input source, you need to apply this selection by establishing a connection between the selected input and the video decoder output. #### Delphi Implementation ``` // Variables at procedure level — compatible with Delphi 6+ (avoids the inline `var` // shorthand introduced in Delphi 10.3 Rio). procedure TForm1.ApplySelectedCrossBarInput; var selectedInput: String; success: Boolean; begin // First clear any existing connections VideoCapture1.Video_CaptureDevice_CrossBar_ClearConnections; // Connect the selected input to the "Video Decoder" output // Parameters: input name, output name, automatic signal routing if cbCrossbarVideoInput.ItemIndex >= 0 then begin selectedInput := cbCrossbarVideoInput.Items[cbCrossbarVideoInput.ItemIndex]; success := VideoCapture1.Video_CaptureDevice_CrossBar_Connect(selectedInput, 'Video Decoder', true); if success then ShowMessage('Successfully connected ' + selectedInput + ' to Video Decoder') else ShowMessage('Failed to establish connection'); end; end; ``` #### C++ MFC Implementation ``` // First clear any existing connections m_videoCapture.Video_CaptureDevice_CrossBar_ClearConnections(); // Connect the selected input to the "Video Decoder" output // Parameters: input name, output name, automatic signal routing int selectedIndex = m_comboVideoInputs.GetCurSel(); if (selectedIndex >= 0) { CString selectedInput; m_comboVideoInputs.GetLBText(selectedIndex, selectedInput); BOOL success = m_videoCapture.Video_CaptureDevice_CrossBar_Connect( selectedInput, _T("Video Decoder"), TRUE); if (success) { CString msg; msg.Format(_T("Successfully connected %s to Video Decoder"), selectedInput); AfxMessageBox(msg); } else { AfxMessageBox(_T("Failed to establish connection")); } } ``` #### VB6 Implementation ``` ' First clear any existing connections VideoCapture1.Video_CaptureDevice_CrossBar_ClearConnections ' Connect the selected input to the "Video Decoder" output ' Parameters: input name, output name, automatic signal routing If cboVideoInputs.ListIndex >= 0 Then Dim selectedInput As String selectedInput = cboVideoInputs.Text Dim success As Boolean success = VideoCapture1.Video_CaptureDevice_CrossBar_Connect(selectedInput, "Video Decoder", True) If success Then MsgBox "Successfully connected " & selectedInput & " to Video Decoder" Else MsgBox "Failed to establish connection" End If End If ``` The third parameter (`true`) enables automatic signal routing, which helps handle complex connection scenarios where intermediate routing might be required. ## Best Practices for Crossbar Implementation For robust video input selection in your applications: 1. **Always initialize the crossbar first**: Check for availability before attempting operations 2. **Clear existing connections**: Before setting a new connection, clear any existing ones 3. **Handle missing crossbar gracefully**: Provide fallback options when crossbar functionality isn't available 4. **Validate selections**: Ensure a valid input is selected before attempting to establish connections 5. **Provide user feedback**: Inform users about successful or failed connection attempts ## Troubleshooting Common Issues If you encounter problems with crossbar connections: - Verify your capture device supports crossbar functionality - Check that input and output names match exactly what the device reports - Ensure proper device driver installation - Use debug logging to track connection attempts - Test with different input sources to isolate hardware-specific issues ## Conclusion Proper implementation of crossbar technology in your video capture applications gives users the flexibility to work with multiple input sources. By following the steps outlined in this guide, you can create a robust and user-friendly video input selection system for your applications regardless of whether you're developing in Delphi, C++ MFC, or Visual Basic 6. The code samples provided demonstrate how to initialize the crossbar, enumerate available inputs, and connect selected inputs to the video decoder output. With these fundamentals in place, you can build sophisticated video capture applications that support a wide range of input devices and connection types. --- For additional assistance with implementing this functionality, explore our other documentation pages and code samples repository for more advanced techniques and solutions. ---END OF PAGE--- ## Video Renderer Selection in Delphi — EVR, VMR9, and GDI **URL:** https://www.visioforge.com/help/docs/delphi/videocapture/video-renderer/ **Description:** Select optimal video renderers in Delphi - Video Renderer, VMR9, EVR with code examples for performance and hardware acceleration on Windows. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Capture **API:** TVFVideoCapture # Video Renderer Selection Guide for TVFVideoCapture ## Overview of Available Renderers When developing video capture applications with TVFVideoCapture, selecting the appropriate video renderer significantly impacts performance and compatibility. This guide provides detailed implementation examples for the three available renderer options in Delphi, C++, and VB6 environments. ## Standard Video Renderer The standard Video Renderer utilizes GDI for drawing operations. This renderer option is primarily recommended for: - Legacy systems - Environments where Direct3D acceleration is unavailable - Maximum compatibility with older hardware ``` // Delphi VideoCapture1.Video_Renderer := VR_VideoRenderer; ``` ``` // C++ MFC m_VideoCapture.SetVideo_Renderer(VR_VideoRenderer); ``` ``` ' VB6 VideoCapture1.Video_Renderer = VR_VideoRenderer ``` ## Video Mixing Renderer 9 (VMR9) VMR9 represents a modern filtering solution capable of leveraging GPU capabilities for enhanced rendering. Key advantages include: - Hardware-accelerated video processing - Advanced deinterlacing options - Improved performance for high-resolution content ``` // Delphi VideoCapture1.Video_Renderer := VR_VMR9; ``` ``` // C++ MFC m_VideoCapture.SetVideo_Renderer(VR_VMR9); ``` ``` ' VB6 VideoCapture1.Video_Renderer = VR_VMR9 ``` ### Accessing Deinterlacing Modes VMR9 supports multiple deinterlacing techniques. The following code demonstrates how to retrieve available deinterlacing options: ``` // Delphi VideoCapture1.Video_Renderer_Deinterlace_Modes_Fill; for I := 0 to VideoCapture1.Video_Renderer_Deinterlace_Modes_GetCount - 1 do cbDeinterlaceModes.Items.Add(VideoCapture1.Video_Renderer_Deinterlace_Modes_GetItem(i)); ``` ``` // C++ MFC m_VideoCapture.Video_Renderer_Deinterlace_Modes_Fill(); for (int i = 0; i < m_VideoCapture.Video_Renderer_Deinterlace_Modes_GetCount(); i++) { m_DeinterlaceCombo.AddString(m_VideoCapture.Video_Renderer_Deinterlace_Modes_GetItem(i)); } ``` ``` ' VB6 VideoCapture1.Video_Renderer_Deinterlace_Modes_Fill For i = 0 To VideoCapture1.Video_Renderer_Deinterlace_Modes_GetCount - 1 cboDeinterlaceModes.AddItem VideoCapture1.Video_Renderer_Deinterlace_Modes_GetItem(i) Next i ``` ## Enhanced Video Renderer (EVR) EVR is the recommended renderer for modern Windows environments (Vista and later). This advanced renderer provides: - Superior video acceleration capabilities - Optimal performance on Windows 7/10/11 - Better resource utilization ``` // Delphi VideoCapture1.Video_Renderer := VR_EVR; ``` ``` // C++ MFC m_VideoCapture.SetVideo_Renderer(VR_EVR); ``` ``` ' VB6 VideoCapture1.Video_Renderer = VR_EVR ``` ## Managing Aspect Ratio and Display Options When displaying video content, you'll often need to handle aspect ratio differences between the source video and the display area. ### Stretching the Video Image To stretch the video to fill the entire display area: ``` // Delphi VideoCapture1.Screen_Stretch := true; VideoCapture1.Screen_Update; ``` ``` // C++ MFC m_VideoCapture.SetScreen_Stretch(true); m_VideoCapture.Screen_Update(); ``` ``` ' VB6 VideoCapture1.Screen_Stretch = True VideoCapture1.Screen_Update ``` ### Using Letterbox Mode (Black Borders) For preserving the original aspect ratio with black borders: ``` // Delphi VideoCapture1.Screen_Stretch := false; VideoCapture1.Screen_Update; ``` ``` // C++ MFC m_VideoCapture.SetScreen_Stretch(false); m_VideoCapture.Screen_Update(); ``` ``` ' VB6 VideoCapture1.Screen_Stretch = False VideoCapture1.Screen_Update ``` ## Performance Considerations When selecting a renderer for your application, consider these factors: 1. Target operating system version 2. Hardware capabilities of end-user systems 3. Video resolution and processing requirements 4. Compatibility needs for your deployment environment --- Please get in touch with [support](https://support.visioforge.com/) if you need technical assistance with this implementation. Visit our [GitHub](https://github.com/visioforge/) repository for additional code samples and resources. ---END OF PAGE--- ## TVFVideoEdit Changelog - Delphi Video Editing SDK Updates **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/changelog/ **Description:** TVFVideoEdit version history from 2.1 to 10.0 with features, bug fixes, FFMPEG integration, Windows 8 support, and video effects updates. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Streaming, Editing **API:** TVFVideoEdit # TVFVideoEdit Library: Complete Version History ## Version 10.0 - Latest Release ### Core Improvements - **Enhanced Media Compatibility**: Added dedicated MP3 splitter component to resolve playback issues with problematic MP3 files that fail with the default splitter - **Audio Processing Enhancements**: Significantly improved information extraction and metadata reading for Speex audio files - **Performance Optimization**: Fixed critical memory leak in FFMPEG source implementation for better resource management - **Expanded Format Support**: YUV2RGB filter now fully supports HDYC format for professional video workflows ## Version 8.7 - Engine Updates ### Technical Enhancements - **VLC Integration**: Updated VLC engine to latest stable release (libVLC 2.2.1.0) for improved codec support - **Decoding Capabilities**: Implemented latest FFMPEG engine version with expanded format compatibility ## Version 8.6 - Stability Improvements ### Bug Fixes & Additions - **Memory Management**: Resolved critical memory leak affecting long-running applications - **File Handling**: Fixed issues with incorrectly closed input and output files that caused resource locking - **WebM Support**: Added new high-performance WebM filters based on the official WebM project specifications ## Version 8.4 - Platform Expansion ### Development Environment Support - **Modern Delphi**: Added full Delphi XE8 integration and compatibility - **Architecture Expansion**: Introduced both Delphi and ActiveX 64-bit (x64) implementations ## Version 8.3.1 - Compatibility Update ### Development Tools - **IDE Support**: Added complete Delphi XE7 compatibility and integration ## Version 8.3 - Performance Release ### Core Improvements - **Decoder Update**: Substantially improved FFMPEG decoder implementation - **Stability**: Fixed multiple bugs affecting reliability and performance ## Version 8.0 - Major Engine Upgrade ### Key Features - **Playback Architecture**: Implemented VLC engine for enhanced video/audio file playback capabilities - **Reliability**: Resolved several critical bugs affecting performance ## Version 7.15 - Security Features ### Media Protection - **Content Security**: Added encrypted video file playback functionality - **Stability**: Implemented minor bug fixes for improved reliability ## Version 7.2 - Effects & Performance ### Visual Enhancements - **FFMPEG Implementation**: Updated FFMPEG decoder for better format support - **Video Effects**: Added professional pan/zoom video effect capabilities - **Reliability**: Fixed minor bugs for improved stability ## Version 7.0 - Windows 8 & FFMPEG ### Platform Support - **Operating System**: Added full Windows 8 RTM support - **Media Handling**: Integrated comprehensive FFMPEG decoding capabilities - **Visual Effects**: Substantially improved video effects processing quality ## Version 6.0 - Windows 8 Preview ### Platform Expansion - **Early Adoption**: Added Windows 8 Developer Preview compatibility - **Visual Processing**: Enhanced quality and performance of video effects ## Version 3.4 - Maintenance Release ### Stability Improvements - **Bug Fixes**: Resolved multiple issues affecting reliability ## Version 3.3 - Delphi XE2 Support ### Developer Tools - **IDE Compatibility**: Added full Delphi XE2 support and integration - **Stability**: Implemented various bug fixes for improved reliability ## Version 3.2 - Effects & Demos ### Enhanced Capabilities - **Visual Effects**: Significantly improved video effects processing - **Developer Resources**: Added additional demo applications for easier implementation ## Version 3.1 - Effects Upgrade ### Visual Processing - **Effects Engine**: Enhanced video effects processing capabilities - **Stability**: Fixed multiple bugs for improved reliability ## Version 3.0 - Feature Expansion ### Major Enhancements - **Effects System**: Substantially improved effects filter functionality - **Streaming**: Added MMS / WMV stream playback support - **Video Analysis**: Implemented motion detection capabilities - **Compositing**: Added professional chroma-key functionality - **Core Performance**: Significantly improved underlying engine ## Version 2.2 - Effects Update ### Visual Processing - **Effects Quality**: Enhanced effects filter implementation for better visual results ## Version 2.1 - Initial Effects ### First Implementations - **Visual Processing**: Introduced initial effects filter capabilities ---END OF PAGE--- ## Deploy TVFVideoEdit in Delphi and ActiveX Applications **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/deployment/ **Description:** Deploy TVFVideoEdit in Delphi and ActiveX applications with automatic installers or manual setup for required components and dependencies. **Tags:** All-in-One Media Framework, Delphi, ActiveX, DirectShow, Windows, VCL, Encoding, Editing, IP Camera, MP4, WebM, H.264, AAC **API:** TVFVideoEdit # TVFVideoEdit Library Deployment Guide ## Introduction The TVFVideoEdit library provides powerful video editing capabilities for your Delphi and ActiveX applications. This guide explains how to properly deploy all necessary components to ensure your application functions correctly on end-user systems without requiring the full development framework. ## Deployment Options You have two primary methods for deploying the TVFVideoEdit library components: automatic installers or manual installation. Each approach has specific advantages depending on your distribution requirements. ### Automatic Silent Installers For streamlined deployment, we offer silent installer packages that handle all necessary component installation without user interaction: #### Required Base Package - **Base components** (always required): - [Delphi version](https://files.visioforge.com/redists_delphi/redist_video_edit_base_delphi.exe) - [ActiveX version](https://files.visioforge.com/redists_delphi/redist_video_edit_base_ax.exe) #### Optional Feature Packages - **FFMPEG package** (required for file and IP camera support (only for FFMPEG source engine)): - [x86 architecture](https://files.visioforge.com/redists_delphi/redist_video_edit_ffmpeg.exe) - **MP4 output package** (for MP4 video creation): - [x86 architecture](https://files.visioforge.com/redists_delphi/redist_video_edit_mp4.exe) ### Manual Installation Process For situations where you need precise control over component deployment, follow these detailed steps: 1. **Install Visual C++ Dependencies** 2. Install VC++ 2010 SP1 redistributable: - [x86 version](https://files.visioforge.com/shared/vcredist_2010_x86.exe) - [x64 version](https://files.visioforge.com/shared/vcredist_2010_x64.exe) 3. **Deploy Core Media Foundation Components** 4. Copy all MFP DLLs from the `Redist\Filters` directory to your application folder 5. **Register DirectShow Filters** 6. Copy and COM-register these essential DirectShow filters using [regsvr32.exe](https://support.microsoft.com/en-us/topic/how-to-use-the-regsvr32-tool-and-troubleshoot-regsvr32-error-messages-a98d960a-7392-e6fe-d90a-3f4e0cb543e5). 7. **Bitness:** the bare filename is the **x86 (32-bit)** filter; the matching **x64 (64-bit)** filter has the `_x64` suffix (for example `VisioForge_Video_Effects_Pro_x64.ax`). Both ship in the redistributable; deploy and register the variant that matches your application's target architecture. 64-bit applications must register the `_x64` variants. - `VisioForge_Audio_Effects_4.ax` - `VisioForge_Dump.ax` - `VisioForge_RGB2YUV.ax` - `VisioForge_Video_Effects_Pro.ax` - `VisioForge_Video_Mixer.ax` - `VisioForge_Video_Resize.ax` - `VisioForge_WavDest.ax` - `VisioForge_YUV2RGB.ax` - `VisioForge_FFMPEG_Source.ax` Screen-capture functionality (formerly delivered as `VisioForge_Screen_Capture.ax`) is now part of the base filters and does not require a separate registration step. 1. **Configure Path Settings** 2. Add the folder containing these filters to the system environment variable `PATH` if your application executable resides in a different directory ## Additional Components Installation ### FFMPEG Integration To enable advanced media format support: - Copy all files from the `Redist\FFMPEG` folder - Add this folder to the Windows system `PATH` variable - Register all .ax files from the `Redist\FFMPEG` folder ### VLC Support For extended format compatibility: - Copy all files from the `Redist\VLC` folder - COM-register the .ax file using regsvr32.exe - Create an environment variable named `VLC_PLUGIN_PATH` - Set its value to point to the `VLC\plugins` folder ### Audio Output Support For MP3 encoding capabilities: - Copy the lame.ax file from the `Redist\Formats` folder - Register the lame.ax file using regsvr32.exe ### WebM Format Support For WebM encoding and decoding: - Install the necessary free codecs available from the [xiph.org website](https://www.xiph.org/dshow/) ### Matroska Container Support For MKV format compatibility: - Install [Haali Matroska Splitter](https://haali.net/mkv/) for proper encoding and decoding ### MP4 H264/AAC Output - Modern Encoder For high-quality MP4 creation with modern codecs: - Copy `libmfxsw32.dll` / `libmfxsw64.dll` files - Register these DirectShow filters: - `VisioForge_H264_Encoder.ax` - `VisioForge_MP4_Muxer.ax` - `VisioForge_AAC_Encoder.ax` - `VisioForge_Video_Resize.ax` ### MP4 H264/AAC Output - Legacy Encoder For compatibility with older systems: - Copy `libmfxxp32.dll` / `libmfxxp64.dll` files - Register these DirectShow filters: - `VisioForge_H264_Encoder_XP.ax` - `VisioForge_MP4_Muxer_XP.ax` - `VisioForge_AAC_Encoder_XP.ax` - `VisioForge_Video_Resize.ax` ## Bulk Registration Utility To simplify the registration process for multiple DirectShow filters: - Place the `reg_special.exe` utility from the redistributable package into the folder containing your filters - Run it with administrator privileges to register all compatible filters in that directory ## Troubleshooting Tips Common issues during deployment often include: - Missing dependencies - Incorrect registration of COM components - Path configuration problems - Insufficient user permissions Ensure all required files are properly deployed and registered before launching your application. --- Please contact [our support team](https://support.visioforge.com/) if you encounter any issues with this deployment process. Visit our [GitHub repository](https://github.com/visioforge/) for additional code samples and implementation examples. ---END OF PAGE--- ## TVFVideoEdit - Video Editing SDK for Delphi and ActiveX **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/ **Description:** Build video editing software in Delphi with TVFVideoEdit - supporting multiple formats, effects, transitions, timeline editing, and encryption. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Editing **API:** TVFVideoEdit # TVFVideoEdit for Delphi / ActiveX Development ## Introduction to TVFVideoEdit The TVFVideoEdit library empowers Delphi developers to integrate sophisticated video editing functionality into their applications. This robust SDK provides a complete framework for handling diverse media operations while maintaining excellent performance and stability across projects of varying complexity. ## Core Capabilities ### Format Support TVFVideoEdit accommodates a wide array of video and audio formats, enabling seamless work with most industry-standard media types. This extensive compatibility ensures your application can process virtually any file users might import. ### Video Processing The library excels in fundamental video manipulation tasks, offering precise control over: - Resolution adjustment - Frame rate conversion - Aspect ratio modification - Color correction tools - Quality enhancement algorithms ### Effects and Transitions Enhance your application with: - Professional visual effects - Smooth transitions between clips - Custom animation capabilities - Real-time preview functionality - Text overlay with font control - Image compositing - Watermarking capabilities - Custom graphic insertion #### Audio Processing Create complete multimedia solutions with: - Volume normalization - Equalization tools - Audio effects application - Voice enhancement options ## Technical Advantages ### Output Flexibility Export finished projects in multiple formats with customizable quality settings to meet specific distribution requirements. ### Timeline Precision The timeline-based editing framework gives developers granular control over media positioning, transitions, and effects timing. ### Multi-Platform Compatibility Deploy your video editing solutions across different Windows environments with consistent performance and reliability. ### Distribution Rights TVFVideoEdit supports royalty-free distribution, making it a cost-effective solution for commercial software development. ## Resources for Developers Accelerate your development with these valuable resources: - [Product Information](https://www.visioforge.com/all-in-one-media-framework) - [API Documentation](https://api.visioforge.org/delphi/video_edit_sdk/index.html) - [Changelog](changelog/) - [Installation Guide](install/) - [Deployment Instructions](deployment/) - [License Agreement](../../eula/) ---END OF PAGE--- ## Install TVFVideoEdit ActiveX Control in C++ Builder **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/install/builder/ **Description:** Import and configure TVFVideoEdit ActiveX components in C++ Builder 5/6, 2006, and newer versions with package and control setup. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Editing **API:** TVFVideoEdit # Complete Guide to TVFVideoEdit Installation in C++ Builder > Related products: [VisioForge All-in-One Media Framework (Delphi / ActiveX)](https://www.visioforge.com/all-in-one-media-framework) ## Introduction to TVFVideoEdit for C++ Builder The TVFVideoEdit library provides powerful media processing capabilities for C++ Builder applications. This guide walks you through the installation process across different C++ Builder versions. Before you begin development, you'll need to properly install the ActiveX control into your IDE environment where it will be accessible through the component palette. ## Installation Process for Borland C++ Builder 5/6 ### Accessing the Import Menu Begin the installation process by navigating to the Component menu in your IDE: 1. Launch your Borland C++ Builder 5/6 environment 2. From the main menu, select **Component -> Import ActiveX Controls** ### Selecting the Video Edit Control In the Import ActiveX Control dialog: 1. Locate and select the **"VisioForge Video Edit Control"** from the available controls list 2. Click the **Install** button to begin the import process ### Confirming Installation The system will prompt you to confirm the installation: 1. A confirmation dialog will appear 2. Click the **Yes** button to proceed with the installation ### Verifying Successful Installation After installation completes: 1. The control will be added to your component palette 2. You can now use it in your C++ Builder projects ## Installation Guide for C++ Builder 2006 and Later Versions Modern versions of C++ Builder require a different installation approach using packages. ### Creating a New Package First, you'll need to create a package for the component: 1. Open C++ Builder 2006 or later 2. Select **File -> New -> Package** 3. This will create the foundation for adding the ActiveX control ### Importing the ActiveX Component Next, import the ActiveX control into your environment: 1. Navigate to **Component → Import Component** in the main menu 2. This opens the import wizard for adding new components ### Selecting Import Type In the import wizard: 1. Select the **Import ActiveX Control** radio button option 2. Click the **Next** button to proceed to component selection ### Choosing the Video Edit Control From the available ActiveX controls: 1. Find and select the **"VisioForge Video Edit Control"** from the list 2. Click **Next** to continue with the import process ### Configuring Output Location Specify where the component files should be stored: 1. Choose an appropriate package output folder for your development environment 2. Click **Next** to proceed with configuration ### Finalizing Component Import Complete the import process: 1. Select the **Add unit to…** radio button option 2. Click the **Finish** button to create the component wrapper ### Saving the Package Project After import completion: 1. The system will prompt you to save your package project 2. Choose an appropriate location and name for your package files ### Installing the Component Package To make the component available in the IDE: 1. Right-click on the package in the Project Manager 2. Select **Install** from the context menu 3. This compiles and registers the package with the IDE ### Verification and Usage Once installed: 1. The TVFVideoEdit control appears in your component palette 2. It's now ready to use in your C++ Builder applications 3. You can drag and drop it onto forms just like native components ## Additional Resources and Support ### Getting Help with Implementation If you encounter any issues during installation or implementation: 1. Our technical support team is available to assist 2. Contact [support](https://support.visioforge.com/) with specific questions 3. Provide details about your Builder version and installation environment ### Code Examples and Documentation To accelerate your development process: 1. Visit our [GitHub repository](https://github.com/visioforge/) for code samples 2. Find implementation examples for common media processing tasks 3. Access additional documentation on component features and usage ## Troubleshooting Common Installation Issues When installing the TVFVideoEdit component, developers may encounter several common issues: 1. **Missing Dependencies**: Ensure all required dependencies are installed 2. **Registration Problems**: Verify ActiveX registration status in Windows registry 3. **IDE Compatibility**: Check compatibility between component and Builder version 4. **Package Conflicts**: Resolve any conflicts with existing packages By following this detailed guide, you'll have TVFVideoEdit successfully integrated into your C++ Builder environment and ready for implementing advanced media functionality in your applications. ---END OF PAGE--- ## Install TVFVideoEdit in Delphi - Setup and Configuration **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/install/delphi/ **Description:** Install TVFVideoEdit packages in Delphi 6/7, 2005+, and 11+ with library paths, package building, and troubleshooting configuration. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Editing **API:** TVFVideoEdit # Install TVFVideoEdit in Delphi > Related products: [VisioForge All-in-One Media Framework (Delphi / ActiveX)](https://www.visioforge.com/all-in-one-media-framework) ## Installation Requirements Before beginning the installation process, ensure that you have: 1. Appropriate Delphi version installed and properly configured 2. Administrative rights for package installation 3. Downloaded the latest version of the TVFVideoEdit library ## Installing in Borland Delphi 6/7 ### Step 1: Configure Library Paths Begin by opening the "Options" window in your Delphi IDE. Navigate to the Library section and add the source directory to both the library and browser paths. This ensures that Delphi can locate the necessary files. ### Step 2: Open and Install the Package Locate and open the main package file from the library. Install the package by clicking the Install button in the IDE. This registers the components with Delphi's component palette. ### Architecture Considerations The library includes both x86 and x64 architecture versions. However, for Delphi 6/7, you must use the x86 version as these Delphi versions do not support 64-bit development. ## Installing in Delphi 2005 and Later ### Step 1: Launch with Administrative Privileges For Delphi 2005 and later versions, launch the IDE with administrative rights to ensure proper installation permissions. ### Step 2: Configure Library Paths Open the Options window and navigate to the Library section. Add the source directory to both the library and browser paths. ### Step 3: Install the Package Open the main package file from the library source directory. Click the Install button to register the components with Delphi's component palette. ### Architecture Support For Delphi 2005 and later versions, both x86 and x64 versions are available. You can utilize the 64-bit version if you need to develop 64-bit applications. Note that the IDE itself may require the x86 version for design-time operations. ## Installing in Delphi 11 and Later Modern Delphi versions feature a streamlined installation process: 1. Open the library `.dproj` package file located in the library folder after installation 2. Select the Release build configuration from the dropdown menu 3. Build and install the package using the IDE's build commands 4. The components will be registered and ready to use ## Project Configuration Best Practices You can install both x86 and x64 packages based on your project requirements. Ensure you've properly configured your application's library path settings: 1. Add the correct library folder path to your project options 2. Configure the path to properly locate `.dcu` files 3. Verify architecture compatibility between your project and the installed packages ## Troubleshooting Common Installation Issues If you encounter problems during installation, check these common issues: ### Delphi 64-bit Package Installation Problems Some specific issues can occur when installing 64-bit packages. See our [detailed troubleshooting guide](../../../general/install-64bit/) for solutions. ### Issues with .otares Files Installation problems related to `.otares` files are documented in our [dedicated troubleshooting page](../../../general/install-otares/). ## Additional Resources and Support For additional code examples and implementations, visit our [GitHub repository](https://github.com/visioforge/) where we maintain a collection of sample projects. If you need personalized assistance with installation or implementation, please contact our [technical support team](https://support.visioforge.com/) who can provide guidance specific to your development environment. --- For technical questions or installation assistance with this library, please reach out to our [development support team](https://support.visioforge.com/). Browse additional code samples and resources on our [GitHub](https://github.com/visioforge/) page. ---END OF PAGE--- ## Install TVFVideoEdit in Delphi, VB6, and C++ Builder **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/install/ **Description:** Install TVFVideoEdit library in Delphi and ActiveX-compatible IDEs including MFC, VB6, and C++ Builder with package and control setup. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Editing **API:** TVFVideoEdit # TVFVideoEdit library installation guide The library is available as a Delphi package exclusively for Delphi developers, offering tailored functionality and integration. Additionally, the ActiveX control version is versatile and can be used in MFC, VB6, or any other ActiveX-compatible IDEs, providing broad compatibility and flexibility for developers across different platforms. This ensures a robust and adaptable development experience regardless of your preferred environment. ## Installation 1. **Download the latest version of the All-in-One Media Framework**: Visit the [product page](https://www.visioforge.com/all-in-one-media-framework) and download the most recent version of the framework that is suitable for your needs. 2. **Run the setup file**: Once the download is complete, locate the setup file in your download directory and run it. This will start the installation process. 3. **Follow the installation wizard instructions**: The installation wizard will guide you through each step of the process. Carefully read and follow the prompts, accept the license agreement, select the installation directory, and continue by clicking the "Next" button. 4. **Completion**: After the installation is complete, navigate to the installation folder. Here, you will find various library samples and comprehensive documentation designed to assist you in getting started with integrating the library into your projects. ### Delphi packages installation For detailed instructions on installing the TVFVideoEdit packages in your Delphi IDE, please refer to the following [Delphi installation guide](delphi/). ### ActiveX installation #### C++ Builder For [C++ Builder](builder/), the installation process involves importing the ActiveX control into your project. This straightforward process ensures that you can quickly start using the TVFVideoEdit library in your C++ Builder projects. #### Visual Basic 6 In [Visual Basic 6](visual-basic-6/), open your project and go to the "Project" menu. Select "Components" item, then click "Browse" and find the ActiveX .ocx file in the installation folder. Add it to your project to make the components available in your toolbox. #### Visual Studio 2010 and later For [Visual Studio 2010 and newer](visual-studio/) versions, open your project in the IDE, right-click on the toolbox, and select "Choose Items". Navigate to the COM components tab, click "Browse", and select the ActiveX .ocx file from the framework's installation directory. This will add the components to your toolbox, allowing their use in your Visual Studio projects. ## Conclusion By following this detailed guide, you can successfully install and integrate the TVFVideoEdit library into your preferred development environment. If you encounter any issues or need further assistance, please refer to the documentation provided with the framework or contact our support team for help. ---END OF PAGE--- ## Install TVFVideoEdit ActiveX Control in Visual Basic 6 **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/install/visual-basic-6/ **Description:** Install TVFVideoEdit ActiveX control in Visual Basic 6 with x86 compatibility for video editing features in legacy applications. **Tags:** All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Editing **API:** TVFVideoEdit # Installing TVFVideoEdit ActiveX Control in Visual Basic 6 ## Introduction Visual Basic 6 remains a popular development environment for creating Windows applications. By leveraging our TVFVideoEdit library as an ActiveX control, developers can incorporate advanced video editing and processing capabilities into their VB6 applications without extensive coding. ## Technical Requirements and Limitations Microsoft Visual Basic 6 operates as a 32-bit development platform and cannot produce 64-bit applications. Due to this architectural constraint, only the x86 (32-bit) version of our library is compatible with VB6 projects. Despite this limitation, the 32-bit implementation delivers excellent performance and provides full access to the library's extensive feature set. ## Installation Process Follow these detailed steps to properly install the TVFVideoEdit ActiveX control in your Visual Basic 6 environment: ### Step 1: Create a New Project Begin by launching Visual Basic 6 and creating a new project: 1. Open Visual Basic 6 IDE 2. Select "New Project" from the File menu 3. Choose "Standard EXE" as the project type 4. Click "OK" to create the baseline project ### Step 2: Access Components Dialog Next, you need to register the ActiveX control within your development environment: 1. In the menu, navigate to "Project" 2. Select "Components" to open the components dialog ### Step 3: Select the TVFVideoEdit Control From the Components dialog: 1. Scroll through the available controls 2. Locate and check the box for "VisioForge Video Edit Control" 3. Click "OK" to confirm your selection ### Step 4: Verify Control Registration After successful registration: 1. The TVFVideoEdit control icon appears in your toolbox 2. This confirms the control is ready for use in your application ### Step 5: Implement the Control To begin using the control in your application: 1. Select the TVFVideoEdit control from the toolbox 2. Click and drag on your form to place an instance of the control 3. Size the control appropriately for your interface 4. Access properties and methods through the Properties window and code ## Advanced Implementation Tips - Set appropriate control properties before loading media files - Handle events for user interaction and processing notifications - Consider memory management when working with large video files - Test your application thoroughly with various media formats --- For technical questions or implementation challenges, contact our [support team](https://support.visioforge.com/). Access additional code examples and resources on our [GitHub repository](https://github.com/visioforge/). ---END OF PAGE--- ## Install TVFVideoEdit ActiveX Control in Visual Studio **URL:** https://www.visioforge.com/help/docs/delphi/videoedit/install/visual-studio/ **Description:** Install TVFVideoEdit ActiveX controls in Visual Studio 2010+ for C++, C#, and VB.NET projects with wrapper assembly configuration. **Tags:** Video Edit SDK, All-in-One Media Framework, Delphi, ActiveX, Windows, VCL, Editing **API:** TVFVideoEdit # Install TVFVideoEdit in Visual Studio ## Overview > Related products: [All-in-One Media Framework (Delphi / ActiveX)](https://www.visioforge.com/all-in-one-media-framework) TVFVideoEdit provides powerful video editing capabilities through ActiveX controls that integrate smoothly with various development environments. This guide walks you through the installation process specifically for Visual Studio 2010 and later versions. ## Compatibility Information The ActiveX control can be used directly in C++ projects without additional wrappers. For C# or VB.Net development, Visual Studio automatically creates a custom wrapper assembly that enables the ActiveX API in managed code environments. ## Prerequisites Before beginning the installation process, ensure you have: - Visual Studio 2010 or later installed on your development machine - Administrative privileges (required for ActiveX registration) - Both x86 and x64 ActiveX controls registered (Visual Studio might use x86 for the UI designer even when targeting x64) ## Step-by-Step Installation Guide ### Creating a New Project 1. Start Visual Studio and create a new project using C++, C#, or Visual Basic. 2. For this demonstration, we'll use a C# Windows Forms application, but the process applies similarly to VB.Net and C++ MFC projects. ### Adding the ActiveX Control to Your Toolbox 1. Right-click on the Toolbox panel in Visual Studio 2. Select the "Choose Items" option from the context menu that appears ### Selecting the Video Edit Control 1. In the Choose Toolbox Items dialog, locate the COM Components tab 2. Browse through the list or use the search functionality 3. Find and select the "VisioForge Video Edit Control" item 4. Click OK to add the control to your toolbox ### Implementing the Control in Your Form 1. Locate the newly added control in your toolbox 2. Click and drag it onto your form design surface 3. The control is now ready for implementation in your application ## Advanced Integration Options ### .NET Development Recommendations For developers working with .NET applications, we strongly recommend considering the native [.NET SDK](https://www.visioforge.com/video-edit-sdk-net) as an alternative to ActiveX integration. The .NET SDK offers several advantages: - Enhanced performance and stability - Native support for WinForms, WPF, and MAUI controls - Broader feature set and API capabilities - Simpler integration with modern development practices ## Troubleshooting Common Issues When integrating TVFVideoEdit, you might encounter these common challenges: - Registration issues: Ensure you have administrative privileges - Architecture mismatches: Verify both x86 and x64 versions are properly registered - Reference errors: Check that all required dependencies are included in your project ## Additional Resources If you encounter any difficulties following this tutorial or need specialized assistance with your implementation, our development team is available to provide technical guidance. - Access additional code samples on our [GitHub repository](https://github.com/visioforge/) - Contact our [technical support team](https://support.visioforge.com/) for personalized assistance ---END OF PAGE--- ## Register DirectShow Filters — regsvr32, C++, and C# Methods **URL:** https://www.visioforge.com/help/docs/directshow/deployment/filter-registration/ **Description:** Register VisioForge DirectShow filters using manual regsvr32, programmatic methods, and installer automation with troubleshooting tips. **Tags:** DirectShow, C++, Windows, Encoding, Mixing, MP4, H.264, AAC, C# **API:** FFMPEGSource, IBaseFilter # DirectShow Filter Registration Guide ## Overview DirectShow filters must be registered with Windows before they can be used in applications. This guide covers all registration methods for VisioForge DirectShow filters. --- ## Registration Methods ### Method 1: Automatic Registration (Installer) The recommended method for end-users is to use the official installer. **Available Installers**: - `visioforge_ffmpeg_source_filter_setup.exe` - FFMPEG Source Filter - `visioforge_vlc_source_filter_setup.exe` - VLC Source Filter - `visioforge_processing_filters_pack_setup.exe` - Processing Filters Pack - `visioforge_encoding_filters_pack_setup.exe` - Encoding Filters Pack - `visioforge_virtual_camera_sdk_setup.exe` - Virtual Camera SDK **Installation Steps**: 1. Run installer as Administrator 2. Follow installation wizard 3. Filters are automatically registered 4. No additional steps required --- ### Method 2: Manual Registration (regsvr32) For development and testing, you can manually register filters using Windows `regsvr32` utility. #### Registration Command ``` # Open Command Prompt as Administrator # Right-click Start → Command Prompt (Admin) # Register x86 (32-bit) filter regsvr32 "C:\Path\To\Filter.ax" # Register x64 (64-bit) filter regsvr32 "C:\Path\To\Filter_x64.ax" # Unregister filter regsvr32 /u "C:\Path\To\Filter.ax" ``` #### SDK-Specific Examples **FFMPEG Source Filter**: ``` # x86 regsvr32 "C:\Program Files (x86)\VisioForge\FFMPEG Source\VisioForge_FFMPEG_Source.ax" # x64 regsvr32 "C:\Program Files\VisioForge\FFMPEG Source\VisioForge_FFMPEG_Source_x64.ax" ``` **VLC Source Filter**: ``` # x86 only regsvr32 "C:\Program Files (x86)\VisioForge\VLC Source\VisioForge_VLC_Source.ax" ``` **Processing Filters Pack** (multiple filters): ``` # Video Effects regsvr32 "C:\Program Files\VisioForge\Processing Filters\VisioForge_Video_Effects_Pro.ax" regsvr32 "C:\Program Files\VisioForge\Processing Filters\VisioForge_Video_Effects_Pro_x64.ax" # Video Mixer regsvr32 "C:\Program Files\VisioForge\Processing Filters\VisioForge_Video_Mixer.ax" regsvr32 "C:\Program Files\VisioForge\Processing Filters\VisioForge_Video_Mixer_x64.ax" # Audio Enhancer regsvr32 "C:\Program Files\VisioForge\Processing Filters\VisioForge_Audio_Enhancer.ax" regsvr32 "C:\Program Files\VisioForge\Processing Filters\VisioForge_Audio_Enhancer_x64.ax" ``` **Encoding Filters Pack** (multiple filters): ``` # NVENC Encoder regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_NVENC.ax" regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_NVENC_x64.ax" # H.264 Encoder regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_H264_Encoder.ax" regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_H264_Encoder_x64.ax" # AAC Encoder regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_AAC_Encoder.ax" regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_AAC_Encoder_x64.ax" # MP4 Muxer regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_MP4_Muxer.ax" regsvr32 "C:\Program Files\VisioForge\Encoding Filters\VisioForge_MP4_Muxer_x64.ax" ``` **Virtual Camera SDK**: ``` # Virtual Camera Driver regsvr32 "C:\Program Files\VisioForge\Virtual Camera\VisioForge_Virtual_Camera.ax" regsvr32 "C:\Program Files\VisioForge\Virtual Camera\VisioForge_Virtual_Camera_x64.ax" # Push Source Filter regsvr32 "C:\Program Files\VisioForge\Virtual Camera\VisioForge_Push_Video_Source.ax" regsvr32 "C:\Program Files\VisioForge\Virtual Camera\VisioForge_Push_Video_Source_x64.ax" ``` --- ### Method 3: Programmatic Registration (C++) Register filters programmatically from your application code. #### Using LoadLibrary and DllRegisterServer ``` #include #include typedef HRESULT (STDAPICALLTYPE *LPFNDLLREGISTERSERVER)(); HRESULT RegisterFilter(const wchar_t* filterPath) { HMODULE hModule = LoadLibraryW(filterPath); if (!hModule) { DWORD error = GetLastError(); std::wcerr << L"Failed to load filter: " << filterPath << std::endl; std::wcerr << L"Error code: " << error << std::endl; return HRESULT_FROM_WIN32(error); } LPFNDLLREGISTERSERVER pfnDllRegisterServer = (LPFNDLLREGISTERSERVER)GetProcAddress(hModule, "DllRegisterServer"); if (!pfnDllRegisterServer) { FreeLibrary(hModule); return E_FAIL; } HRESULT hr = pfnDllRegisterServer(); FreeLibrary(hModule); if (SUCCEEDED(hr)) { std::wcout << L"Filter registered successfully: " << filterPath << std::endl; } else { std::wcerr << L"Registration failed with HRESULT: " << std::hex << hr << std::endl; } return hr; } HRESULT UnregisterFilter(const wchar_t* filterPath) { HMODULE hModule = LoadLibraryW(filterPath); if (!hModule) { return HRESULT_FROM_WIN32(GetLastError()); } typedef HRESULT (STDAPICALLTYPE *LPFNDLLUNREGISTERSERVER)(); LPFNDLLUNREGISTERSERVER pfnDllUnregisterServer = (LPFNDLLUNREGISTERSERVER)GetProcAddress(hModule, "DllUnregisterServer"); if (!pfnDllUnregisterServer) { FreeLibrary(hModule); return E_FAIL; } HRESULT hr = pfnDllUnregisterServer(); FreeLibrary(hModule); return hr; } // Usage int main() { const wchar_t* filterPath = L"C:\\Program Files\\VisioForge\\FFMPEG Source\\VisioForge_FFMPEG_Source_x64.ax"; HRESULT hr = RegisterFilter(filterPath); if (SUCCEEDED(hr)) { std::cout << "Filter registered successfully!" << std::endl; } else { std::cout << "Failed to register filter" << std::endl; } return 0; } ``` #### Using reg\_special.exe Utility VisioForge SDKs include a `reg_special.exe` utility for simplified registration: ``` #include #include HRESULT RegisterWithUtility(const wchar_t* filterPath) { // Build command line wchar_t cmdLine[MAX_PATH * 2]; swprintf_s(cmdLine, L"reg_special.exe /regserver \"%s\"", filterPath); // Execute registration utility SHELLEXECUTEINFO sei = { sizeof(sei) }; sei.lpVerb = L"runas"; // Run as administrator sei.lpFile = L"reg_special.exe"; sei.lpParameters = cmdLine; sei.nShow = SW_HIDE; sei.fMask = SEE_MASK_NOCLOSEPROCESS; if (!ShellExecuteEx(&sei)) { return HRESULT_FROM_WIN32(GetLastError()); } // Wait for completion WaitForSingleObject(sei.hProcess, INFINITE); DWORD exitCode; GetExitCodeProcess(sei.hProcess, &exitCode); CloseHandle(sei.hProcess); return (exitCode == 0) ? S_OK : E_FAIL; } ``` --- ### Method 4: Programmatic Registration (.NET/C#) Register filters from .NET applications using P/Invoke. ``` using System; using System.Runtime.InteropServices; using System.ComponentModel; public class FilterRegistration { [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] private static extern IntPtr LoadLibrary(string lpFileName); [DllImport("kernel32.dll", SetLastError = true)] private static extern bool FreeLibrary(IntPtr hModule); [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)] private static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int DllRegisterServerDelegate(); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int DllUnregisterServerDelegate(); public static void RegisterFilter(string filterPath) { IntPtr hModule = LoadLibrary(filterPath); if (hModule == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error(), $"Failed to load filter: {filterPath}"); } try { IntPtr procAddress = GetProcAddress(hModule, "DllRegisterServer"); if (procAddress == IntPtr.Zero) { throw new Exception("DllRegisterServer function not found"); } DllRegisterServerDelegate registerServer = Marshal.GetDelegateForFunctionPointer(procAddress); int result = registerServer(); if (result != 0) { throw new COMException($"Registration failed with HRESULT: 0x{result:X8}"); } Console.WriteLine($"Filter registered successfully: {filterPath}"); } finally { FreeLibrary(hModule); } } public static void UnregisterFilter(string filterPath) { IntPtr hModule = LoadLibrary(filterPath); if (hModule == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } try { IntPtr procAddress = GetProcAddress(hModule, "DllUnregisterServer"); if (procAddress == IntPtr.Zero) { throw new Exception("DllUnregisterServer function not found"); } DllUnregisterServerDelegate unregisterServer = Marshal.GetDelegateForFunctionPointer(procAddress); int result = unregisterServer(); if (result != 0) { throw new COMException($"Unregistration failed with HRESULT: 0x{result:X8}"); } Console.WriteLine($"Filter unregistered successfully: {filterPath}"); } finally { FreeLibrary(hModule); } } // Alternative: Use Process.Start with regsvr32 public static void RegisterFilterWithRegsvr32(string filterPath) { var startInfo = new System.Diagnostics.ProcessStartInfo { FileName = "regsvr32.exe", Arguments = $"/s \"{filterPath}\"", // /s = silent Verb = "runas", // Run as administrator UseShellExecute = true, CreateNoWindow = true }; using (var process = System.Diagnostics.Process.Start(startInfo)) { process.WaitForExit(); if (process.ExitCode != 0) { throw new Exception($"regsvr32 failed with exit code: {process.ExitCode}"); } } } } // Usage example class Program { static void Main(string[] args) { string filterPath = @"C:\Program Files\VisioForge\FFMPEG Source\VisioForge_FFMPEG_Source_x64.ax"; try { FilterRegistration.RegisterFilter(filterPath); Console.WriteLine("Filter registered successfully!"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } } ``` --- ## Registration Verification ### Method 1: Using GraphEdit/GraphStudioNext 1. Launch GraphEdit (Windows SDK) or GraphStudioNext 2. Click "Graph" → "Insert Filters" 3. Search for filter name (e.g., "FFMPEG Source", "VLC Source") 4. If filter appears in list, registration succeeded ### Method 2: Using Registry Editor ``` # Open Registry Editor regedit # Navigate to: HKEY_CLASSES_ROOT\CLSID\{GUID} # Example for FFMPEG Source: # HKEY_CLASSES_ROOT\CLSID\{1974D893-83E4-4F89-9908-795C524CC17E} ``` ### Method 3: Programmatic Verification (C++) ``` #include bool IsFilterRegistered(const CLSID& filterClsid) { IBaseFilter* pFilter = nullptr; HRESULT hr = CoCreateInstance(filterClsid, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pFilter); if (SUCCEEDED(hr) && pFilter) { pFilter->Release(); return true; } return false; } // Usage int main() { CoInitialize(NULL); // FFMPEG Source Filter CLSID CLSID ffmpegSourceClsid = { 0x1974D893, 0x83E4, 0x4F89, { 0x99, 0x08, 0x79, 0x5C, 0x52, 0x4C, 0xC1, 0x7E } }; if (IsFilterRegistered(ffmpegSourceClsid)) { std::cout << "FFMPEG Source filter is registered" << std::endl; } else { std::cout << "FFMPEG Source filter is NOT registered" << std::endl; } CoUninitialize(); return 0; } ``` ### Method 4: Programmatic Verification (.NET/C#) ## ``` using System; using System.Runtime.InteropServices; public static bool IsFilterRegistered(Guid clsid) { try { Type comType = Type.GetTypeFromCLSID(clsid, throwOnError: false); if (comType == null) return false; object instance = Activator.CreateInstance(comType); if (instance != null) { Marshal.ReleaseComObject(instance); return true; } } catch { return false; } return false; } // Usage Guid ffmpegSourceClsid = new Guid("1974D893-83E4-4F89-9908-795C524CC17E"); if (IsFilterRegistered(ffmpegSourceClsid)) { Console.WriteLine("FFMPEG Source filter is registered"); } ``` ## Troubleshooting ### Issue: "DllRegisterServer failed" or "Error 0x80004005" **Causes**: - Not running as Administrator - Missing dependencies (DLLs) - Wrong architecture (x86 vs x64) **Solutions**: 1. **Run as Administrator**: ``` # Right-click Command Prompt → Run as Administrator regsvr32 "C:\Path\To\Filter.ax" ``` 2. **Check Dependencies**: Use Dependency Walker or Dependencies.exe to check for missing DLLs: ``` # Download Dependencies from: https://github.com/lucasg/Dependencies Dependencies.exe "C:\Path\To\Filter.ax" ``` 3. **Verify Architecture**: ``` # For 32-bit application, register 32-bit filter regsvr32 "C:\Path\To\Filter.ax" # For 64-bit application, register 64-bit filter regsvr32 "C:\Path\To\Filter_x64.ax" ``` ### Issue: "The module was loaded but the entry-point was not found" **Cause**: File is not a valid DirectShow filter or is corrupted. **Solutions**: - Verify file integrity - Re-download or reinstall SDK - Check if file is a DirectShow filter (.ax extension) ### Issue: Filter registered but not found in applications **Causes**: - 32-bit/64-bit mismatch - Filter registered in wrong HKEY (per-user vs system-wide) **Solutions**: 1. **Match Application Architecture**: 2. 32-bit app needs 32-bit filter 3. 64-bit app needs 64-bit filter 4. **System-Wide Registration**: ``` # Run Command Prompt as Administrator # This registers system-wide (HKEY_LOCAL_MACHINE) regsvr32 "C:\Path\To\Filter.ax" ``` 5. **Check Both Registries**: 6. `HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID` 7. `HKEY_CURRENT_USER\SOFTWARE\Classes\CLSID` ### Issue: Access Denied **Cause**: Insufficient permissions. **Solution**: ``` # Always run as Administrator for filter registration # Right-click Command Prompt → Run as Administrator ``` ### Issue: Registration succeeds but filter doesn't work **Causes**: - Missing license key - Missing runtime dependencies - Incorrect installation path **Solutions**: 1. **Verify License**: 2. Check if trial license is expired 3. Ensure license key is properly activated 4. **Check Runtime Dependencies**: 5. FFMPEG Source: Requires FFmpeg DLLs (avcodec, avformat, etc.) 6. VLC Source: Requires VLC libraries (libvlc.dll, libvlccore.dll, plugins/) 7. NVENC: Requires NVIDIA GPU and drivers 8. Processing/Encoding: May require Visual C++ Redistributables 9. **Verify File Locations**: All dependent DLLs must be in same directory as .ax file or in system PATH. --- ## Registration-Free COM (Advanced) For xcopy deployment without registration, use registration-free COM with manifest files. ### Creating Manifest File **filter.manifest** (place next to .ax file): ``` ``` **application.exe.manifest** (place next to your .exe): ``` ``` **Limitations**: - More complex to set up - Requires manifest files - May not work with all DirectShow filters - System-registered filters take precedence --- ## Batch Registration Scripts ### Register All Filters (Batch Script) ``` @echo off echo Registering VisioForge DirectShow Filters... echo. REM Check for Administrator privileges net session >nul 2>&1 if %errorLevel% neq 0 ( echo ERROR: This script must be run as Administrator! pause exit /b 1 ) REM Set installation path set INSTALL_PATH=C:\Program Files\VisioForge REM Register FFMPEG Source echo Registering FFMPEG Source... regsvr32 /s "%INSTALL_PATH%\FFMPEG Source\VisioForge_FFMPEG_Source_x64.ax" if %errorLevel% equ 0 ( echo [OK] FFMPEG Source registered ) else ( echo [FAILED] FFMPEG Source registration failed ) REM Register VLC Source echo Registering VLC Source... regsvr32 /s "%INSTALL_PATH%\VLC Source\VisioForge_VLC_Source.ax" if %errorLevel% equ 0 ( echo [OK] VLC Source registered ) else ( echo [FAILED] VLC Source registration failed ) REM Register Processing Filters echo Registering Processing Filters... regsvr32 /s "%INSTALL_PATH%\Processing Filters\VisioForge_Video_Effects_Pro_x64.ax" regsvr32 /s "%INSTALL_PATH%\Processing Filters\VisioForge_Video_Mixer_x64.ax" regsvr32 /s "%INSTALL_PATH%\Processing Filters\VisioForge_Audio_Enhancer_x64.ax" echo [OK] Processing Filters registered REM Register Encoding Filters echo Registering Encoding Filters... regsvr32 /s "%INSTALL_PATH%\Encoding Filters\VisioForge_NVENC_x64.ax" regsvr32 /s "%INSTALL_PATH%\Encoding Filters\VisioForge_H264_Encoder_x64.ax" regsvr32 /s "%INSTALL_PATH%\Encoding Filters\VisioForge_AAC_Encoder_x64.ax" regsvr32 /s "%INSTALL_PATH%\Encoding Filters\VisioForge_MP4_Muxer_x64.ax" echo [OK] Encoding Filters registered echo. echo Registration complete! pause ``` ### Unregister All Filters ``` @echo off echo Unregistering VisioForge DirectShow Filters... echo. REM Check for Administrator privileges net session >nul 2>&1 if %errorLevel% neq 0 ( echo ERROR: This script must be run as Administrator! pause exit /b 1 ) set INSTALL_PATH=C:\Program Files\VisioForge REM Unregister all filters regsvr32 /s /u "%INSTALL_PATH%\FFMPEG Source\VisioForge_FFMPEG_Source_x64.ax" regsvr32 /s /u "%INSTALL_PATH%\VLC Source\VisioForge_VLC_Source.ax" regsvr32 /s /u "%INSTALL_PATH%\Processing Filters\VisioForge_Video_Effects_Pro_x64.ax" regsvr32 /s /u "%INSTALL_PATH%\Processing Filters\VisioForge_Video_Mixer_x64.ax" regsvr32 /s /u "%INSTALL_PATH%\Encoding Filters\VisioForge_NVENC_x64.ax" echo Unregistration complete! pause ``` --- ## See Also - [Redistributable Files](../redistributable-files/) - Complete file list for each SDK - [Installer Integration](../installer-integration/) - Creating custom installers - [Deployment Overview](../) - Main deployment guide ---END OF PAGE--- ## Deploy and Register DirectShow COM Filters on Windows **URL:** https://www.visioforge.com/help/docs/directshow/deployment/ **Description:** Deploy DirectShow filters with COM registration, WiX/NSIS/Inno Setup installer integration, redistributable files list, and troubleshooting tips. **Tags:** DirectShow, C++, Windows, Streaming # DirectShow SDKs - Deployment Guide ## Overview This comprehensive deployment guide covers everything you need to know about deploying VisioForge DirectShow SDKs in production environments. From filter registration to creating professional installers, this guide ensures your applications deploy smoothly. --- ## What's Covered ### Core Deployment Topics #### [Filter Registration](filter-registration/) Learn how to register DirectShow filters using multiple methods. **Topics**: - Manual registration with regsvr32 - Programmatic registration (C++, C#) - Batch scripts for automation - Verification techniques - Troubleshooting registration issues - Registration-free COM **When to Read**: Essential for all deployment scenarios --- #### [Redistributable Files](redistributable-files/) Complete reference of files to include in your deployment. **Topics**: - FFMPEG Source Filter files (~80-100MB) - VLC Source Filter files (~150-200MB) - Processing Filters Pack files (~20-180MB) - Encoding Filters Pack files (~40-300MB) - Virtual Camera SDK files (~15-35MB) - Dependencies and directory structures **When to Read**: Before creating installers or deployment packages --- #### [Installer Integration](installer-integration/) Create professional installers with WiX, NSIS, InstallShield, and Inno Setup. **Topics**: - WiX Toolset (MSI) - NSIS scripts - InstallShield projects - Inno Setup scripts - Custom actions for registration - Silent installation - Prerequisite bundling **When to Read**: When creating automated installation packages --- ## Quick Start ### Deployment Workflow Follow this recommended workflow for deploying DirectShow filters: ``` graph TD A[Identify Required SDKs] --> B[Collect Redistributable Files] B --> C[Choose Deployment Method] C --> D{Installation Method?} D -->|Manual| E[Create Batch Scripts] D -->|Installer| F[Create Installer Package] E --> G[Register Filters] F --> G G --> H[Test Deployment] H --> I{Works?} I -->|No| J[Troubleshoot] I -->|Yes| K[Deploy to Production] J --> H ``` ### Step-by-Step Quick Start #### Step 1: Identify Your SDKs Determine which SDKs your application uses: | SDK | Purpose | Key File | | --- | --- | --- | | **FFMPEG Source** | Media playback, streaming | VisioForge\_FFMPEG\_Source\_x64.ax | | **VLC Source** | Multi-track playback | VisioForge\_VLC\_Source.ax | | **Processing Filters** | Effects, mixing | VisioForge\_Video\_Effects\_Pro\_x64.ax | | **Encoding Filters** | Video encoding | VisioForge\_NVENC\_x64.ax | | **Virtual Camera** | Virtual devices | VisioForge\_Virtual\_Camera\_x64.ax | [View Complete File Lists →](redistributable-files/) --- #### Step 2: Collect Files Create deployment folder structure: ``` YourApp\ ├── YourApp.exe ├── YourApp.exe.config └── Filters\ ├── VisioForge_FFMPEG_Source_x64.ax ├── avcodec-58.dll ├── avformat-58.dll └── ... (other dependencies) ``` [View Directory Structures →](redistributable-files/#installation-directory-structure) --- #### Step 3: Choose Deployment Method | Method | Best For | Complexity | | --- | --- | --- | | **Batch Script** | Internal deployment, testing | Low | | **WiX (MSI)** | Enterprise, IT automation | Medium-High | | **NSIS** | Small installers, custom UI | Medium | | **InstallShield** | Commercial apps, advanced features | Medium | | **Inno Setup** | Simple installers, open-source | Low-Medium | [View Installer Comparisons →](#choosing-an-installer-technology) --- #### Step 4: Register Filters **Option A: Manual Registration (Development/Testing)** ``` @echo off cd /d "%~dp0Filters" regsvr32 /s VisioForge_FFMPEG_Source_x64.ax if %ERRORLEVEL% EQU 0 ( echo Registration successful ) else ( echo Registration failed ) ``` **Option B: Installer Custom Action (Production)** See [Installer Integration Guide](installer-integration/) for WiX, NSIS, and other examples. [View All Registration Methods →](filter-registration/) --- #### Step 5: Test Deployment **Verification Checklist**: - [ ] Install on clean test machine - [ ] Verify all files copied correctly - [ ] Check filter registration in registry - [ ] Test filter with GraphEdit/GraphStudioNext - [ ] Run application end-to-end test - [ ] Verify uninstall removes all components - [ ] Test on Windows 10 and Windows 11 - [ ] Test both x64 and x86 (if applicable) [View Testing Procedures →](#testing-deployments) --- ## Choosing an Installer Technology ### WiX Toolset **Pros**: - Industry-standard MSI format - Excellent for enterprise deployment - Group Policy support - Strong Windows Installer integration - Active community and documentation **Cons**: - XML-based syntax has learning curve - Requires compilation step - Less flexible UI than custom installers **Recommended For**: - Enterprise applications - IT-managed deployments - Applications requiring Group Policy deployment - Organizations with existing MSI infrastructure [View WiX Examples →](installer-integration/#wix-toolset-examples) --- ### NSIS **Pros**: - Very small installer size - Fast execution - Highly customizable UI - Simple scripting language - No external dependencies **Cons**: - Not MSI-based (may not suit all enterprises) - Less Windows Installer integration - Manual upgrade management **Recommended For**: - Consumer applications - Small to medium installers - Applications requiring custom UI - Portable application creation [View NSIS Examples →](installer-integration/#nsis-examples) --- ### InstallShield **Pros**: - Professional GUI designer - Comprehensive feature set - Visual Studio integration - Advanced prerequisite handling - Suite/bundle creation **Cons**: - Commercial license required (except Limited Edition) - Can be complex for simple installers - Larger learning curve **Recommended For**: - Commercial software products - Complex installation requirements - Professional installer appearance - Organizations with InstallShield expertise [View InstallShield Guide →](installer-integration/#installshield-integration) --- ### Inno Setup **Pros**: - Free and open-source - Easy to learn Pascal scripting - Good documentation - Unicode support - Active development **Cons**: - Not MSI-based - Fewer advanced features than commercial tools - Limited enterprise features **Recommended For**: - Open-source projects - Simple installers - Small applications - Budget-conscious deployments [View Inno Setup Examples →](installer-integration/#inno-setup-examples) --- ## Common Deployment Scenarios ### Scenario 1: Media Player Application **Requirements**: - FFMPEG Source Filter - Processing Filters (video effects) - User-friendly installer **Recommended Approach**: 1. Use **NSIS** or **Inno Setup** for consumer-friendly installer 2. Include Visual C++ Redistributable check 3. Register filters during installation 4. Create desktop shortcut 5. Associate media file types (optional) **Files to Deploy** (~100-150MB): - VisioForge\_FFMPEG\_Source\_x64.ax + FFmpeg DLLs - VisioForge\_Video\_Effects\_Pro\_x64.ax + dependencies [View Complete File List →](redistributable-files/#ffmpeg-source-filter) --- ### Scenario 2: Enterprise Video Processing **Requirements**: - FFMPEG Source + Encoding Filters - Silent installation support - MSI-based deployment - Group Policy deployment **Recommended Approach**: 1. Use **WiX Toolset** for MSI creation 2. Bundle Visual C++ Redistributable 3. Support silent installation parameters 4. Implement proper logging 5. Create deployment documentation **Example**: ``` msiexec /i EnterpriseVideoApp.msi /quiet /norestart /l*v install.log ``` [View WiX Bundle Examples →](installer-integration/#advanced-wix-self-extracting-bundle) --- ### Scenario 3: Virtual Camera Solution **Requirements**: - Virtual Camera SDK - Driver installation - System-level access **Recommended Approach**: 1. Use **WiX** or **InstallShield** for driver support 2. Require administrator privileges 3. Install virtual camera drivers 4. Register DirectShow filters 5. Provide clear installation instructions **Special Considerations**: - Drivers require digital signatures - May need system restart - Enhanced security warnings [View Virtual Camera Files →](redistributable-files/#virtual-camera-sdk) --- ### Scenario 4: Development SDK Redistribution **Requirements**: - Include filters with your SDK - Support both x86 and x64 - Flexible integration **Recommended Approach**: 1. Provide separate x86/x64 packages 2. Include registration batch scripts 3. Provide documentation for developers 4. Consider NuGet package distribution 5. Include header files and type libraries **Package Structure**: ``` YourSDK\ ├── bin\ │ ├── x86\ │ │ └── Filters\ │ └── x64\ │ └── Filters\ ├── docs\ ├── samples\ └── tools\ └── register_filters.bat ``` --- ## Prerequisites and Dependencies ### Visual C++ Redistributable **Required Version**: Visual C++ 2015-2022 Redistributable **Download Links**: - x64: - x86: **Detection Registry Keys**: ``` x64: HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64 x86: HKLM\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86 Value: "Installed" = 1 (DWORD) ``` **Installer Integration**: See [Bundling Dependencies](installer-integration/#bundling-dependencies) for WiX, NSIS, and other examples. --- ### .NET Requirements If your application uses .NET: - **.NET Framework 4.8** - For .NET Framework applications - **.NET 8.0 Runtime** - For modern .NET applications **Detection**: - .NET Framework: Check registry `HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full` - .NET 8.0: Check for `dotnet --list-runtimes` --- ### Hardware Requirements (Optional) For hardware acceleration features: | Feature | Requirement | | --- | --- | | **NVENC Encoding** | NVIDIA GPU (GTX 600+) | | **QuickSync** | Intel CPU with integrated graphics | | **DXVA Decoding** | DirectX 11 compatible GPU | Document hardware requirements in your installer or documentation. --- ## Testing Deployments ### Test Environment Setup Create isolated test environments: 1. **Clean Windows 10 VM** - Test on fresh installation 2. **Clean Windows 11 VM** - Test latest OS 3. **Minimal Installation** - No Visual Studio or dev tools 4. **Different User Accounts** - Test standard user vs. admin ### Testing Checklist #### Installation Testing - [ ] Installer runs without errors - [ ] All files copied to correct locations - [ ] Filters registered successfully - [ ] Start menu shortcuts created - [ ] Registry entries created - [ ] Prerequisites detected/installed - [ ] User can launch application - [ ] Application functions correctly #### Uninstallation Testing - [ ] Uninstaller runs without errors - [ ] All files removed - [ ] Filters unregistered - [ ] Registry entries cleaned - [ ] Start menu shortcuts removed - [ ] No orphaned files remain #### Upgrade Testing - [ ] Upgrade from previous version works - [ ] User data preserved - [ ] Settings maintained - [ ] Old filters replaced with new versions #### Silent Installation Testing ``` REM Install silently MyAppSetup.exe /S REM Verify installation reg query "HKLM\SOFTWARE\MyApp" /v InstallDir REM Uninstall silently "%ProgramFiles%\MyApp\Uninstall.exe" /S ``` ### Automated Testing Script ``` # PowerShell deployment test script param( [string]$InstallerPath, [string]$FilterCLSID ) Write-Host "Testing installation..." -ForegroundColor Cyan # Install Start-Process $InstallerPath -ArgumentList "/S" -Wait # Verify filter registration $regPath = "HKLM:\SOFTWARE\Classes\CLSID\$FilterCLSID" if (Test-Path $regPath) { Write-Host "✓ Filter registered" -ForegroundColor Green } else { Write-Host "✗ Filter NOT registered" -ForegroundColor Red Exit 1 } # Test with GraphEdit $graphEdit = "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\graphedt.exe" if (Test-Path $graphEdit) { Write-Host "✓ Testing with GraphEdit..." -ForegroundColor Cyan # Add GraphEdit automation here } # Uninstall $uninstaller = Get-ChildItem "C:\Program Files\MyApp\Uninstall.exe" -ErrorAction SilentlyContinue if ($uninstaller) { Start-Process $uninstaller.FullName -ArgumentList "/S" -Wait Write-Host "✓ Uninstall completed" -ForegroundColor Green } # Verify cleanup if (Test-Path $regPath) { Write-Host "✗ Filter still registered after uninstall" -ForegroundColor Red Exit 1 } else { Write-Host "✓ Filter unregistered successfully" -ForegroundColor Green } Write-Host "All tests passed!" -ForegroundColor Green ``` --- ## Architecture Considerations ### x86 vs x64 Deployment **x64 Applications**: - Use x64 filters only - Install to `C:\Program Files\YourApp` - Register in 64-bit registry view **x86 Applications**: - Use x86 filters only - Install to `C:\Program Files (x86)\YourApp` - Register in 32-bit registry view (regsvr32 handles automatically) **Mixed Applications**: - Include both x86 and x64 filters - Separate subdirectories: `Filters\x86` and `Filters\x64` - Conditional registration based on process architecture ### Registry Considerations **64-bit Windows Registry Views**: ``` HKLM\SOFTWARE\Classes\CLSID\{GUID} ← 64-bit view HKLM\SOFTWARE\Wow6432Node\Classes\CLSID\{GUID} ← 32-bit view ``` **Important**: regsvr32 automatically uses correct registry view: - `C:\Windows\System32\regsvr32.exe` → 64-bit registry - `C:\Windows\SysWOW64\regsvr32.exe` → 32-bit registry --- ## Security Considerations ### Code Signing **Recommended**: Sign all executables and installers with Authenticode certificate. ``` REM Sign installer with certificate signtool sign /f MyCert.pfx /p password /t https://timestamp.digicert.com MyAppSetup.exe ``` **Benefits**: - Removes SmartScreen warnings - Establishes trust with users - Required for kernel-mode drivers (Virtual Camera) ### Permission Requirements **Filter Registration Requires**: - Administrator privileges - Write access to HKLM registry - Write access to System32 (if registering there) **Best Practices**: - Always request elevation in installer manifest - Check privileges before registration - Provide clear error messages for permission issues ``` ``` --- ## Troubleshooting Common Issues ### Issue: Filter Registration Fails **Symptoms**: regsvr32 returns error, filter not in registry **Possible Causes**: 1. Missing dependencies (Visual C++ Runtime, DLLs) 2. Insufficient privileges 3. Corrupted filter file 4. Architecture mismatch **Solutions**: 1. Use Dependency Walker to check dependencies 2. Run installer as administrator 3. Verify file integrity (checksums) 4. Ensure x86 app uses x86 filter, x64 uses x64 filter [View Complete Troubleshooting →](filter-registration/#troubleshooting) --- ### Issue: Application Can't Find Filter **Symptoms**: Application fails to create filter graph, CLSID not found **Possible Causes**: 1. Filter not registered 2. Wrong CLSID used 3. 32-bit app looking for 64-bit filter **Solutions**: ``` // Verify filter registration programmatically HRESULT hr = CoCreateInstance(CLSID_FFMPEGSource, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pFilter); if (hr == REGDB_E_CLASSNOTREG) { // Filter not registered - prompt user } ``` --- ### Issue: Silent Installation Hangs **Symptoms**: Installer stops responding during silent install **Possible Causes**: 1. Waiting for user input 2. Reboot required 3. Prerequisite installation prompting **Solutions**: ``` # Add /norestart parameter msiexec /i MyApp.msi /quiet /norestart # NSIS: Check silent mode in script ${IfSilent} # Skip UI interactions ${EndIf} ``` --- ### Issue: Uninstall Leaves Files **Symptoms**: Application directory still exists after uninstall **Possible Causes**: 1. Files created after installation not tracked 2. Open file handles preventing deletion 3. Uninstall custom action not running **Solutions**: - Use Windows Installer RemoveFile table for dynamic files - Implement file cleanup in uninstall custom action - Ensure application not running during uninstall --- ## Best Practices Summary ### DO ✅ **Always** require administrator privileges for installation ✅ **Always** bundle or check for Visual C++ Redistributable ✅ **Always** test on clean machines before release ✅ **Always** implement proper uninstall ✅ **Always** log installation steps for troubleshooting ✅ **Always** verify filter registration after install ✅ **Do** support silent installation for enterprise deployments ✅ **Do** sign installers with Authenticode certificate ✅ **Do** provide clear error messages ✅ **Do** document system requirements ### DON'T ❌ **Never** register filters to System32 directory ❌ **Never** overwrite newer files with older versions ❌ **Never** fail installation if registration fails (warn instead) ❌ **Never** leave registry entries after uninstall ❌ **Never** require user to manually register filters ❌ **Don't** skip prerequisite checks ❌ **Don't** use hardcoded paths ❌ **Don't** forget to test upgrade scenarios ❌ **Don't** ignore HRESULT return values ❌ **Don't** deploy debug builds to production --- ## Deployment Checklist Use this checklist before releasing your installer: ### Pre-Release - [ ] All redistributable files identified - [ ] Correct architecture (x86/x64) selected - [ ] Dependencies documented - [ ] Installer created and tested - [ ] Silent installation tested - [ ] Uninstall tested completely - [ ] Code signing completed - [ ] Installation guide written - [ ] System requirements documented ### Testing - [ ] Tested on Windows 10 (21H2 or later) - [ ] Tested on Windows 11 - [ ] Tested on clean VM without dev tools - [ ] Tested with standard user account - [ ] Tested upgrade from previous version - [ ] Tested uninstall cleanup - [ ] Tested silent installation - [ ] Verified filter registration - [ ] Tested application functionality ### Documentation - [ ] Installation instructions written - [ ] Uninstallation instructions provided - [ ] Troubleshooting section included - [ ] System requirements listed - [ ] Support contact information provided --- ## Additional Resources ### Documentation - [Filter Registration Guide](filter-registration/) - Complete registration reference - [Redistributable Files](redistributable-files/) - All SDK files listed - [Installer Integration](installer-integration/) - WiX, NSIS, InstallShield examples ### External Resources - [DirectShow Registration (Microsoft)](https://learn.microsoft.com/en-us/windows/win32/directshow/how-to-register-directshow-filters) - [Windows Installer Best Practices](https://learn.microsoft.com/en-us/windows/win32/msi/windows-installer-best-practices) - [WiX Toolset](https://www.firegiant.com/wixtoolset/) - [NSIS](https://nsis.sourceforge.io/Main_Page) - [Inno Setup](https://jrsoftware.org/isinfo.php) ### Tools - **GraphEdit** - Filter testing (Windows SDK) - **GraphStudioNext** - Advanced filter testing - **Dependency Walker** - DLL dependency analysis - **Process Monitor** - Installation troubleshooting - **Registry Editor** - Registration verification --- ## Support For deployment assistance: 1. Check [Troubleshooting](#troubleshooting-common-issues) section 2. Review [Filter Registration](filter-registration/#troubleshooting) 3. Contact VisioForge support: [support@visioforge.com](mailto:support@visioforge.com) 4. Visit: ---END OF PAGE--- ## Deploy DirectShow Filters with WiX, NSIS, and Inno Setup **URL:** https://www.visioforge.com/help/docs/directshow/deployment/installer-integration/ **Description:** Step-by-step installer integration for VisioForge DirectShow filters. WiX, NSIS, Inno Setup, and InstallShield examples with COM registration custom actions. **Tags:** DirectShow, C++, Windows # Installer Integration Guide ## Overview This guide provides comprehensive instructions for integrating VisioForge DirectShow filters into Windows installers. It covers multiple installer technologies, custom actions for filter registration, dependency management, and best practices. --- ## Prerequisites Before creating an installer, ensure you understand: - [Redistributable Files](../redistributable-files/) - Files to include in installer - [Filter Registration](../filter-registration/) - Registration mechanisms - Target platform architecture (x86/x64) - Visual C++ Redistributable requirements --- ## Installer Technologies Overview ### WiX Toolset **Best For**: Enterprise applications, MSI-based deployments, IT automation **Advantages**: - XML-based declarative syntax - Native MSI support - Excellent Windows Installer integration - Group Policy deployment support - Active development and community **Requirements**: - WiX Toolset 3.x or 4.x - Visual Studio integration (optional) - .wixproj project files [View WiX Examples →](#wix-toolset-examples) --- ### NSIS (Nullsoft Scriptable Install System) **Best For**: Lightweight installers, custom UI, portable applications **Advantages**: - Small installer size - Highly customizable - Simple scripting language - No runtime dependencies - Fast execution **Requirements**: - NSIS 3.x compiler - .nsi script files [View NSIS Examples →](#nsis-examples) --- ### InstallShield **Best For**: Commercial applications, complex installations, advanced features **Advantages**: - Professional GUI designer - Built-in prerequisites detection - Multi-platform support - Suite/bundle creation - Visual Studio integration **Requirements**: - InstallShield Limited Edition (Visual Studio) or Professional - .ism project files [View InstallShield Guide →](#installshield-integration) --- ### Inno Setup **Best For**: Simple installers, small applications, freeware **Advantages**: - Free and open-source - Pascal scripting support - Unicode support - Good documentation - Active community **Requirements**: - Inno Setup 6.x compiler - .iss script files [View Inno Setup Examples →](#inno-setup-examples) --- ## WiX Toolset Examples ### Basic Filter Installation Create a complete WiX installer for a DirectShow filter with automatic registration. #### Product.wxs ``` NOT Installed Installed ``` #### Filters.wxs (Component Definition) ``` ``` #### VCRedist.wxs (Prerequisite Check) ``` ``` #### Building WiX Installer ``` # Using WiX 3.x command line candle.exe Product.wxs Filters.wxs VCRedist.wxs -ext WixUIExtension light.exe -out MyApp.msi Product.wixobj Filters.wixobj VCRedist.wixobj -ext WixUIExtension # Using WiX 4.x (newer syntax) wix build Product.wxs Filters.wxs VCRedist.wxs -ext WixToolset.UI.wixext -out MyApp.msi ``` --- ### Advanced WiX: Self-Extracting Bundle Create a bundle that includes Visual C++ Redistributable. #### Bundle.wxs ``` ``` Build bundle: ``` # WiX 3.x candle.exe Bundle.wxs -ext WixBalExtension light.exe -out MyAppSetup.exe Bundle.wixobj -ext WixBalExtension # WiX 4.x wix build Bundle.wxs -ext WixToolset.Bal.wixext -out MyAppSetup.exe ``` --- ### WiX: Custom C++ DLL for Registration For more control, create a custom action DLL. #### CustomActions.cpp ``` #include #include #include #pragma comment(lib, "msi.lib") // Forward declarations typedef HRESULT (STDAPICALLTYPE *LPFNDLLREGISTERSERVER)(); typedef HRESULT (STDAPICALLTYPE *LPFNDLLUNREGISTERSERVER)(); // Helper function to write to MSI log void LogMessage(MSIHANDLE hInstall, LPCTSTR message) { PMSIHANDLE hRecord = MsiCreateRecord(1); MsiRecordSetString(hRecord, 0, message); MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRecord); } // Custom action: Register DirectShow filters extern "C" __declspec(dllexport) UINT __stdcall RegisterDirectShowFilters(MSIHANDLE hInstall) { TCHAR installDir[MAX_PATH]; DWORD installDirSize = MAX_PATH; // Get INSTALLFOLDER property if (MsiGetProperty(hInstall, TEXT("INSTALLFOLDER"), installDir, &installDirSize) != ERROR_SUCCESS) { LogMessage(hInstall, TEXT("Failed to get INSTALLFOLDER property")); return ERROR_INSTALL_FAILURE; } LogMessage(hInstall, TEXT("Registering DirectShow filters...")); // Build path to filter TCHAR filterPath[MAX_PATH]; StringCchCopy(filterPath, MAX_PATH, installDir); StringCchCat(filterPath, MAX_PATH, TEXT("Filters\\VisioForge_FFMPEG_Source_x64.ax")); // Load filter DLL HMODULE hModule = LoadLibrary(filterPath); if (!hModule) { TCHAR errorMsg[512]; StringCchPrintf(errorMsg, 512, TEXT("Failed to load filter: %s (Error: %d)"), filterPath, GetLastError()); LogMessage(hInstall, errorMsg); return ERROR_INSTALL_FAILURE; } // Get DllRegisterServer function LPFNDLLREGISTERSERVER pfnRegister = (LPFNDLLREGISTERSERVER)GetProcAddress(hModule, "DllRegisterServer"); if (!pfnRegister) { LogMessage(hInstall, TEXT("DllRegisterServer not found in filter")); FreeLibrary(hModule); return ERROR_INSTALL_FAILURE; } // Register filter HRESULT hr = pfnRegister(); FreeLibrary(hModule); if (SUCCEEDED(hr)) { LogMessage(hInstall, TEXT("DirectShow filters registered successfully")); return ERROR_SUCCESS; } else { TCHAR errorMsg[256]; StringCchPrintf(errorMsg, 256, TEXT("Filter registration failed: HRESULT 0x%08X"), hr); LogMessage(hInstall, errorMsg); return ERROR_INSTALL_FAILURE; } } // Custom action: Unregister DirectShow filters extern "C" __declspec(dllexport) UINT __stdcall UnregisterDirectShowFilters(MSIHANDLE hInstall) { TCHAR installDir[MAX_PATH]; DWORD installDirSize = MAX_PATH; if (MsiGetProperty(hInstall, TEXT("INSTALLFOLDER"), installDir, &installDirSize) != ERROR_SUCCESS) { // Don't fail uninstall if we can't get the path return ERROR_SUCCESS; } LogMessage(hInstall, TEXT("Unregistering DirectShow filters...")); TCHAR filterPath[MAX_PATH]; StringCchCopy(filterPath, MAX_PATH, installDir); StringCchCat(filterPath, MAX_PATH, TEXT("Filters\\VisioForge_FFMPEG_Source_x64.ax")); HMODULE hModule = LoadLibrary(filterPath); if (!hModule) { // Filter may already be deleted, don't fail return ERROR_SUCCESS; } LPFNDLLUNREGISTERSERVER pfnUnregister = (LPFNDLLUNREGISTERSERVER)GetProcAddress(hModule, "DllUnregisterServer"); if (pfnUnregister) { pfnUnregister(); } FreeLibrary(hModule); LogMessage(hInstall, TEXT("DirectShow filters unregistered")); return ERROR_SUCCESS; } // DLL entry point BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID reserved) { return TRUE; } ``` #### CustomActions.wxs ``` NOT Installed Installed ``` --- ## NSIS Examples ### Basic NSIS Installer Create a complete NSIS installer script. #### Installer.nsi ``` ; MyApp Installer with DirectShow Filters ; NSIS 3.x script ;-------------------------------- ; Includes !include "MUI2.nsh" !include "x64.nsh" ;-------------------------------- ; General Name "MyApp" OutFile "MyAppSetup.exe" Unicode True ; Default installation folder InstallDir "$PROGRAMFILES64\MyApp" ; Get installation folder from registry if available InstallDirRegKey HKLM "Software\MyApp" "InstallDir" ; Request application privileges RequestExecutionLevel admin ;-------------------------------- ; Interface Settings !define MUI_ABORTWARNING !define MUI_ICON "installer.ico" !define MUI_UNICON "uninstaller.ico" ;-------------------------------- ; Pages !insertmacro MUI_PAGE_LICENSE "License.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ; Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ; Version Information VIProductVersion "1.0.0.0" VIAddVersionKey "ProductName" "MyApp" VIAddVersionKey "CompanyName" "Your Company" VIAddVersionKey "FileDescription" "MyApp Installer" VIAddVersionKey "FileVersion" "1.0.0.0" ;-------------------------------- ; Installer Sections Section "MyApp (required)" SecMain SectionIn RO ; Set output path SetOutPath "$INSTDIR" ; Install main application files File "MyApp.exe" File "MyApp.exe.config" ; Create Filters subdirectory CreateDirectory "$INSTDIR\Filters" SetOutPath "$INSTDIR\Filters" ; Install FFMPEG Source Filter File "Filters\VisioForge_FFMPEG_Source_x64.ax" File "Filters\avcodec-58.dll" File "Filters\avdevice-58.dll" File "Filters\avfilter-7.dll" File "Filters\avformat-58.dll" File "Filters\avutil-56.dll" File "Filters\swresample-3.dll" File "Filters\swscale-5.dll" ; Register DirectShow filter DetailPrint "Registering DirectShow filters..." ExecWait 'regsvr32 /s "$INSTDIR\Filters\VisioForge_FFMPEG_Source_x64.ax"' $0 ${If} $0 != 0 MessageBox MB_OK|MB_ICONEXCLAMATION "Filter registration failed. Code: $0" ${EndIf} ; Store installation folder WriteRegStr HKLM "Software\MyApp" "InstallDir" $INSTDIR ; Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" ; Create Start Menu shortcuts CreateDirectory "$SMPROGRAMS\MyApp" CreateShortcut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe" CreateShortcut "$SMPROGRAMS\MyApp\Uninstall.lnk" "$INSTDIR\Uninstall.exe" ; Add/Remove Programs entry WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "DisplayName" "MyApp" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "UninstallString" "$INSTDIR\Uninstall.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "DisplayIcon" "$INSTDIR\MyApp.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "Publisher" "Your Company" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "DisplayVersion" "1.0.0.0" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" "NoRepair" 1 SectionEnd ;-------------------------------- ; Optional Sections Section "VLC Source Filter" SecVLC SetOutPath "$INSTDIR\Filters" ; Install VLC Source filter File "Filters\VisioForge_VLC_Source.ax" File "Filters\libvlc.dll" File "Filters\libvlccore.dll" ; Install VLC plugins directory SetOutPath "$INSTDIR\Filters\plugins" File /r "Filters\plugins\*.*" ; Register VLC Source filter DetailPrint "Registering VLC Source filter..." ExecWait 'regsvr32 /s "$INSTDIR\Filters\VisioForge_VLC_Source.ax"' SectionEnd ;-------------------------------- ; Section Descriptions !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "Main application files and FFMPEG Source filter (required)" !insertmacro MUI_DESCRIPTION_TEXT ${SecVLC} "VLC Source filter for additional format support (optional)" !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ; Installer Functions Function .onInit ; Check if 64-bit Windows ${If} ${RunningX64} ; OK ${Else} MessageBox MB_OK|MB_ICONSTOP "This application requires 64-bit Windows." Abort ${EndIf} ; Check for Visual C++ Redistributable 2015-2022 ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed" ${If} $0 != 1 MessageBox MB_YESNO|MB_ICONQUESTION "Visual C++ 2015-2022 Redistributable (x64) is required.$\n$\nDownload and install now?" IDYES download IDNO skip download: ExecShell "open" "https://aka.ms/vs/17/release/vc_redist.x64.exe" Abort skip: ${EndIf} FunctionEnd ;-------------------------------- ; Uninstaller Section Section "Uninstall" ; Unregister filters DetailPrint "Unregistering DirectShow filters..." ExecWait 'regsvr32 /s /u "$INSTDIR\Filters\VisioForge_FFMPEG_Source_x64.ax"' ExecWait 'regsvr32 /s /u "$INSTDIR\Filters\VisioForge_VLC_Source.ax"' ; Remove files Delete "$INSTDIR\MyApp.exe" Delete "$INSTDIR\MyApp.exe.config" Delete "$INSTDIR\Uninstall.exe" ; Remove Filters directory Delete "$INSTDIR\Filters\*.ax" Delete "$INSTDIR\Filters\*.dll" RMDir /r "$INSTDIR\Filters\plugins" RMDir "$INSTDIR\Filters" ; Remove installation directory RMDir "$INSTDIR" ; Remove Start Menu shortcuts Delete "$SMPROGRAMS\MyApp\MyApp.lnk" Delete "$SMPROGRAMS\MyApp\Uninstall.lnk" RMDir "$SMPROGRAMS\MyApp" ; Remove registry keys DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp" DeleteRegKey HKLM "Software\MyApp" SectionEnd ``` #### Building NSIS Installer ## ``` # Compile with NSIS makensis.exe Installer.nsi # Or use NSIS compiler GUI # File > Load Script > Select Installer.nsi > Test Installer ``` ### NSIS: Silent Installation Support Add silent installation parameters. ``` ; Add to .onInit function ; Check for silent mode ${GetParameters} $R0 ${GetOptions} $R0 "/S" $0 ${IfNot} ${Errors} ; Silent mode - skip prerequisite checks Goto silent_mode ${EndIf} ; Normal checks here... silent_mode: ; Continue with installation ; For silent uninstall, add to uninstaller: ; Run with: Uninstall.exe /S ``` --- ### NSIS: Custom Plugin for Registration Create a custom NSIS plugin for more control. #### FilterRegistration.cpp (NSIS Plugin) ``` #include #include "pluginapi.h" typedef HRESULT (STDAPICALLTYPE *LPFNDLLREGISTERSERVER)(); // Register filter function extern "C" void __declspec(dllexport) RegisterFilter( HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra) { EXDLL_INIT(); // Pop filter path from stack TCHAR filterPath[MAX_PATH]; popstring(filterPath); // Load DLL HMODULE hModule = LoadLibrary(filterPath); if (!hModule) { pushstring(_T("ERROR")); return; } // Get registration function LPFNDLLREGISTERSERVER pfnRegister = (LPFNDLLREGISTERSERVER)GetProcAddress(hModule, "DllRegisterServer"); if (!pfnRegister) { FreeLibrary(hModule); pushstring(_T("ERROR")); return; } // Register HRESULT hr = pfnRegister(); FreeLibrary(hModule); pushstring(SUCCEEDED(hr) ? _T("OK") : _T("ERROR")); } BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { return TRUE; } ``` Usage in NSIS script: ``` ; Load plugin FilterRegistration::RegisterFilter "$INSTDIR\Filters\VisioForge_FFMPEG_Source_x64.ax" Pop $0 ${If} $0 == "ERROR" MessageBox MB_OK "Filter registration failed" ${EndIf} ``` --- ## InstallShield Integration ### Basic InstallShield Project Setup 1. **Create New Project**: 2. File > New Project 3. Select "Basic MSI Project" 4. Set project name and location 5. **Add Files**: 6. Application Files view 7. Add filter files to `[INSTALLDIR]\Filters` 8. Add application executables 9. **Add Custom Action**: #### Method 1: Using regsvr32 1. Go to **Behavior and Logic** > **Custom Actions** 2. Right-click **Install** > **New Custom Action** 3. Set properties: 4. Name: `Register DirectShow Filters` 5. Type: `Stored in the Directory Table` 6. Working Directory: `[INSTALLDIR]Filters` 7. Filename: `regsvr32.exe` 8. Command Line: `/s VisioForge_FFMPEG_Source_x64.ax` 9. Run: `Deferred Execution in System Context` 10. Condition: `NOT Installed` 11. For uninstall: 12. Name: `Unregister DirectShow Filters` 13. Command Line: `/s /u VisioForge_FFMPEG_Source_x64.ax` 14. Sequence: Before **RemoveFiles** 15. Condition: `Installed` #### Method 2: Using Custom DLL 1. Create C++ DLL with registration code (similar to WiX example above) 2. Add DLL to **Support Files** in InstallShield 3. Create custom action: 4. Type: `DLL from the installation` 5. DLL Name: `CustomActions.dll` 6. Function: `RegisterDirectShowFilters` ### InstallShield: Prerequisite Configuration 1. Go to **Redistributables** view 2. Add **Microsoft Visual C++ 2015-2022 Redistributable (x64)**: 3. Right-click > **Add Prerequisite** 4. Browse to `VC_redist.x64.exe` 5. Set: **Install Before This Application** --- ## Inno Setup Examples ### Basic Inno Setup Script #### Setup.iss ``` ; MyApp Setup Script for Inno Setup 6.x [Setup] AppName=MyApp AppVersion=1.0 DefaultDirName={autopf}\MyApp DefaultGroupName=MyApp UninstallDisplayIcon={app}\MyApp.exe Compression=lzma2 SolidCompression=yes OutputDir=Output OutputBaseFilename=MyAppSetup ArchitecturesInstallIn64BitMode=x64 PrivilegesRequired=admin MinVersion=10.0 [Files] ; Main application Source: "MyApp.exe"; DestDir: "{app}"; Flags: ignoreversion ; FFMPEG Source Filter Source: "Filters\VisioForge_FFMPEG_Source_x64.ax"; DestDir: "{app}\Filters"; Flags: ignoreversion regserver restartreplace uninsrestartdelete Source: "Filters\avcodec-58.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion Source: "Filters\avdevice-58.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion Source: "Filters\avfilter-7.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion Source: "Filters\avformat-58.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion Source: "Filters\avutil-56.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion Source: "Filters\swresample-3.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion Source: "Filters\swscale-5.dll"; DestDir: "{app}\Filters"; Flags: ignoreversion [Icons] Name: "{group}\MyApp"; Filename: "{app}\MyApp.exe" Name: "{group}\Uninstall MyApp"; Filename: "{uninstallexe}" [Run] ; Optionally launch application after install Filename: "{app}\MyApp.exe"; Description: "Launch MyApp"; Flags: nowait postinstall skipifsilent [Registry] Root: HKLM; Subkey: "Software\MyApp"; ValueType: string; ValueName: "InstallDir"; ValueData: "{app}"; Flags: uninsdeletekey [Code] // Check for Visual C++ Redistributable function InitializeSetup(): Boolean; var ResultCode: Integer; VCInstalled: Cardinal; begin Result := True; // Check if VC++ 2015-2022 is installed if not RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Installed', VCInstalled) or (VCInstalled <> 1) then begin if MsgBox('Visual C++ 2015-2022 Redistributable (x64) is required.' + #13#10 + 'Download and install now?', mbConfirmation, MB_YESNO) = IDYES then begin ShellExec('open', 'https://aka.ms/vs/17/release/vc_redist.x64.exe', '', '', SW_SHOW, ewNoWait, ResultCode); Result := False; // Abort installation end; end; end; ``` #### Advanced Inno Setup: Custom Registration ## ``` [Files] ; Don't use regserver flag - we'll register manually Source: "Filters\VisioForge_FFMPEG_Source_x64.ax"; DestDir: "{app}\Filters"; Flags: ignoreversion [Code] // Import Windows API functions function LoadLibrary(lpFileName: String): THandle; external 'LoadLibraryW@kernel32.dll stdcall'; function FreeLibrary(hModule: THandle): Boolean; external 'FreeLibrary@kernel32.dll stdcall'; function GetProcAddress(hModule: THandle; lpProcName: AnsiString): Longword; external 'GetProcAddress@kernel32.dll stdcall'; type TDllRegisterServer = function: HRESULT; // Register DirectShow filter function RegisterDirectShowFilter(FilterPath: String): Boolean; var hModule: THandle; DllRegisterServer: TDllRegisterServer; RegisterFunc: Longword; hr: HRESULT; begin Result := False; hModule := LoadLibrary(FilterPath); if hModule = 0 then begin Log('Failed to load filter: ' + FilterPath); Exit; end; try RegisterFunc := GetProcAddress(hModule, 'DllRegisterServer'); if RegisterFunc = 0 then begin Log('DllRegisterServer not found'); Exit; end; @DllRegisterServer := Pointer(RegisterFunc); hr := DllRegisterServer(); Result := Succeeded(hr); if Result then Log('Filter registered successfully') else Log('Filter registration failed: ' + IntToHex(hr, 8)); finally FreeLibrary(hModule); end; end; // Called after installation procedure CurStepChanged(CurStep: TSetupStep); var FilterPath: String; begin if CurStep = ssPostInstall then begin FilterPath := ExpandConstant('{app}\Filters\VisioForge_FFMPEG_Source_x64.ax'); if not RegisterDirectShowFilter(FilterPath) then begin MsgBox('Warning: DirectShow filter registration failed.' + #13#10 + 'You may need to register it manually.', mbError, MB_OK); end; end; end; // Called before uninstallation procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); var ResultCode: Integer; FilterPath: String; begin if CurUninstallStep = usUninstall then begin FilterPath := ExpandConstant('{app}\Filters\VisioForge_FFMPEG_Source_x64.ax'); // Unregister using regsvr32 Exec('regsvr32.exe', '/s /u "' + FilterPath + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); end; end; ``` ## Silent Installation ### Silent Installation Parameters #### MSI (WiX, InstallShield MSI) ``` # Silent install msiexec /i MyApp.msi /quiet /norestart # Silent install with log msiexec /i MyApp.msi /quiet /norestart /l*v install.log # Silent uninstall msiexec /x MyApp.msi /quiet /norestart # Silent install with custom install directory msiexec /i MyApp.msi /quiet INSTALLFOLDER="C:\CustomPath\MyApp" ``` #### NSIS ``` # Silent install MyAppSetup.exe /S # Silent install with custom directory MyAppSetup.exe /S /D=C:\CustomPath\MyApp # Silent uninstall Uninstall.exe /S ``` #### Inno Setup ``` # Silent install MyAppSetup.exe /SILENT # Very silent (no progress) MyAppSetup.exe /VERYSILENT # Silent with custom directory MyAppSetup.exe /SILENT /DIR="C:\CustomPath\MyApp" # Silent uninstall unins000.exe /SILENT ``` --- ## Bundling Dependencies ### Visual C++ Redistributable #### Option 1: Download Bootstrapper ``` ``` #### Option 2: Include Redistributable ``` ; NSIS Section "VC++ Redistributable" File "Prerequisites\VC_redist.x64.exe" ExecWait '"$INSTDIR\VC_redist.x64.exe" /install /quiet /norestart' Delete "$INSTDIR\VC_redist.x64.exe" SectionEnd ``` #### Option 3: Merge Modules (WiX) ## ``` ``` ## Best Practices ### Registration Timing 1. **Install Sequence**: ``` InstallFiles ↓ Register Filters (Custom Action) ↓ InstallFinalize ``` 1. **Uninstall Sequence**: ``` Unregister Filters (Custom Action) ↓ RemoveFiles ↓ UninstallFinalize ``` ### Error Handling **Always**: - Log registration attempts - Check HRESULT values - Provide user feedback on failure - Don't fail entire installation if registration fails - Allow manual registration post-install **Example error handling**: ``` HRESULT hr = RegisterFilter(filterPath); if (FAILED(hr)) { if (hr == REGDB_E_CLASSNOTREG) LogError("Class not registered - check dependencies"); else if (hr == E_ACCESSDENIED) LogError("Access denied - requires admin privileges"); else LogError("Registration failed with HRESULT: 0x%08X", hr); } ``` ### Rollback Support Ensure proper rollback if installation fails: ``` NOT Installed NOT Installed ``` ### Admin Privileges **Always require** admin/elevated privileges: ``` ``` ``` ; NSIS RequestExecutionLevel admin ``` ``` { Inno Setup } PrivilegesRequired=admin ``` ### Architecture Considerations ``` ``` ``` ; NSIS: Runtime architecture detection ${If} ${RunningX64} File "Filters\VisioForge_FFMPEG_Source_x64.ax" ${Else} File "Filters\VisioForge_FFMPEG_Source.ax" ${EndIf} ``` --- ## Testing Installation ### Manual Testing Checklist - [ ] Install on clean Windows 10/11 - [ ] Verify all files copied - [ ] Check filter registration (GraphEdit/GraphStudioNext) - [ ] Test application functionality - [ ] Uninstall completely - [ ] Verify no files remain - [ ] Check registry cleanup - [ ] Test upgrade scenario - [ ] Test repair functionality - [ ] Test silent installation - [ ] Test on different user accounts ### Automated Testing ## ``` # PowerShell test script $installerPath = ".\MyAppSetup.msi" $logPath = ".\install_test.log" # Install silently Start-Process msiexec.exe -ArgumentList "/i `"$installerPath`" /quiet /l*v `"$logPath`"" -Wait # Check if filter registered $filterCLSID = "{1974D893-83E4-4F89-9908-795C524CC17E}" $regPath = "HKLM:\SOFTWARE\Classes\CLSID\$filterCLSID" if (Test-Path $regPath) { Write-Host "Filter registered successfully" -ForegroundColor Green } else { Write-Host "Filter registration failed" -ForegroundColor Red Exit 1 } # Uninstall Start-Process msiexec.exe -ArgumentList "/x `"$installerPath`" /quiet" -Wait # Verify cleanup if (Test-Path $regPath) { Write-Host "Filter not unregistered" -ForegroundColor Red Exit 1 } else { Write-Host "Uninstall successful" -ForegroundColor Green } ``` ## Troubleshooting ### Common Issues #### Registration Fails with Access Denied **Cause**: Insufficient privileges **Solution**: ``` ``` #### Filter Works in Development but not After Install **Cause**: Missing dependencies or incorrect paths **Solution**: - Use Dependency Walker to check all DLL dependencies - Ensure all DLLs in same directory as filter - Check PATH environment variable #### Silent Install Hangs **Cause**: User interaction required **Solution**: ``` # Add /norestart parameter msiexec /i MyApp.msi /quiet /norestart ``` #### Uninstall Leaves Registry Entries **Cause**: Unregistration custom action not running **Solution**: ``` ``` --- ## See Also ### Documentation - [Filter Registration](../filter-registration/) - Manual registration methods - [Redistributable Files](../redistributable-files/) - Files to include in installer - [Deployment Overview](../) - Complete deployment guide ### External Resources - [WiX Toolset Documentation](https://docs.firegiant.com/wix/) - [NSIS Documentation](https://nsis.sourceforge.io/Docs/) - [Inno Setup Documentation](https://jrsoftware.org/ishelp/) - [Windows Installer (MSI) Documentation](https://learn.microsoft.com/en-us/windows/win32/Msi/windows-installer-portal) ---END OF PAGE--- ## DirectShow SDK Redistributable Files for Deployment **URL:** https://www.visioforge.com/help/docs/directshow/deployment/redistributable-files/ **Description:** Complete list of redistributable files for VisioForge DirectShow SDKs with dependencies, architecture files, and deployment requirements. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, Decoding, Mixing, Screen Capture, WebM, H.264, MP3 # DirectShow SDKs - Redistributable Files Reference ## Overview This document provides a complete list of files required to redistribute each DirectShow SDK with your application. All files must be included in your installer or deployment package. --- ## FFMPEG Source Filter ### Core Files #### x86 (32-bit) **Filter**: - `VisioForge_FFMPEG_Source.ax` - Main DirectShow filter **FFmpeg Libraries** (required): - `avcodec-58.dll` - Video/audio codec library - `avdevice-58.dll` - Device handling - `avfilter-7.dll` - Audio/video filtering - `avformat-58.dll` - Container format handling - `avutil-56.dll` - Utility functions - `swresample-3.dll` - Audio resampling - `swscale-5.dll` - Video scaling and color conversion **Total Size**: ~80-100 MB #### x64 (64-bit) **Filter**: - `VisioForge_FFMPEG_Source_x64.ax` - Main DirectShow filter (64-bit) **FFmpeg Libraries** (required): - `avcodec-58.dll` - 64-bit version - `avdevice-58.dll` - 64-bit version - `avfilter-7.dll` - 64-bit version - `avformat-58.dll` - 64-bit version - `avutil-56.dll` - 64-bit version - `swresample-3.dll` - 64-bit version - `swscale-5.dll` - 64-bit version **Total Size**: ~90-110 MB ### Installation Directory Structure ``` YourApp\ ├── VisioForge_FFMPEG_Source.ax (x86) ├── VisioForge_FFMPEG_Source_x64.ax (x64) ├── avcodec-58.dll ├── avdevice-58.dll ├── avfilter-7.dll ├── avformat-58.dll ├── avutil-56.dll ├── swresample-3.dll └── swscale-5.dll ``` ### License Files - `license.rtf` - SDK license agreement (include in installer) ### Dependencies - **Visual C++ Redistributable 2015-2022** (x86 or x64) - Download: https://aka.ms/vs/17/release/vc\_redist.x64.exe --- ## VLC Source Filter ### Core Files #### x86 (32-bit) Only **Filter**: - `VisioForge_VLC_Source.ax` - Main DirectShow filter **VLC Libraries** (required): - `libvlc.dll` - VLC core library - `libvlccore.dll` - VLC core functionality **VLC Plugins Directory** (required): - `plugins\` - Complete VLC plugins folder (~100+ plugin DLLs) - `plugins\access\` - Input protocols - `plugins\audio_filter\` - Audio processing - `plugins\audio_mixer\` - Audio mixing - `plugins\audio_output\` - Audio output - `plugins\codec\` - Codecs - `plugins\control\` - Control interfaces - `plugins\demux\` - Demultiplexers - `plugins\misc\` - Miscellaneous - `plugins\packetizer\` - Packetizers - `plugins\services_discovery\` - Service discovery - `plugins\stream_filter\` - Stream filters - `plugins\stream_out\` - Stream output - `plugins\text_renderer\` - Text rendering - `plugins\video_chroma\` - Color conversion - `plugins\video_filter\` - Video filters - `plugins\video_output\` - Video output - `plugins\visualization\` - Visualizations **VLC Data Directories**: - `locale\` - Localization files (optional, ~50+ language folders) - `lua\` - Lua scripts for playlists and extensions - `hrtfs\` - HRTF audio files - `dodeca_and_7channel_3DSL_HRTF.sofa` **Total Size**: ~150-200 MB (with all plugins and locales) ### Installation Directory Structure ``` YourApp\ ├── VisioForge_VLC_Source.ax ├── libvlc.dll ├── libvlccore.dll ├── plugins\ │ ├── access\ │ ├── audio_filter\ │ ├── codec\ │ └── ... (all plugin directories) ├── locale\ (optional) ├── lua\ └── hrtfs\ ``` ### License Files - `license.rtf` - SDK license agreement ### Dependencies - **Visual C++ Redistributable 2015-2022** (x86) ### Important Notes - **All VLC plugins must be included** - Missing plugins will cause playback failures for certain formats - **Maintain directory structure** - VLC expects plugins in `plugins\` subdirectory - **No x64 version** - VLC Source Filter is 32-bit only --- ## Processing Filters Pack ### Core Filters #### x86 (32-bit) **Video Processing**: - `VisioForge_Video_Effects_Pro.ax` - Video effects filter (35+ effects) - `VisioForge_Video_Mixer.ax` - Multi-source video mixer - `VisioForge_Screen_Capture_DD.ax` - DirectDraw screen capture **Audio Processing**: - `VisioForge_Audio_Enhancer.ax` - Audio enhancement filter - `VisioForge_Audio_Effects_4.ax` - Audio effects (optional) - `VisioForge_Audio_Mixer.ax` - Audio mixer **Base Filters** (required): - `VisioForge_BaseFilters.ax` - Core base filter library - `VisioForge_AsyncEx.ax` - Async file reader (optional) **Helper Libraries**: - `VisioForge_MFP.dll` - Media Foundation helper - `VisioForge_MFPX.dll` - Extended MF functions #### x64 (64-bit) **Video Processing**: - `VisioForge_Video_Effects_Pro_x64.ax` - `VisioForge_Video_Mixer_x64.ax` - `VisioForge_Screen_Capture_DD_x64.ax` **Audio Processing**: - `VisioForge_Audio_Enhancer_x64.ax` - `VisioForge_Audio_Mixer_x64.ax` **Base Filters** (required): - `VisioForge_BaseFilters_x64.ax` - `VisioForge_AsyncEx_x64.ax` (optional) **Helper Libraries**: - `VisioForge_MFP64.dll` - `VisioForge_MFPX64.dll` ### LAV Filters (Optional but Recommended) LAV Filters provide additional codec support and are included with Processing Filters Pack. #### x86 **LAV Filters**: - `LAVSplitter.ax` - Source splitter - `LAVVideo.ax` - Video decoder - `LAVAudio.ax` - Audio decoder **FFmpeg Libraries for LAV**: - `avcodec-lav-58.dll` - `avformat-lav-58.dll` - `avfilter-lav-7.dll` - `avresample-lav-4.dll` - `avutil-lav-56.dll` - `swscale-lav-5.dll` **Additional Libraries**: - `libbluray.dll` - Blu-ray support - `IntelQuickSyncDecoder.dll` - Intel QuickSync hardware decoding **Manifest**: - `LAVFilters.Dependencies.manifest` **License**: - `COPYING` - LAV Filters license (LGPL) #### x64 Same files as x86 but 64-bit versions. ### Installation Directory Structure ``` YourApp\ ├── Filters\ │ ├── VisioForge_Video_Effects_Pro.ax │ ├── VisioForge_Video_Effects_Pro_x64.ax │ ├── VisioForge_Video_Mixer.ax │ ├── VisioForge_Video_Mixer_x64.ax │ ├── VisioForge_Audio_Enhancer.ax │ ├── VisioForge_Audio_Enhancer_x64.ax │ ├── VisioForge_BaseFilters.ax │ ├── VisioForge_BaseFilters_x64.ax │ ├── VisioForge_MFP.dll │ ├── VisioForge_MFP64.dll │ ├── VisioForge_MFPX.dll │ └── VisioForge_MFPX64.dll └── LAV\ ├── x86\ │ ├── LAVSplitter.ax │ ├── LAVVideo.ax │ ├── LAVAudio.ax │ ├── avcodec-lav-58.dll │ └── ... (other LAV files) └── x64\ ├── LAVSplitter.ax ├── LAVVideo.ax └── ... (other LAV files) ``` ### License Files - `license.rtf` - VisioForge SDK license - `VisioForge_AsyncEx_license.htm` - Async filter license - `VisioForge_Audio_Effects_4_note.txt` - Audio effects notes - `COPYING` - LAV Filters license (in LAV directory) ### Total Size - **Without LAV Filters**: ~20-30 MB - **With LAV Filters**: ~80-100 MB --- ## Encoding Filters Pack ### Core Filters #### x86 (32-bit) **Video Encoders**: - `VisioForge_NVENC.ax` - NVIDIA hardware encoder - `VisioForge_H264_Encoder.ax` - H.264 software encoder - `VisioForge_H264_Encoder_v9.ax` - H.264 encoder v9 - `VisioForge_H264_Decoder.ax` - H.264 decoder - `VisioForge_WebM_VP8_Encoder.ax` - VP8 encoder - `VisioForge_WebM_VP9_Encoder.ax` - VP9 encoder (in x64) - `VisioForge_WebM_VP8_Decoder.ax` - VP8 decoder - `VisioForge_WebM_VP9_Decoder.ax` - VP9 decoder **Audio Encoders**: - `VisioForge_AAC_Encoder.ax` - AAC encoder - `VisioForge_AAC_Encoder_v10.ax` - AAC encoder v10 - `VisioForge_LAME.ax` - MP3 encoder (LAME) - `VisioForge_WebM_Vorbis_Encoder.ax` - Vorbis encoder - `VisioForge_WebM_Vorbis_Decoder.ax` - Vorbis decoder **Muxers/Demuxers**: - `VisioForge_MP4_Muxer.ax` - MP4 container muxer - `VisioForge_MP4_Muxer_v10.ax` - MP4 muxer v10 - `VisioForge_MF_Mux.ax` - Media Foundation muxer - `VisioForge_WebM_Mux.ax` - WebM muxer - `VisioForge_WebM_Split.ax` - WebM splitter - `VisioForge_WebM_Source.ax` - WebM source - `VisioForge_WebM_Ogg_Source.ax` - Ogg source - `VisioForge_SSF_Muxer.ax` - SSF muxer **Network**: - `VisioForge_RTSP_Sink.ax` - RTSP sink - `VisioForge_RTSP_Source_Live555.ax` - RTSP source **Base Filters** (required): - `VisioForge_BaseFilters.ax` **Helper Libraries** (required): - `VisioForge_MFP.dll` - Media Foundation helper - `VisioForge_MFP64.dll` - 64-bit MF helper - `VisioForge_MFPX.dll` - Extended MF functions - `VisioForge_MFPX64.dll` - 64-bit extended MF - `VisioForge_MFT.dll` - Media Foundation Transform **Intel QuickSync** (optional): - `libmfxsw32.dll` - QuickSync software library - `libmfxxp32.dll` - QuickSync XP library #### x64 (64-bit) **Video Encoders**: - `VisioForge_NVENC_x64.ax` - `VisioForge_H264_Encoder_x64.ax` - `VisioForge_H264_Encoder_v9_x64.ax` - `VisioForge_H264_Decoder_x64.ax` - `VisioForge_WebM_VP8_Encoder_x64.ax` - `VisioForge_WebM_VP9_Encoder_x64.ax` - `VisioForge_WebM_VP8_Decoder_x64.ax` - `VisioForge_WebM_VP9_Decoder_x64.ax` **Audio Encoders**: - `VisioForge_AAC_Encoder_x64.ax` - `VisioForge_AAC_Encoder_v10_x64.ax` - `VisioForge_LAME_x64.ax` - `VisioForge_WebM_Vorbis_Encoder_x64.ax` - `VisioForge_WebM_Vorbis_Decoder_x64.ax` **Muxers/Demuxers**: - `VisioForge_MP4_Muxer_x64.ax` - `VisioForge_MP4_Muxer_v10_x64.ax` - `VisioForge_MF_Mux_x64.ax` - `VisioForge_WebM_Mux_x64.ax` - `VisioForge_WebM_Split_x64.ax` - `VisioForge_WebM_Source_x64.ax` - `VisioForge_WebM_Ogg_Source_x64.ax` - `VisioForge_SSF_Muxer_x64.ax` **Network**: - `VisioForge_RTSP_Sink_x64.ax` - `VisioForge_RTSP_Sink_X_x64.ax` - `VisioForge_RTSP_Source_Live555_x64.ax` **Base Filters** (required): - `VisioForge_BaseFilters_x64.ax` **Helper Libraries** (same as x86): - `VisioForge_MFP64.dll` - `VisioForge_MFPX64.dll` - `VisioForge_MFT64.dll` **Intel QuickSync** (optional): - `libmfxsw64.dll` - `libmfxxp64.dll` ### FFMPEG Encoder The FFMPEG Encoder has its own set of FFmpeg libraries: #### x86 **Filter**: - `VisioForge_FFMPEG_Encoder.ax` **FFmpeg Libraries**: - `avcodec-58.dll` - `avdevice-58.dll` - `avfilter-7.dll` - `avformat-58.dll` - `avutil-56.dll` - `swresample-3.dll` - `swscale-5.dll` - `ffmedia.dll` - VisioForge FFmpeg wrapper **Info**: - `vfffmpeg_info.txt` - FFmpeg build information #### x64 Same files as x86 but 64-bit versions. ### Installation Directory Structure ``` YourApp\ ├── Filters\ │ ├── VisioForge_NVENC.ax │ ├── VisioForge_NVENC_x64.ax │ ├── VisioForge_H264_Encoder.ax │ ├── VisioForge_H264_Encoder_x64.ax │ ├── VisioForge_AAC_Encoder.ax │ ├── VisioForge_AAC_Encoder_x64.ax │ ├── VisioForge_MP4_Muxer.ax │ ├── VisioForge_MP4_Muxer_x64.ax │ ├── VisioForge_BaseFilters.ax │ ├── VisioForge_BaseFilters_x64.ax │ ├── VisioForge_MFP.dll │ ├── VisioForge_MFP64.dll │ ├── VisioForge_MFPX.dll │ ├── VisioForge_MFPX64.dll │ ├── VisioForge_MFT.dll │ ├── VisioForge_MFT64.dll │ ├── libmfxsw32.dll (QuickSync) │ ├── libmfxsw64.dll (QuickSync) │ └── ... (other filters) └── FFMPEG\ ├── x86\ │ ├── VisioForge_FFMPEG_Encoder.ax │ ├── avcodec-58.dll │ ├── avformat-58.dll │ ├── ffmedia.dll │ └── ... (other FFmpeg DLLs) └── x64\ ├── VisioForge_FFMPEG_Encoder_x64.ax └── ... (FFmpeg DLLs) ``` ### License Files - `license.rtf` - SDK license ### Total Size - **Core Filters Only**: ~40-60 MB - **With FFMPEG Encoder**: ~120-150 MB - **Complete Pack**: ~150-180 MB ### Hardware Requirements - **NVENC**: Requires NVIDIA GPU (GeForce GTX 600+ or Quadro K+) and drivers - **QuickSync**: Requires Intel CPU with integrated graphics (4th gen+) --- ## Virtual Camera SDK ### Core Files #### x86 (32-bit) **Virtual Camera Drivers**: - `VisioForge_Virtual_Camera.ax` - Virtual camera device driver - `VisioForge_Virtual_Audio_Card.ax` - Virtual audio device driver **Source Filters**: - `VisioForge_Push_Video_Source.ax` - Push source for streaming to virtual camera - `VisioForge_Screen_Capture_DD.ax` - DirectDraw screen capture **Processing** (included): - `VisioForge_Video_Effects_Pro.ax` - Video effects **Base Filters** (required): - `VisioForge_BaseFilters.ax` **Helper Libraries** (required): - `VisioForge_MFP.dll` - `VisioForge_MFPX.dll` **Runtime** (required): - `vcomp140.dll` - Visual C++ OpenMP runtime #### x64 (64-bit) **Virtual Camera Drivers**: - `VisioForge_Virtual_Camera_x64.ax` - `VisioForge_Virtual_Audio_Card_x64.ax` **Source Filters**: - `VisioForge_Push_Video_Source_x64.ax` - `VisioForge_Screen_Capture_DD_x64.ax` **Processing**: - `VisioForge_Video_Effects_Pro_x64.ax` **Base Filters** (required): - `VisioForge_BaseFilters_x64.ax` **Helper Libraries** (required): - `VisioForge_MFP64.dll` - `VisioForge_MFPX64.dll` ### Installation Directory Structure ``` YourApp\ ├── VisioForge_Virtual_Camera.ax ├── VisioForge_Virtual_Camera_x64.ax ├── VisioForge_Virtual_Audio_Card.ax ├── VisioForge_Virtual_Audio_Card_x64.ax ├── VisioForge_Push_Video_Source.ax ├── VisioForge_Push_Video_Source_x64.ax ├── VisioForge_Screen_Capture_DD.ax ├── VisioForge_Screen_Capture_DD_x64.ax ├── VisioForge_Video_Effects_Pro.ax ├── VisioForge_Video_Effects_Pro_x64.ax ├── VisioForge_BaseFilters.ax ├── VisioForge_BaseFilters_x64.ax ├── VisioForge_MFP.dll ├── VisioForge_MFP64.dll ├── VisioForge_MFPX.dll ├── VisioForge_MFPX64.dll └── vcomp140.dll ``` ### License Files - `license.rtf` - SDK license ### Total Size ~15-20 MB ### Important Notes - Virtual camera devices appear in video conferencing apps (Zoom, Teams, Skype, etc.) - Supports up to 4 virtual camera instances - Requires driver installation (included in installer) --- ## Common Dependencies ### Visual C++ Redistributables All SDKs require Visual C++ Redistributable 2015-2022. **Download Links**: - x86: https://aka.ms/vs/17/release/vc\_redist.x86.exe - x64: https://aka.ms/vs/17/release/vc\_redist.x64.exe **Installation Check** (programmatic): ``` // Check if VC++ Redistributable is installed bool IsVCRedistInstalled() { HKEY hKey; LONG result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", 0, KEY_READ, &hKey); if (result == ERROR_SUCCESS) { RegCloseKey(hKey); return true; } return false; } ``` ### Registration Utility All SDKs include: - `reg_special.exe` - Custom registration utility This tool can be used instead of `regsvr32` for filter registration. --- ## Deployment Checklist ### Minimum Required Files For each SDK, you must include: 1. ✅ **Filter Files** - All .ax files for your architecture (x86/x64) 2. ✅ **Base Filters** - VisioForge\_BaseFilters.ax (if required by SDK) 3. ✅ **Helper DLLs** - VisioForge\_MFP*.dll, VisioForge\_MFPX*.dll 4. ✅ **Dependencies** - FFmpeg DLLs, VLC libraries, etc. 5. ✅ **License File** - license.rtf (display in installer) 6. ✅ **VC++ Redistributable** - Bundle or download in installer ### Optional Files - 📄 **LAV Filters** - Enhanced codec support (Processing Filters Pack) - 📄 **QuickSync DLLs** - Intel hardware encoding (Encoding Filters Pack) - 📄 **VLC Locale** - Multi-language support (VLC Source) - 📄 **Registration Utility** - reg\_special.exe (alternative to regsvr32) ### Architecture Considerations **32-bit Application**: - Include only x86 (.ax) files - No need for x64 versions **64-bit Application**: - Include only x64 (\_x64.ax) files - No need for x86 versions **AnyCPU/.NET Application**: - Include both x86 and x64 versions - Register both during installation - Application will use appropriate architecture at runtime --- ## File Size Summary | SDK | Minimum Size | With All Options | | --- | --- | --- | | **FFMPEG Source** | ~80 MB (x86) | ~190 MB (both arch) | | **VLC Source** | ~150 MB | ~200 MB (with locales) | | **Processing Filters** | ~20 MB | ~180 MB (with LAV) | | **Encoding Filters** | ~40 MB | ~300 MB (complete) | | **Virtual Camera** | ~15 MB | ~35 MB (both arch) | --- ## Testing Deployment Package Before releasing, verify all files are included: ``` @echo off echo Testing Filter Registration... REM Test each filter regsvr32 /s "VisioForge_FFMPEG_Source_x64.ax" if %errorLevel% neq 0 ( echo ERROR: FFMPEG Source failed to register echo Check if all FFmpeg DLLs are present exit /b 1 ) REM Test filter creation YourTestApp.exe echo All filters registered successfully! ``` --- ## See Also - [Filter Registration](../filter-registration/) - How to register filters - [Installer Integration](../installer-integration/) - Creating installers - [Deployment Overview](../) - Main deployment guide ---END OF PAGE--- ## FFmpeg Source Filter DirectShow Examples - C++, C#, VB.NET **URL:** https://www.visioforge.com/help/docs/directshow/ffmpeg-source-filters/examples/ **Description:** Build DirectShow graphs with FFmpeg Source Filter — file playback, hardware decoding, network streaming, and custom buffering in C++, C#, and VB.NET. **Tags:** DirectShow, C++, Windows, WinForms, Playback, Streaming, Decoding, RTSP, HLS, MP4, MKV, AVI, MOV, C#, VB.NET **API:** IFileSourceFilter, IFFMPEGSourceSettings, IBaseFilter, IVFRegister # Code Examples ## Overview This page provides practical code examples for using the FFMPEG Source Filter in DirectShow applications. Examples are provided in C++, C#, and VB.NET. ## Complete Working Samples **Official GitHub Repository**: All examples shown on this page are available as complete, working Visual Studio projects in our GitHub samples repository: 🔗 **[DirectShow Samples Repository](https://github.com/visioforge/directshow-samples)** ### FFMPEG Source Filter Samples - **[C# Sample](https://github.com/visioforge/directshow-samples/tree/master/FFMPEG%20Source%20Filter/dotnet/cs)** - Full-featured media player with all filter capabilities - **[VB.NET Sample](https://github.com/visioforge/directshow-samples/tree/master/FFMPEG%20Source%20Filter/dotnet/vbnet)** - VB.NET implementation - **[C++Builder Sample](https://github.com/visioforge/directshow-samples/tree/master/FFMPEG%20Source%20Filter/cpp_builder)** - C++ implementation Each sample includes: - Complete Visual Studio/C++Builder project files - Working code for playback, stream selection, and configuration - Hardware acceleration examples - Network streaming (RTSP/HLS) examples --- ## Prerequisites ### C++ Projects ``` #include #include #include "IFFMPEGSourceSettings.h" // From SDK #pragma comment(lib, "strmiids.lib") ``` ### C# Projects ``` using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; using System.Runtime.InteropServices; ``` **NuGet Packages**: - VisioForge.DirectShowAPI - MediaFoundationCore --- ## Example 1: Basic File Playback Play a local media file with default settings. ### C++ Implementation ``` #include #include #include "IFFMPEGSourceSettings.h" // CLSID for FFMPEG Source Filter DEFINE_GUID(CLSID_VFFFMPEGSource, 0x1974d893, 0x83e4, 0x4f89, 0x99, 0x8, 0x79, 0x5c, 0x52, 0x4c, 0xc1, 0x7e); HRESULT PlayFile(LPCWSTR filename, HWND hVideoWindow) { IGraphBuilder* pGraph = NULL; IMediaControl* pControl = NULL; IMediaEventEx* pEvent = NULL; IBaseFilter* pSourceFilter = NULL; IFileSourceFilter* pFileSource = NULL; IVideoWindow* pVideoWindow = NULL; HRESULT hr = S_OK; // Create Filter Graph hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph); if (FAILED(hr)) return hr; // Create FFMPEG Source Filter hr = CoCreateInstance(CLSID_VFFFMPEGSource, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pSourceFilter); if (FAILED(hr)) goto cleanup; // Add filter to graph hr = pGraph->AddFilter(pSourceFilter, L"FFMPEG Source"); if (FAILED(hr)) goto cleanup; // Load file hr = pSourceFilter->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSource); if (FAILED(hr)) goto cleanup; hr = pFileSource->Load(filename, NULL); if (FAILED(hr)) goto cleanup; // Render streams automatically hr = pGraph->QueryInterface(IID_IGraphBuilder, (void**)&pGraph); ICaptureGraphBuilder2* pBuild = NULL; hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild); if (SUCCEEDED(hr)) { hr = pBuild->SetFiltergraph(pGraph); // Render video stream hr = pBuild->RenderStream(NULL, &MEDIATYPE_Video, pSourceFilter, NULL, NULL); // Render audio stream hr = pBuild->RenderStream(NULL, &MEDIATYPE_Audio, pSourceFilter, NULL, NULL); pBuild->Release(); } // Set video window hr = pGraph->QueryInterface(IID_IVideoWindow, (void**)&pVideoWindow); if (SUCCEEDED(hr)) { pVideoWindow->put_Owner((OAHWND)hVideoWindow); pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS); RECT rc; GetClientRect(hVideoWindow, &rc); pVideoWindow->SetWindowPosition(0, 0, rc.right, rc.bottom); } // Get control interface hr = pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); if (FAILED(hr)) goto cleanup; // Run the graph hr = pControl->Run(); cleanup: if (pFileSource) pFileSource->Release(); if (pVideoWindow) pVideoWindow->Release(); if (pControl) pControl->Release(); if (pSourceFilter) pSourceFilter->Release(); if (pGraph) pGraph->Release(); return hr; } ``` ### C# Implementation ``` using System; using System.Runtime.InteropServices; using System.Windows.Forms; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class FFMPEGSourceBasicExample { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; private IVideoWindow videoWindow; private IBaseFilter sourceFilter; public void PlayFile(string filename, IntPtr videoWindowHandle) { try { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); mediaControl = (IMediaControl)filterGraph; videoWindow = (IVideoWindow)filterGraph; // Create and add FFMPEG Source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Load file var fileSource = sourceFilter as IFileSourceFilter; int hr = fileSource.Load(filename, null); DsError.ThrowExceptionForHR(hr); // Render streams ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Render video hr = captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); // Render audio hr = captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Set video window videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); videoWindow.put_Visible(OABool.True); // Run graph mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}", "Playback Error"); } } public void Stop() { if (mediaControl != null) { mediaControl.Stop(); } if (videoWindow != null) { videoWindow.put_Visible(OABool.False); videoWindow.put_Owner(IntPtr.Zero); } FilterGraphTools.RemoveAllFilters(filterGraph); if (sourceFilter != null) Marshal.ReleaseComObject(sourceFilter); if (videoWindow != null) Marshal.ReleaseComObject(videoWindow); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } ``` ### VB.NET Implementation ``` Imports System.Runtime.InteropServices Imports VisioForge.DirectShowAPI Imports VisioForge.DirectShowLib Public Class FFMPEGSourceBasicExample Private filterGraph As IFilterGraph2 Private mediaControl As IMediaControl Private videoWindow As IVideoWindow Private sourceFilter As IBaseFilter Public Sub PlayFile(filename As String, videoWindowHandle As IntPtr) Try ' Create filter graph filterGraph = DirectCast(New FilterGraph(), IFilterGraph2) mediaControl = DirectCast(filterGraph, IMediaControl) videoWindow = DirectCast(filterGraph, IVideoWindow) ' Create and add FFMPEG Source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source") ' Load file Dim fileSource = DirectCast(sourceFilter, IFileSourceFilter) Dim hr As Integer = fileSource.Load(filename, Nothing) DsError.ThrowExceptionForHR(hr) ' Render streams Dim captureGraph As ICaptureGraphBuilder2 = DirectCast(New CaptureGraphBuilder2(), ICaptureGraphBuilder2) hr = captureGraph.SetFiltergraph(filterGraph) DsError.ThrowExceptionForHR(hr) ' Render video and audio captureGraph.RenderStream(Nothing, MediaType.Video, sourceFilter, Nothing, Nothing) captureGraph.RenderStream(Nothing, MediaType.Audio, sourceFilter, Nothing, Nothing) ' Set video window videoWindow.put_Owner(videoWindowHandle) videoWindow.put_WindowStyle(WindowStyle.Child Or WindowStyle.ClipSiblings) videoWindow.put_Visible(OABool.True) ' Run graph mediaControl.Run() Marshal.ReleaseComObject(captureGraph) Catch ex As Exception MessageBox.Show($"Error: {ex.Message}", "Playback Error") End Try End Sub Public Sub [Stop]() If mediaControl IsNot Nothing Then mediaControl.Stop() End If If videoWindow IsNot Nothing Then videoWindow.put_Visible(OABool.False) videoWindow.put_Owner(IntPtr.Zero) End If FilterGraphTools.RemoveAllFilters(filterGraph) If sourceFilter IsNot Nothing Then Marshal.ReleaseComObject(sourceFilter) If videoWindow IsNot Nothing Then Marshal.ReleaseComObject(videoWindow) If mediaControl IsNot Nothing Then Marshal.ReleaseComObject(mediaControl) If filterGraph IsNot Nothing Then Marshal.ReleaseComObject(filterGraph) End Sub End Class ``` --- ## Example 2: Hardware Acceleration Enable GPU decoding for better performance. ### C++ with Hardware Acceleration ``` HRESULT PlayFileWithGPU(LPCWSTR filename) { IBaseFilter* pSourceFilter = NULL; IFFMPEGSourceSettings* pSettings = NULL; // Create source filter HRESULT hr = CoCreateInstance(CLSID_VFFFMPEGSource, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pSourceFilter); if (FAILED(hr)) return hr; // Get configuration interface hr = pSourceFilter->QueryInterface(IID_IFFMPEGSourceSettings, (void**)&pSettings); if (FAILED(hr)) { pSourceFilter->Release(); return hr; } // Enable hardware acceleration (NVDEC/QuickSync/DXVA) hr = pSettings->SetHWAccelerationEnabled(TRUE); if (FAILED(hr)) { pSettings->Release(); pSourceFilter->Release(); return hr; } // Load file IFileSourceFilter* pFileSource = NULL; hr = pSourceFilter->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSource); if (SUCCEEDED(hr)) { hr = pFileSource->Load(filename, NULL); pFileSource->Release(); } // Continue building graph... // (Add to graph, render streams, etc.) pSettings->Release(); pSourceFilter->Release(); return hr; } ``` ### C# with Hardware Acceleration ## ``` public void PlayFileWithHardwareAcceleration(string filename, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); // Create source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Configure hardware acceleration var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { // Enable GPU decoding int hr = settings.SetHWAccelerationEnabled(true); DsError.ThrowExceptionForHR(hr); } // Load file var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(filename, null); // Build and run graph... ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ## Example 3: Network Streaming (RTSP/HLS) Stream video from network sources. ### C# RTSP Streaming ``` public void PlayRTSPStream(string rtspUrl, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Configure for network streaming var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { // Set buffering mode for network streams settings.SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_ON); // Set connection timeout (in seconds) settings.SetLoadTimeOut(30); // Enable hardware decoding for performance settings.SetHWAccelerationEnabled(true); } // Load RTSP stream // Example: "rtsp://camera.example.com:554/stream" var fileSource = sourceFilter as IFileSourceFilter; int hr = fileSource.Load(rtspUrl, null); DsError.ThrowExceptionForHR(hr); // Build graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Setup video window videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); videoWindow.put_Visible(OABool.True); // Run mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ### C# HLS Streaming ``` public void PlayHLSStream(string hlsUrl, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { // HLS streams benefit from buffering settings.SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_ON); // Longer timeout for HLS playlist loading settings.SetLoadTimeOut(60); // Hardware acceleration settings.SetHWAccelerationEnabled(true); } // Load HLS stream // Example: "https://example.com/stream/playlist.m3u8" var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(hlsUrl, null); // Build and run graph (same as RTSP example) ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` --- ## Example 4: Custom FFmpeg Options Pass custom FFmpeg demuxer/decoder options. ### C# with Custom Options ``` public void PlayWithCustomOptions(string filename, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { // Set custom FFmpeg options // Format: "key=value" for each option // Example 1: Set buffer size for network streams settings.SetCustomOption("buffer_size", "1024000"); // Example 2: Enable low latency mode settings.SetCustomOption("fflags", "nobuffer"); // Example 3: Set analyzer duration (microseconds) settings.SetCustomOption("analyzeduration", "1000000"); // Example 4: Set probe size settings.SetCustomOption("probesize", "5000000"); // Example 5: RTSP transport protocol settings.SetCustomOption("rtsp_transport", "tcp"); // Example 6: Set timeout (microseconds) settings.SetCustomOption("timeout", "5000000"); } // Load file var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(filename, null); // Build graph... ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ### Common FFmpeg Options ## ``` // Network streaming options settings.SetCustomOption("rtsp_transport", "tcp"); // Use TCP for RTSP settings.SetCustomOption("rtsp_flags", "prefer_tcp"); // Prefer TCP over UDP settings.SetCustomOption("timeout", "10000000"); // 10 second timeout settings.SetCustomOption("stimeout", "5000000"); // 5 second socket timeout // Buffer and probing options settings.SetCustomOption("buffer_size", "2097152"); // 2MB buffer settings.SetCustomOption("analyzeduration", "2000000"); // 2 seconds analysis settings.SetCustomOption("probesize", "10000000"); // 10MB probe size // Low latency options settings.SetCustomOption("fflags", "nobuffer"); // Disable buffering settings.SetCustomOption("flags", "low_delay"); // Low delay flag settings.SetCustomOption("framedrop", "1"); // Allow frame dropping // HTTP options settings.SetCustomOption("user_agent", "MyApp/1.0"); // Custom user agent settings.SetCustomOption("headers", "Authorization: Bearer token"); // Clear all custom options settings.ClearCustomOptions(); ``` ## Example 5: Buffering Mode Configuration Control buffering behavior for different scenarios. ### C# Buffering Examples ``` public enum BufferingScenario { LocalFile, NetworkStream, LowLatency } public void PlayWithBuffering(string source, BufferingScenario scenario, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { switch (scenario) { case BufferingScenario.LocalFile: // Auto mode - let filter decide settings.SetBufferingMode( FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_AUTO); break; case BufferingScenario.NetworkStream: // Enable buffering for smooth playback settings.SetBufferingMode( FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_ON); settings.SetLoadTimeOut(30); // 30 second timeout break; case BufferingScenario.LowLatency: // Disable buffering for minimal latency settings.SetBufferingMode( FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_OFF); settings.SetCustomOption("fflags", "nobuffer"); settings.SetCustomOption("flags", "low_delay"); break; } } // Load source var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(source, null); // Build and run graph... ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` --- ## Example 6: Multi-Stream Selection Select specific video and audio tracks. ### C# Stream Selection ## ``` public void PlayWithStreamSelection(string filename, int videoStreamIndex, int audioStreamIndex, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Load file first var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(filename, null); // Get available streams var streamSelect = sourceFilter as IAMStreamSelect; if (streamSelect != null) { streamSelect.Count(out int streamCount); List videoStreams = new List(); List audioStreams = new List(); // Enumerate streams for (int i = 0; i < streamCount; i++) { streamSelect.Info(i, out AMMediaType mt, out _, out _, out _, out string name, out _, out _); if (mt.majorType == MediaType.Video) { videoStreams.Add(i); Console.WriteLine($"Video Stream {videoStreams.Count - 1}: {name}"); } else if (mt.majorType == MediaType.Audio) { audioStreams.Add(i); Console.WriteLine($"Audio Stream {audioStreams.Count - 1}: {name}"); } DsUtils.FreeAMMediaType(mt); } // Enable selected streams if (videoStreamIndex >= 0 && videoStreamIndex < videoStreams.Count) { streamSelect.Enable(videoStreams[videoStreamIndex], AMStreamSelectEnableFlags.Enable); } if (audioStreamIndex >= 0 && audioStreamIndex < audioStreams.Count) { streamSelect.Enable(audioStreams[audioStreamIndex], AMStreamSelectEnableFlags.Enable); } } // Build graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ## Example 7: Container Data Callback (e.g., SMPTE KLV metadata) Receive raw out-of-band data buffers carried in the container (such as SMPTE KLV metadata packets in MPEG-TS streams). The callback fires once per data packet and surfaces the packet bytes plus its presentation/end timestamps. ### C# Data Callback Implementation ``` // Real signature (per IFFmpegSourceSettings.h): // HRESULT (BYTE* buffer, int bufferLen, int dataType, LONGLONG startTime, LONGLONG stopTime) // dataType is a VF_DATA_TYPE enum: // 0 = unknown, 1 = SMPTE_KLV public delegate int FFMPEGDataCallbackDelegate( IntPtr buffer, int bufferLen, int dataType, long startTime, long stopTime); public class FFMPEGDataCallbackExample { private IFilterGraph2 filterGraph; private IBaseFilter sourceFilter; private FFMPEGDataCallbackDelegate dataCallback; public void PlayWithCallback(string filename, Action onPacket) { // Keep a managed reference to the delegate so the GC doesn't collect it // while native code holds a function pointer to it. this.dataCallback = (buffer, bufferLen, dataType, startTime, stopTime) => { byte[] managed = new byte[bufferLen]; Marshal.Copy(buffer, managed, 0, bufferLen); onPacket(managed, dataType, startTime, stopTime); return 0; // S_OK }; filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { // Wire up the data callback settings.SetDataCallback(this.dataCallback); } // Load file var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(filename, null); // Build graph (without renderers if you only want callbacks) ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); // Render normally; the data callback fires alongside playback. captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } // Usage: // example.PlayWithCallback("input.ts", (bytes, dataType, startTime, stopTime) => // { // const int VF_DATA_TYPE_SMPTE_KLV = 1; // if (dataType == VF_DATA_TYPE_SMPTE_KLV) // { // // Decode KLV metadata packet // Console.WriteLine($"KLV packet: {bytes.Length} bytes, {startTime}–{stopTime}"); // } // }); ``` --- ## Example 8: Timestamp Callback Monitor demuxer/stream timing per media type. ### C# Timestamp Callback ## ``` // Real signature (per IFFmpegSourceSettings.h): // HRESULT (int mediaType, __int64 demuxerStartTime, // __int64 streamStartTime, __int64 timestamp) // mediaType selects between audio and video streams. public delegate int FFMPEGTimestampCallbackDelegate( int mediaType, long demuxerStartTime, long streamStartTime, long timestamp); private FFMPEGTimestampCallbackDelegate timestampCallback; public void PlayWithTimestampCallback(string filename) { // Hold the delegate so it isn't GC'd while native code calls back. this.timestampCallback = (mediaType, demuxerStart, streamStart, timestamp) => { Console.WriteLine( $"mediaType={mediaType} demuxerStart={demuxerStart} " + $"streamStart={streamStart} timestamp={timestamp}"); return 0; // S_OK }; filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { settings.SetTimestampCallback(this.timestampCallback); } // Load and play file... var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(filename, null); ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ## Example 9: License Activation Activate purchased license. ### C# License Activation ``` public void PlayWithLicense(string filename, string licenseKey, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Activate license var registration = sourceFilter as IVFRegister; if (registration != null) { int hr = registration.SetLicenseKey(licenseKey); if (hr != 0) { throw new Exception("License activation failed"); } } // Configure and play... var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { settings.SetHWAccelerationEnabled(true); } var fileSource = sourceFilter as IFileSourceFilter; fileSource.Load(filename, null); ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` --- ## Example 10: Complete Media Player Full-featured media player with all features. ### C# Complete Example ``` using System; using System.Runtime.InteropServices; using System.Windows.Forms; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class FFMPEGMediaPlayer : IDisposable { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IMediaSeeking mediaSeeking; private IVideoWindow videoWindow; private IMediaEventEx mediaEventEx; private IBaseFilter sourceFilter; private const int WM_GRAPHNOTIFY = 0x8000 + 1; public event EventHandler PlaybackComplete; public void Initialize(IntPtr windowHandle, IntPtr notifyHandle) { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; mediaSeeking = (IMediaSeeking)filterGraph; videoWindow = (IVideoWindow)filterGraph; mediaEventEx = (IMediaEventEx)filterGraph; // Setup event notifications int hr = mediaEventEx.SetNotifyWindow(notifyHandle, WM_GRAPHNOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); // Attach capture graph hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); } public void LoadFile(string filename, bool enableGPU, bool enableBuffering, string licenseKey = null) { // Create source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Register license if provided if (!string.IsNullOrEmpty(licenseKey)) { var registration = sourceFilter as IVFRegister; registration?.SetLicenseKey(licenseKey); } // Configure filter var settings = sourceFilter as IFFMPEGSourceSettings; if (settings != null) { settings.SetHWAccelerationEnabled(enableGPU); if (enableBuffering) { settings.SetBufferingMode( FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_ON); } else { settings.SetBufferingMode( FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_AUTO); } settings.SetLoadTimeOut(30); } // Load file var fileSource = sourceFilter as IFileSourceFilter; int hr = fileSource.Load(filename, null); DsError.ThrowExceptionForHR(hr); // Render streams hr = captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); hr = captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); } public void SetVideoWindow(IntPtr handle, int width, int height) { if (videoWindow != null) { videoWindow.put_Owner(handle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); videoWindow.SetWindowPosition(0, 0, width, height); videoWindow.put_Visible(OABool.True); } } public void Play() { mediaControl?.Run(); } public void Pause() { mediaControl?.Pause(); } public void Stop() { mediaControl?.Stop(); } public void Seek(long timeInSeconds) { if (mediaSeeking != null) { long duration; mediaSeeking.GetDuration(out duration); long seekPos = timeInSeconds * 10000000; // Convert to 100-nanosecond units if (seekPos <= duration) { mediaSeeking.SetPositions(ref seekPos, AMSeekingSeekingFlags.AbsolutePositioning, IntPtr.Zero, AMSeekingSeekingFlags.NoPositioning); } } } public long GetPosition() { if (mediaSeeking != null) { mediaSeeking.GetCurrentPosition(out long position); return position / 10000000; // Convert to seconds } return 0; } public long GetDuration() { if (mediaSeeking != null) { mediaSeeking.GetDuration(out long duration); return duration / 10000000; // Convert to seconds } return 0; } public void HandleGraphEvent() { if (mediaEventEx != null) { while (mediaEventEx.GetEvent(out EventCode eventCode, out IntPtr param1, out IntPtr param2, 0) == 0) { mediaEventEx.FreeEventParams(eventCode, param1, param2); if (eventCode == EventCode.Complete) { PlaybackComplete?.Invoke(this, EventArgs.Empty); } } } } public void Dispose() { if (mediaControl != null) { mediaControl.Stop(); } if (mediaEventEx != null) { mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); } if (videoWindow != null) { videoWindow.put_Visible(OABool.False); videoWindow.put_Owner(IntPtr.Zero); } FilterGraphTools.RemoveAllFilters(filterGraph); if (sourceFilter != null) Marshal.ReleaseComObject(sourceFilter); if (videoWindow != null) Marshal.ReleaseComObject(videoWindow); if (mediaSeeking != null) Marshal.ReleaseComObject(mediaSeeking); if (mediaEventEx != null) Marshal.ReleaseComObject(mediaEventEx); if (captureGraph != null) Marshal.ReleaseComObject(captureGraph); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } ``` ### Usage Example ## ``` public partial class MainForm : Form { private FFMPEGMediaPlayer player; public MainForm() { InitializeComponent(); player = new FFMPEGMediaPlayer(); } private void btnLoad_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Video Files|*.mp4;*.mkv;*.avi;*.mov|All Files|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { player.Initialize(panelVideo.Handle, this.Handle); player.LoadFile(dlg.FileName, enableGPU: true, enableBuffering: true); player.SetVideoWindow(panelVideo.Handle, panelVideo.Width, panelVideo.Height); player.PlaybackComplete += Player_PlaybackComplete; player.Play(); } } private void Player_PlaybackComplete(object sender, EventArgs e) { MessageBox.Show("Playback complete"); } protected override void WndProc(ref Message m) { if (m.Msg == 0x8000 + 1) // WM_GRAPHNOTIFY { player?.HandleGraphEvent(); } base.WndProc(ref m); } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { player?.Dispose(); } } ``` ## Troubleshooting ### Issue: "Class not registered" Error **Solution**: Ensure filter is registered: ``` regsvr32 VisioForge_FFMPEG_Source_x64.ax ``` ### Issue: Hardware Acceleration Not Working **Solution**: Check GPU support and drivers: ``` var settings = sourceFilter as IFFMPEGSourceSettings; bool isEnabled; settings.GetHWAccelerationEnabled(out isEnabled); Console.WriteLine($"HW Acceleration: {isEnabled}"); ``` ### Issue: Network Stream Connection Fails **Solution**: Increase timeout and use custom options: ``` settings.SetLoadTimeOut(60); settings.SetCustomOption("timeout", "30000000"); // 30 seconds settings.SetCustomOption("rtsp_transport", "tcp"); ``` --- ## See Also ### Documentation - [Interface Reference](../interface-reference/) - Complete API reference - [Deployment Guide](../../deployment/) - Filter deployment ### Code Samples - **[GitHub Samples Repository](https://github.com/visioforge/directshow-samples)** - Complete working examples - **[C# Sample Project](https://github.com/visioforge/directshow-samples/tree/master/FFMPEG%20Source%20Filter/dotnet/cs)** - Full-featured C# implementation - **[VB.NET Sample Project](https://github.com/visioforge/directshow-samples/tree/master/FFMPEG%20Source%20Filter/dotnet/vbnet)** - VB.NET implementation - **[C++ Sample Project](https://github.com/visioforge/directshow-samples/tree/master/FFMPEG%20Source%20Filter/cpp_builder)** - C++Builder implementation ### External Resources - [FFmpeg Documentation](https://ffmpeg.org/documentation.html) - [DirectShow Programming Guide](https://learn.microsoft.com/en-us/windows/win32/DirectShow/directshow) ### Support - [Technical Support](https://support.visioforge.com) - Get help from VisioForge team - [Discord Community](https://discord.com/invite/yvXUG56WCH) - Join our community ---END OF PAGE--- ## FFmpeg Source DirectShow Filter - 100+ Media Formats **URL:** https://www.visioforge.com/help/docs/directshow/ffmpeg-source-filters/ **Description:** DirectShow source filter powered by FFmpeg for decoding MP4, MKV, H.265, and 100+ formats with hardware acceleration. COM interface for C++, C#, and Delphi. **Tags:** DirectShow, C++, Windows, Streaming **API:** IBaseFilter, IFileSourceFilter, FFMPEGFilter, FileSource, IFFMPEGSourceSettings # FFMPEG Source DirectShow Filter ## Introduction The FFMPEG Source DirectShow filter enables developers to seamlessly integrate advanced media decoding and playback capabilities into any DirectShow-compatible application. This powerful component bridges the gap between complex multimedia formats and your software development needs, providing a robust foundation for building media-rich applications. --- ## Installation Before using the code samples and integrating the filter into your application, you must first install the FFMPEG Source DirectShow Filter from the [product page](https://www.visioforge.com/ffmpeg-source-directshow-filter). **Installation Steps**: 1. Download the SDK installer from the product page 2. Run the installer with administrative privileges 3. The installer will register the FFMPEG Source filter and deploy all necessary FFMPEG DLLs 4. Sample applications and source code will be available in the installation directory **Note**: The filter must be properly registered on the system before it can be used in your applications. The installer handles this automatically. --- ## Key Features and Capabilities Our filter comes bundled with all necessary FFMPEG DLLs and provides a feature-rich DirectShow filter interface that supports: - **Extensive Format Compatibility**: Handle a wide range of video and audio formats including MP4, MKV, AVI, MOV, WMV, FLV, and many others without additional codec installations - **Network Stream Support**: Connect to RTSP, RTMP, HTTP, UDP, and TCP streams for live media integration - **Multiple Stream Management**: Select between video and audio streams in multi-stream media files - **Advanced Seeking Capabilities**: Implement precise seeking functionality in your applications - **GPU Acceleration**: Utilize hardware acceleration for optimal performance ## Implementation Examples The SDK includes comprehensive sample applications for multiple development environments: ### Delphi Integration (Primary) ``` // Initialize the FFMPEG Source filter in Delphi using DSPack procedure TMainForm.InitializeFFMPEGSource; var FFMPEGFilter: IBaseFilter; FileSource: IFileSourceFilter; begin // Create FFMPEG Source filter instance // IMPORTANT: Ensure proper COM initialization before this call CoCreateInstance(CLSID_FFMPEGSource, nil, CLSCTX_INPROC_SERVER, IID_IBaseFilter, FFMPEGFilter); // Query for file source interface FFMPEGFilter.QueryInterface(IID_IFileSourceFilter, FileSource); // Load media file - can be local or network URL FileSource.Load('C:\media\sample.mp4', nil); // Add to filter graph for rendering FilterGraph.AddFilter(FFMPEGFilter, 'FFMPEG Source'); // Connect to appropriate renderers or processing filters // FilterGraph.RenderStream(...); end; ``` ### C# Integration (.NET) ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; // Initialize the FFMPEG Source filter in C# using DirectShowLib public class FFMPEGSourcePlayer { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IMediaSeeking mediaSeeking; private IMediaEventEx mediaEventEx; private IBaseFilter sourceFilter; private IBaseFilter videoRenderer; public void Initialize(string filename, IntPtr videoWindowHandle) { try { // Create the filter graph manager filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; mediaSeeking = (IMediaSeeking)filterGraph; mediaEventEx = (IMediaEventEx)filterGraph; // Attach the filter graph to the capture graph int hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Create the FFMPEG Source filter using the correct CLSID sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFFFMPEGSource, "FFMPEG Source"); // Optional: Register purchased version // var reg = sourceFilter as IVFRegister; // reg?.SetLicenseKey("your-license-key-here"); // Configure filter settings var filterConfig = sourceFilter as IFFMPEGSourceSettings; if (filterConfig != null) { // Set buffering mode (AUTO, ON, or OFF) filterConfig.SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE.FFMPEG_SOURCE_BUFFERING_MODE_AUTO); // Enable hardware acceleration (GPU decoding) filterConfig.SetHWAccelerationEnabled(true); // Set connection timeout (milliseconds) filterConfig.SetLoadTimeOut(30000); } // Load the media file or network stream var sourceFilterIntf = sourceFilter as IFileSourceFilter; hr = sourceFilterIntf.Load(filename, null); DsError.ThrowExceptionForHR(hr); // Create video renderer (EVR - Enhanced Video Renderer) Guid CLSID_EVR = new Guid("FA10746C-9B63-4B6C-BC49-FC300EA5F256"); videoRenderer = FilterGraphTools.AddFilterFromClsid(filterGraph, CLSID_EVR, "EVR"); // Configure EVR var evrConfig = videoRenderer as MediaFoundation.EVR.IEVRFilterConfig; evrConfig?.SetNumberOfStreams(1); // Set video window for rendering var getService = videoRenderer as MediaFoundation.IMFGetService; if (getService != null) { getService.GetService( MediaFoundation.MFServices.MR_VIDEO_RENDER_SERVICE, typeof(MediaFoundation.IMFVideoDisplayControl).GUID, out var videoDisplayControlObj); var videoDisplayControl = videoDisplayControlObj as MediaFoundation.IMFVideoDisplayControl; videoDisplayControl?.SetVideoWindow(videoWindowHandle); } // Render the streams hr = captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, videoRenderer); DsError.ThrowExceptionForHR(hr); hr = captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Note: Audio rendering errors are not critical for video-only playback // Start playback hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); } catch (Exception ex) { Console.WriteLine($"Error initializing FFMPEG Source: {ex.Message}"); Cleanup(); throw; } } public void Cleanup() { // Stop playback if (mediaControl != null) { mediaControl.StopWhenReady(); mediaControl.Stop(); } // Stop receiving events mediaEventEx?.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); // Remove all filters FilterGraphTools.RemoveAllFilters(filterGraph); // Release DirectShow interfaces if (mediaControl != null) { Marshal.ReleaseComObject(mediaControl); mediaControl = null; } if (mediaSeeking != null) { Marshal.ReleaseComObject(mediaSeeking); mediaSeeking = null; } if (mediaEventEx != null) { Marshal.ReleaseComObject(mediaEventEx); mediaEventEx = null; } if (sourceFilter != null) { Marshal.ReleaseComObject(sourceFilter); sourceFilter = null; } if (videoRenderer != null) { Marshal.ReleaseComObject(videoRenderer); videoRenderer = null; } if (filterGraph != null) { Marshal.ReleaseComObject(filterGraph); filterGraph = null; } if (captureGraph != null) { Marshal.ReleaseComObject(captureGraph); captureGraph = null; } } } ``` **Key CLSIDs and GUIDs:** ``` // FFMPEG Source Filter CLSID — same value used across the C# / C++ samples and // the registry registration in ../deployment/filter-registration.md. public static readonly Guid CLSID_VFFFMPEGSource = new Guid("1974D893-83E4-4F89-9908-795C524CC17E"); // IFFMPEGSourceSettings interface — for the canonical IID see the interface header // (`IFFmpegSourceSettings.h` / `IFFmpegSourceSettings.cs`) linked from // [interface-reference.md](./interface-reference.md). The interface IID is distinct // from the filter CLSID above (a single GUID cannot serve as both). public interface IFFMPEGSourceSettings { /* ... */ } // IVFRegister Interface IID (for licensing) [Guid("59E82754-B531-4A8E-A94D-57C75F01DA30")] public interface IVFRegister { /* ... */ } ``` **Required NuGet Packages:** - `VisioForge.DirectShowAPI` - DirectShow wrapper library - `MediaFoundation.Net` - Media Foundation wrapper for EVR renderer **Stream Selection Example:** ``` // Select specific video or audio streams in multi-stream files var streamSelect = sourceFilter as IAMStreamSelect; if (streamSelect != null) { streamSelect.Count(out int streamCount); for (int i = 0; i < streamCount; i++) { streamSelect.Info(i, out var mediaType, out _, out _, out _, out var name, out _, out _); if (mediaType.majorType == MediaType.Video) { // Enable the first video stream streamSelect.Enable(i, AMStreamSelectEnableFlags.Enable); break; } } } ``` ### C++ Integration Example ``` // Initialize the FFMPEG Source filter in C++ using DirectShow HRESULT InitializeFFMPEGSource() { HRESULT hr = S_OK; IGraphBuilder* pGraph = NULL; IMediaControl* pControl = NULL; IBaseFilter* pFFMPEGSource = NULL; IFileSourceFilter* pFileSource = NULL; // Initialize COM CoInitialize(NULL); // Create the filter graph manager hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph); if (FAILED(hr)) return hr; // Create the FFMPEG Source filter hr = CoCreateInstance(CLSID_FFMPEGSource, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pFFMPEGSource); if (FAILED(hr)) goto cleanup; // Add the filter to the graph hr = pGraph->AddFilter(pFFMPEGSource, L"FFMPEG Source"); if (FAILED(hr)) goto cleanup; // Get the IFileSourceFilter interface hr = pFFMPEGSource->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSource); if (FAILED(hr)) goto cleanup; // Load the media file hr = pFileSource->Load(L"C:\\media\\sample.mp4", NULL); if (FAILED(hr)) goto cleanup; // Render the output pins of the FFMPEG Source filter hr = pGraph->Render(GetPin(pFFMPEGSource, PINDIR_OUTPUT, 0)); // Get the media control interface for playback control hr = pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); if (SUCCEEDED(hr)) { // Start playback hr = pControl->Run(); // ... handle playback as needed } cleanup: // Release interfaces if (pControl) pControl->Release(); if (pFileSource) pFileSource->Release(); if (pFFMPEGSource) pFFMPEGSource->Release(); if (pGraph) pGraph->Release(); return hr; } // Helper function to get pins from a filter IPin* GetPin(IBaseFilter* pFilter, PIN_DIRECTION PinDir, int nPin) { IEnumPins* pEnum = NULL; IPin* pPin = NULL; if (pFilter) { pFilter->EnumPins(&pEnum); if (pEnum) { while (pEnum->Next(1, &pPin, NULL) == S_OK) { PIN_DIRECTION PinDirThis; pPin->QueryDirection(&PinDirThis); if (PinDir == PinDirThis) { if (nPin == 0) break; nPin--; } pPin->Release(); pPin = NULL; } pEnum->Release(); } } return pPin; } ``` ## Integration with Processing Filters Enhance your media pipeline by connecting the FFMPEG Source filter with additional processing components: - Apply real-time video effects and transformations - Process audio streams for custom sound manipulation - Implement specialized media analysis features Our [Processing Filters pack](https://www.visioforge.com/processing-filters-pack) offers additional capabilities, or you can integrate with any standard DirectShow-compatible filters. ## Technical Specifications ### Supported DirectShow Interfaces The filter implements these standard DirectShow interfaces for maximum compatibility: - **IAMStreamSelect**: Select between multiple video and audio streams - **IAMStreamConfig**: Configure video and audio settings - **IFileSourceFilter**: Set filename or streaming URL - **IMediaSeeking**: Implement precise seeking functionality - **ISpecifyPropertyPages**: Access configuration through property pages ## Version History and Updates ### Version 15.0 - Enhanced FFMPEG libraries with latest codecs - Added GPU decoding support for improved performance - Optimized memory management for large files ### Version 12.0 - Updated FFMPEG libraries - Improved compatibility with Windows 10/11 ### Version 11.0 - Updated FFMPEG libraries - Fixed seeking issues with certain file formats ### Version 10.0 - Updated FFMPEG libraries - Added support for additional container formats ### Version 9.0 - Updated FFMPEG libraries - Performance optimizations ### Version 8.0 - Updated FFMPEG libraries - Improved error handling ### Version 7.0 - Initial release as an independent product - Core functionality established ## Additional Resources - Explore our [product page](https://www.visioforge.com/ffmpeg-source-directshow-filter) for detailed specifications - View our [End User License Agreement](../../eula/) for licensing details - Check our developer documentation for advanced implementation scenarios ---END OF PAGE--- ## FFmpeg Source DirectShow Filter Interface API Reference **URL:** https://www.visioforge.com/help/docs/directshow/ffmpeg-source-filters/interface-reference/ **Description:** IFFmpegSourceSettings interface with hardware acceleration, buffering modes, custom FFmpeg options, and callbacks for DirectShow. **Tags:** DirectShow, C++, Windows, Streaming, Decoding, RTSP, C# **API:** IFFmpegSourceSettings, IFileSourceFilter, IFFMPEGSourceSettings # IFFMPEGSourceSettings Interface Reference ## Overview The `IFFMPEGSourceSettings` interface provides advanced configuration options for the FFMPEG Source DirectShow filter. This interface enables developers to control hardware acceleration, buffering behavior, custom FFmpeg options, and various callbacks for media playback. > The .NET / C++ / Delphi headers spell this interface `IFFMPEGSourceSettings` (all uppercase `FFMPEG`). The legacy header file paths `IFFmpegSourceSettings.h` / `.cs` keep the historical mixed-case filename — but the symbol exposed by all three languages is the all-caps form. The two are equivalent identifiers in C#; this page uses the all-caps form consistently with examples.md / index.md. ## Interface Definition - **Interface Name**: `IFFMPEGSourceSettings` - **Filter CLSID it queries through**: `{1974D893-83E4-4F89-9908-795C524CC17E}` (the FFMPEG Source filter — the interface IID itself is distinct; consult the header). - **Inherits From**: `IUnknown` ### Interface Definition Files Complete interface definitions are available on GitHub: - **C# (.NET)**: [IFFmpegSourceSettings.cs](https://github.com/visioforge/directshow-samples/blob/main/Interfaces/dotnet/IFFmpegSourceSettings.cs) - **C++ Header**: [IFFmpegSourceSettings.h](https://github.com/visioforge/directshow-samples/blob/main/Interfaces/cpp/FFMPEG%20Source/IFFmpegSourceSettings.h) - **Delphi**: [VCFiltersAPI.pas](https://github.com/visioforge/directshow-samples/blob/main/Interfaces/delphi/VCFiltersAPI.pas) (search for `IFFMPEGSourceSettings`) All interface definitions include: - Complete method signatures with proper marshalling attributes - Callback delegate definitions - Enumeration types (buffering modes, media types) - Usage documentation and examples ## Methods Reference ### Hardware Acceleration #### GetHWAccelerationEnabled Retrieves the current hardware acceleration state. **Syntax (C++)**: ``` BOOL GetHWAccelerationEnabled(); ``` **Syntax (C#)**: ``` [PreserveSig] bool GetHWAccelerationEnabled(); ``` **Returns**: `TRUE` if hardware acceleration is enabled, `FALSE` otherwise. **Default**: `TRUE` --- #### SetHWAccelerationEnabled Enables or disables hardware video decoding acceleration. **Syntax (C++)**: ``` HRESULT SetHWAccelerationEnabled(BOOL enabled); ``` **Syntax (C#)**: ``` [PreserveSig] int SetHWAccelerationEnabled([MarshalAs(UnmanagedType.Bool)] bool enabled); ``` **Parameters**: - `enabled`: Set to `TRUE` to enable hardware acceleration, `FALSE` to disable. **Returns**: `S_OK` (0) on success, error code otherwise. **Usage Notes**: - Must be called **before** connecting downstream video filters - When enabled, the filter attempts to use hardware decoding (DXVA, NVDEC, QuickSync, etc.) - Falls back to software decoding if hardware acceleration is unavailable - Hardware acceleration significantly improves performance for H.264, H.265, VP9, and AV1 codecs **Example (C++)**: ``` IFFmpegSourceSettings* pSettings = nullptr; pFilter->QueryInterface(IID_IFFmpegSourceSettings, (void**)&pSettings); // Enable hardware acceleration pSettings->SetHWAccelerationEnabled(TRUE); pSettings->Release(); ``` **Example (C#)**: ``` var settings = filter as IFFmpegSourceSettings; if (settings != null) { // Enable hardware acceleration settings.SetHWAccelerationEnabled(true); } ``` --- ### Load Timeout Configuration #### GetLoadTimeOut Retrieves the current source loading timeout value. **Syntax (C++)**: ``` DWORD GetLoadTimeOut(); ``` **Syntax (C#)**: ``` [PreserveSig] uint GetLoadTimeOut(); ``` **Returns**: Timeout value in milliseconds. **Default**: `15000` (15 seconds) --- #### SetLoadTimeOut Sets the timeout duration for source loading operations. **Syntax (C++)**: ``` HRESULT SetLoadTimeOut(DWORD milliseconds); ``` **Syntax (C#)**: ``` [PreserveSig] int SetLoadTimeOut(uint milliseconds); ``` **Parameters**: - `milliseconds`: Timeout duration in milliseconds. **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the source file/URL - Particularly important for network streams that may have slow connection times - Set higher values for slow network connections or large files - Set lower values to fail fast on unreachable sources **Example (C++)**: ``` // Set 30-second timeout for network streams pSettings->SetLoadTimeOut(30000); // Load RTSP stream IFileSourceFilter* pFileSource = nullptr; pFilter->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSource); pFileSource->Load(L"rtsp://example.com/stream", nullptr); ``` --- ### Buffering Configuration #### GetBufferingMode Retrieves the current buffering mode. **Syntax (C++)**: ``` FFMPEG_SOURCE_BUFFERING_MODE GetBufferingMode(); ``` **Syntax (C#)**: ``` [PreserveSig] FFMPEG_SOURCE_BUFFERING_MODE GetBufferingMode(); ``` **Returns**: Current buffering mode (see enumeration below). **Default**: `FFMPEG_SOURCE_BUFFERING_MODE_AUTO` --- #### SetBufferingMode Sets the buffering mode for live sources. **Syntax (C++)**: ``` HRESULT SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE mode); ``` **Syntax (C#)**: ``` [PreserveSig] int SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE mode); ``` **Parameters**: - `mode`: Buffering mode to use. **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the source - Affects latency and stability for live streams **Buffering Modes**: | Mode | Value | Description | Use Case | |------|-------|-------------|----------| | `FFMPEG_SOURCE_BUFFERING_MODE_AUTO` | 0 | Automatically detect if buffering is needed | Default - recommended for most scenarios | | `FFMPEG_SOURCE_BUFFERING_MODE_ON` | 1 | Force buffering enabled | Use for unstable network streams | | `FFMPEG_SOURCE_BUFFERING_MODE_OFF` | 2 | Force buffering disabled | Use for low-latency live streams | **Example (C++)**: ``` // Disable buffering for low-latency RTSP stream pSettings->SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE_OFF); pSettings->SetLoadTimeOut(5000); // 5-second timeout ``` **Example (C#)**: ``` // Enable buffering for unstable network settings.SetBufferingMode(FFMPEG_SOURCE_BUFFERING_MODE.ON); ``` --- ### Custom FFmpeg Options #### SetCustomOption Sets a custom FFmpeg option for the demuxer or decoder. **Syntax (C++)**: ``` HRESULT SetCustomOption(LPSTR name, LPSTR value); ``` **Syntax (C#)**: ``` [PreserveSig] int SetCustomOption([MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string value); ``` **Parameters**: - `name`: Option name (ASCII string). - `value`: Option value (ASCII string). **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the source - Allows passing any FFmpeg AVFormatContext or AVCodecContext option - Options are passed directly to FFmpeg libraries - Invalid options are ignored with a warning **Common Options**: | Option | Value | Description | | --- | --- | --- | | `rtsp_transport` | `tcp` or `udp` | Force RTSP transport protocol | | `timeout` | Microseconds | Network timeout for protocols | | `buffer_size` | Bytes | Input buffer size | | `analyzeduration` | Microseconds | Duration to analyze stream | | `probesize` | Bytes | Size of data to probe | | `fflags` | `nobuffer` | Disable buffering | | `threads` | Number | Decoder thread count | **Example (C++)**: ``` // Configure RTSP to use TCP transport pSettings->SetCustomOption("rtsp_transport", "tcp"); // Set network timeout to 5 seconds pSettings->SetCustomOption("timeout", "5000000"); // 5 seconds in microseconds // Increase probe size for better format detection pSettings->SetCustomOption("probesize", "10000000"); // 10MB ``` **Example (C#)**: ``` // Low-latency configuration settings.SetCustomOption("fflags", "nobuffer"); settings.SetCustomOption("flags", "low_delay"); settings.SetCustomOption("probesize", "32"); ``` --- #### ClearCustomOptions Clears all previously set custom options. **Syntax (C++)**: ``` HRESULT ClearCustomOptions(); ``` **Syntax (C#)**: ``` [PreserveSig] int ClearCustomOptions(); ``` **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the source - Resets all custom options to FFmpeg defaults **Example (C++)**: ``` pSettings->ClearCustomOptions(); ``` --- ### Callback Configuration #### SetDataCallback Sets a callback function to receive decoded video/audio data. **Syntax (C++)**: ``` HRESULT SetDataCallback(FFMPEGDataCallbackDelegate callback); ``` **Syntax (C#)**: ``` [PreserveSig] int SetDataCallback([MarshalAs(UnmanagedType.FunctionPtr)] FFMPEGDataCallbackDelegate callback); ``` **Parameters**: - `callback`: Pointer to callback function. **Returns**: `S_OK` (0) on success. **Callback Signature (C++)**: ``` typedef HRESULT(_stdcall* FFMPEGDataCallbackDelegate) ( BYTE* buffer, // Pointer to data buffer int bufferLen, // Buffer length in bytes int dataType, // 0 = video, 1 = audio LONGLONG startTime, // Start timestamp (100-nanosecond units) LONGLONG stopTime // Stop timestamp (100-nanosecond units) ); ``` **Usage Notes**: - Callback is invoked for each decoded frame/audio sample - Called from filter's streaming thread - keep processing minimal - Buffer data is valid only during callback execution - Return `S_OK` from callback to continue processing **Example (C++)**: ``` HRESULT __stdcall DataCallback(BYTE* buffer, int bufferLen, int dataType, LONGLONG startTime, LONGLONG stopTime) { if (dataType == 0) // Video { // Process video frame ProcessVideoFrame(buffer, bufferLen, startTime); } else // Audio { // Process audio data ProcessAudioData(buffer, bufferLen); } return S_OK; } // Set callback pSettings->SetDataCallback(&DataCallback); ``` --- #### SetTimestampCallback Sets a callback function to receive timestamp information. **Syntax (C++)**: ``` HRESULT SetTimestampCallback(FFMPEGTimestampCallbackDelegate callback); ``` **Syntax (C#)**: ``` [PreserveSig] int SetTimestampCallback([MarshalAs(UnmanagedType.FunctionPtr)] FFMPEGTimestampCallbackDelegate callback); ``` **Parameters**: - `callback`: Pointer to callback function. **Returns**: `S_OK` (0) on success. **Callback Signature (C++)**: ``` typedef HRESULT(_stdcall* FFMPEGTimestampCallbackDelegate) ( int mediaType, // 0 = video, 1 = audio __int64 demuxerStartTime, // Demuxer start time __int64 streamStartTime, // Stream start time __int64 timestamp // Current timestamp ); ``` **Usage Notes**: - Useful for timestamp analysis and synchronization debugging - Called for each decoded frame/sample --- ### Audio Control #### SetAudioEnabled Enables or disables audio stream processing. **Syntax (C++)**: ``` HRESULT SetAudioEnabled(BOOL enabled); ``` **Syntax (C#)**: ``` [PreserveSig] int SetAudioEnabled([MarshalAs(UnmanagedType.Bool)] bool enabled); ``` **Parameters**: - `enabled`: Set to `TRUE` to enable audio, `FALSE` to disable. **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the source - When disabled, audio streams are not decoded (saves CPU/memory) - Useful for video-only applications **Example (C++)**: ``` // Disable audio for video-only processing pSettings->SetAudioEnabled(FALSE); ``` ## Related Interfaces - **IFileSourceFilter** - Standard DirectShow interface for loading files/URLs - **IAMStreamSelect** - Select between multiple audio/video streams - **IMediaSeeking** - Seek to specific positions in the media - **IAMStreamConfig** - Configure video/audio format ## See Also ### Documentation - [FFMPEG Source Filter Overview](../) - Product overview and features - [Code Examples](../examples/) - Complete working code samples ### Interface Definitions - [C# Interface (.NET)](https://github.com/visioforge/directshow-samples/blob/main/Interfaces/dotnet/IFFmpegSourceSettings.cs) - Complete .NET interface definition - [C++ Interface Header](https://github.com/visioforge/directshow-samples/blob/main/Interfaces/cpp/FFMPEG%20Source/IFFmpegSourceSettings.h) - C++ header file - [Delphi Interface](https://github.com/visioforge/directshow-samples/blob/main/Interfaces/delphi/VCFiltersAPI.pas) - Delphi interface definition ### Working Samples - [GitHub Samples Repository](https://github.com/visioforge/directshow-samples) - Complete working examples for all platforms ### External Resources - [FFmpeg Documentation](https://ffmpeg.org/documentation.html) - FFmpeg library documentation - [DirectShow SDK](https://learn.microsoft.com/en-us/windows/win32/DirectShow/directshow) - Microsoft DirectShow documentation ---END OF PAGE--- ## DirectShow Encoding Codecs - H.264, H.265, AAC, and More **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/codecs-reference/ **Description:** DirectShow codec reference with H.264/H.265/VP8/VP9 video, AAC/MP3/Opus audio, and hardware acceleration (NVENC, QuickSync, AMF). **Tags:** DirectShow, C++, Windows, Streaming, Encoding, MKV, WebM, TS, H.264, H.265, VP8, VP9, MPEG-2, AAC, MP3, Opus, FLAC, Vorbis, Speex # Encoding Filters Pack - Codecs Reference ## Overview This document provides a comprehensive reference for all video and audio codecs supported by the DirectShow Encoding Filters Pack. The pack includes both software and hardware-accelerated encoders for professional media encoding. --- ## Video Codecs ### H.264/AVC (MPEG-4 Part 10) The most widely used video codec for streaming, broadcasting, and file storage. #### Encoder Options | Encoder Type | Description | Hardware Support | Performance | Quality | | --- | --- | --- | --- | --- | | **Software (x264)** | CPU-based H.264 encoder | None | Moderate | Excellent | | **NVENC** | NVIDIA GPU encoder | NVIDIA GPUs (Kepler+) | Very Fast | Good-Excellent | | **QuickSync** | Intel integrated graphics | Intel CPUs (2nd gen+) | Fast | Good | | **AMD AMF** | AMD GPU encoder | AMD GPUs (GCN+) | Fast | Good | | **Media Foundation** | Windows MF encoder | Various (OS-dependent) | Moderate | Good | | #### Profiles and Levels | | | | | | **Profiles**: | | | | | | - **Baseline** - Basic features, mobile devices | | | | | | - **Main** - Standard features, most applications | | | | | | - **High** - Advanced features, HD content, Blu-ray | | | | | | **Common Levels**: | | | | | | - **Level 3.0** - SD (720x480 @ 30 fps) | | | | | | - **Level 3.1** - 720p (1280x720 @ 30 fps) | | | | | | - **Level 4.0** - 1080p (1920x1080 @ 30 fps) | | | | | | - **Level 4.1** - 1080p @ 60 fps | | | | | | - **Level 5.0** - 4K (3840x2160 @ 30 fps) | | | | | | - **Level 5.1** - 4K @ 60 fps | | | | | | #### Rate Control Modes | | | | | | Mode | Description | Use Case | Bitrate Behavior | | | ------ | ------------- | ---------- | ------------------ | | | **CBR** | Constant Bitrate | Streaming, broadcasting | Fixed bitrate | | | **VBR** | Variable Bitrate | File storage | Varies based on complexity | | | **CQP** | Constant Quantization | High quality archival | Varies significantly | | | #### Recommended Settings | | | | | | **Streaming (1080p @ 30fps)**: | | | | | | - Bitrate: 4-6 Mbps | | | | | | - Profile: High | | | | | | - Level: 4.0 | | | | | | - GOP Size: 60 (2 seconds) | | | | | | - B-frames: 2 | | | | | | **Recording (1080p @ 60fps)**: | | | | | | - Bitrate: 8-12 Mbps | | | | | | - Profile: High | | | | | | - Level: 4.1 | | | | | | - GOP Size: 120 (2 seconds) | | | | | | - B-frames: 3 | | | | | | **Low Latency Streaming**: | | | | | | - Bitrate: 2-4 Mbps | | | | | | - Profile: Main | | | | | | - Level: 3.1 | | | | | | - GOP Size: 30 (1 second) | | | | | | - B-frames: 0 | | | | | | --- | | | | | ### H.265/HEVC (High Efficiency Video Coding) Next-generation codec offering 40-50% better compression than H.264. #### Encoder Options | Encoder Type | Description | Hardware Support | Performance | Quality | | --- | --- | --- | --- | --- | | **Software (x265)** | CPU-based HEVC encoder | None | Slow | Excellent | | **NVENC** | NVIDIA GPU encoder | NVIDIA GPUs (Maxwell+) | Fast | Good-Excellent | | **QuickSync** | Intel integrated graphics | Intel CPUs (6th gen+) | Fast | Good | | **AMD AMF** | AMD GPU encoder | AMD GPUs (Fiji+) | Fast | Good | #### Profiles and Tiers **Profiles**: - **Main** - 8-bit, 4:2:0, standard use - **Main 10** - 10-bit, HDR support - **Main Still Picture** - Single images **Tiers**: - **Main Tier** - Standard applications - **High Tier** - Professional/broadcast **Common Levels**: - **Level 3.1** - 720p @ 30 fps - **Level 4.0** - 1080p @ 30 fps - **Level 4.1** - 1080p @ 60 fps - **Level 5.0** - 4K @ 30 fps - **Level 5.1** - 4K @ 60 fps #### Recommended Settings **4K Streaming (2160p @ 30fps)**: - Bitrate: 15-20 Mbps - Profile: Main - Level: 5.0 - GOP Size: 60 - Tile Encoding: Enabled **1080p High Quality**: - Bitrate: 3-5 Mbps - Profile: Main or Main 10 - Level: 4.0 - GOP Size: 90 --- ### VP8 Google's open-source video codec, primarily for WebM containers. #### Features - **License**: Royalty-free, open source - **Container**: WebM (preferred), MKV - **Hardware Support**: Limited - **Quality**: Good at medium-high bitrates - **Complexity**: Moderate encoding time #### Recommended Settings **WebM Streaming (720p)**: - Bitrate: 1-2 Mbps - GOP Size: 120 - Quality: Good (0-63 scale, lower is better) - Threads: Auto --- ### VP9 Successor to VP8 with significantly improved compression efficiency. #### Features - **License**: Royalty-free, open source - **Container**: WebM (primary), MKV - **Hardware Support**: Recent GPUs (Intel, NVIDIA, AMD) - **Quality**: Comparable to H.265 - **Complexity**: Very high (software), moderate (hardware) #### Profiles - **Profile 0** - 8-bit, 4:2:0 (most common) - **Profile 1** - 8-bit, 4:2:2/4:4:4 - **Profile 2** - 10/12-bit, 4:2:0 - **Profile 3** - 10/12-bit, 4:2:2/4:4:4 #### Recommended Settings **YouTube/WebM (1080p @ 30fps)**: - Bitrate: 2-4 Mbps - Quality/Speed: 1 (fastest), 0 (slowest/best) - GOP Size: 60 - Tile Columns: 2 --- ### MPEG-2 Legacy codec still used for DVDs and broadcasting. #### Features - **License**: Requires license - **Container**: MPEG-PS, MPEG-TS, VOB - **Hardware Support**: Universal - **Quality**: Good but requires higher bitrates - **Use Cases**: DVD authoring, broadcasting #### Common Variants - **MPEG-2 DVD** - 4-8 Mbps, 720x480/720x576 - **MPEG-2 SVCD** - 2.5 Mbps, 480x480/480x576 - **MPEG-2 HD** - 15-25 Mbps, 1920x1080 #### Recommended Settings **DVD Video (NTSC)**: - Resolution: 720x480 - Bitrate: 6 Mbps - GOP Size: 15 (NTSC) or 12 (PAL) - Aspect Ratio: 16:9 or 4:3 --- ### MPEG-4 Part 2 Older MPEG-4 Visual codec (DivX/Xvid era). #### Features - **License**: Requires license - **Container**: AVI, MP4, MKV - **Quality**: Moderate - **Use Cases**: Legacy content, low-power devices #### Recommended Settings **Standard Definition**: - Resolution: 640x480 - Bitrate: 1-2 Mbps - GOP Size: 250 --- ## Audio Codecs ### AAC (Advanced Audio Coding) Industry-standard audio codec for most applications. #### Encoder Options | Encoder Type | Description | Quality | Performance | | --- | --- | --- | --- | | **FFmpeg AAC** | Software encoder | Good | Fast | | **Media Foundation AAC** | Windows built-in | Good | Fast | | **FAAC** | Open-source encoder | Moderate | Fast | | #### Profiles | | | | | - **AAC-LC (Low Complexity)** - Standard, most compatible | | | | | - **HE-AAC (High Efficiency)** - Better at low bitrates | | | | | - **HE-AAC v2** - Even better for very low bitrates | | | | | #### Recommended Bitrates | | | | | Quality | Stereo | 5.1 Surround | | | --------- | -------- | -------------- | | | **Low** | 64-96 kbps | 192 kbps | | | **Medium** | 128 kbps | 256 kbps | | | **High** | 192 kbps | 384 kbps | | | **Very High** | 256-320 kbps | 448-640 kbps | | | #### Sample Rates | | | | | - **44.1 kHz** - CD quality, music | | | | | - **48 kHz** - Professional audio, video | | | | | - **32 kHz** - Lower quality (voice) | | | | | --- | | | | ### MP3 (MPEG-1/2 Audio Layer III) Legacy but still widely used audio codec. #### Encoder Options - **LAME** - Excellent quality open-source encoder - **FFmpeg MP3** - Built-in encoder #### Bitrate Modes | Mode | Description | File Size | Quality | | --- | --- | --- | --- | | **CBR** | Constant Bitrate | Predictable | Consistent | | **VBR** | Variable Bitrate | Smaller | Better | | **ABR** | Average Bitrate | Balanced | Good | #### Recommended Settings **Music (High Quality)**: - Mode: VBR - Quality: V0-V2 (LAME scale) - Approximate Bitrate: 190-245 kbps - Sample Rate: 44.1 kHz **Podcast/Speech**: - Mode: CBR - Bitrate: 96-128 kbps - Sample Rate: 44.1 kHz **Low Bandwidth**: - Mode: VBR - Quality: V5-V6 - Approximate Bitrate: 120-150 kbps --- ### Vorbis Open-source alternative to MP3 and AAC. #### Features - **License**: Completely free, no patents - **Container**: OGG (primary), WebM, MKV - **Quality**: Excellent, especially at low-mid bitrates - **Compatibility**: Good but not universal #### Recommended Settings **Music (High Quality)**: - Quality: 6-8 (0-10 scale) - Approximate Bitrate: 192-256 kbps - Sample Rate: 44.1 kHz or 48 kHz **Streaming**: - Quality: 4-5 - Approximate Bitrate: 128-160 kbps --- ### Opus Modern, highly efficient codec for both speech and music. #### Features - **License**: Royalty-free, standardized (RFC 6716) - **Container**: WebM, MKV, OGG - **Latency**: Extremely low (5-66.5 ms) - **Bitrate Range**: 6-510 kbps - **Quality**: Superior to MP3, AAC, Vorbis #### Applications - **VoIP/Voice Chat**: 8-24 kbps - **Music Streaming**: 64-128 kbps - **High Fidelity**: 128-256 kbps #### Recommended Settings **Voice Chat**: - Bitrate: 16-24 kbps - Sample Rate: 16 kHz or 48 kHz - Application: VoIP **Music**: - Bitrate: 96-160 kbps - Sample Rate: 48 kHz - Application: Audio --- ### FLAC (Free Lossless Audio Codec) Lossless audio compression. #### Features - **License**: Open source, royalty-free - **Compression**: Typically 40-60% of original - **Quality**: Bit-perfect lossless - **Compatibility**: Good and improving #### Compression Levels - **Level 0** - Fastest, ~50% compression - **Level 5** - Default, ~55% compression - **Level 8** - Slowest, ~60% compression #### Recommended Settings **Archival**: - Compression Level: 5-8 - Sample Rate: Original (typically 44.1 or 48 kHz) - Bit Depth: Original (16 or 24-bit) **Streaming**: - Compression Level: 0-3 - Sample Rate: 44.1 or 48 kHz --- ### Speex Specialized codec for voice compression. #### Features - **License**: Open source (BSD) - **Purpose**: Speech compression (not music) - **Bitrate**: 2-44 kbps - **Quality**: Optimized for voice #### Modes - **Narrowband** (8 kHz) - Phone quality, 2.15-24.6 kbps - **Wideband** (16 kHz) - Better clarity, 4-44 kbps - **Ultra-wideband** (32 kHz) - Full speech spectrum #### Recommended Settings **VoIP**: - Mode: Wideband - Quality: 6-8 (0-10 scale) - Bitrate: ~15-20 kbps --- ## Hardware Acceleration Overview ### NVIDIA NVENC **Supported Codecs**: - H.264/AVC (all NVIDIA GPUs from Kepler generation) - H.265/HEVC (Maxwell generation and newer) **Generations**: - **Kepler** (GTX 600/700) - 1st gen, basic H.264 - **Maxwell** (GTX 900) - 2nd gen, HEVC support - **Pascal** (GTX 10XX) - 3rd gen, improved quality - **Turing/Ampere** (RTX 20XX/30XX) - 7th/8th gen, excellent quality **Performance**: Up to 8K @ 30 fps (GPU dependent) **Quality Settings**: - Preset: P1 (fastest) to P7 (slowest, best quality) - Recommended: P4-P6 for balanced quality/speed --- ### Intel QuickSync **Supported Codecs**: - H.264/AVC (2nd gen Core and newer) - H.265/HEVC (6th gen Core and newer) - VP9 (9th gen Core and newer) **Generations**: - **Sandy Bridge** (2nd gen) - H.264 support - **Skylake** (6th gen) - HEVC support - **Ice Lake** (10th gen mobile) - Improved quality - **Rocket Lake** (11th gen) - Enhanced features **Performance**: Up to 4K @ 60 fps **Quality**: Good, improving with each generation --- ### AMD AMF (Advanced Media Framework) **Supported Codecs**: - H.264/AVC (GCN 1.0 and newer) - H.265/HEVC (Fiji/Polaris and newer) **Generations**: - **GCN 1-4** (R7/R9, RX 400/500) - H.264 only - **Vega** (RX Vega) - HEVC support - **RDNA** (RX 5000/6000) - Improved quality **Performance**: Up to 4K @ 60 fps **Quality**: Good, competitive with QuickSync --- ## Codec Selection Guide ### For Streaming (Live) **Recommended**: H.264 (NVENC/QuickSync) - **Reason**: Universal compatibility, low latency, hardware acceleration - **Fallback**: H.264 (software) **Settings**: - 1080p @ 30fps: 4-6 Mbps - 720p @ 30fps: 2.5-4 Mbps - Low latency: Disable B-frames --- ### For Recording (High Quality) **Recommended**: H.265 (NVENC/QuickSync) or H.264 (software) - **Reason**: Best quality-to-size ratio - **Alternative**: HEVC software for maximum quality **Settings**: - 4K @ 30fps: 15-25 Mbps (HEVC) or 35-50 Mbps (H.264) - 1080p @ 60fps: 8-15 Mbps (HEVC) or 15-25 Mbps (H.264) --- ### For Web Delivery **Recommended**: VP9 or H.264 - **Reason**: Browser compatibility, royalty-free (VP9) **Settings**: - VP9: 1080p @ 2-4 Mbps - H.264: 1080p @ 4-6 Mbps --- ### For Audio **Music**: AAC (128-192 kbps) or Opus (96-160 kbps) **Voice**: Opus (16-32 kbps) or Speex (15-20 kbps) **Archival**: FLAC (lossless) **Podcast**: MP3 VBR (V4-V2, ~130-190 kbps) or AAC (128 kbps) --- ## Compatibility Matrix | Codec | MP4 | MKV | AVI | WebM | OGG | MPEG-TS | | --- | --- | --- | --- | --- | --- | --- | | **H.264** | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ | | **H.265** | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | | **VP8** | ✗ | ✓ | ✗ | ✓ | ✗ | ✗ | | **VP9** | ✗ | ✓ | ✗ | ✓ | ✗ | ✗ | | **MPEG-2** | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ | | **AAC** | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | | **MP3** | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ | | **Vorbis** | ✗ | ✓ | ✗ | ✓ | ✓ | ✗ | | **Opus** | ✗ | ✓ | ✗ | ✓ | ✓ | ✗ | | **FLAC** | ✓ | ✓ | ✗ | ✓ | ✓ | ✗ | --- ## See Also - [Encoding Filters Pack Overview](../) - [Muxers Reference](../muxers-reference/) - [NVENC Interface Reference](../interfaces/nvenc/) - [Code Examples](../examples/) ---END OF PAGE--- ## DirectShow Encoding Filter Examples - C++, C#, VB.NET **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/examples/ **Description:** Code examples for DirectShow encoding — NVENC GPU, H.264/H.265 software, AAC/MP3/Opus audio, and MP4/MKV/WebM muxer configuration. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, MP4, MKV, WebM, TS, H.264, H.265, VP9, AAC, MP3, Opus, FLAC, Vorbis, C# **API:** IBaseFilter, IFileSinkFilter, ProgressEventArgs # Encoding Filters Pack - Code Examples ## Overview This page provides practical code examples for encoding video and audio using the Encoding Filters Pack. Covers: - **NVENC Encoder** - NVIDIA hardware encoding (H.264/H.265) - **Software Encoders** - H.264, H.265, VP8, VP9, MPEG-2 - **Audio Encoders** - AAC, MP3, Opus, Vorbis, FLAC - **Muxers** - MP4, MKV, WebM, MPEG-TS, AVI --- ## Prerequisites ### C++ Projects ``` #include #include #include "INVEncConfig.h" // NVENC interface #pragma comment(lib, "strmiids.lib") ``` ### C# Projects ``` using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; using System.Runtime.InteropServices; ``` **NuGet Packages**: - VisioForge.DirectShowAPI - MediaFoundationCore --- ## NVENC Hardware Encoding Examples > **NVENC Preset and Profile GUIDs** — The `SetPreset(Guid)` and `SetProfile(Guid)` methods accept NVIDIA NVENC SDK GUID constants. Real presets: `NV_ENC_PRESET_DEFAULT_GUID`, `NV_ENC_PRESET_HP_GUID` (high performance), `NV_ENC_PRESET_HQ_GUID` (high quality), `NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID`, `NV_ENC_PRESET_LOW_LATENCY_HQ_GUID`, `NV_ENC_PRESET_LOW_LATENCY_HP_GUID`, `NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID`, `NV_ENC_PRESET_BD_GUID`. H.264 profiles: `NV_ENC_H264_PROFILE_BASELINE_GUID`, `NV_ENC_H264_PROFILE_MAIN_GUID`, `NV_ENC_H264_PROFILE_HIGH_GUID`. HEVC: `NV_ENC_HEVC_PROFILE_MAIN_GUID`. These GUIDs are defined in the NVIDIA NVENC SDK (`nvEncodeAPI.h`). ### Example 1: Basic NVENC H.264 Encoding Encode video with NVIDIA hardware acceleration. #### C# NVENC H.264 Encoding ``` using VisioForge.Core.Types.Output; // ... var nvenc = encoderFilter as INVEncConfig; if (nvenc != null) { nvenc.SetCodec(NVENCEncoder.H264); nvenc.SetRateControl(NVENCRateControlMode.CBR); nvenc.SetBitrate(5000000); // 5 Mbps nvenc.SetPreset(NV_ENC_PRESET_DEFAULT_GUID); // Balanced quality/speed nvenc.SetGOP(60); // Keyframe every 60 frames nvenc.SetBFrames(2); // B-frames nvenc.SetProfile(NV_ENC_H264_PROFILE_HIGH_GUID); nvenc.SetLevel(NVENCEncoderLevel.H264_41); // Level 4.1 } ``` #### C++ NVENC H.264 Encoding ``` hr = pEncoder->QueryInterface(IID_INVEncConfig, (void**)&pNVEnc); if (SUCCEEDED(hr)) { pNVEnc->SetCodec(0); // H264 pNVEnc->SetRateControl(2); // CBR pNVEnc->SetBitrate(5000000); // 5 Mbps pNVEnc->SetPreset(NV_ENC_PRESET_DEFAULT_GUID); // Balanced pNVEnc->SetGOP(60); // Keyframe interval pNVEnc->SetBFrames(2); // B-frames pNVEnc->SetProfile(NV_ENC_H264_PROFILE_HIGH_GUID); pNVEnc->SetLevel(41); // Level 4.1 pNVEnc->Release(); } ``` --- ### Example 2: NVENC H.265 (HEVC) Encoding Encode with H.265 for better compression. #### C# NVENC H.265 ## ``` public void EncodeH265(string inputFile, string outputFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add NVENC encoder var encoderFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFNVENCEncoder, "NVENC Encoder"); var nvenc = encoderFilter as INVEncConfig; if (nvenc != null) { nvenc.SetCodec(NVENCEncoder.HEVC); nvenc.SetRateControl(NVENCRateControlMode.CONST_QP); nvenc.SetQp(23); // QP 23: good balance nvenc.SetPreset(NV_ENC_PRESET_HQ_GUID); // High quality nvenc.SetProfile(NV_ENC_HEVC_PROFILE_MAIN_GUID); nvenc.SetLevel(NVENCEncoderLevel.H264_41); // Level 4.1 nvenc.SetGOP(120); // 4 seconds at 30fps nvenc.SetBFrames(3); } // Add muxer var muxerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFMP4Muxer, "MP4 Muxer"); var fileSink = muxerFilter as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Connect and encode... ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, encoderFilter, muxerFilter); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ### Example 3: NVENC Rate Control Modes Different rate control strategies for various use cases. #### C# Rate Control Examples ``` using VisioForge.Core.Types.Output; public void ConfigureRateControl(INVEncConfig nvenc, NVENCRateControlMode mode) { switch (mode) { case NVENCRateControlMode.CBR: nvenc.SetRateControl(NVENCRateControlMode.CBR); nvenc.SetBitrate(5000000); // 5 Mbps target nvenc.SetVbvBitrate(5000000); // Same as target for CBR nvenc.SetVbvSize(10000000); // 10 Mb buffer break; case NVENCRateControlMode.VBR: nvenc.SetRateControl(NVENCRateControlMode.VBR); nvenc.SetBitrate(5000000); // Average 5 Mbps nvenc.SetVbvBitrate(8000000); // Peak 8 Mbps nvenc.SetVbvSize(10000000); break; case NVENCRateControlMode.CONST_QP: nvenc.SetRateControl(NVENCRateControlMode.CONST_QP); nvenc.SetQp(23); // QP: lower = better quality break; } } ``` --- ### Example 4: NVENC Quality Presets Balance between speed and quality. #### C# Quality Presets ## ``` public void SetQualityPreset(INVEncConfig nvenc, string useCase) { switch (useCase.ToLower()) { case "realtime": nvenc.SetPreset(NV_ENC_PRESET_LOW_LATENCY_HP_GUID); nvenc.SetBFrames(0); break; case "fast": nvenc.SetPreset(NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID); nvenc.SetBFrames(1); break; case "balanced": nvenc.SetPreset(NV_ENC_PRESET_DEFAULT_GUID); nvenc.SetBFrames(2); break; case "quality": nvenc.SetPreset(NV_ENC_PRESET_HQ_GUID); nvenc.SetBFrames(3); break; default: nvenc.SetPreset(NV_ENC_PRESET_DEFAULT_GUID); nvenc.SetBFrames(2); break; } } ``` ## Software Encoding Examples ### Example 5: Software H.264 Encoder Use CPU-based H.264 encoding. #### C# Software H.264 ``` public void EncodeSoftwareH264(string inputFile, string outputFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add software H.264 encoder var encoderFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFH264Encoder, // Software encoder "H.264 Encoder"); // Configure encoder (if interface available) // var h264Config = encoderFilter as IH264EncoderConfig; // Configure bitrate, quality, etc. // Add muxer var muxerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFMP4Muxer, "MP4 Muxer"); var fileSink = muxerFilter as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Connect and encode ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, encoderFilter, muxerFilter); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` --- ## Audio Encoding Examples ### Example 6: AAC Audio Encoding Encode audio to AAC format. #### C# AAC Encoding ## ``` public void EncodeAACAudio(string inputFile, string outputFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add video encoder (e.g., NVENC) var videoEncoderFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFNVENCEncoder, "NVENC Encoder"); var nvenc = videoEncoderFilter as INVEncConfig; if (nvenc != null) { nvenc.SetCodec(NVENCEncoder.H264); nvenc.SetRateControl(NVENCRateControlMode.CBR); nvenc.SetBitrate(5000000); nvenc.SetPreset(NV_ENC_PRESET_DEFAULT_GUID); } // Add AAC audio encoder var audioEncoderFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFAACEncoder, "AAC Encoder"); // Configure AAC (if interface available) // var aacConfig = audioEncoderFilter as IAACEncoderConfig; // aacConfig?.SetBitrate(192000); // 192 kbps // aacConfig?.SetProfile(AAC_PROFILE_LC); // Add muxer var muxerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFMP4Muxer, "MP4 Muxer"); var fileSink = muxerFilter as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Connect filters ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); // Video path captureGraph.RenderStream(null, MediaType.Video, sourceFilter, videoEncoderFilter, muxerFilter); // Audio path captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, audioEncoderFilter, muxerFilter); // Run encoding var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ### Example 7: Multiple Audio Codec Support Support for different audio codecs. #### C# Audio Codec Selection ``` public enum AudioCodec { AAC, MP3, Opus, Vorbis, FLAC } public IBaseFilter CreateAudioEncoder(IFilterGraph2 filterGraph, AudioCodec codec) { Guid encoderCLSID; string encoderName; switch (codec) { case AudioCodec.AAC: encoderCLSID = Consts.CLSID_VFAACEncoder; encoderName = "AAC Encoder"; break; case AudioCodec.MP3: encoderCLSID = Consts.CLSID_VFMP3Encoder; encoderName = "MP3 Encoder"; break; case AudioCodec.Opus: encoderCLSID = Consts.CLSID_VFOpusEncoder; encoderName = "Opus Encoder"; break; case AudioCodec.Vorbis: encoderCLSID = Consts.CLSID_VFVorbisEncoder; encoderName = "Vorbis Encoder"; break; case AudioCodec.FLAC: encoderCLSID = Consts.CLSID_VFFLACEncoder; encoderName = "FLAC Encoder"; break; default: throw new ArgumentException("Unsupported audio codec"); } return FilterGraphTools.AddFilterFromClsid(filterGraph, encoderCLSID, encoderName); } ``` --- ## Container Muxing Examples ### Example 8: MP4 Container Mux video and audio to MP4 format. #### C# MP4 Muxing ## ``` public void CreateMP4(string inputFile, string outputFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add video encoder var videoEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFNVENCEncoder, "NVENC Encoder"); // Add audio encoder var audioEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFAACEncoder, "AAC Encoder"); // Add MP4 muxer var muxerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFMP4Muxer, "MP4 Muxer"); // Set output file var fileSink = muxerFilter as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Configure muxer (if needed) // var mp4Config = muxerFilter as IMP4MuxerConfig; // mp4Config?.SetFastStart(true); // Enable fast start for web // Connect filters ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, videoEncoder, muxerFilter); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, audioEncoder, muxerFilter); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ### Example 9: MKV Container Create Matroska (MKV) files. #### C# MKV Muxing ``` public void CreateMKV(string inputFile, string outputFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add encoders var videoEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFNVENCEncoder, "NVENC Encoder"); var audioEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFAACEncoder, "AAC Encoder"); // Add MKV muxer var muxerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFMKVMuxer, "MKV Muxer"); var fileSink = muxerFilter as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Connect and encode ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, videoEncoder, muxerFilter); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, audioEncoder, muxerFilter); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` --- ### Example 10: WebM Container Create WebM files for web delivery. #### C# WebM Muxing ## ``` public void CreateWebM(string inputFile, string outputFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add VP9 video encoder (WebM standard) var videoEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVP9Encoder, "VP9 Encoder"); // Add Opus audio encoder (WebM standard) var audioEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFOpusEncoder, "Opus Encoder"); // Add WebM muxer var muxerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFWebMMuxer, "WebM Muxer"); var fileSink = muxerFilter as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Connect and encode ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, videoEncoder, muxerFilter); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, audioEncoder, muxerFilter); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` ## Complete Encoding Pipeline ### Example 11: Full-Featured Encoder Complete encoding application with all features. #### C# Complete Encoder ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class CompleteEncoder : IDisposable { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IMediaEventEx mediaEventEx; private IMediaSeeking mediaSeeking; private const int WM_GRAPHNOTIFY = 0x8000 + 1; public event EventHandler EncodingComplete; public event EventHandler ProgressChanged; public class ProgressEventArgs : EventArgs { public long CurrentPosition { get; set; } public long Duration { get; set; } public double PercentComplete { get; set; } } public void Initialize(IntPtr notifyHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; mediaEventEx = (IMediaEventEx)filterGraph; mediaSeeking = (IMediaSeeking)filterGraph; int hr = mediaEventEx.SetNotifyWindow(notifyHandle, WM_GRAPHNOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); } public void ConfigureEncoding( string inputFile, string outputFile, VideoCodec videoCodec, AudioCodec audioCodec, ContainerFormat container, int videoBitrate = 5000000, int audioBitrate = 192000) { // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Create video encoder IBaseFilter videoEncoder = CreateVideoEncoder(videoCodec); ConfigureVideoEncoder(videoEncoder, videoCodec, videoBitrate); // Create audio encoder IBaseFilter audioEncoder = CreateAudioEncoder(audioCodec); ConfigureAudioEncoder(audioEncoder, audioCodec, audioBitrate); // Create muxer IBaseFilter muxer = CreateMuxer(container); // Set output file var fileSink = muxer as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Connect pipeline int hr = captureGraph.RenderStream(null, MediaType.Video, sourceFilter, videoEncoder, muxer); hr = captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, audioEncoder, muxer); } private IBaseFilter CreateVideoEncoder(VideoCodec codec) { Guid clsid; string name; switch (codec) { case VideoCodec.H264_NVENC: clsid = Consts.CLSID_VFNVENCEncoder; name = "NVENC H.264"; break; case VideoCodec.H265_NVENC: clsid = Consts.CLSID_VFNVENCEncoder; name = "NVENC H.265"; break; case VideoCodec.H264_Software: clsid = Consts.CLSID_VFH264Encoder; name = "Software H.264"; break; default: throw new ArgumentException("Unsupported video codec"); } return FilterGraphTools.AddFilterFromClsid(filterGraph, clsid, name); } private void ConfigureVideoEncoder(IBaseFilter encoder, VideoCodec codec, int bitrate) { if (codec == VideoCodec.H264_NVENC || codec == VideoCodec.H265_NVENC) { var nvenc = encoder as INVEncConfig; if (nvenc != null) { nvenc.SetCodec(codec == VideoCodec.H264_NVENC ? NVENCEncoder.H264 : NVENCEncoder.HEVC); nvenc.SetRateControl(NVENCRateControlMode.CBR); nvenc.SetBitrate(bitrate); nvenc.SetPreset(NV_ENC_PRESET_DEFAULT_GUID); nvenc.SetGOP(60); nvenc.SetBFrames(2); } } // Configure other encoders... } private IBaseFilter CreateAudioEncoder(AudioCodec codec) { Guid clsid; string name; switch (codec) { case AudioCodec.AAC: clsid = Consts.CLSID_VFAACEncoder; name = "AAC Encoder"; break; case AudioCodec.MP3: clsid = Consts.CLSID_VFMP3Encoder; name = "MP3 Encoder"; break; default: throw new ArgumentException("Unsupported audio codec"); } return FilterGraphTools.AddFilterFromClsid(filterGraph, clsid, name); } private void ConfigureAudioEncoder(IBaseFilter encoder, AudioCodec codec, int bitrate) { // Configure audio encoder based on codec type // (Interface-specific configuration) } private IBaseFilter CreateMuxer(ContainerFormat format) { Guid clsid; string name; switch (format) { case ContainerFormat.MP4: clsid = Consts.CLSID_VFMP4Muxer; name = "MP4 Muxer"; break; case ContainerFormat.MKV: clsid = Consts.CLSID_VFMKVMuxer; name = "MKV Muxer"; break; case ContainerFormat.WebM: clsid = Consts.CLSID_VFWebMMuxer; name = "WebM Muxer"; break; default: throw new ArgumentException("Unsupported container format"); } return FilterGraphTools.AddFilterFromClsid(filterGraph, clsid, name); } public void StartEncoding() { mediaControl?.Run(); } public void Stop() { mediaControl?.Stop(); } public double GetProgress() { if (mediaSeeking != null) { mediaSeeking.GetCurrentPosition(out long position); mediaSeeking.GetDuration(out long duration); if (duration > 0) { return (double)position / duration * 100.0; } } return 0.0; } public void HandleGraphEvent() { if (mediaEventEx != null) { while (mediaEventEx.GetEvent(out EventCode eventCode, out IntPtr param1, out IntPtr param2, 0) == 0) { mediaEventEx.FreeEventParams(eventCode, param1, param2); if (eventCode == EventCode.Complete) { EncodingComplete?.Invoke(this, EventArgs.Empty); } } } } public void Dispose() { if (mediaControl != null) { mediaControl.Stop(); } if (mediaEventEx != null) { mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); } FilterGraphTools.RemoveAllFilters(filterGraph); if (mediaEventEx != null) Marshal.ReleaseComObject(mediaEventEx); if (mediaSeeking != null) Marshal.ReleaseComObject(mediaSeeking); if (captureGraph != null) Marshal.ReleaseComObject(captureGraph); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } public enum VideoCodec { H264_NVENC, H265_NVENC, H264_Software, VP8, VP9 } public enum ContainerFormat { MP4, MKV, WebM, MPEG_TS, AVI } ``` --- ## Troubleshooting ### Issue: NVENC Not Available **Solution**: Check GPU compatibility: ``` var nvenc2 = encoder as INVEncConfig2; if (nvenc2 != null) { int hr = nvenc2.CheckNVENCAvailable(out bool available, out int status); if (hr != 0 || !available) { Console.WriteLine("NVENC not available - GPU may not support it"); // Fall back to software encoder } } ``` ### Issue: Encoding Too Slow **Solution**: Adjust quality preset: ``` // Use faster preset nvenc.SetPreset(NV_ENC_PRESET_LOW_LATENCY_HP_GUID); nvenc.SetBFrames(0); // Disable B-frames ``` ### Issue: Output File Size Too Large **Solution**: Adjust bitrate or use better codec: ``` // Lower bitrate nvenc.SetBitrate(2000000); // 2 Mbps instead of 5 // Or use H.265 for better compression nvenc.SetCodec(NVENCEncoder.HEVC); ``` --- ## See Also ### Documentation - [NVENC Interface](../interfaces/nvenc/) - Complete NVENC API - [Codecs Reference](../codecs-reference/) - All video/audio codecs - [Muxers Reference](../muxers-reference/) - Container formats ### External Resources - [NVIDIA NVENC Documentation](https://developer.nvidia.com/video-codec-sdk) - [H.264 Specification](https://www.itu.int/rec/T-REC-H.264) ---END OF PAGE--- ## DirectShow Encoding Filters — H.264, H.265, NVENC & More **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/ **Description:** DirectShow video/audio encoders with H.264, H.265, VP8, VP9, AAC, MP3, and GPU acceleration (NVENC, QuickSync, AMF) for Windows apps. **Tags:** DirectShow, C++, Windows, Streaming # DirectShow Encoding Filters Pack ## Introduction The DirectShow Encoding Filters Pack provides a powerful set of media encoding components designed specifically for software developers building professional multimedia applications. This toolkit enables seamless integration of high-performance encoding capabilities for both audio and video streams across a wide variety of popular formats. --- ## Installation Before using the code samples and integrating the filters into your application, you must first install the DirectShow Encoding Filters Pack from the [product page](https://www.visioforge.com/encoding-filters-pack). **Installation Steps**: 1. Download the Encoding Filters Pack installer from the product page 2. Run the installer with administrative privileges 3. The installer will register all encoding and muxing filters 4. Sample applications and source code will be available in the installation directory **Note**: All filters must be properly registered on the system before they can be used in your applications. The installer handles this automatically. --- ## Key Features ### Multi-Format Encoding Support The filters pack supports numerous industry-standard formats, including: - **MP4 container** with H264, HEVC, and AAC codecs - **MPEG-TS** streams - **MKV** (Matroska) containers - **WebM** format with VP8/VP9 video codecs - Multiple audio formats including **Vorbis**, **MP3**, **FLAC**, and **Opus** ### Hardware Acceleration Developers can leverage GPU acceleration for improved encoding performance: - **Intel** QuickSync technology - **AMD/ATI** hardware acceleration - **Nvidia** NVENC encoding support This hardware optimization dramatically improves encoding speeds while reducing CPU load in your applications. ### Flexible Implementation Options The pack includes: - Standalone H264/AAC encoders utilizing CPU resources - Specialized muxer components with integrated video and audio encoders - Options for both CPU and GPU-based encoding paths ## Technical Capabilities The filter components integrate seamlessly into DirectShow application pipelines, providing developers with: - High-quality video encoding at various bitrates and resolutions - Efficient audio compression with configurable quality settings - Advanced container format support with customizable parameters - DirectShow filter graph compatibility for straightforward implementation For detailed specifications and a comprehensive list of all supported video/audio encoders and output formats, please visit the [product page](https://www.visioforge.com/encoding-filters-pack). ## Version History ### 11.4 Release - Updated filter components to match current .Net SDK implementations - Enhanced AMD AMF H264/H265 encoders with latest optimizations - Improved Intel QuickSync H265 encoders for better performance - Refreshed sample applications with new coding examples ### 11.0 Release - Synchronized filters with current .Net SDK versions - Upgraded Nvidia NVENC H264/H265 encoders for better quality - Introduced new SSF muxer filter component ### 10.0 Release - Updated all filters to align with .Net SDK implementations - Enhanced Media Foundation encoders (H264, H265, AAC) - Added dedicated NVENC video encoder filter as CUDA encoder replacement ### 9.0 Release - Optimized MP4 container with H264/AAC output - Expanded WebM format support with VP9 encoding capabilities - Improved H265 encoder filter performance - Enhanced Intel QuickSync H264 encoders ### 8.6 Release - Implemented RTSP sink filter for streaming applications - Added RTMP sink filter in BETA status - Upgraded AAC encoder filter with quality improvements ### 8.5 Initial Release - First public release including filters from .Net SDKs - Core components: AAC encoder, H264 encoders (CPU/GPU) - Additional encoders: H265 (CPU/GPU), VP8, Vorbis - Container support: MP4 muxer, WebM muxer - Streaming capabilities: RTSP source, RTMP source --- ## Resources - [Product Page](https://www.visioforge.com/encoding-filters-pack) - Purchase, licensing, and product information - [Code Examples](https://github.com/visioforge/directshow-samples/tree/main/Encoding%20Filters%20Pack) - Sample applications and implementation examples --- ## See Also - [Codecs Reference](codecs-reference/) - Complete video and audio codec documentation - [Muxers Reference](muxers-reference/) - Container format specifications - [NVENC Interface](interfaces/nvenc/) - NVIDIA hardware encoder API - [Code Examples](examples/) - Practical encoding examples ---END OF PAGE--- ## AAC Encoder DirectShow Filter - COM Interface Reference **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/aac/ **Description:** Configure AAC encoding in DirectShow with IMonogramAACEncoder and IVFAACEncoder interfaces. Bitrate, profile, sample rate, and channel settings for C++/C#. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, Decoding, MP4, TS, AAC, MP3, C# **API:** IMonogramAACEncoder, IVFAACEncoder, AACConfig, VFAACEncoder, IBaseFilter # AAC Encoder Interface Reference ## Overview The AAC (Advanced Audio Coding) encoder DirectShow filters provide interfaces for high-quality audio encoding to the AAC format. AAC is the successor to MP3, offering better sound quality at the same bitrate and is the standard audio codec for MP4, M4A, and streaming applications. Two AAC encoder interfaces are available: - **IMonogramAACEncoder**: Simple configuration interface using a single configuration structure - **IVFAACEncoder**: Comprehensive interface with individual property methods for fine-grained control ## IMonogramAACEncoder Interface ### Overview The **IMonogramAACEncoder** interface provides a simple, structure-based configuration approach for AAC encoding. Configuration is performed using the `AACConfig` structure that contains all essential encoding parameters. **Interface GUID**: `{B2DE30C0-1441-4451-A0CE-A914FD561D7F}` **Inherits From**: `IUnknown` ### AACConfig Structure ``` /// /// AAC encoder configuration structure. /// public struct AACConfig { /// /// AAC version/profile (typically 2 for AAC-LC, 4 for AAC-HE) /// public int version; /// /// Object type / profile: /// 2 = AAC-LC (Low Complexity) - recommended for most uses /// 5 = AAC-HE (High Efficiency) /// 29 = AAC-HEv2 (High Efficiency version 2) /// public int object_type; /// /// Output format type (0 = Raw AAC, 1 = ADTS) /// public int output_type; /// /// Target bitrate in bits per second (e.g., 128000 for 128 kbps) /// public int bitrate; } ``` ### AACInfo Structure ``` /// /// AAC encoder runtime information. /// public struct AACInfo { /// /// Input sample rate in Hz (e.g., 44100, 48000) /// public int samplerate; /// /// Number of audio channels (1 = mono, 2 = stereo, 6 = 5.1, etc.) /// public int channels; /// /// AAC frame size in samples (typically 1024 for AAC-LC) /// public int frame_size; /// /// Total number of frames encoded /// public long frames_done; } ``` ### Interface Definitions #### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// AAC encoder configuration structure. /// [StructLayout(LayoutKind.Sequential)] public struct AACConfig { public int version; public int object_type; public int output_type; public int bitrate; } /// /// AAC encoder runtime information. /// [StructLayout(LayoutKind.Sequential)] public struct AACInfo { public int samplerate; public int channels; public int frame_size; public long frames_done; } /// /// Monogram AAC encoder configuration interface. /// Provides structure-based configuration for AAC encoding. /// [ComImport] [Guid("B2DE30C0-1441-4451-A0CE-A914FD561D7F")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IMonogramAACEncoder { /// /// Gets the current AAC encoder configuration. /// /// Reference to AACConfig structure to receive current settings /// HRESULT (0 for success) [PreserveSig] int GetConfig(ref AACConfig config); /// /// Sets the AAC encoder configuration. /// /// Reference to AACConfig structure containing desired settings /// HRESULT (0 for success) [PreserveSig] int SetConfig(ref AACConfig config); } } ``` #### C++ Definition ``` #include // {B2DE30C0-1441-4451-A0CE-A914FD561D7F} DEFINE_GUID(IID_IMonogramAACEncoder, 0xb2de30c0, 0x1441, 0x4451, 0xa0, 0xce, 0xa9, 0x14, 0xfd, 0x56, 0x1d, 0x7f); /// /// AAC encoder configuration structure. /// struct AACConfig { int version; int object_type; int output_type; int bitrate; }; /// /// AAC encoder runtime information. /// struct AACInfo { int samplerate; int channels; int frame_size; __int64 frames_done; }; /// /// Monogram AAC encoder configuration interface. /// DECLARE_INTERFACE_(IMonogramAACEncoder, IUnknown) { /// /// Gets the current AAC encoder configuration. /// /// Pointer to AACConfig structure to receive settings /// S_OK for success STDMETHOD(GetConfig)(THIS_ AACConfig* config ) PURE; /// /// Sets the AAC encoder configuration. /// /// Pointer to AACConfig structure with desired settings /// S_OK for success STDMETHOD(SetConfig)(THIS_ const AACConfig* config ) PURE; }; ``` #### Delphi Definition ``` uses ActiveX, ComObj; const IID_IMonogramAACEncoder: TGUID = '{B2DE30C0-1441-4451-A0CE-A914FD561D7F}'; type /// /// AAC encoder configuration structure. /// TAACConfig = record version: Integer; object_type: Integer; output_type: Integer; bitrate: Integer; end; /// /// AAC encoder runtime information. /// TAACInfo = record samplerate: Integer; channels: Integer; frame_size: Integer; frames_done: Int64; end; /// /// Monogram AAC encoder configuration interface. /// IMonogramAACEncoder = interface(IUnknown) ['{B2DE30C0-1441-4451-A0CE-A914FD561D7F}'] /// /// Gets the current AAC encoder configuration. /// function GetConfig(var config: TAACConfig): HRESULT; stdcall; /// /// Sets the AAC encoder configuration. /// function SetConfig(const config: TAACConfig): HRESULT; stdcall; end; ``` --- ## IVFAACEncoder Interface ### Overview The **IVFAACEncoder** interface provides comprehensive, property-based configuration for AAC encoding with individual getter/setter methods for each parameter. This interface offers finer control and is easier to use for incremental configuration changes. **Interface GUID**: `{0BEF7533-39E6-42a5-863F-E087FAB5D84F}` **Inherits From**: `IUnknown` ### Interface Definitions #### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// VisioForge AAC encoder configuration interface. /// Provides comprehensive property-based control over AAC encoding parameters. /// [ComImport] [Guid("0BEF7533-39E6-42a5-863F-E087FAB5D84F")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFAACEncoder { /// /// Forces a specific input sample rate. Set to 0 to accept any rate. /// /// Sample rate in Hz (e.g., 44100, 48000). 0 = any rate /// HRESULT (0 for success) [PreserveSig] int SetInputSampleRate(uint ulSampleRate); /// /// Gets the configured input sample rate. /// /// Receives sample rate in Hz. 0 if not fixed /// HRESULT (0 for success) [PreserveSig] int GetInputSampleRate(out uint pulSampleRate); /// /// Sets the number of input channels. /// /// Number of channels (1=mono, 2=stereo, 6=5.1, etc.) /// HRESULT (0 for success) [PreserveSig] int SetInputChannels(short nChannels); /// /// Gets the number of input channels. /// /// Receives the number of channels /// HRESULT (0 for success) [PreserveSig] int GetInputChannels(out short pnChannels); /// /// Sets the target bitrate. Set to -1 to use maximum bitrate. /// /// Bitrate in bits per second (e.g., 128000). -1 = maximum /// HRESULT (0 for success) [PreserveSig] int SetBitRate(uint ulBitRate); /// /// Gets the configured bitrate. /// /// Receives bitrate in bps. -1 if set to maximum /// HRESULT (0 for success) [PreserveSig] int GetBitRate(out uint pulBitRate); /// /// Sets the AAC profile type. /// /// Profile: 2=AAC-LC, 5=AAC-HE, 29=AAC-HEv2 /// HRESULT (0 for success) [PreserveSig] int SetProfile(uint uProfile); /// /// Gets the current AAC profile. /// /// Receives the profile type /// HRESULT (0 for success) [PreserveSig] int GetProfile(out uint puProfile); /// /// Sets the output format. /// /// Format: 0=Raw AAC, 1=ADTS /// HRESULT (0 for success) [PreserveSig] int SetOutputFormat(uint uFormat); /// /// Gets the output format. /// /// Receives the output format /// HRESULT (0 for success) [PreserveSig] int GetOutputFormat(out uint puFormat); /// /// Sets the time shift value for timestamp adjustment. /// /// Time shift in milliseconds /// HRESULT (0 for success) [PreserveSig] int SetTimeShift(int timeShift); /// /// Gets the time shift value. /// /// Receives the time shift in milliseconds /// HRESULT (0 for success) [PreserveSig] int GetTimeShift(out int ptimeShift); /// /// Enables or disables Low Frequency Effects (LFE) channel. /// /// 1 to enable LFE, 0 to disable /// HRESULT (0 for success) [PreserveSig] int SetLFE(uint lfe); /// /// Gets the LFE channel state. /// /// Receives LFE state (1=enabled, 0=disabled) /// HRESULT (0 for success) [PreserveSig] int GetLFE(out uint p); /// /// Enables or disables Temporal Noise Shaping (TNS). /// TNS improves encoding of transient sounds. /// /// 1 to enable TNS, 0 to disable /// HRESULT (0 for success) [PreserveSig] int SetTNS(uint tns); /// /// Gets the TNS state. /// /// Receives TNS state (1=enabled, 0=disabled) /// HRESULT (0 for success) [PreserveSig] int GetTNS(out uint p); /// /// Enables or disables Mid-Side stereo coding. /// Can improve compression for stereo audio. /// /// 1 to enable mid-side coding, 0 to disable /// HRESULT (0 for success) [PreserveSig] int SetMidSide(uint v); /// /// Gets the mid-side coding state. /// /// Receives mid-side state (1=enabled, 0=disabled) /// HRESULT (0 for success) [PreserveSig] int GetMidSide(out uint p); } } ``` #### C++ Definition ``` #include // {0BEF7533-39E6-42a5-863F-E087FAB5D84F} DEFINE_GUID(IID_IVFAACEncoder, 0x0bef7533, 0x39e6, 0x42a5, 0x86, 0x3f, 0xe0, 0x87, 0xfa, 0xb5, 0xd8, 0x4f); /// /// VisioForge AAC encoder configuration interface. /// DECLARE_INTERFACE_(IVFAACEncoder, IUnknown) { STDMETHOD(SetInputSampleRate)(THIS_ unsigned long ulSampleRate ) PURE; STDMETHOD(GetInputSampleRate)(THIS_ unsigned long* pulSampleRate ) PURE; STDMETHOD(SetInputChannels)(THIS_ short nChannels ) PURE; STDMETHOD(GetInputChannels)(THIS_ short* pnChannels ) PURE; STDMETHOD(SetBitRate)(THIS_ unsigned long ulBitRate ) PURE; STDMETHOD(GetBitRate)(THIS_ unsigned long* pulBitRate ) PURE; STDMETHOD(SetProfile)(THIS_ unsigned long uProfile ) PURE; STDMETHOD(GetProfile)(THIS_ unsigned long* puProfile ) PURE; STDMETHOD(SetOutputFormat)(THIS_ unsigned long uFormat ) PURE; STDMETHOD(GetOutputFormat)(THIS_ unsigned long* puFormat ) PURE; STDMETHOD(SetTimeShift)(THIS_ int timeShift ) PURE; STDMETHOD(GetTimeShift)(THIS_ int* ptimeShift ) PURE; STDMETHOD(SetLFE)(THIS_ unsigned long lfe ) PURE; STDMETHOD(GetLFE)(THIS_ unsigned long* p ) PURE; STDMETHOD(SetTNS)(THIS_ unsigned long tns ) PURE; STDMETHOD(GetTNS)(THIS_ unsigned long* p ) PURE; STDMETHOD(SetMidSide)(THIS_ unsigned long v ) PURE; STDMETHOD(GetMidSide)(THIS_ unsigned long* p ) PURE; }; ``` #### Delphi Definition ``` uses ActiveX, ComObj; const IID_IVFAACEncoder: TGUID = '{0BEF7533-39E6-42a5-863F-E087FAB5D84F}'; type /// /// VisioForge AAC encoder configuration interface. /// IVFAACEncoder = interface(IUnknown) ['{0BEF7533-39E6-42a5-863F-E087FAB5D84F}'] function SetInputSampleRate(ulSampleRate: Cardinal): HRESULT; stdcall; function GetInputSampleRate(out pulSampleRate: Cardinal): HRESULT; stdcall; function SetInputChannels(nChannels: SmallInt): HRESULT; stdcall; function GetInputChannels(out pnChannels: SmallInt): HRESULT; stdcall; function SetBitRate(ulBitRate: Cardinal): HRESULT; stdcall; function GetBitRate(out pulBitRate: Cardinal): HRESULT; stdcall; function SetProfile(uProfile: Cardinal): HRESULT; stdcall; function GetProfile(out puProfile: Cardinal): HRESULT; stdcall; function SetOutputFormat(uFormat: Cardinal): HRESULT; stdcall; function GetOutputFormat(out puFormat: Cardinal): HRESULT; stdcall; function SetTimeShift(timeShift: Integer): HRESULT; stdcall; function GetTimeShift(out ptimeShift: Integer): HRESULT; stdcall; function SetLFE(lfe: Cardinal): HRESULT; stdcall; function GetLFE(out p: Cardinal): HRESULT; stdcall; function SetTNS(tns: Cardinal): HRESULT; stdcall; function GetTNS(out p: Cardinal): HRESULT; stdcall; function SetMidSide(v: Cardinal): HRESULT; stdcall; function GetMidSide(out p: Cardinal): HRESULT; stdcall; end; ``` ## AAC Profiles and Configuration ### AAC Profiles **AAC-LC (Low Complexity) - Profile 2** (Recommended): - Best quality-to-bitrate ratio - Lowest computational complexity - Universal decoder support - Use for: Music, podcasts, video soundtracks - Bitrate range: 64-320 kbps **AAC-HE (High Efficiency) - Profile 5**: - Optimized for low bitrates - Uses Spectral Band Replication (SBR) - Better quality than AAC-LC at low bitrates (<= 64 kbps) - Use for: Streaming, voice, low-bitrate applications - Bitrate range: 32-80 kbps **AAC-HEv2 (High Efficiency version 2) - Profile 29**: - Further optimized for very low bitrates - Uses Parametric Stereo (PS) in addition to SBR - Best for mono/stereo at extremely low bitrates - Use for: Voice streaming, very low bandwidth - Bitrate range: 16-40 kbps ### Output Formats **Raw AAC (Format 0)**: - Pure AAC bitstream without container - Requires external container (MP4, M4A, MKV) - Use for: Muxing into MP4/M4A files - Smallest output size **ADTS (Audio Data Transport Stream) - Format 1**: - AAC with frame headers - Self-contained, can be played directly - Slightly larger than raw AAC - Use for: Standalone AAC files, streaming - Better error resilience ### Recommended Bitrates | Use Case | Channels | Profile | Bitrate | Notes | | --- | --- | --- | --- | --- | | Voice/Podcast (mono) | 1 | AAC-LC | 64-96 kbps | Clear speech | | Voice/Podcast (stereo) | 2 | AAC-LC | 96-128 kbps | High quality speech | | Music (stereo) standard | 2 | AAC-LC | 128-192 kbps | Good quality | | Music (stereo) high quality | 2 | AAC-LC | 256-320 kbps | Excellent quality | | Low-bandwidth streaming | 2 | AAC-HE | 48-64 kbps | Acceptable quality | | Very low bandwidth | 1-2 | AAC-HEv2 | 24-40 kbps | Basic quality | | 5.1 surround | 6 | AAC-LC | 384-512 kbps | Cinema quality | | ## Usage Examples | | | | | | ### C# Example - IMonogramAACEncoder (High Quality Music) | | | | | | ``` using System; using DirectShowLib; using VisioForge.DirectShowAPI; public class MonogramAACHighQuality { public void ConfigureHighQualityMusic(IBaseFilter audioEncoder) { // Query the Monogram AAC encoder interface var aacEncoder = audioEncoder as IMonogramAACEncoder; if (aacEncoder == null) { Console.WriteLine("Error: Filter does not support IMonogramAACEncoder"); return; } // Configure high quality stereo music encoding var config = new AACConfig { version = 2, // AAC version 2 object_type = 2, // AAC-LC profile output_type = 0, // Raw AAC (for MP4 muxing) bitrate = 192000 // 192 kbps }; int hr = aacEncoder.SetConfig(ref config); if (hr == 0) { Console.WriteLine("AAC encoder configured for high quality music:"); Console.WriteLine(" Profile: AAC-LC"); Console.WriteLine(" Bitrate: 192 kbps"); Console.WriteLine(" Output: Raw AAC for MP4 container"); } else { Console.WriteLine($"Error configuring AAC encoder: 0x{hr:X8}"); } } } ``` | | | | | | ### C# Example - IVFAACEncoder (Comprehensive Configuration) | | | | | | ``` public class VFAACHighQualityMusic { public void ConfigureComprehensive(IBaseFilter audioEncoder) { // Query the VisioForge AAC encoder interface var vfAacEncoder = audioEncoder as IVFAACEncoder; if (vfAacEncoder == null) { Console.WriteLine("Error: Filter does not support IVFAACEncoder"); return; } // Configure comprehensive stereo music encoding vfAacEncoder.SetInputSampleRate(48000); // 48 kHz vfAacEncoder.SetInputChannels(2); // Stereo vfAacEncoder.SetBitRate(256000); // 256 kbps vfAacEncoder.SetProfile(2); // AAC-LC vfAacEncoder.SetOutputFormat(0); // Raw AAC vfAacEncoder.SetTNS(1); // Enable TNS vfAacEncoder.SetMidSide(1); // Enable mid-side coding vfAacEncoder.SetLFE(0); // No LFE (stereo only) vfAacEncoder.SetTimeShift(0); // No time shift Console.WriteLine("VisioForge AAC encoder configured:"); // Verify configuration vfAacEncoder.GetBitRate(out uint bitrate); vfAacEncoder.GetProfile(out uint profile); vfAacEncoder.GetInputChannels(out short channels); Console.WriteLine($" Bitrate: {bitrate / 1000} kbps"); Console.WriteLine($" Profile: {(profile == 2 ? "AAC-LC" : profile.ToString())}"); Console.WriteLine($" Channels: {channels}"); } } ``` | | | | | | ### C# Example - Low Bitrate Streaming (AAC-HE) | | | | | | ``` public class VFAACLowBitrateStreaming { public void ConfigureLowBitrate(IBaseFilter audioEncoder) { var vfAacEncoder = audioEncoder as IVFAACEncoder; if (vfAacEncoder == null) return; // Configure for low-bitrate streaming vfAacEncoder.SetInputSampleRate(44100); // 44.1 kHz vfAacEncoder.SetInputChannels(2); // Stereo vfAacEncoder.SetBitRate(64000); // 64 kbps vfAacEncoder.SetProfile(5); // AAC-HE (High Efficiency) vfAacEncoder.SetOutputFormat(1); // ADTS for streaming vfAacEncoder.SetTNS(1); // Enable TNS vfAacEncoder.SetMidSide(1); // Enable mid-side vfAacEncoder.SetLFE(0); // No LFE Console.WriteLine("AAC-HE configured for low-bitrate streaming"); Console.WriteLine(" 64 kbps stereo with ADTS output"); } } ``` | | | | | | ### C# Example - Voice/Podcast Encoding | | | | | | ``` public class VFAACVoicePodcast { public void ConfigureVoicePodcast(IBaseFilter audioEncoder) { var vfAacEncoder = audioEncoder as IVFAACEncoder; if (vfAacEncoder == null) return; // Configure for voice/podcast (mono) vfAacEncoder.SetInputSampleRate(44100); // 44.1 kHz vfAacEncoder.SetInputChannels(1); // Mono vfAacEncoder.SetBitRate(80000); // 80 kbps vfAacEncoder.SetProfile(2); // AAC-LC vfAacEncoder.SetOutputFormat(0); // Raw AAC vfAacEncoder.SetTNS(1); // Enable TNS for speech vfAacEncoder.SetMidSide(0); // N/A for mono vfAacEncoder.SetLFE(0); // No LFE Console.WriteLine("AAC configured for voice/podcast"); Console.WriteLine(" 80 kbps mono AAC-LC"); } } ``` | | | | | | ### C++ Example - IMonogramAACEncoder | | | | | | ``` #include #include #include "IMonogramAACEncoder.h" void ConfigureMonogramAAC(IBaseFilter* pAudioEncoder) { IMonogramAACEncoder* pAACEncoder = NULL; HRESULT hr = S_OK; // Query the Monogram AAC encoder interface hr = pAudioEncoder->QueryInterface(IID_IMonogramAACEncoder, (void**)&pAACEncoder); if (FAILED(hr) || !pAACEncoder) { std::cout << "Error: Filter does not support IMonogramAACEncoder" << std::endl; return; } // Configure high quality music encoding AACConfig config; config.version = 2; // AAC version 2 config.object_type = 2; // AAC-LC config.output_type = 0; // Raw AAC config.bitrate = 192000; // 192 kbps hr = pAACEncoder->SetConfig(&config); if (SUCCEEDED(hr)) { std::cout << "AAC encoder configured for high quality music" << std::endl; std::cout << " Profile: AAC-LC" << std::endl; std::cout << " Bitrate: 192 kbps" << std::endl; } pAACEncoder->Release(); } ``` | | | | | | ### C++ Example - IVFAACEncoder | | | | | | ``` #include "IVFAACEncoder.h" void ConfigureVFAAC(IBaseFilter* pAudioEncoder) { IVFAACEncoder* pVFAACEncoder = NULL; HRESULT hr = pAudioEncoder->QueryInterface(IID_IVFAACEncoder, (void**)&pVFAACEncoder); if (SUCCEEDED(hr) && pVFAACEncoder) { // Configure comprehensive stereo encoding pVFAACEncoder->SetInputSampleRate(48000); // 48 kHz pVFAACEncoder->SetInputChannels(2); // Stereo pVFAACEncoder->SetBitRate(256000); // 256 kbps pVFAACEncoder->SetProfile(2); // AAC-LC pVFAACEncoder->SetOutputFormat(0); // Raw AAC pVFAACEncoder->SetTNS(1); // Enable TNS pVFAACEncoder->SetMidSide(1); // Enable mid-side pVFAACEncoder->SetLFE(0); // No LFE std::cout << "VisioForge AAC encoder configured" << std::endl; pVFAACEncoder->Release(); } } ``` | | | | | | ### Delphi Example - IMonogramAACEncoder | | | | | | ``` uses DirectShow9, ActiveX; procedure ConfigureMonogramAAC(AudioEncoder: IBaseFilter); var AACEncoder: IMonogramAACEncoder; Config: TAACConfig; hr: HRESULT; begin // Query the Monogram AAC encoder interface hr := AudioEncoder.QueryInterface(IID_IMonogramAACEncoder, AACEncoder); if Failed(hr) or (AACEncoder = nil) then begin WriteLn('Error: Filter does not support IMonogramAACEncoder'); Exit; end; try // Configure high quality music encoding Config.version := 2; // AAC version 2 Config.object_type := 2; // AAC-LC Config.output_type := 0; // Raw AAC Config.bitrate := 192000; // 192 kbps hr := AACEncoder.SetConfig(Config); if Succeeded(hr) then begin WriteLn('AAC encoder configured for high quality music'); WriteLn(' Profile: AAC-LC'); WriteLn(' Bitrate: 192 kbps'); end; finally AACEncoder := nil; end; end; ``` | | | | | | ### Delphi Example - IVFAACEncoder | | | | | | ``` procedure ConfigureVFAAC(AudioEncoder: IBaseFilter); var VFAACEncoder: IVFAACEncoder; begin if Succeeded(AudioEncoder.QueryInterface(IID_IVFAACEncoder, VFAACEncoder)) then begin try // Configure comprehensive stereo encoding VFAACEncoder.SetInputSampleRate(48000); // 48 kHz VFAACEncoder.SetInputChannels(2); // Stereo VFAACEncoder.SetBitRate(256000); // 256 kbps VFAACEncoder.SetProfile(2); // AAC-LC VFAACEncoder.SetOutputFormat(0); // Raw AAC VFAACEncoder.SetTNS(1); // Enable TNS VFAACEncoder.SetMidSide(1); // Enable mid-side VFAACEncoder.SetLFE(0); // No LFE WriteLn('VisioForge AAC encoder configured'); finally VFAACEncoder := nil; end; end; end; ``` | | | | | | ## Best Practices | | | | | | ### Profile Selection | | | | | | **Use AAC-LC (Profile 2) when**: | | | | | | - Encoding music or high-quality audio | | | | | | - Bitrate >= 96 kbps | | | | | | - Maximum decoder compatibility required | | | | | | - **Recommended for most scenarios** | | | | | | **Use AAC-HE (Profile 5) when**: | | | | | | - Bitrate constraints (32-80 kbps) | | | | | | - Streaming over limited bandwidth | | | | | | - Voice/speech content acceptable at lower quality | | | | | | - Mobile/web streaming applications | | | | | | **Use AAC-HEv2 (Profile 29) when**: | | | | | | - Extremely limited bandwidth (< 40 kbps) | | | | | | - Voice-only content | | | | | | - Mono or stereo only (not multichannel) | | | | | | ### Bitrate Guidelines | | | | | | **Mono Speech/Podcast**: | | | | | | - Minimum: 48-64 kbps (AAC-LC) | | | | | | - Recommended: 80-96 kbps (AAC-LC) | | | | | | - High quality: 128 kbps (AAC-LC) | | | | | | **Stereo Music**: | | | | | | - Minimum: 96-128 kbps (AAC-LC) | | | | | | - Recommended: 192-256 kbps (AAC-LC) | | | | | | - High quality: 256-320 kbps (AAC-LC) | | | | | | **Streaming Applications**: | | | | | | - Low bandwidth: 48-64 kbps (AAC-HE, stereo) | | | | | | - Standard bandwidth: 96-128 kbps (AAC-LC, stereo) | | | | | | - High bandwidth: 192-256 kbps (AAC-LC, stereo) | | | | | | ### Output Format Selection | | | | | | **Use Raw AAC (Format 0) when**: | | | | | | - Muxing into MP4, M4A, or MKV containers | | | | | | - Container provides framing and synchronization | | | | | | - **Recommended for most video/multimedia applications** | | | | | | **Use ADTS (Format 1) when**: | | | | | | - Creating standalone .aac files | | | | | | - Streaming without container | | | | | | - Better error recovery needed | | | | | | - Testing/debugging audio independently | | | | | | ### Feature Flags | | | | | | **Temporal Noise Shaping (TNS)**: | | | | | | - **Enable** for all encoding scenarios | | | | | | - Improves transient response | | | | | | - Better quality for percussive sounds | | | | | | - Minimal computational overhead | | | | | | **Mid-Side Stereo Coding**: | | | | | | - **Enable** for stereo music encoding | | | | | | - Improves compression efficiency | | | | | | - Better stereo imaging | | | | | | - No benefit for mono or uncorrelated stereo | | | | | | **Low Frequency Effects (LFE)**: | | | | | | - **Enable** only for 5.1/7.1 surround sound | | | | | | - Dedicated subwoofer channel (.1) | | | | | | - Disable for stereo/mono | | | | | | ## Troubleshooting | | | | | | ### Low Audio Quality | | | | | | **Symptoms**: Muffled sound, artifacts, poor clarity | | | | | | **Possible Causes**: | | | | | | 1. Bitrate too low for content | | | | | | 2. Wrong profile for bitrate | | | | | | 3. TNS disabled | | | | | | **Solutions**: | | | | | | - Increase bitrate to recommended levels (see tables above) | | | | | | - For low bitrates (<= 80 kbps), use AAC-HE instead of AAC-LC | | | | | | - Enable TNS: `SetTNS(1)` | | | | | | - For music, ensure bitrate >= 128 kbps with AAC-LC | | | | | | ### Encoder Initialization Failures | | | | | | **Symptoms**: SetConfig or Set methods return error codes | | | | | | **Possible Causes**: | | | | | | 1. Unsupported sample rate | | | | | | 2. Invalid bitrate for profile | | | | | | 3. Incompatible channel configuration | | | | | | **Solutions**: | | | | | | - Use standard sample rates: 44100, 48000 Hz | | | | | | - Verify bitrate is appropriate for profile | | | | | | - Check channel count matches source audio | | | | | | - For AAC-HE, keep bitrate <= 128 kbps | | | | | | ### File Won't Play | | | | | | **Symptoms**: AAC file doesn't play in media players | | | | | | **Possible Causes**: | | | | | | 1. Raw AAC without container | | | | | | 2. Unsupported profile | | | | | | 3. Corrupted stream | | | | | | **Solutions**: | | | | | | - Use ADTS output format (`SetOutputFormat(1)`) for standalone files | | | | | | - Use Raw AAC (`SetOutputFormat(0)`) only with MP4/M4A container | | | | | | - Verify player supports AAC profile (HE/HEv2 may not be supported on old players) | | | | | | - Ensure proper stream finalization in filter graph | | | | | | ### Compatibility Issues | | | | | | **Symptoms**: AAC plays on some devices but not others | | | | | | **Possible Causes**: | | | | | | 1. Advanced profile not supported (AAC-HE/HEv2) | | | | | | 2. Non-standard configuration | | | | | | **Solutions**: | | | | | | - Use AAC-LC (Profile 2) for maximum compatibility | | | | | | - Use standard sample rates (44100 or 48000 Hz) | | | | | | - Keep bitrates within recommended ranges | | | | | | - Avoid very low bitrates (< 64 kbps) for AAC-LC | | | | | | --- | | | | | ## See Also - [LAME MP3 Encoder Interface](../lame/) - [FLAC Encoder Interface](../flac/) - [Audio Codecs Reference](../../codecs-reference/) - [MP4 Muxer Interface](../mp4-muxer/) - [Encoding Filters Pack Overview](../../) ---END OF PAGE--- ## FFmpeg Encoder DirectShow Filter - MPEG, FLV, DVD Output **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/ffmpeg/ **Description:** IVFFFMPEGEncoder COM interface for encoding to MPEG-1, MPEG-2, FLV, VCD, SVCD, DVD, and Transport Stream in DirectShow. Audio/video codec parameters for C++/C#. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, MP4, FLV, TS, H.264, MPEG-2, AC-3, C# **API:** IVFFFMPEGEncoder, FFMPEGOutputSettings, IBaseFilter, CVFOutputSettings, TFFMPEGOutputSettings # FFMPEG Encoder Interface Reference ## Overview The **IVFFFMPEGEncoder** interface provides comprehensive configuration for encoding video and audio to various formats using the FFMPEG library. This powerful encoder supports multiple output formats including Flash Video (FLV), MPEG-1, MPEG-2, VCD, SVCD, DVD, and MPEG-2 Transport Stream. The encoder uses a structure-based configuration approach where all encoding parameters are set at once, providing a simple yet complete interface for professional video encoding to legacy and streaming formats. **Interface GUID**: `{17B8FF7D-A67F-45CE-B425-0E4F607D8C60}` **Filter CLSID**: `{554AB365-B293-4C1D-9245-E8DB01F027F7}` **Inherits From**: `IUnknown` ## Filter and Interface GUIDs ``` // FFMPEG Encoder Filter CLSID public static readonly Guid CLSID_FFMPEGEncoder = new Guid("554AB365-B293-4C1D-9245-E8DB01F027F7"); // IVFFFMPEGEncoder Interface IID public static readonly Guid IID_IVFFFMPEGEncoder = new Guid("17B8FF7D-A67F-45CE-B425-0E4F607D8C60"); ``` ## Output Formats ### VFFFMPEGDLLOutputFormat Enumeration ``` /// /// FFMPEG encoder output format options. /// public enum VFFFMPEGDLLOutputFormat { /// /// Flash Video (.flv) - Web streaming format /// FLV = 0, /// /// MPEG-1 (.mpg) - Standard MPEG-1 video /// MPEG1 = 1, /// /// MPEG-1 VCD - Video CD compliant format /// Resolution: 352x240 (NTSC) or 352x288 (PAL) /// Bitrate: 1150 kbps /// MPEG1VCD = 2, /// /// MPEG-2 (.mpg) - Standard MPEG-2 video /// MPEG2 = 3, /// /// MPEG-2 Transport Stream (.ts) - Broadcasting and streaming /// MPEG2TS = 4, /// /// MPEG-2 SVCD - Super Video CD compliant format /// Resolution: 480x480 (NTSC) or 480x576 (PAL) /// Bitrate: 2500 kbps /// MPEG2SVCD = 5, /// /// MPEG-2 DVD - DVD-Video compliant format /// Resolution: 720x480 (NTSC) or 720x576 (PAL) /// Bitrate: Up to 9800 kbps /// MPEG2DVD = 6 } ``` ### TV System Standards ``` /// /// Television system standards for video encoding. /// public enum VFFFMPEGDLLTVSystem { /// /// No specific TV system / Auto-detect /// None = 0, /// /// PAL (Phase Alternating Line) /// 25 fps, 576 lines /// Used in: Europe, Asia, Australia, Africa /// PAL = 1, /// /// NTSC (National Television System Committee) /// 29.97 fps, 480 lines /// Used in: North America, Japan, South Korea /// NTSC = 2, /// /// Film standard /// 24 fps /// Used for: Cinema, film transfers /// Film = 3 } ``` ## FFMPEGOutputSettings Structure ``` /// /// Complete configuration structure for FFMPEG encoder. /// Contains all audio, video, and output format settings. /// [StructLayout(LayoutKind.Sequential)] public struct FFMPEGOutputSettings { /// /// Output filename with path. /// [MarshalAs(UnmanagedType.LPWStr)] public string Filename; /// /// True if audio stream is included in output. /// [MarshalAs(UnmanagedType.Bool)] public bool AudioAvailable; /// /// Audio bitrate in bits per second (e.g., 128000 for 128 kbps). /// public int AudioBitrate; /// /// Audio sample rate in Hz (e.g., 44100, 48000). /// public int AudioSamplerate; /// /// Number of audio channels (1 = mono, 2 = stereo). /// public int AudioChannels; /// /// Video frame width in pixels. /// public int VideoWidth; /// /// Video frame height in pixels. /// public int VideoHeight; /// /// Display aspect ratio width (e.g., 16 for 16:9). /// public int AspectRatioW; /// /// Display aspect ratio height (e.g., 9 for 16:9). /// public int AspectRatioH; /// /// Video bitrate in bits per second (e.g., 5000000 for 5 Mbps). /// public int VideoBitrate; /// /// Maximum video bitrate for VBR encoding (bits per second). /// public int VideoMaxRate; /// /// Minimum video bitrate for VBR encoding (bits per second). /// public int VideoMinRate; /// /// Video buffer size in bits (affects latency and smoothness). /// public int VideoBufferSize; /// /// True to enable interlaced encoding (for broadcast TV). /// [MarshalAs(UnmanagedType.Bool)] public bool Interlace; /// /// GOP (Group of Pictures) size - keyframe interval. /// Typical: 12-15 for MPEG-2, 30-60 for web video. /// public int VideoGopSize; /// /// TV system standard (PAL, NTSC, Film, or None). /// [MarshalAs(UnmanagedType.I4)] public VFFFMPEGDLLTVSystem TVSystem; /// /// Output format (FLV, MPEG-1, MPEG-2, etc.). /// [MarshalAs(UnmanagedType.I4)] public VFFFMPEGDLLOutputFormat OutputFormat; } ``` ## Interface Definitions ### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// FFMPEG encoder configuration interface. /// Provides comprehensive encoding to multiple formats using FFMPEG library. /// [ComImport] [Guid("17B8FF7D-A67F-45CE-B425-0E4F607D8C60")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFFFMPEGEncoder { /// /// Sets the complete FFMPEG encoder configuration. /// All encoding parameters must be set at once via this structure. /// /// Complete encoder settings structure [PreserveSig] void set_settings([In] FFMPEGOutputSettings settings); } } ``` ### C++ Definition ``` #include // {17B8FF7D-A67F-45CE-B425-0E4F607D8C60} DEFINE_GUID(IID_IVFFFMPEGEncoder, 0x17b8ff7d, 0xa67f, 0x45ce, 0xb4, 0x25, 0xe, 0x4f, 0x60, 0x7d, 0x8c, 0x60); // {554AB365-B293-4C1D-9245-E8DB01F027F7} DEFINE_GUID(CLSID_FFMPEGEncoder, 0x554ab365, 0xb293, 0x4c1d, 0x92, 0x45, 0xe8, 0xdb, 0x01, 0xf0, 0x27, 0xf7); /// /// Output format enumeration. /// enum FFOutputFormat { of_FLV = 0, of_MPEG1 = 1, of_MPEG1VCD = 2, of_MPEG2 = 3, of_MPEG2TS = 4, of_MPEG2SVCD = 5, of_MPEG2DVD = 6 }; /// /// TV system enumeration. /// enum video_tv_system_t { video_norm_unknown = 0, video_norm_pal = 1, video_norm_ntsc = 2, video_norm_film = 3 }; /// /// FFMPEG encoder output settings structure. /// struct CVFOutputSettings { wchar_t* filename; BOOL audioAvailable; int audioBitrate; int audioSamplerate; int audioChannels; int videoWidth; int videoHeight; int aspectRatioW; int aspectRatioH; int videoBitrate; int videoMaxRate; int videoMinRate; int videoBufferSize; BOOL interlace; int videoGopSize; int tvSystem; int outputFormat; }; /// /// FFMPEG encoder configuration interface. /// DECLARE_INTERFACE_(IVFFFMPEGEncoder, IUnknown) { /// /// Sets the complete FFMPEG encoder configuration. /// /// Complete encoder settings structure STDMETHOD(set_settings)(THIS_ CVFOutputSettings settings ) PURE; }; ``` ### Delphi Definition ``` uses ActiveX, ComObj; const IID_IVFFFMPEGEncoder: TGUID = '{17B8FF7D-A67F-45CE-B425-0E4F607D8C60}'; CLSID_FFMPEGEncoder: TGUID = '{554AB365-B293-4C1D-9245-E8DB01F027F7}'; type /// /// FFMPEG output format enumeration. /// TVFFFMPEGDLLOutputFormat = ( FLV, MPEG1, MPEG1VCD, MPEG2, MPEG2TS, MPEG2SVCD, MPEG2DVD ); /// /// TV system enumeration. Note: the `None` member can collide with the bare /// `None` identifier exposed by other Delphi units (e.g., RTL's `Variants`). /// Reference values via the enum's qualified name — /// `TVFFFMPEGDLLTVSystem.None` — to avoid ambiguity in real code. /// TVFFFMPEGDLLTVSystem = ( None, PAL, NTSC, Film ); /// /// FFMPEG encoder output settings structure. /// TFFMPEGOutputSettings = record Filename: PWideChar; AudioAvailable: BOOL; AudioBitrate: Integer; AudioSamplerate: Integer; AudioChannels: Integer; VideoWidth: Integer; VideoHeight: Integer; AspectRatioW: Integer; AspectRatioH: Integer; VideoBitrate: Integer; VideoMaxRate: Integer; VideoMinRate: Integer; VideoBufferSize: Integer; Interlace: BOOL; VideoGopSize: Integer; TVSystem: Integer; OutputFormat: Integer; end; /// /// FFMPEG encoder configuration interface. /// IVFFFMPEGEncoder = interface(IUnknown) ['{17B8FF7D-A67F-45CE-B425-0E4F607D8C60}'] /// /// Sets the complete FFMPEG encoder configuration. /// procedure set_settings(const settings: TFFMPEGOutputSettings); stdcall; end; ``` ## Output Format Specifications ### FLV (Flash Video) **Format**: Adobe Flash Video (.flv) **Use Cases**: Web streaming, legacy Flash content **Typical Settings**: - Resolution: 640x480, 854x480, 1280x720 - Video Bitrate: 500-2500 kbps - Audio: MP3, 64-128 kbps, 44100 Hz - GOP: 30-60 frames ### MPEG-1 **Format**: MPEG-1 video (.mpg) **Use Cases**: Basic video, legacy systems, web **Typical Settings**: - Resolution: 352x240 (NTSC), 352x288 (PAL) - Video Bitrate: 1150 kbps - Audio: MPEG Layer 2, 224 kbps, 44100 Hz - GOP: 12-15 frames ### MPEG-1 VCD (Video CD) **Format**: Video CD compliant MPEG-1 (.mpg) **Use Cases**: VCD authoring, disc distribution **Required Settings**: - Resolution: 352x240 (NTSC), 352x288 (PAL) - Video Bitrate: 1150 kbps (fixed) - Audio: MPEG Layer 2, 224 kbps, 44100 Hz - GOP: 12 frames (NTSC), 15 frames (PAL) - TV System: Must match (NTSC or PAL) ### MPEG-2 **Format**: MPEG-2 video (.mpg) **Use Cases**: DVD authoring, broadcast, high quality **Typical Settings**: - Resolution: 720x480 (NTSC), 720x576 (PAL) - Video Bitrate: 4000-9800 kbps - Audio: MPEG Layer 2 or AC-3, 192-448 kbps - GOP: 12-15 frames ### MPEG-2 TS (Transport Stream) **Format**: MPEG-2 Transport Stream (.ts) **Use Cases**: Broadcasting, streaming, Blu-ray **Typical Settings**: - Resolution: 720x480, 1280x720, 1920x1080 - Video Bitrate: 3000-15000 kbps - Audio: MPEG Layer 2 or AC-3 - GOP: 12-30 frames - Better error resilience than MPEG-2 PS ### MPEG-2 SVCD (Super Video CD) **Format**: Super Video CD compliant MPEG-2 (.mpg) **Use Cases**: SVCD authoring, disc distribution **Required Settings**: - Resolution: 480x480 (NTSC), 480x576 (PAL) - Video Bitrate: 2500 kbps (typical) - Audio: MPEG Layer 2, 224 kbps, 44100 Hz - GOP: 12-15 frames - TV System: Must match (NTSC or PAL) ### MPEG-2 DVD (DVD-Video) **Format**: DVD-Video compliant MPEG-2 (.mpg) **Use Cases**: DVD authoring, professional distribution **Required Settings**: - Resolution: 720x480 (NTSC), 720x576 (PAL) - Video Bitrate: 4000-9800 kbps - Audio: AC-3 or PCM, up to 448 kbps - GOP: 12 frames (NTSC), 15 frames (PAL) - TV System: Must match (NTSC or PAL) - Interlaced: Typically enabled for broadcast ## Usage Examples ### C# Example - DVD-Quality MPEG-2 (NTSC) ``` using System; using DirectShowLib; using VisioForge.DirectShowAPI; public class FFMPEGDVDEncoder { public void ConfigureDVDNTSC(IBaseFilter ffmpegEncoder) { // Query the FFMPEG encoder interface var encoder = ffmpegEncoder as IVFFFMPEGEncoder; if (encoder == null) { Console.WriteLine("Error: Filter does not support IVFFFMPEGEncoder"); return; } // Configure DVD-compliant MPEG-2 encoding (NTSC) var settings = new FFMPEGOutputSettings { // Output file Filename = "C:\\output\\movie.mpg", // Audio settings AudioAvailable = true, AudioBitrate = 224000, // 224 kbps AudioSamplerate = 48000, // 48 kHz for DVD AudioChannels = 2, // Stereo // Video settings - DVD NTSC specs VideoWidth = 720, VideoHeight = 480, AspectRatioW = 16, AspectRatioH = 9, VideoBitrate = 6000000, // 6 Mbps VideoMaxRate = 9800000, // 9.8 Mbps max for DVD VideoMinRate = 0, VideoBufferSize = 1835008, // Standard DVD buffer Interlace = true, // DVD is interlaced VideoGopSize = 12, // 12 frames for NTSC // Format settings TVSystem = VFFFMPEGDLLTVSystem.NTSC, OutputFormat = VFFFMPEGDLLOutputFormat.MPEG2DVD }; encoder.set_settings(settings); Console.WriteLine("FFMPEG encoder configured for DVD NTSC:"); Console.WriteLine(" Resolution: 720x480 (16:9)"); Console.WriteLine(" Video: 6 Mbps MPEG-2, interlaced"); Console.WriteLine(" Audio: 224 kbps, 48 kHz stereo"); Console.WriteLine(" GOP: 12 frames"); } } ``` ### C# Example - Web Streaming FLV ``` public class FFMPEGWebStreaming { public void ConfigureFLV(IBaseFilter ffmpegEncoder) { var encoder = ffmpegEncoder as IVFFFMPEGEncoder; if (encoder == null) return; // Configure Flash Video for web streaming var settings = new FFMPEGOutputSettings { Filename = "C:\\output\\video.flv", // Audio settings AudioAvailable = true, AudioBitrate = 96000, // 96 kbps AudioSamplerate = 44100, AudioChannels = 2, // Video settings - 720p web streaming VideoWidth = 1280, VideoHeight = 720, AspectRatioW = 16, AspectRatioH = 9, VideoBitrate = 2000000, // 2 Mbps VideoMaxRate = 2500000, // 2.5 Mbps max VideoMinRate = 1500000, // 1.5 Mbps min VideoBufferSize = 2000000, Interlace = false, // Progressive for web VideoGopSize = 60, // 2 seconds at 30fps TVSystem = VFFFMPEGDLLTVSystem.None, OutputFormat = VFFFMPEGDLLOutputFormat.FLV }; encoder.set_settings(settings); Console.WriteLine("FFMPEG encoder configured for FLV web streaming:"); Console.WriteLine(" 720p @ 2 Mbps, progressive"); } } ``` ### C# Example - VCD Compliant MPEG-1 (PAL) ``` public class FFMPEGVCDEncoder { public void ConfigureVCDPAL(IBaseFilter ffmpegEncoder) { var encoder = ffmpegEncoder as IVFFFMPEGEncoder; if (encoder == null) return; // Configure VCD-compliant MPEG-1 (PAL) var settings = new FFMPEGOutputSettings { Filename = "C:\\output\\vcd.mpg", // Audio settings - VCD spec AudioAvailable = true, AudioBitrate = 224000, // 224 kbps required AudioSamplerate = 44100, // 44.1 kHz required AudioChannels = 2, // Video settings - VCD PAL specs VideoWidth = 352, VideoHeight = 288, // PAL resolution AspectRatioW = 4, AspectRatioH = 3, VideoBitrate = 1150000, // 1150 kbps required VideoMaxRate = 1150000, VideoMinRate = 1150000, VideoBufferSize = 327680, // VCD buffer size Interlace = false, VideoGopSize = 15, // 15 frames for PAL TVSystem = VFFFMPEGDLLTVSystem.PAL, OutputFormat = VFFFMPEGDLLOutputFormat.MPEG1VCD }; encoder.set_settings(settings); Console.WriteLine("FFMPEG encoder configured for VCD PAL:"); Console.WriteLine(" 352x288 @ 1150 kbps"); } } ``` ### C# Example - MPEG-2 Transport Stream ``` public class FFMPEGMPEG2TS { public void ConfigureMPEG2TS(IBaseFilter ffmpegEncoder) { var encoder = ffmpegEncoder as IVFFFMPEGEncoder; if (encoder == null) return; // Configure MPEG-2 Transport Stream for broadcasting var settings = new FFMPEGOutputSettings { Filename = "C:\\output\\stream.ts", // Audio settings AudioAvailable = true, AudioBitrate = 192000, AudioSamplerate = 48000, AudioChannels = 2, // Video settings - 1080i HD broadcast VideoWidth = 1920, VideoHeight = 1080, AspectRatioW = 16, AspectRatioH = 9, VideoBitrate = 12000000, // 12 Mbps VideoMaxRate = 15000000, // 15 Mbps max VideoMinRate = 8000000, // 8 Mbps min VideoBufferSize = 8000000, Interlace = true, // Broadcast is interlaced VideoGopSize = 15, TVSystem = VFFFMPEGDLLTVSystem.NTSC, OutputFormat = VFFFMPEGDLLOutputFormat.MPEG2TS }; encoder.set_settings(settings); Console.WriteLine("FFMPEG encoder configured for MPEG-2 TS:"); Console.WriteLine(" 1080i HD broadcast stream"); } } ``` ### C++ Example - DVD NTSC ``` #include #include #include "InterfaceDefine.h" void ConfigureFFMPEGDVD(IBaseFilter* pFFMPEGEncoder) { IVFFFMPEGEncoder* pEncoder = NULL; HRESULT hr = S_OK; // Query the FFMPEG encoder interface hr = pFFMPEGEncoder->QueryInterface(IID_IVFFFMPEGEncoder, (void**)&pEncoder); if (FAILED(hr) || !pEncoder) { std::cout << "Error: Filter does not support IVFFFMPEGEncoder" << std::endl; return; } // Configure DVD-compliant MPEG-2 encoding (NTSC) CVFOutputSettings settings; ZeroMemory(&settings, sizeof(settings)); settings.filename = L"C:\\output\\movie.mpg"; // Audio settings settings.audioAvailable = TRUE; settings.audioBitrate = 224000; settings.audioSamplerate = 48000; settings.audioChannels = 2; // Video settings - DVD NTSC specs settings.videoWidth = 720; settings.videoHeight = 480; settings.aspectRatioW = 16; settings.aspectRatioH = 9; settings.videoBitrate = 6000000; settings.videoMaxRate = 9800000; settings.videoMinRate = 0; settings.videoBufferSize = 1835008; settings.interlace = TRUE; settings.videoGopSize = 12; settings.tvSystem = video_norm_ntsc; settings.outputFormat = of_MPEG2DVD; pEncoder->set_settings(settings); std::cout << "FFMPEG encoder configured for DVD NTSC" << std::endl; pEncoder->Release(); } ``` ### C++ Example - FLV Web Streaming ``` void ConfigureFFMPEGFLV(IBaseFilter* pFFMPEGEncoder) { IVFFFMPEGEncoder* pEncoder = NULL; HRESULT hr = pFFMPEGEncoder->QueryInterface(IID_IVFFFMPEGEncoder, (void**)&pEncoder); if (SUCCEEDED(hr) && pEncoder) { CVFOutputSettings settings; ZeroMemory(&settings, sizeof(settings)); settings.filename = L"C:\\output\\video.flv"; // Audio settings settings.audioAvailable = TRUE; settings.audioBitrate = 96000; settings.audioSamplerate = 44100; settings.audioChannels = 2; // Video settings - 720p web settings.videoWidth = 1280; settings.videoHeight = 720; settings.aspectRatioW = 16; settings.aspectRatioH = 9; settings.videoBitrate = 2000000; settings.videoMaxRate = 2500000; settings.videoMinRate = 1500000; settings.videoBufferSize = 2000000; settings.interlace = FALSE; settings.videoGopSize = 60; settings.tvSystem = video_norm_unknown; settings.outputFormat = of_FLV; pEncoder->set_settings(settings); std::cout << "FFMPEG FLV encoder configured" << std::endl; pEncoder->Release(); } } ``` ### Delphi Example - DVD PAL ``` uses DirectShow9, ActiveX; procedure ConfigureFFMPEGDVDPAL(FFMPEGEncoder: IBaseFilter); var Encoder: IVFFFMPEGEncoder; Settings: TFFMPEGOutputSettings; hr: HRESULT; begin hr := FFMPEGEncoder.QueryInterface(IID_IVFFFMPEGEncoder, Encoder); if Failed(hr) or (Encoder = nil) then begin WriteLn('Error: Filter does not support IVFFFMPEGEncoder'); Exit; end; try ZeroMemory(@Settings, SizeOf(Settings)); Settings.Filename := 'C:\output\movie.mpg'; // Audio settings Settings.AudioAvailable := True; Settings.AudioBitrate := 224000; Settings.AudioSamplerate := 48000; Settings.AudioChannels := 2; // Video settings - DVD PAL specs Settings.VideoWidth := 720; Settings.VideoHeight := 576; Settings.AspectRatioW := 16; Settings.AspectRatioH := 9; Settings.VideoBitrate := 6000000; Settings.VideoMaxRate := 9800000; Settings.VideoMinRate := 0; Settings.VideoBufferSize := 1835008; Settings.Interlace := True; Settings.VideoGopSize := 15; Settings.TVSystem := Ord(PAL); Settings.OutputFormat := Ord(MPEG2DVD); Encoder.set_settings(Settings); WriteLn('FFMPEG encoder configured for DVD PAL'); finally Encoder := nil; end; end; ``` ## Best Practices ### Format-Specific Recommendations **For DVD Authoring (MPEG2DVD)**: - Always match TV system to target region (NTSC for Americas/Japan, PAL for Europe/Asia) - Use 720x480 for NTSC, 720x576 for PAL - Enable interlacing for broadcast compatibility - GOP: 12 frames (NTSC), 15 frames (PAL) - Video bitrate: 4-9.8 Mbps - Audio: 48 kHz, 224-448 kbps **For VCD/SVCD (MPEG1VCD, MPEG2SVCD)**: - Strictly follow format specifications (resolution, bitrate) - Match TV system to target region - Use exact specified bitrates for best compatibility - Test on target hardware (standalone VCD/SVCD players) **For Web Streaming (FLV)**: - Use progressive (non-interlaced) encoding - Lower bitrates for broader reach (500-2500 kbps) - GOP: 30-60 frames for seek points every 1-2 seconds - Consider modern alternatives (MP4/H.264) for better quality **For Broadcasting (MPEG2TS)**: - Transport Stream has better error resilience - Use for live streaming and broadcast applications - Higher bitrates acceptable (10-15 Mbps for HD) - Match interlacing to broadcast standard ### Resolution and Aspect Ratio **Standard Resolutions by Format**: | Format | NTSC Resolution | PAL Resolution | Aspect Ratio | | --- | --- | --- | --- | | VCD | 352x240 | 352x288 | 4:3 | | SVCD | 480x480 | 480x576 | 4:3 or 16:9 | | DVD | 720x480 | 720x576 | 4:3 or 16:9 | | FLV/MPEG-2 | Any | Any | Any | **Aspect Ratio Settings**: - 4:3 standard: `AspectRatioW = 4, AspectRatioH = 3` - 16:9 widescreen: `AspectRatioW = 16, AspectRatioH = 9` - Ensure display aspect ratio matches pixel aspect ratio ### GOP Size Guidelines **VCD/SVCD/DVD**: - NTSC: 12 frames (0.4 seconds at 29.97 fps) - PAL: 15 frames (0.6 seconds at 25 fps) - Required for format compliance **Web Streaming**: - 30-60 frames (1-2 seconds) - Shorter GOP: Better seeking, larger file - Longer GOP: Smaller file, slower seeking **Broadcast**: - 12-15 frames for high quality - Match to TV system standard ### Bitrate Configuration **VBR (Variable Bitrate)**: - Set `VideoBitrate` (average), `VideoMinRate`, `VideoMaxRate` - Better quality for same average bitrate - Use for file-based encoding **CBR (Constant Bitrate)**: - Set all three bitrates to the same value - Predictable file size and bandwidth - Use for streaming and broadcasting ### Audio Settings **Sample Rates**: - 44100 Hz: CD quality, VCD/SVCD - 48000 Hz: DVD, professional broadcast - Match source when possible **Bitrates**: - Mono speech: 64-96 kbps - Stereo music: 128-224 kbps - DVD audio: 192-448 kbps ## Troubleshooting ### Encoder Initialization Fails **Symptoms**: `set_settings` call fails or crashes **Possible Causes**: 1. Invalid filename or path 2. Incorrect format specifications 3. Unsupported resolution/bitrate combination **Solutions**: - Ensure output directory exists and is writable - Verify resolution matches format requirements - Check bitrate is within format limits - For VCD/SVCD/DVD, strictly follow specifications ### Output File Won't Play **Symptoms**: Encoded file doesn't play or has errors **Possible Causes**: 1. Format specifications not met 2. Wrong TV system for format 3. Interlacing mismatch 4. GOP size issues **Solutions**: - For DVD/VCD/SVCD: Use exact specification parameters - Match TV system to target region - Enable interlacing for DVD/broadcast - Use standard GOP sizes (12 for NTSC, 15 for PAL) ### Poor Video Quality **Symptoms**: Blocky, blurry, or artifact-laden video **Possible Causes**: 1. Bitrate too low for resolution 2. Incorrect GOP size 3. Bitrate range too restrictive **Solutions**: - Increase video bitrate (see format recommendations) - For VBR, widen min/max bitrate range - Use appropriate GOP size for format - Ensure resolution matches format specifications ### A/V Sync Issues **Symptoms**: Audio and video drift out of sync **Possible Causes**: 1. Incorrect sample rate 2. Wrong frame rate for TV system 3. Buffer size issues **Solutions**: - Use 48000 Hz for DVD, 44100 Hz for VCD - Ensure TV system matches source frame rate - Increase `VideoBufferSize` for complex content - Verify source audio/video are synchronized ### DVD/VCD Won't Play on Hardware **Symptoms**: File plays on computer but not on standalone player **Possible Causes**: 1. Format specifications not strictly followed 2. Wrong TV system 3. Non-compliant GOP size or bitrate **Solutions**: - **Critical**: Use exact format specifications - VCD: 352x240/288, 1150 kbps, GOP 12/15 - DVD: 720x480/576, max 9.8 Mbps, GOP 12/15 - Match TV system to player region - Enable interlacing for DVD - Test with software DVD/VCD player first ### Large File Sizes **Symptoms**: Output files larger than expected **Possible Causes**: 1. Bitrate too high 2. CBR instead of VBR 3. Small GOP size **Solutions**: - Reduce video bitrate - Use VBR with appropriate min/max range - Increase GOP size (for non-DVD/VCD formats) - Consider more efficient formats (H.264/MP4 instead of MPEG-2) --- ## See Also - [H.264 Encoder Interface](../h264/) - [Video Codecs Reference](../../codecs-reference/) - [MP4 Muxer Interface](../mp4-muxer/) - [Encoding Filters Pack Overview](../../) ---END OF PAGE--- ## FLAC Lossless Audio Encoder DirectShow Filter Interface **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/flac/ **Description:** FLAC encoder DirectShow interface with encoding levels, LPC configuration, block sizes, and compression for lossless audio encoding. **Tags:** DirectShow, C++, Windows, Encoding, Decoding, MP3, FLAC, C# **API:** FLACEncoder, IFLACEncodeSettings, IBaseFilter, AudioEncoder, FLACArchivalEncoder # FLAC Encoder Interface Reference ## Overview The **IFLACEncodeSettings** interface provides complete control over FLAC (Free Lossless Audio Codec) audio encoding parameters in DirectShow filter graphs. FLAC is a lossless audio compression format that reduces file size without any loss in audio quality, making it ideal for archival, professional audio production, and high-fidelity music distribution. This interface allows developers to configure encoding quality levels, Linear Predictive Coding (LPC) parameters, block sizes, mid-side stereo coding, and Rice partition orders to achieve optimal compression efficiency for different types of audio content. **Interface GUID**: `{A6096781-2A65-4540-A536-011235D0A5FE}` **Inherits From**: `IUnknown` ## Interface Definitions ### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// FLAC (Free Lossless Audio Codec) encoder configuration interface. /// Provides comprehensive control over FLAC encoding parameters for lossless audio compression. /// [ComImport] [Guid("A6096781-2A65-4540-A536-011235D0A5FE")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IFLACEncodeSettings { /// /// Checks if encoding settings can be modified at the current time. /// /// True if settings can be modified, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool canModifySettings(); /// /// Sets the FLAC encoding level (compression quality). /// /// Encoding level (0-8, where 8 is highest compression, slowest) /// True if successful, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool setEncodingLevel(uint inLevel); /// /// Sets the Linear Predictive Coding (LPC) order. /// Higher values provide better compression but slower encoding. /// /// LPC order (typically 0-32) /// True if successful, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool setLPCOrder(uint inLPCOrder); /// /// Sets the audio block size for encoding. /// Larger blocks can provide better compression but increase latency. /// /// Block size in samples (typically 192-4608) /// True if successful, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool setBlockSize(uint inBlockSize); /// /// Enables or disables mid-side stereo coding for 2-channel audio. /// Can improve compression for stereo audio with correlated channels. /// /// True to enable mid-side coding, false to disable /// True if successful, false otherwise /// Only applicable for 2-channel (stereo) audio [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool useMidSideCoding([In, MarshalAs(UnmanagedType.Bool)] bool inUseMidSideCoding); /// /// Enables or disables adaptive mid-side stereo coding. /// Automatically decides whether to use mid-side coding on a per-block basis. /// Overrides useMidSideCoding and is generally faster. /// /// True to enable adaptive mid-side coding, false to disable /// True if successful, false otherwise /// Only for 2-channel audio. Overrides useMidSideCoding setting. Generally provides better performance. [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool useAdaptiveMidSideCoding([In, MarshalAs(UnmanagedType.Bool)] bool inUseAdaptiveMidSideCoding); /// /// Enables or disables exhaustive model search for best compression. /// Significantly slower but can provide better compression ratios. /// /// True to enable exhaustive search, false to disable /// True if successful, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool useExhaustiveModelSearch([In, MarshalAs(UnmanagedType.Bool)] bool inUseExhaustiveModelSearch); /// /// Sets the Rice partition order range for entropy coding. /// Controls the trade-off between compression efficiency and encoding speed. /// /// Minimum Rice partition order /// Maximum Rice partition order /// True if successful, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool setRicePartitionOrder(uint inMin, uint inMax); /// /// Gets the current encoding level setting. /// /// Current encoding level (0-8) [PreserveSig] int encoderLevel(); /// /// Gets the current Linear Predictive Coding (LPC) order. /// /// Current LPC order [PreserveSig] uint LPCOrder(); /// /// Gets the current block size setting. /// /// Current block size in samples [PreserveSig] uint blockSize(); /// /// Gets the minimum Rice partition order. /// /// Minimum Rice partition order [PreserveSig] uint riceMin(); /// /// Gets the maximum Rice partition order. /// /// Maximum Rice partition order [PreserveSig] uint riceMax(); /// /// Checks if mid-side stereo coding is enabled. /// /// True if mid-side coding is enabled, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool isUsingMidSideCoding(); /// /// Checks if adaptive mid-side stereo coding is enabled. /// /// True if adaptive mid-side coding is enabled, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool isUsingAdaptiveMidSideCoding(); /// /// Checks if exhaustive model search is enabled. /// /// True if exhaustive model search is enabled, false otherwise [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool isUsingExhaustiveModel(); } } ``` ### C++ Definition ``` #include // {A6096781-2A65-4540-A536-011235D0A5FE} DEFINE_GUID(IID_IFLACEncodeSettings, 0xa6096781, 0x2a65, 0x4540, 0xa5, 0x36, 0x01, 0x12, 0x35, 0xd0, 0xa5, 0xfe); /// /// FLAC (Free Lossless Audio Codec) encoder configuration interface. /// Provides comprehensive control over FLAC encoding parameters for lossless audio compression. /// DECLARE_INTERFACE_(IFLACEncodeSettings, IUnknown) { /// /// Checks if encoding settings can be modified at the current time. /// /// TRUE if settings can be modified, FALSE otherwise STDMETHOD_(BOOL, canModifySettings)(THIS) PURE; /// /// Sets the FLAC encoding level (compression quality). /// /// Encoding level (0-8, where 8 is highest compression, slowest) /// TRUE if successful, FALSE otherwise STDMETHOD_(BOOL, setEncodingLevel)(THIS_ unsigned long inLevel ) PURE; /// /// Sets the Linear Predictive Coding (LPC) order. /// Higher values provide better compression but slower encoding. /// /// LPC order (typically 0-32) /// TRUE if successful, FALSE otherwise STDMETHOD_(BOOL, setLPCOrder)(THIS_ unsigned long inLPCOrder ) PURE; /// /// Sets the audio block size for encoding. /// Larger blocks can provide better compression but increase latency. /// /// Block size in samples (typically 192-4608) /// TRUE if successful, FALSE otherwise STDMETHOD_(BOOL, setBlockSize)(THIS_ unsigned long inBlockSize ) PURE; /// /// Enables or disables mid-side stereo coding for 2-channel audio. /// Can improve compression for stereo audio with correlated channels. /// /// TRUE to enable mid-side coding, FALSE to disable /// TRUE if successful, FALSE otherwise /// Only applicable for 2-channel (stereo) audio STDMETHOD_(BOOL, useMidSideCoding)(THIS_ BOOL inUseMidSideCoding ) PURE; /// /// Enables or disables adaptive mid-side stereo coding. /// Automatically decides whether to use mid-side coding on a per-block basis. /// Overrides useMidSideCoding and is generally faster. /// /// TRUE to enable adaptive mid-side coding, FALSE to disable /// TRUE if successful, FALSE otherwise /// Only for 2-channel audio. Overrides useMidSideCoding setting. Generally provides better performance. STDMETHOD_(BOOL, useAdaptiveMidSideCoding)(THIS_ BOOL inUseAdaptiveMidSideCoding ) PURE; /// /// Enables or disables exhaustive model search for best compression. /// Significantly slower but can provide better compression ratios. /// /// TRUE to enable exhaustive search, FALSE to disable /// TRUE if successful, FALSE otherwise STDMETHOD_(BOOL, useExhaustiveModelSearch)(THIS_ BOOL inUseExhaustiveModelSearch ) PURE; /// /// Sets the Rice partition order range for entropy coding. /// Controls the trade-off between compression efficiency and encoding speed. /// /// Minimum Rice partition order /// Maximum Rice partition order /// TRUE if successful, FALSE otherwise STDMETHOD_(BOOL, setRicePartitionOrder)(THIS_ unsigned long inMin, unsigned long inMax ) PURE; /// /// Gets the current encoding level setting. /// /// Current encoding level (0-8) STDMETHOD_(int, encoderLevel)(THIS) PURE; /// /// Gets the current Linear Predictive Coding (LPC) order. /// /// Current LPC order STDMETHOD_(unsigned long, LPCOrder)(THIS) PURE; /// /// Gets the current block size setting. /// /// Current block size in samples STDMETHOD_(unsigned long, blockSize)(THIS) PURE; /// /// Gets the minimum Rice partition order. /// /// Minimum Rice partition order STDMETHOD_(unsigned long, riceMin)(THIS) PURE; /// /// Gets the maximum Rice partition order. /// /// Maximum Rice partition order STDMETHOD_(unsigned long, riceMax)(THIS) PURE; /// /// Checks if mid-side stereo coding is enabled. /// /// TRUE if mid-side coding is enabled, FALSE otherwise STDMETHOD_(BOOL, isUsingMidSideCoding)(THIS) PURE; /// /// Checks if adaptive mid-side stereo coding is enabled. /// /// TRUE if adaptive mid-side coding is enabled, FALSE otherwise STDMETHOD_(BOOL, isUsingAdaptiveMidSideCoding)(THIS) PURE; /// /// Checks if exhaustive model search is enabled. /// /// TRUE if exhaustive model search is enabled, FALSE otherwise STDMETHOD_(BOOL, isUsingExhaustiveModel)(THIS) PURE; }; ``` ### Delphi Definition ``` uses ActiveX, ComObj; const IID_IFLACEncodeSettings: TGUID = '{A6096781-2A65-4540-A536-011235D0A5FE}'; type /// /// FLAC (Free Lossless Audio Codec) encoder configuration interface. /// Provides comprehensive control over FLAC encoding parameters for lossless audio compression. /// IFLACEncodeSettings = interface(IUnknown) ['{A6096781-2A65-4540-A536-011235D0A5FE}'] /// /// Checks if encoding settings can be modified at the current time. /// /// True if settings can be modified, false otherwise function canModifySettings: BOOL; stdcall; /// /// Sets the FLAC encoding level (compression quality). /// /// Encoding level (0-8, where 8 is highest compression, slowest) /// True if successful, false otherwise function setEncodingLevel(inLevel: Cardinal): BOOL; stdcall; /// /// Sets the Linear Predictive Coding (LPC) order. /// Higher values provide better compression but slower encoding. /// /// LPC order (typically 0-32) /// True if successful, false otherwise function setLPCOrder(inLPCOrder: Cardinal): BOOL; stdcall; /// /// Sets the audio block size for encoding. /// Larger blocks can provide better compression but increase latency. /// /// Block size in samples (typically 192-4608) /// True if successful, false otherwise function setBlockSize(inBlockSize: Cardinal): BOOL; stdcall; /// /// Enables or disables mid-side stereo coding for 2-channel audio. /// Can improve compression for stereo audio with correlated channels. /// /// True to enable mid-side coding, false to disable /// True if successful, false otherwise /// Only applicable for 2-channel (stereo) audio function useMidSideCoding(inUseMidSideCoding: BOOL): BOOL; stdcall; /// /// Enables or disables adaptive mid-side stereo coding. /// Automatically decides whether to use mid-side coding on a per-block basis. /// Overrides useMidSideCoding and is generally faster. /// /// True to enable adaptive mid-side coding, false to disable /// True if successful, false otherwise /// Only for 2-channel audio. Overrides useMidSideCoding setting. Generally provides better performance. function useAdaptiveMidSideCoding(inUseAdaptiveMidSideCoding: BOOL): BOOL; stdcall; /// /// Enables or disables exhaustive model search for best compression. /// Significantly slower but can provide better compression ratios. /// /// True to enable exhaustive search, false to disable /// True if successful, false otherwise function useExhaustiveModelSearch(inUseExhaustiveModelSearch: BOOL): BOOL; stdcall; /// /// Sets the Rice partition order range for entropy coding. /// Controls the trade-off between compression efficiency and encoding speed. /// /// Minimum Rice partition order /// Maximum Rice partition order /// True if successful, false otherwise function setRicePartitionOrder(inMin: Cardinal; inMax: Cardinal): BOOL; stdcall; /// /// Gets the current encoding level setting. /// /// Current encoding level (0-8) function encoderLevel: Integer; stdcall; /// /// Gets the current Linear Predictive Coding (LPC) order. /// /// Current LPC order function LPCOrder: Cardinal; stdcall; /// /// Gets the current block size setting. /// /// Current block size in samples function blockSize: Cardinal; stdcall; /// /// Gets the minimum Rice partition order. /// /// Minimum Rice partition order function riceMin: Cardinal; stdcall; /// /// Gets the maximum Rice partition order. /// /// Maximum Rice partition order function riceMax: Cardinal; stdcall; /// /// Checks if mid-side stereo coding is enabled. /// /// True if mid-side coding is enabled, false otherwise function isUsingMidSideCoding: BOOL; stdcall; /// /// Checks if adaptive mid-side stereo coding is enabled. /// /// True if adaptive mid-side coding is enabled, false otherwise function isUsingAdaptiveMidSideCoding: BOOL; stdcall; /// /// Checks if exhaustive model search is enabled. /// /// True if exhaustive model search is enabled, false otherwise function isUsingExhaustiveModel: BOOL; stdcall; end; ``` ## Method Reference ### Configuration Check #### canModifySettings Checks if encoding settings can be modified at the current time. This is useful to verify the encoder is in a state where configuration changes are allowed (typically before the filter graph starts running). **Returns**: `true` if settings can be modified, `false` otherwise **Example Usage**: ``` if (flacEncoder.canModifySettings()) { // Safe to modify encoder settings flacEncoder.setEncodingLevel(5); } ``` ### Encoding Configuration Methods #### setEncodingLevel Sets the FLAC encoding level, which controls the compression quality and encoding speed trade-off. **Parameters**: - `inLevel` - Encoding level (0-8): - 0 = Fastest encoding, lowest compression - 5 = Balanced (recommended for most uses) - 8 = Slowest encoding, highest compression **Returns**: `true` if successful, `false` otherwise **Recommended Values**: - **Fast archival**: Level 3-5 - **High-quality archival**: Level 6-8 - **Real-time encoding**: Level 0-2 #### setLPCOrder Sets the Linear Predictive Coding (LPC) order, which affects compression efficiency and encoding speed. **Parameters**: - `inLPCOrder` - LPC order value (typically 0-32) - 0 = No LPC (fastest) - 12 = Default for most audio - 32 = Maximum compression (slowest) **Returns**: `true` if successful, `false` otherwise **Note**: Higher LPC orders provide better compression but significantly increase encoding time. #### setBlockSize Sets the audio block size for encoding. The block size affects both compression efficiency and latency. **Parameters**: - `inBlockSize` - Block size in samples - Common values: 192, 576, 1152, 2304, 4608 - Default is typically 4096 for 44.1kHz audio **Returns**: `true` if successful, `false` otherwise **Recommendations**: - **Low latency**: 192-1152 samples - **Standard archival**: 4096 samples - **Maximum compression**: 4608 samples #### useMidSideCoding Enables or disables mid-side stereo coding for 2-channel audio. Mid-side coding can improve compression for stereo audio where the left and right channels are highly correlated. **Parameters**: - `inUseMidSideCoding` - `true` to enable, `false` to disable **Returns**: `true` if successful, `false` otherwise **Note**: Only applicable for 2-channel (stereo) audio. Most music benefits from mid-side coding. #### useAdaptiveMidSideCoding Enables or disables adaptive mid-side stereo coding. This mode automatically decides whether to use mid-side coding on a per-block basis, providing better compression than fixed mid-side coding. **Parameters**: - `inUseAdaptiveMidSideCoding` - `true` to enable, `false` to disable **Returns**: `true` if successful, `false` otherwise **Note**: - Only for 2-channel audio - Overrides `useMidSideCoding` setting - Generally provides better performance than fixed mid-side coding - Recommended for most stereo encoding scenarios #### useExhaustiveModelSearch Enables or disables exhaustive model search for finding the best compression predictor. **Parameters**: - `inUseExhaustiveModelSearch` - `true` to enable, `false` to disable **Returns**: `true` if successful, `false` otherwise **Warning**: Exhaustive search significantly slows down encoding (often 2-4x slower) but can provide marginally better compression (typically 1-3% file size reduction). **Recommended**: Only enable for archival of critical audio where encoding time is not a concern. #### setRicePartitionOrder Sets the Rice partition order range for entropy coding. Rice coding is the final compression stage in FLAC. **Parameters**: - `inMin` - Minimum Rice partition order (typically 0-2) - `inMax` - Maximum Rice partition order (typically 3-8) **Returns**: `true` if successful, `false` otherwise **Typical Values**: - Fast encoding: min=0, max=3 - Standard encoding: min=0, max=6 - Maximum compression: min=0, max=8 ### Status Query Methods #### encoderLevel Gets the current encoding level setting. **Returns**: Current encoding level (0-8) #### LPCOrder Gets the current Linear Predictive Coding (LPC) order. **Returns**: Current LPC order value #### blockSize Gets the current block size setting. **Returns**: Current block size in samples #### riceMin Gets the minimum Rice partition order. **Returns**: Minimum Rice partition order #### riceMax Gets the maximum Rice partition order. **Returns**: Maximum Rice partition order #### isUsingMidSideCoding Checks if fixed mid-side stereo coding is enabled. **Returns**: `true` if mid-side coding is enabled, `false` otherwise #### isUsingAdaptiveMidSideCoding Checks if adaptive mid-side stereo coding is enabled. **Returns**: `true` if adaptive mid-side coding is enabled, `false` otherwise #### isUsingExhaustiveModel Checks if exhaustive model search is enabled. **Returns**: `true` if exhaustive model search is enabled, `false` otherwise ## Usage Examples ### C# Example - High Quality Archival ``` using System; using DirectShowLib; using VisioForge.DirectShowAPI; public class FLACArchivalEncoder { public void ConfigureHighQualityArchival(IBaseFilter audioEncoder) { // Query the FLAC encoder interface var flacEncoder = audioEncoder as IFLACEncodeSettings; if (flacEncoder == null) { Console.WriteLine("Error: Filter does not support IFLACEncodeSettings"); return; } // Check if we can modify settings if (!flacEncoder.canModifySettings()) { Console.WriteLine("Warning: Cannot modify encoder settings at this time"); return; } // High quality archival settings flacEncoder.setEncodingLevel(8); // Maximum compression flacEncoder.setLPCOrder(12); // Good LPC order for music flacEncoder.setBlockSize(4096); // Standard block size for 44.1kHz flacEncoder.useAdaptiveMidSideCoding(true); // Adaptive mid-side for stereo flacEncoder.useExhaustiveModelSearch(true); // Best possible compression flacEncoder.setRicePartitionOrder(0, 8); // Maximum Rice partition range Console.WriteLine("FLAC encoder configured for high-quality archival:"); Console.WriteLine($" Encoding Level: {flacEncoder.encoderLevel()}"); Console.WriteLine($" LPC Order: {flacEncoder.LPCOrder()}"); Console.WriteLine($" Block Size: {flacEncoder.blockSize()}"); Console.WriteLine($" Adaptive Mid-Side: {flacEncoder.isUsingAdaptiveMidSideCoding()}"); Console.WriteLine($" Exhaustive Search: {flacEncoder.isUsingExhaustiveModel()}"); Console.WriteLine($" Rice Partition: {flacEncoder.riceMin()}-{flacEncoder.riceMax()}"); } } ``` ### C# Example - Fast Real-Time Encoding ``` public class FLACRealTimeEncoder { public void ConfigureFastEncoding(IBaseFilter audioEncoder) { var flacEncoder = audioEncoder as IFLACEncodeSettings; if (flacEncoder == null || !flacEncoder.canModifySettings()) return; // Fast encoding settings for real-time use flacEncoder.setEncodingLevel(2); // Fast encoding flacEncoder.setLPCOrder(8); // Lower LPC for speed flacEncoder.setBlockSize(1152); // Smaller blocks for lower latency flacEncoder.useAdaptiveMidSideCoding(true); // Still good compression flacEncoder.useExhaustiveModelSearch(false); // Disable for speed flacEncoder.setRicePartitionOrder(0, 4); // Reduced Rice partition range Console.WriteLine("FLAC encoder configured for fast real-time encoding"); Console.WriteLine($" Encoding Level: {flacEncoder.encoderLevel()}"); Console.WriteLine($" LPC Order: {flacEncoder.LPCOrder()}"); Console.WriteLine($" Block Size: {flacEncoder.blockSize()} (lower latency)"); } } ``` ### C# Example - Balanced Music Encoding ``` public class FLACMusicEncoder { public void ConfigureBalancedMusic(IBaseFilter audioEncoder) { var flacEncoder = audioEncoder as IFLACEncodeSettings; if (flacEncoder == null || !flacEncoder.canModifySettings()) return; // Balanced settings for music encoding (good compression, reasonable speed) flacEncoder.setEncodingLevel(5); // Balanced compression flacEncoder.setLPCOrder(12); // Standard LPC for music flacEncoder.setBlockSize(4096); // Optimal for 44.1kHz flacEncoder.useAdaptiveMidSideCoding(true); // Adaptive mid-side flacEncoder.useExhaustiveModelSearch(false); // Not needed for music flacEncoder.setRicePartitionOrder(0, 6); // Good Rice partition range Console.WriteLine("FLAC encoder configured for balanced music encoding"); } } ``` ### C++ Example - High Quality Archival ``` #include #include #include "IFLACEncodeSettings.h" void ConfigureHighQualityFLAC(IBaseFilter* pAudioEncoder) { IFLACEncodeSettings* pFLACEncoder = NULL; HRESULT hr = S_OK; // Query the FLAC encoder interface hr = pAudioEncoder->QueryInterface(IID_IFLACEncodeSettings, (void**)&pFLACEncoder); if (FAILED(hr) || !pFLACEncoder) { std::cout << "Error: Filter does not support IFLACEncodeSettings" << std::endl; return; } // Check if we can modify settings if (!pFLACEncoder->canModifySettings()) { std::cout << "Warning: Cannot modify encoder settings" << std::endl; pFLACEncoder->Release(); return; } // Configure high quality archival settings pFLACEncoder->setEncodingLevel(8); // Maximum compression pFLACEncoder->setLPCOrder(12); // Good LPC order pFLACEncoder->setBlockSize(4096); // Standard block size pFLACEncoder->useAdaptiveMidSideCoding(TRUE); // Adaptive mid-side pFLACEncoder->useExhaustiveModelSearch(TRUE); // Best compression pFLACEncoder->setRicePartitionOrder(0, 8); // Maximum range // Display configuration std::cout << "FLAC encoder configured for high-quality archival:" << std::endl; std::cout << " Encoding Level: " << pFLACEncoder->encoderLevel() << std::endl; std::cout << " LPC Order: " << pFLACEncoder->LPCOrder() << std::endl; std::cout << " Block Size: " << pFLACEncoder->blockSize() << std::endl; std::cout << " Adaptive Mid-Side: " << (pFLACEncoder->isUsingAdaptiveMidSideCoding() ? "Yes" : "No") << std::endl; std::cout << " Exhaustive Search: " << (pFLACEncoder->isUsingExhaustiveModel() ? "Yes" : "No") << std::endl; pFLACEncoder->Release(); } ``` ### C++ Example - Fast Real-Time Encoding ``` void ConfigureFastFLAC(IBaseFilter* pAudioEncoder) { IFLACEncodeSettings* pFLACEncoder = NULL; HRESULT hr = pAudioEncoder->QueryInterface(IID_IFLACEncodeSettings, (void**)&pFLACEncoder); if (SUCCEEDED(hr) && pFLACEncoder) { if (pFLACEncoder->canModifySettings()) { // Fast encoding configuration pFLACEncoder->setEncodingLevel(2); // Fast pFLACEncoder->setLPCOrder(8); // Lower LPC pFLACEncoder->setBlockSize(1152); // Smaller blocks pFLACEncoder->useAdaptiveMidSideCoding(TRUE); // Still good pFLACEncoder->useExhaustiveModelSearch(FALSE); // Disabled for speed pFLACEncoder->setRicePartitionOrder(0, 4); // Reduced range std::cout << "FLAC encoder configured for fast real-time encoding" << std::endl; } pFLACEncoder->Release(); } } ``` ### Delphi Example - High Quality Archival ``` uses DirectShow9, ActiveX; procedure ConfigureHighQualityFLAC(AudioEncoder: IBaseFilter); var FLACEncoder: IFLACEncodeSettings; hr: HRESULT; begin // Query the FLAC encoder interface hr := AudioEncoder.QueryInterface(IID_IFLACEncodeSettings, FLACEncoder); if Failed(hr) or (FLACEncoder = nil) then begin WriteLn('Error: Filter does not support IFLACEncodeSettings'); Exit; end; try // Check if we can modify settings if not FLACEncoder.canModifySettings then begin WriteLn('Warning: Cannot modify encoder settings'); Exit; end; // Configure high quality archival settings FLACEncoder.setEncodingLevel(8); // Maximum compression FLACEncoder.setLPCOrder(12); // Good LPC order FLACEncoder.setBlockSize(4096); // Standard block size FLACEncoder.useAdaptiveMidSideCoding(True); // Adaptive mid-side FLACEncoder.useExhaustiveModelSearch(True); // Best compression FLACEncoder.setRicePartitionOrder(0, 8); // Maximum range // Display configuration WriteLn('FLAC encoder configured for high-quality archival:'); WriteLn(' Encoding Level: ', FLACEncoder.encoderLevel); WriteLn(' LPC Order: ', FLACEncoder.LPCOrder); WriteLn(' Block Size: ', FLACEncoder.blockSize); WriteLn(' Adaptive Mid-Side: ', FLACEncoder.isUsingAdaptiveMidSideCoding); WriteLn(' Exhaustive Search: ', FLACEncoder.isUsingExhaustiveModel); finally FLACEncoder := nil; end; end; ``` ### Delphi Example - Balanced Music Encoding ``` procedure ConfigureBalancedMusicFLAC(AudioEncoder: IBaseFilter); var FLACEncoder: IFLACEncodeSettings; begin if Succeeded(AudioEncoder.QueryInterface(IID_IFLACEncodeSettings, FLACEncoder)) then begin try if FLACEncoder.canModifySettings then begin // Balanced settings for music FLACEncoder.setEncodingLevel(5); // Balanced FLACEncoder.setLPCOrder(12); // Standard for music FLACEncoder.setBlockSize(4096); // Optimal FLACEncoder.useAdaptiveMidSideCoding(True); // Adaptive FLACEncoder.useExhaustiveModelSearch(False); // Not needed FLACEncoder.setRicePartitionOrder(0, 6); // Good range WriteLn('FLAC encoder configured for balanced music encoding'); end; finally FLACEncoder := nil; end; end; end; ``` ## Best Practices ### Encoding Level Selection **Level 0-2**: Fast encoding, suitable for real-time applications - Use when encoding speed is critical - Typical compression: 50-55% of original size **Level 3-5**: Balanced encoding (recommended for most uses) - Good balance between speed and compression - Typical compression: 45-50% of original size - **Level 5 is recommended** for general-purpose archival **Level 6-8**: Maximum compression, slower encoding - Use for long-term archival where storage space is critical - Typical compression: 40-45% of original size - Encoding can be 2-5x slower than level 5 ### Mid-Side Stereo Coding - **Always enable** `useAdaptiveMidSideCoding` for stereo audio - Adaptive mode automatically determines when mid-side coding helps - Provides better compression than fixed mid-side mode - No significant performance penalty ### LPC Order Recommendations **Music and General Audio**: - Use LPC order 12 for most music encoding - Higher orders (16-32) provide minimal benefit for music - Lower orders (8) are suitable for speech **Classical and High-Dynamic Range**: - Consider LPC order 16-32 for orchestral recordings - Provides better prediction for complex harmonic content ### Block Size Selection **Sample Rate Considerations**: - 44.1kHz: 4096 samples (default, ~93ms) - 48kHz: 4608 samples (~96ms) - 96kHz: 4608-8192 samples **Latency Requirements**: - Real-time: 192-1152 samples - Standard archival: 4096 samples - Maximum compression: 4608 samples ### Exhaustive Model Search **When to Enable**: - Critical archival projects where every byte counts - Unlimited encoding time available - File size reduction is paramount **When to Disable** (recommended for most users): - Real-time or near-real-time encoding - Large batch encoding projects - Compression improvement is typically <3% - Encoding time increases 2-4x ### Rice Partition Order **Fast Encoding**: `setRicePartitionOrder(0, 3)` **Standard Encoding**: `setRicePartitionOrder(0, 6)` (recommended) **Maximum Compression**: `setRicePartitionOrder(0, 8)` ## Troubleshooting ### Settings Cannot Be Modified **Symptom**: `canModifySettings()` returns `false` **Causes**: 1. Filter graph is already running 2. Encoder is actively processing audio 3. Filter is in an incorrect state **Solutions**: - Stop the filter graph before modifying settings - Configure encoder before connecting filter pins - Query settings before starting playback/capture ### Poor Compression Ratio **Symptom**: FLAC files are larger than expected **Possible Causes**: 1. Low encoding level (0-2) 2. Source audio is already compressed (MP3, AAC) 3. Source audio has high noise floor 4. Inappropriate block size for sample rate **Solutions**: - Increase encoding level to 5-8 - **Never re-encode already compressed audio** - FLAC cannot improve quality - Use noise reduction on source audio before encoding - Adjust block size to match sample rate (see recommendations above) ### Encoding Too Slow **Symptom**: Real-time encoding cannot keep up with audio stream **Solutions**: 1. Reduce encoding level to 0-3 2. Disable exhaustive model search 3. Reduce LPC order to 8 4. Reduce Rice partition max to 4 5. Use smaller block sizes (1152 or less) ### Audio Pops or Clicks in Encoded Output **Symptom**: Audible artifacts in encoded FLAC files **Possible Causes**: 1. Encoder cannot process fast enough (buffer underruns) 2. Incompatible block size with sample rate 3. Hardware performance issues **Solutions**: - Reduce encoding complexity (lower level, disable exhaustive search) - Use standard block sizes for the sample rate - Increase DirectShow buffer sizes - Reduce system load during encoding ### Stereo Encoding Issues **Symptom**: Stereo audio sounds incorrect or mono **Check**: - Verify input is actually stereo (2 channels) - Mid-side coding only works with stereo input - Check if adaptive mid-side is enabled for best results - Verify filter graph audio format (use GraphEdit to inspect) ## Technical Notes ### FLAC Encoding Process FLAC encoding involves several stages: 1. **Blocking**: Audio divided into blocks 2. **Prediction**: LPC analysis predicts sample values 3. **Mid-Side Coding**: Optional stereo decorrelation (for 2-channel audio) 4. **Residual Encoding**: Rice coding compresses prediction errors 5. **Frame Assembly**: Blocks assembled into FLAC frames ### Performance Characteristics **CPU Usage by Setting**: - Encoding Level: ~10% increase per level - LPC Order: ~5% increase per 4 orders - Exhaustive Search: 200-400% increase - Mid-Side Coding: ~2-5% increase **Memory Requirements**: - Minimal: ~512KB working memory - Larger blocks require more memory - No significant dependency on audio duration ### Compatibility FLAC files encoded with any settings combination are compatible with all FLAC decoders. Higher compression settings only affect encoding time and file size, not decoder compatibility or playback quality. --- ## See Also - [LAME MP3 Encoder Interface](../lame/) - [Audio Codecs Reference](../../codecs-reference/) - [Encoding Filters Pack Overview](../../) ---END OF PAGE--- ## H.264 DirectShow Encoder Filter - COM Interface API **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/h264/ **Description:** Configure H.264/AVC encoding in DirectShow — bitrate control (CBR/VBR), profiles (Baseline/Main/High), GOP structure, and rate control. IH264Encoder reference. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, Decoding, H.264, C# **API:** H264Encoder, IH264Encoder, IBaseFilter, VideoEncoder, H264HighQualityEncoder # H.264 Encoder Interface Reference ## Overview The **IH264Encoder** interface provides comprehensive control over H.264/AVC (Advanced Video Coding) video encoding in DirectShow filter graphs. H.264 is the industry-standard video compression format used for broadcast, streaming, and distribution applications. This interface allows developers to configure encoding profiles, bitrate control, Group of Pictures (GOP) structure, macroblock encoding modes, and advanced timing parameters for optimal video quality and file size in various scenarios including streaming, broadcast, and archival. **Interface GUID**: `{09FA2EA3-4773-41a8-90DC-9499D4061E9F}` **Inherits From**: `IUnknown` ## Interface Definitions ### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// H.264/AVC (Advanced Video Coding) encoder configuration interface. /// Provides comprehensive control over H.264 encoding parameters including /// bitrate control, profile/level settings, GOP structure, and rate control modes. /// [ComImport] [Guid("09FA2EA3-4773-41a8-90DC-9499D4061E9F")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IH264Encoder { /// /// Gets the target bitrate for encoding. /// /// Receives the bitrate in bits per second (bps) /// HRESULT (0 for success) [PreserveSig] int get_Bitrate([Out] out int plValue); /// /// Sets the target bitrate for encoding. /// /// Bitrate in bits per second (bps). Typical range: 500,000 to 50,000,000 /// HRESULT (0 for success) [PreserveSig] int put_Bitrate([In] int lValue); /// /// Gets the rate control mode. /// /// Receives the rate control mode (0=CBR, 1=VBR) /// HRESULT (0 for success) [PreserveSig] int get_RateControl([Out] out int pValue); /// /// Sets the rate control mode. /// /// Rate control mode: 0 = CBR (Constant Bitrate), 1 = VBR (Variable Bitrate) /// HRESULT (0 for success) [PreserveSig] int put_RateControl([In] int value); /// /// Gets the macroblock encoding mode. /// /// Receives the MB encoding mode /// HRESULT (0 for success) [PreserveSig] int get_MbEncoding([Out] out int pValue); /// /// Sets the macroblock encoding mode (affects encoding complexity and quality). /// /// MB encoding mode value /// HRESULT (0 for success) [PreserveSig] int put_MbEncoding([In] int value); /// /// Gets the GOP (Group of Pictures) enable state. /// /// Receives true if GOP is enabled, false otherwise /// HRESULT (0 for success) [PreserveSig] int get_GOP([Out] [MarshalAs(UnmanagedType.Bool)] out bool pValue); /// /// Enables or disables GOP (Group of Pictures) structure. /// /// True to enable GOP, false to disable (all I-frames) /// HRESULT (0 for success) [PreserveSig] int put_GOP([In] [MarshalAs(UnmanagedType.Bool)] bool value); /// /// Gets the auto-bitrate adjustment state. /// /// Receives true if auto-bitrate is enabled, false otherwise /// HRESULT (0 for success) [PreserveSig] int get_AutoBitrate([Out] [MarshalAs(UnmanagedType.Bool)] out bool pValue); /// /// Enables or disables automatic bitrate adjustment. /// When enabled, the encoder automatically adjusts bitrate based on content complexity. /// /// True to enable auto-bitrate, false for fixed bitrate /// HRESULT (0 for success) [PreserveSig] int put_AutoBitrate([In] [MarshalAs(UnmanagedType.Bool)] bool value); /// /// Gets the H.264 profile. /// /// Receives the profile value /// HRESULT (0 for success) [PreserveSig] int get_Profile([Out] out int pValue); /// /// Sets the H.264 profile (Baseline, Main, High, etc.). /// /// Profile value: 66=Baseline, 77=Main, 100=High /// HRESULT (0 for success) [PreserveSig] int put_Profile([In] int value); /// /// Gets the H.264 level. /// /// Receives the level value /// HRESULT (0 for success) [PreserveSig] int get_Level([Out] out int pValue); /// /// Sets the H.264 level (constrains resolution, bitrate, and frame rate). /// /// Level value: 10=Level 1.0, 11=Level 1.1, ..., 51=Level 5.1 /// HRESULT (0 for success) [PreserveSig] int put_Level([In] int value); /// /// Gets the usage mode (quality/speed trade-off). /// /// Receives the usage mode value /// HRESULT (0 for success) [PreserveSig] int get_Usage([Out] out int pValue); /// /// Sets the usage mode to optimize for quality vs. speed. /// /// Usage mode: 0=Quality, 1=Balanced, 2=Speed /// HRESULT (0 for success) [PreserveSig] int put_Usage([In] int value); /// /// Gets the sequential timing mode. /// /// Receives the sequential timing value /// HRESULT (0 for success) [PreserveSig] int get_SequentialTiming([Out] out int pValue); /// /// Sets the sequential timing mode for frame processing. /// /// Sequential timing mode value /// HRESULT (0 for success) [PreserveSig] int put_SequentialTiming([In] int value); /// /// Gets the slice intervals for IDR and P frames. /// /// Receives the IDR frame interval /// Receives the P frame interval /// HRESULT (0 for success) [PreserveSig] int get_SliceIntervals([Out] out int piIDR, [Out] out int piP); /// /// Sets the slice intervals for IDR (Instantaneous Decoder Refresh) and P frames. /// IDR frames are full keyframes, P frames are predicted frames. /// /// IDR frame interval (every N frames). Typical: 30-300 /// P frame interval. Typical: 1-3 /// HRESULT (0 for success) [PreserveSig] int put_SliceIntervals([In] ref int piIDR, [In] ref int piP); /// /// Gets the maximum bitrate for VBR encoding. /// /// Receives the maximum bitrate in bps /// HRESULT (0 for success) [PreserveSig] int get_MaxBitrate([Out] out int plValue); /// /// Sets the maximum bitrate for Variable Bitrate (VBR) encoding. /// Only applicable when rate control is set to VBR. /// /// Maximum bitrate in bits per second (bps) /// HRESULT (0 for success) [PreserveSig] int put_MaxBitrate([In] int lValue); /// /// Gets the minimum bitrate for VBR encoding. /// /// Receives the minimum bitrate in bps /// HRESULT (0 for success) [PreserveSig] int get_MinBitrate([Out] out int plValue); /// /// Sets the minimum bitrate for Variable Bitrate (VBR) encoding. /// Only applicable when rate control is set to VBR. /// /// Minimum bitrate in bits per second (bps) /// HRESULT (0 for success) [PreserveSig] int put_MinBitrate([In] int lValue); } } ``` ### C++ Definition ``` #include // {09FA2EA3-4773-41a8-90DC-9499D4061E9F} DEFINE_GUID(IID_IH264Encoder, 0x09fa2ea3, 0x4773, 0x41a8, 0x90, 0xdc, 0x94, 0x99, 0xd4, 0x06, 0x1e, 0x9f); /// /// H.264/AVC (Advanced Video Coding) encoder configuration interface. /// Provides comprehensive control over H.264 encoding parameters. /// DECLARE_INTERFACE_(IH264Encoder, IUnknown) { /// /// Gets the target bitrate for encoding. /// /// Pointer to receive bitrate in bits per second (bps) /// S_OK for success STDMETHOD(get_Bitrate)(THIS_ long* plValue ) PURE; /// /// Sets the target bitrate for encoding. /// /// Bitrate in bits per second (bps) /// S_OK for success STDMETHOD(put_Bitrate)(THIS_ long lValue ) PURE; /// /// Gets the rate control mode. /// /// Pointer to receive rate control mode /// S_OK for success STDMETHOD(get_RateControl)(THIS_ int* pValue ) PURE; /// /// Sets the rate control mode. /// /// Rate control mode: 0 = CBR, 1 = VBR /// S_OK for success STDMETHOD(put_RateControl)(THIS_ int value ) PURE; /// /// Gets the macroblock encoding mode. /// /// Pointer to receive MB encoding mode /// S_OK for success STDMETHOD(get_MbEncoding)(THIS_ int* pValue ) PURE; /// /// Sets the macroblock encoding mode. /// /// MB encoding mode value /// S_OK for success STDMETHOD(put_MbEncoding)(THIS_ int value ) PURE; /// /// Gets the GOP enable state. /// /// Pointer to receive GOP enabled state /// S_OK for success STDMETHOD(get_GOP)(THIS_ BOOL* pValue ) PURE; /// /// Enables or disables GOP structure. /// /// TRUE to enable GOP, FALSE to disable /// S_OK for success STDMETHOD(put_GOP)(THIS_ BOOL value ) PURE; /// /// Gets the auto-bitrate adjustment state. /// /// Pointer to receive auto-bitrate state /// S_OK for success STDMETHOD(get_AutoBitrate)(THIS_ BOOL* pValue ) PURE; /// /// Enables or disables automatic bitrate adjustment. /// /// TRUE to enable auto-bitrate, FALSE for fixed /// S_OK for success STDMETHOD(put_AutoBitrate)(THIS_ BOOL value ) PURE; /// /// Gets the H.264 profile. /// /// Pointer to receive profile value /// S_OK for success STDMETHOD(get_Profile)(THIS_ int* pValue ) PURE; /// /// Sets the H.264 profile. /// /// Profile value: 66=Baseline, 77=Main, 100=High /// S_OK for success STDMETHOD(put_Profile)(THIS_ int value ) PURE; /// /// Gets the H.264 level. /// /// Pointer to receive level value /// S_OK for success STDMETHOD(get_Level)(THIS_ int* pValue ) PURE; /// /// Sets the H.264 level. /// /// Level value: 10-51 /// S_OK for success STDMETHOD(put_Level)(THIS_ int value ) PURE; /// /// Gets the usage mode. /// /// Pointer to receive usage mode /// S_OK for success STDMETHOD(get_Usage)(THIS_ int* pValue ) PURE; /// /// Sets the usage mode. /// /// Usage mode: 0=Quality, 1=Balanced, 2=Speed /// S_OK for success STDMETHOD(put_Usage)(THIS_ int value ) PURE; /// /// Gets the sequential timing mode. /// /// Pointer to receive sequential timing value /// S_OK for success STDMETHOD(get_SequentialTiming)(THIS_ int* pValue ) PURE; /// /// Sets the sequential timing mode. /// /// Sequential timing mode value /// S_OK for success STDMETHOD(put_SequentialTiming)(THIS_ int value ) PURE; /// /// Gets the slice intervals. /// /// Pointer to receive IDR frame interval /// Pointer to receive P frame interval /// S_OK for success STDMETHOD(get_SliceIntervals)(THIS_ int* piIDR, int* piP ) PURE; /// /// Sets the slice intervals. /// /// Pointer to IDR frame interval /// Pointer to P frame interval /// S_OK for success STDMETHOD(put_SliceIntervals)(THIS_ int* piIDR, int* piP ) PURE; /// /// Gets the maximum bitrate. /// /// Pointer to receive maximum bitrate in bps /// S_OK for success STDMETHOD(get_MaxBitrate)(THIS_ long* plValue ) PURE; /// /// Sets the maximum bitrate for VBR encoding. /// /// Maximum bitrate in bps /// S_OK for success STDMETHOD(put_MaxBitrate)(THIS_ long lValue ) PURE; /// /// Gets the minimum bitrate. /// /// Pointer to receive minimum bitrate in bps /// S_OK for success STDMETHOD(get_MinBitrate)(THIS_ long* plValue ) PURE; /// /// Sets the minimum bitrate for VBR encoding. /// /// Minimum bitrate in bps /// S_OK for success STDMETHOD(put_MinBitrate)(THIS_ long lValue ) PURE; }; ``` ### Delphi Definition ``` uses ActiveX, ComObj; const IID_IH264Encoder: TGUID = '{09FA2EA3-4773-41a8-90DC-9499D4061E9F}'; type /// /// H.264/AVC encoder configuration interface. /// IH264Encoder = interface(IUnknown) ['{09FA2EA3-4773-41a8-90DC-9499D4061E9F}'] /// /// Gets the target bitrate for encoding. /// function get_Bitrate(out plValue: Integer): HRESULT; stdcall; /// /// Sets the target bitrate for encoding. /// function put_Bitrate(lValue: Integer): HRESULT; stdcall; /// /// Gets the rate control mode. /// function get_RateControl(out pValue: Integer): HRESULT; stdcall; /// /// Sets the rate control mode (0=CBR, 1=VBR). /// function put_RateControl(value: Integer): HRESULT; stdcall; /// /// Gets the macroblock encoding mode. /// function get_MbEncoding(out pValue: Integer): HRESULT; stdcall; /// /// Sets the macroblock encoding mode. /// function put_MbEncoding(value: Integer): HRESULT; stdcall; /// /// Gets the GOP enable state. /// function get_GOP(out pValue: BOOL): HRESULT; stdcall; /// /// Enables or disables GOP structure. /// function put_GOP(value: BOOL): HRESULT; stdcall; /// /// Gets the auto-bitrate adjustment state. /// function get_AutoBitrate(out pValue: BOOL): HRESULT; stdcall; /// /// Enables or disables automatic bitrate adjustment. /// function put_AutoBitrate(value: BOOL): HRESULT; stdcall; /// /// Gets the H.264 profile. /// function get_Profile(out pValue: Integer): HRESULT; stdcall; /// /// Sets the H.264 profile (66=Baseline, 77=Main, 100=High). /// function put_Profile(value: Integer): HRESULT; stdcall; /// /// Gets the H.264 level. /// function get_Level(out pValue: Integer): HRESULT; stdcall; /// /// Sets the H.264 level (10-51). /// function put_Level(value: Integer): HRESULT; stdcall; /// /// Gets the usage mode. /// function get_Usage(out pValue: Integer): HRESULT; stdcall; /// /// Sets the usage mode (0=Quality, 1=Balanced, 2=Speed). /// function put_Usage(value: Integer): HRESULT; stdcall; /// /// Gets the sequential timing mode. /// function get_SequentialTiming(out pValue: Integer): HRESULT; stdcall; /// /// Sets the sequential timing mode. /// function put_SequentialTiming(value: Integer): HRESULT; stdcall; /// /// Gets the slice intervals. /// function get_SliceIntervals(out piIDR: Integer; out piP: Integer): HRESULT; stdcall; /// /// Sets the slice intervals for IDR and P frames. /// function put_SliceIntervals(var piIDR: Integer; var piP: Integer): HRESULT; stdcall; /// /// Gets the maximum bitrate. /// function get_MaxBitrate(out plValue: Integer): HRESULT; stdcall; /// /// Sets the maximum bitrate for VBR encoding. /// function put_MaxBitrate(lValue: Integer): HRESULT; stdcall; /// /// Gets the minimum bitrate. /// function get_MinBitrate(out plValue: Integer): HRESULT; stdcall; /// /// Sets the minimum bitrate for VBR encoding. /// function put_MinBitrate(lValue: Integer): HRESULT; stdcall; end; ``` ## H.264 Profiles and Levels ### Profiles H.264 profiles define the features and capabilities available for encoding: **Profile 66 - Baseline Profile**: - Lowest complexity, best decoder compatibility - No B-frames, no CABAC entropy coding - Used for: Video conferencing, mobile devices, web streaming - Compatibility: All H.264 decoders **Profile 77 - Main Profile**: - Medium complexity, good compression - Supports B-frames, CABAC entropy coding - Used for: Standard definition broadcast, streaming services - Better compression than Baseline **Profile 100 - High Profile**: - Highest quality, best compression - Advanced features including 8x8 transforms - Used for: Blu-ray, HDTV broadcast, high-quality streaming - Recommended for most professional applications **Profile 110 - High 10 Profile**: - 10-bit color depth support - Used for: Professional production, HDR content **Profile 122 - High 4:2:2 Profile**: - 4:2:2 chroma subsampling - Used for: Professional editing, broadcast production ### Levels H.264 levels constrain maximum resolution, frame rate, and bitrate: | Level | Max Resolution | Max Frame Rate | Max Bitrate | Typical Use Case | | --- | --- | --- | --- | --- | | 1.0 (10) | 176x144 | 15 fps | 64 Kbps | Mobile, low res | | 3.0 (30) | 720x576 | 30 fps | 10 Mbps | SD broadcast | | 3.1 (31) | 1280x720 | 30 fps | 14 Mbps | 720p HD | | 4.0 (40) | 1920x1080 | 30 fps | 20 Mbps | 1080p HD | | 4.1 (41) | 1920x1080 | 30 fps | 50 Mbps | 1080p HD high bitrate | | 5.0 (50) | 2560x1920 | 30 fps | 135 Mbps | 2K, professional | | 5.1 (51) | 4096x2304 | 30 fps | 240 Mbps | 4K UHD | | 5.2 (52) | 4096x2304 | 60 fps | 480 Mbps | 4K UHD 60fps | **Auto-Selection**: Set level to 0 for automatic selection based on resolution and frame rate. ## Rate Control Modes ### Constant Bitrate (CBR) - Mode 0 **Characteristics**: - Maintains consistent bitrate throughout encoding - Predictable file size and network bandwidth usage - Quality varies based on scene complexity **Use Cases**: - Live streaming (RTMP, HLS, DASH) - Video conferencing - Broadcast transmission - Network-constrained scenarios **Configuration**: ``` h264Encoder.put_RateControl(0); // CBR mode h264Encoder.put_Bitrate(5000000); // 5 Mbps fixed ``` ### Variable Bitrate (VBR) - Mode 1 **Characteristics**: - Allocates more bits to complex scenes, fewer to simple scenes - Better overall quality for the same average bitrate - File size and bitrate fluctuate **Use Cases**: - File-based encoding for storage - VOD (Video On Demand) content - Archival and distribution - When quality is more important than consistent bandwidth **Configuration**: ``` h264Encoder.put_RateControl(1); // VBR mode h264Encoder.put_Bitrate(5000000); // 5 Mbps target h264Encoder.put_MinBitrate(3000000); // 3 Mbps minimum h264Encoder.put_MaxBitrate(8000000); // 8 Mbps maximum ``` ## Method Reference ### Bitrate Configuration #### get\_Bitrate / put\_Bitrate Gets or sets the target bitrate for encoding in bits per second. **Typical Values**: - **360p (SD)**: 500,000 - 1,500,000 bps (0.5-1.5 Mbps) - **720p (HD)**: 2,500,000 - 5,000,000 bps (2.5-5 Mbps) - **1080p (Full HD)**: 5,000,000 - 15,000,000 bps (5-15 Mbps) - **4K (UHD)**: 20,000,000 - 50,000,000 bps (20-50 Mbps) **Example**: ``` h264Encoder.put_Bitrate(5000000); // 5 Mbps for 1080p ``` #### get\_MaxBitrate / put\_MaxBitrate Gets or sets the maximum bitrate for VBR encoding. Only applicable when rate control is set to VBR (mode 1). **Recommendation**: Set MaxBitrate to 1.5-2x the target bitrate for VBR encoding. #### get\_MinBitrate / put\_MinBitrate Gets or sets the minimum bitrate for VBR encoding. Only applicable for VBR mode. **Recommendation**: Set MinBitrate to 0.5-0.7x the target bitrate for VBR encoding. ### Rate Control Methods #### get\_RateControl / put\_RateControl Gets or sets the rate control mode: - **0**: Constant Bitrate (CBR) - **1**: Variable Bitrate (VBR) #### get\_AutoBitrate / put\_AutoBitrate Enables or disables automatic bitrate adjustment based on content complexity. **When enabled**: Encoder automatically adjusts bitrate within configured constraints based on scene complexity, motion, and detail. **Recommended**: Enable for VBR mode, disable for CBR mode. ### Profile and Level Configuration #### get\_Profile / put\_Profile Gets or sets the H.264 profile: - **66**: Baseline Profile - **77**: Main Profile - **100**: High Profile - **110**: High 10 Profile - **122**: High 4:2:2 Profile **Recommendation**: Use High Profile (100) for most applications. Use Baseline (66) only for maximum compatibility with old devices. #### get\_Level / put\_Level Gets or sets the H.264 level (10 = Level 1.0, 11 = Level 1.1, ..., 51 = Level 5.1, 52 = Level 5.2). **Auto-Selection**: Set to 0 for automatic level selection based on resolution and frame rate. ### GOP (Group of Pictures) Configuration #### get\_GOP / put\_GOP Enables or disables GOP structure: - **true**: Normal GOP with I/P/B frames - **false**: All I-frames (intra-only encoding) **All I-frames mode**: - Higher bitrate required - Better editing capability (every frame is a keyframe) - No temporal compression - Use for: Production/editing workflows **Normal GOP mode** (recommended): - Efficient compression with I/P/B frame structure - Lower bitrate for same quality - Use for: Distribution, streaming, archival ### Slice Interval Configuration #### get\_SliceIntervals / put\_SliceIntervals Gets or sets the slice intervals for IDR (Instantaneous Decoder Refresh) frames and P frames. **Parameters**: - `piIDR`: IDR frame interval (keyframe every N frames) - `piP`: P frame interval **Typical Values**: - **Streaming (low latency)**: IDR=30-60 (1-2 seconds at 30fps), P=1 - **Standard encoding**: IDR=120-300 (4-10 seconds), P=1-3 - **Long-form video**: IDR=300+ (10+ seconds), P=3 **IDR Frame Interval**: - Lower values (30-60): Better seeking, higher bitrate overhead, faster error recovery - Higher values (240-600): Lower bitrate overhead, slower seeking, slower error recovery **Example**: ``` int idr = 120; // Keyframe every 120 frames (4 seconds at 30fps) int p = 1; // P frame every frame h264Encoder.put_SliceIntervals(ref idr, ref p); ``` ### Advanced Configuration #### get\_Usage / put\_Usage Sets the encoding usage mode (quality vs. speed trade-off): - **0**: Quality Mode - Slower encoding, best quality - **1**: Balanced Mode - Good quality, reasonable speed - **2**: Speed Mode - Fast encoding, lower quality **Recommendation**: - Use Quality Mode (0) for file-based encoding - Use Balanced Mode (1) for most real-time applications - Use Speed Mode (2) only when encoding performance is critical #### get\_MbEncoding / put\_MbEncoding Configures macroblock encoding mode, affecting encoding complexity and compression efficiency. **Note**: Specific values are encoder-dependent. Consult encoder documentation for supported modes. #### get\_SequentialTiming / put\_SequentialTiming Configures sequential timing mode for frame processing. **Note**: Implementation-specific. Affects frame ordering and presentation timing. ## Usage Examples ### C# Example - High Quality 1080p Encoding ``` using System; using DirectShowLib; using VisioForge.DirectShowAPI; public class H264HighQualityEncoder { public void ConfigureHighQuality1080p(IBaseFilter videoEncoder) { // Query the H.264 encoder interface var h264Encoder = videoEncoder as IH264Encoder; if (h264Encoder == null) { Console.WriteLine("Error: Filter does not support IH264Encoder"); return; } // High quality 1080p settings h264Encoder.put_Profile(100); // High Profile h264Encoder.put_Level(41); // Level 4.1 (1080p @ 30fps) h264Encoder.put_RateControl(1); // VBR mode h264Encoder.put_Bitrate(10000000); // 10 Mbps target h264Encoder.put_MinBitrate(6000000); // 6 Mbps minimum h264Encoder.put_MaxBitrate(15000000); // 15 Mbps maximum h264Encoder.put_Usage(0); // Quality mode h264Encoder.put_GOP(true); // Enable GOP structure h264Encoder.put_AutoBitrate(true); // Auto bitrate adjustment // Set keyframe interval: 120 frames (4 seconds at 30fps) int idr = 120; int p = 1; h264Encoder.put_SliceIntervals(ref idr, ref p); Console.WriteLine("H.264 encoder configured for high-quality 1080p:"); h264Encoder.get_Bitrate(out int bitrate); h264Encoder.get_Profile(out int profile); h264Encoder.get_Level(out int level); Console.WriteLine($" Bitrate: {bitrate / 1000000.0:F1} Mbps"); Console.WriteLine($" Profile: {profile} (High)"); Console.WriteLine($" Level: {level / 10.0:F1}"); } } ``` ### C# Example - Live Streaming Configuration ``` public class H264LiveStreamingEncoder { public void ConfigureLiveStreaming720p(IBaseFilter videoEncoder) { var h264Encoder = videoEncoder as IH264Encoder; if (h264Encoder == null) return; // Live streaming 720p settings h264Encoder.put_Profile(77); // Main Profile (good compatibility) h264Encoder.put_Level(31); // Level 3.1 (720p @ 30fps) h264Encoder.put_RateControl(0); // CBR mode for streaming h264Encoder.put_Bitrate(3500000); // 3.5 Mbps constant h264Encoder.put_Usage(1); // Balanced mode h264Encoder.put_GOP(true); // Enable GOP h264Encoder.put_AutoBitrate(false); // Fixed bitrate for streaming // Low latency: keyframe every 2 seconds int idr = 60; // 2 seconds at 30fps int p = 1; h264Encoder.put_SliceIntervals(ref idr, ref p); Console.WriteLine("H.264 encoder configured for live streaming"); Console.WriteLine(" 720p @ 3.5 Mbps CBR"); Console.WriteLine(" Keyframe interval: 2 seconds"); } } ``` ### C# Example - Fast Encoding for Recording ``` public class H264FastRecording { public void ConfigureFastRecording(IBaseFilter videoEncoder) { var h264Encoder = videoEncoder as IH264Encoder; if (h264Encoder == null) return; // Fast recording settings h264Encoder.put_Profile(66); // Baseline (fastest encoding) h264Encoder.put_Level(40); // Level 4.0 (1080p @ 30fps) h264Encoder.put_RateControl(0); // CBR mode h264Encoder.put_Bitrate(8000000); // 8 Mbps h264Encoder.put_Usage(2); // Speed mode (fast encoding) h264Encoder.put_GOP(true); // Enable GOP h264Encoder.put_AutoBitrate(false); // Fixed bitrate // Longer keyframe interval for faster encoding int idr = 300; // 10 seconds at 30fps int p = 1; h264Encoder.put_SliceIntervals(ref idr, ref p); Console.WriteLine("H.264 encoder configured for fast recording"); } } ``` ### C++ Example - High Quality Configuration ``` #include #include #include "IH264Encoder.h" void ConfigureH264HighQuality(IBaseFilter* pVideoEncoder) { IH264Encoder* pH264Encoder = NULL; HRESULT hr = S_OK; // Query the H.264 encoder interface hr = pVideoEncoder->QueryInterface(IID_IH264Encoder, (void**)&pH264Encoder); if (FAILED(hr) || !pH264Encoder) { std::cout << "Error: Filter does not support IH264Encoder" << std::endl; return; } // Configure high quality 1080p encoding pH264Encoder->put_Profile(100); // High Profile pH264Encoder->put_Level(41); // Level 4.1 pH264Encoder->put_RateControl(1); // VBR mode pH264Encoder->put_Bitrate(10000000); // 10 Mbps pH264Encoder->put_MinBitrate(6000000); // 6 Mbps min pH264Encoder->put_MaxBitrate(15000000); // 15 Mbps max pH264Encoder->put_Usage(0); // Quality mode pH264Encoder->put_GOP(TRUE); // Enable GOP pH264Encoder->put_AutoBitrate(TRUE); // Auto bitrate // Set keyframe interval int idr = 120; int p = 1; pH264Encoder->put_SliceIntervals(&idr, &p); // Display configuration long bitrate; pH264Encoder->get_Bitrate(&bitrate); std::cout << "H.264 encoder configured:" << std::endl; std::cout << " Bitrate: " << (bitrate / 1000000.0) << " Mbps" << std::endl; pH264Encoder->Release(); } ``` ### C++ Example - Live Streaming ``` void ConfigureH264LiveStreaming(IBaseFilter* pVideoEncoder) { IH264Encoder* pH264Encoder = NULL; HRESULT hr = pVideoEncoder->QueryInterface(IID_IH264Encoder, (void**)&pH264Encoder); if (SUCCEEDED(hr) && pH264Encoder) { // Live streaming configuration pH264Encoder->put_Profile(77); // Main Profile pH264Encoder->put_Level(31); // Level 3.1 (720p) pH264Encoder->put_RateControl(0); // CBR for streaming pH264Encoder->put_Bitrate(3500000); // 3.5 Mbps pH264Encoder->put_Usage(1); // Balanced mode pH264Encoder->put_GOP(TRUE); // Enable GOP pH264Encoder->put_AutoBitrate(FALSE); // Fixed bitrate // Low latency keyframes int idr = 60; // 2 seconds int p = 1; pH264Encoder->put_SliceIntervals(&idr, &p); std::cout << "H.264 live streaming configured" << std::endl; pH264Encoder->Release(); } } ``` ### Delphi Example - High Quality Encoding ``` uses DirectShow9, ActiveX; procedure ConfigureH264HighQuality(VideoEncoder: IBaseFilter); var H264Encoder: IH264Encoder; IDR, P: Integer; Bitrate: Integer; hr: HRESULT; begin // Query the H.264 encoder interface hr := VideoEncoder.QueryInterface(IID_IH264Encoder, H264Encoder); if Failed(hr) or (H264Encoder = nil) then begin WriteLn('Error: Filter does not support IH264Encoder'); Exit; end; try // Configure high quality 1080p encoding H264Encoder.put_Profile(100); // High Profile H264Encoder.put_Level(41); // Level 4.1 H264Encoder.put_RateControl(1); // VBR mode H264Encoder.put_Bitrate(10000000); // 10 Mbps H264Encoder.put_MinBitrate(6000000); // 6 Mbps minimum H264Encoder.put_MaxBitrate(15000000); // 15 Mbps maximum H264Encoder.put_Usage(0); // Quality mode H264Encoder.put_GOP(True); // Enable GOP H264Encoder.put_AutoBitrate(True); // Auto bitrate // Set keyframe interval IDR := 120; P := 1; H264Encoder.put_SliceIntervals(IDR, P); // Display configuration H264Encoder.get_Bitrate(Bitrate); WriteLn('H.264 encoder configured for high quality:'); WriteLn(' Bitrate: ', Bitrate / 1000000:0:1, ' Mbps'); finally H264Encoder := nil; end; end; ``` ### Delphi Example - Live Streaming ``` procedure ConfigureH264LiveStreaming(VideoEncoder: IBaseFilter); var H264Encoder: IH264Encoder; IDR, P: Integer; begin if Succeeded(VideoEncoder.QueryInterface(IID_IH264Encoder, H264Encoder)) then begin try // Live streaming configuration H264Encoder.put_Profile(77); // Main Profile H264Encoder.put_Level(31); // Level 3.1 (720p) H264Encoder.put_RateControl(0); // CBR mode H264Encoder.put_Bitrate(3500000); // 3.5 Mbps H264Encoder.put_Usage(1); // Balanced mode H264Encoder.put_GOP(True); // Enable GOP H264Encoder.put_AutoBitrate(False); // Fixed bitrate // Low latency keyframes IDR := 60; // 2 seconds at 30fps P := 1; H264Encoder.put_SliceIntervals(IDR, P); WriteLn('H.264 live streaming configured'); finally H264Encoder := nil; end; end; end; ``` ## Best Practices ### Bitrate Selection Guidelines **Resolution-Based Recommendations**: | Resolution | CBR (Streaming) | VBR Target | VBR Min-Max | | --- | --- | --- | --- | | 360p (SD) | 0.8 Mbps | 1 Mbps | 0.5 - 1.5 Mbps | | 480p (SD) | 1.5 Mbps | 2 Mbps | 1 - 3 Mbps | | 720p (HD) | 3 Mbps | 4 Mbps | 2.5 - 6 Mbps | | 1080p (Full HD) | 6 Mbps | 8 Mbps | 5 - 12 Mbps | | 1440p (2K) | 12 Mbps | 16 Mbps | 10 - 24 Mbps | | 2160p (4K UHD) | 25 Mbps | 35 Mbps | 20 - 50 Mbps | **Content Type Adjustments**: - **Low motion** (presentations, talking head): Use 60-70% of recommended bitrate - **Medium motion** (standard video): Use recommended bitrate - **High motion** (sports, action): Use 120-150% of recommended bitrate ### Profile Selection **Use Baseline Profile (66) when**: - Maximum device compatibility required - Targeting old mobile devices or web browsers - Real-time encoding performance is critical **Use Main Profile (77) when**: - Good balance between quality and compatibility needed - Live streaming to mixed audiences - Standard broadcast applications **Use High Profile (100) when** (recommended): - Best quality is required - Modern device compatibility is acceptable (post-2010 devices) - File-based encoding for distribution - **Most production scenarios** ### GOP Structure Recommendations **Streaming Applications**: - IDR interval: 60-120 frames (2-4 seconds at 30fps) - Shorter intervals: Better seeking, faster error recovery, slightly higher bitrate - Longer intervals: Lower bitrate overhead, but slower seeking **File-Based Encoding**: - IDR interval: 240-300 frames (8-10 seconds at 30fps) - Balance between file size and seeking capability **Low-Latency Applications** (video conferencing): - IDR interval: 30-60 frames (1-2 seconds at 30fps) - Short intervals reduce lag from dropped frames **All-Intra Encoding** (editing workflows): - Disable GOP (`put_GOP(false)`) - Every frame is a keyframe - Higher bitrate required (typically 3-5x normal encoding) - Perfect frame-accurate editing ### Usage Mode Selection **Quality Mode (0)**: - Slowest encoding, best quality - Use for: File-based encoding, archival, VOD content - Not suitable for real-time encoding on slower hardware **Balanced Mode (1)** (recommended): - Good quality, reasonable performance - Use for: Most real-time applications, live streaming - Best choice for general-purpose encoding **Speed Mode (2)**: - Fastest encoding, lower quality - Use for: High-resolution real-time encoding on limited hardware - Screen recording, surveillance applications ## Troubleshooting ### Low Video Quality **Symptoms**: Blocky artifacts, blurring, loss of detail **Possible Causes**: 1. Bitrate too low for resolution 2. Wrong profile selection 3. GOP interval too long 4. Usage mode set to Speed instead of Quality **Solutions**: - Increase bitrate to recommended levels (see table above) - Switch to High Profile (100) for better compression - Shorten IDR interval to 120-180 frames - Use Balanced (1) or Quality (0) usage mode - For VBR, increase minimum bitrate ### Encoding Too Slow / Cannot Keep Up **Symptoms**: Dropped frames, encoding slower than real-time **Solutions**: 1. Switch to Baseline Profile (66) for faster encoding 2. Set Usage mode to Speed (2) 3. Reduce bitrate to lower computational requirements 4. Increase IDR interval (longer GOP = less processing) 5. Consider hardware encoder (NVENC, QuickSync) instead ### Large File Sizes **Symptoms**: Files larger than expected **Possible Causes**: 1. Bitrate too high for target quality 2. CBR mode with conservative bitrate setting 3. GOP disabled (all I-frames) 4. Wrong level setting **Solutions**: - Switch from CBR to VBR for variable content - Enable GOP structure (`put_GOP(true)`) - Reduce target bitrate - Adjust min/max bitrate range for VBR - Use High Profile (100) for better compression ### Streaming Compatibility Issues **Symptoms**: Video plays on some devices but not others **Possible Causes**: 1. Profile too advanced (High Profile not supported on old devices) 2. Level too high for device capabilities 3. Incorrect slice configuration **Solutions**: - Use Main Profile (77) or Baseline Profile (66) for maximum compatibility - Set level to 0 for automatic selection - Test on target devices - Verify player/device H.264 capabilities ### Seeking Issues / Slow Scrubbing **Symptoms**: Slow or inaccurate seeking in encoded video **Cause**: IDR interval too long (keyframes too far apart) **Solutions**: - Reduce IDR interval to 60-120 frames (2-4 seconds) - For editing workflows, consider all-intra encoding (`put_GOP(false)`) - Shorter IDR intervals improve seeking at cost of slightly higher bitrate --- ## See Also - [NVENC Encoder Interface](../nvenc/) - NVIDIA hardware H.264/HEVC encoding - [Video Codecs Reference](../../codecs-reference/) - [Encoding Filters Pack Overview](../../) - [MP4 Muxer Interface](../mp4-muxer/) ---END OF PAGE--- ## LAME MP3 Encoder Settings via DirectShow COM Interface **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/lame/ **Description:** IAudioEncoderProperties interface for LAME MP3 encoding with variable and constant bitrate modes and quality configuration. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, MP3, C# **API:** IBaseFilter, AudioEncoder # LAME MP3 Encoder Interface Reference ## Overview The `IAudioEncoderProperties` interface provides comprehensive control over LAME MP3 audio encoding. LAME (LAME Ain't an MP3 Encoder) is a high-quality MP3 encoder that produces excellent audio quality with efficient compression. This interface allows configuration of bitrate, quality, variable bitrate (VBR) settings, and various encoding flags for optimal MP3 output. ## Interface Definition - **Interface Name**: `IAudioEncoderProperties` - **GUID**: `{595EB9D1-F454-41AD-A1FA-EC232AD9DA52}` - **Inherits From**: `IUnknown` ## Interface Definitions ### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// LAME MP3 encoder interface. /// /// /// Configuring MPEG audio encoder parameters with unspecified /// input stream type may lead to misbehavior and confusing /// results. In most cases the specified parameters will be /// overridden by defaults for the input media type. /// To achieve proper results use this interface on the /// audio encoder filter with input pin connected to a valid source. /// [ComImport] [System.Security.SuppressUnmanagedCodeSecurity] [Guid("595EB9D1-F454-41AD-A1FA-EC232AD9DA52")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IAudioEncoderProperties { // PES Output Control [PreserveSig] int get_PESOutputEnabled(out int dwEnabled); [PreserveSig] int set_PESOutputEnabled([In] int dwEnabled); // Bitrate Configuration [PreserveSig] int get_Bitrate(out int dwBitrate); [PreserveSig] int set_Bitrate([In] int dwBitrate); // Variable Bitrate (VBR) [PreserveSig] int get_Variable(out int dwVariable); [PreserveSig] int set_Variable([In] int dwVariable); [PreserveSig] int get_VariableMin(out int dwmin); [PreserveSig] int set_VariableMin([In] int dwmin); [PreserveSig] int get_VariableMax(out int dwmax); [PreserveSig] int set_VariableMax([In] int dwmax); // Quality Settings [PreserveSig] int get_Quality(out int dwQuality); [PreserveSig] int set_Quality([In] int dwQuality); [PreserveSig] int get_VariableQ(out int dwVBRq); [PreserveSig] int set_VariableQ([In] int dwVBRq); // Source Information [PreserveSig] int get_SourceSampleRate(out int dwSampleRate); [PreserveSig] int get_SourceChannels(out int dwChannels); // Output Configuration [PreserveSig] int get_SampleRate(out int dwSampleRate); [PreserveSig] int set_SampleRate([In] int dwSampleRate); [PreserveSig] int get_ChannelMode(out int dwChannelMode); [PreserveSig] int set_ChannelMode([In] int dwChannelMode); // Flags [PreserveSig] int get_CRCFlag(out int dwFlag); [PreserveSig] int set_CRCFlag([In] int dwFlag); [PreserveSig] int get_OriginalFlag(out int dwFlag); [PreserveSig] int set_OriginalFlag([In] int dwFlag); [PreserveSig] int get_CopyrightFlag(out int dwFlag); [PreserveSig] int set_CopyrightFlag([In] int dwFlag); [PreserveSig] int get_EnforceVBRmin(out int dwFlag); [PreserveSig] int set_EnforceVBRmin([In] int dwFlag); [PreserveSig] int get_VoiceMode(out int dwFlag); [PreserveSig] int set_VoiceMode([In] int dwFlag); [PreserveSig] int get_KeepAllFreq(out int dwFlag); [PreserveSig] int set_KeepAllFreq([In] int dwFlag); [PreserveSig] int get_StrictISO(out int dwFlag); [PreserveSig] int set_StrictISO([In] int dwFlag); [PreserveSig] int get_NoShortBlock(out int dwDisable); [PreserveSig] int set_NoShortBlock([In] int dwDisable); [PreserveSig] int get_XingTag(out int dwXingTag); [PreserveSig] int set_XingTag([In] int dwXingTag); [PreserveSig] int get_ForceMS(out int dwFlag); [PreserveSig] int set_ForceMS([In] int dwFlag); [PreserveSig] int get_ModeFixed(out int dwFlag); [PreserveSig] int set_ModeFixed([In] int dwFlag); // Configuration Management // pcBlock is a BYTE[] buffer in C++; use LPArray with SizeParamIndex=1 // so the marshaler reads pdwSize bytes back from native code. [PreserveSig] int get_ParameterBlockSize( [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pcBlock, out int pdwSize); [PreserveSig] int set_ParameterBlockSize( [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pcBlock, [In] int dwSize); [PreserveSig] int DefaultAudioEncoderProperties(); [PreserveSig] int LoadAudioEncoderPropertiesFromRegistry(); [PreserveSig] int SaveAudioEncoderPropertiesToRegistry(); [PreserveSig] int InputTypeDefined(); } } ``` ### C++ Definition ``` #include // {595EB9D1-F454-41AD-A1FA-EC232AD9DA52} static const GUID IID_IAudioEncoderProperties = { 0x595eb9d1, 0xf454, 0x41ad, { 0xa1, 0xfa, 0xec, 0x23, 0x2a, 0xd9, 0xda, 0x52 } }; DECLARE_INTERFACE_(IAudioEncoderProperties, IUnknown) { // PES Output STDMETHOD(get_PESOutputEnabled)(THIS_ int* dwEnabled) PURE; STDMETHOD(set_PESOutputEnabled)(THIS_ int dwEnabled) PURE; // Bitrate STDMETHOD(get_Bitrate)(THIS_ int* dwBitrate) PURE; STDMETHOD(set_Bitrate)(THIS_ int dwBitrate) PURE; // Variable Bitrate STDMETHOD(get_Variable)(THIS_ int* dwVariable) PURE; STDMETHOD(set_Variable)(THIS_ int dwVariable) PURE; STDMETHOD(get_VariableMin)(THIS_ int* dwmin) PURE; STDMETHOD(set_VariableMin)(THIS_ int dwmin) PURE; STDMETHOD(get_VariableMax)(THIS_ int* dwmax) PURE; STDMETHOD(set_VariableMax)(THIS_ int dwmax) PURE; // Quality STDMETHOD(get_Quality)(THIS_ int* dwQuality) PURE; STDMETHOD(set_Quality)(THIS_ int dwQuality) PURE; STDMETHOD(get_VariableQ)(THIS_ int* dwVBRq) PURE; STDMETHOD(set_VariableQ)(THIS_ int dwVBRq) PURE; // Source Information STDMETHOD(get_SourceSampleRate)(THIS_ int* dwSampleRate) PURE; STDMETHOD(get_SourceChannels)(THIS_ int* dwChannels) PURE; // Output Configuration STDMETHOD(get_SampleRate)(THIS_ int* dwSampleRate) PURE; STDMETHOD(set_SampleRate)(THIS_ int dwSampleRate) PURE; STDMETHOD(get_ChannelMode)(THIS_ int* dwChannelMode) PURE; STDMETHOD(set_ChannelMode)(THIS_ int dwChannelMode) PURE; // Flags STDMETHOD(get_CRCFlag)(THIS_ int* dwFlag) PURE; STDMETHOD(set_CRCFlag)(THIS_ int dwFlag) PURE; STDMETHOD(get_OriginalFlag)(THIS_ int* dwFlag) PURE; STDMETHOD(set_OriginalFlag)(THIS_ int dwFlag) PURE; STDMETHOD(get_CopyrightFlag)(THIS_ int* dwFlag) PURE; STDMETHOD(set_CopyrightFlag)(THIS_ int dwFlag) PURE; STDMETHOD(get_EnforceVBRmin)(THIS_ int* dwFlag) PURE; STDMETHOD(set_EnforceVBRmin)(THIS_ int dwFlag) PURE; STDMETHOD(get_VoiceMode)(THIS_ int* dwFlag) PURE; STDMETHOD(set_VoiceMode)(THIS_ int dwFlag) PURE; STDMETHOD(get_KeepAllFreq)(THIS_ int* dwFlag) PURE; STDMETHOD(set_KeepAllFreq)(THIS_ int dwFlag) PURE; STDMETHOD(get_StrictISO)(THIS_ int* dwFlag) PURE; STDMETHOD(set_StrictISO)(THIS_ int dwFlag) PURE; STDMETHOD(get_NoShortBlock)(THIS_ int* dwDisable) PURE; STDMETHOD(set_NoShortBlock)(THIS_ int dwDisable) PURE; STDMETHOD(get_XingTag)(THIS_ int* dwXingTag) PURE; STDMETHOD(set_XingTag)(THIS_ int dwXingTag) PURE; STDMETHOD(get_ForceMS)(THIS_ int* dwFlag) PURE; STDMETHOD(set_ForceMS)(THIS_ int dwFlag) PURE; STDMETHOD(get_ModeFixed)(THIS_ int* dwFlag) PURE; STDMETHOD(set_ModeFixed)(THIS_ int dwFlag) PURE; // Configuration Management STDMETHOD(get_ParameterBlockSize)(THIS_ byte* pcBlock, int* pdwSize) PURE; STDMETHOD(set_ParameterBlockSize)(THIS_ byte* pcBlock, int dwSize) PURE; STDMETHOD(DefaultAudioEncoderProperties)(THIS) PURE; STDMETHOD(LoadAudioEncoderPropertiesFromRegistry)(THIS) PURE; STDMETHOD(SaveAudioEncoderPropertiesToRegistry)(THIS) PURE; STDMETHOD(InputTypeDefined)(THIS) PURE; }; ``` ### Delphi Definition ``` uses ActiveX, ComObj; const IID_IAudioEncoderProperties: TGUID = '{595EB9D1-F454-41AD-A1FA-EC232AD9DA52}'; type IAudioEncoderProperties = interface(IUnknown) ['{595EB9D1-F454-41AD-A1FA-EC232AD9DA52}'] // PES Output function get_PESOutputEnabled(out dwEnabled: Integer): HRESULT; stdcall; function set_PESOutputEnabled(dwEnabled: Integer): HRESULT; stdcall; // Bitrate function get_Bitrate(out dwBitrate: Integer): HRESULT; stdcall; function set_Bitrate(dwBitrate: Integer): HRESULT; stdcall; // Variable Bitrate function get_Variable(out dwVariable: Integer): HRESULT; stdcall; function set_Variable(dwVariable: Integer): HRESULT; stdcall; function get_VariableMin(out dwmin: Integer): HRESULT; stdcall; function set_VariableMin(dwmin: Integer): HRESULT; stdcall; function get_VariableMax(out dwmax: Integer): HRESULT; stdcall; function set_VariableMax(dwmax: Integer): HRESULT; stdcall; // Quality function get_Quality(out dwQuality: Integer): HRESULT; stdcall; function set_Quality(dwQuality: Integer): HRESULT; stdcall; function get_VariableQ(out dwVBRq: Integer): HRESULT; stdcall; function set_VariableQ(dwVBRq: Integer): HRESULT; stdcall; // Source Information function get_SourceSampleRate(out dwSampleRate: Integer): HRESULT; stdcall; function get_SourceChannels(out dwChannels: Integer): HRESULT; stdcall; // Output Configuration function get_SampleRate(out dwSampleRate: Integer): HRESULT; stdcall; function set_SampleRate(dwSampleRate: Integer): HRESULT; stdcall; function get_ChannelMode(out dwChannelMode: Integer): HRESULT; stdcall; function set_ChannelMode(dwChannelMode: Integer): HRESULT; stdcall; // Flags function get_CRCFlag(out dwFlag: Integer): HRESULT; stdcall; function set_CRCFlag(dwFlag: Integer): HRESULT; stdcall; function get_OriginalFlag(out dwFlag: Integer): HRESULT; stdcall; function set_OriginalFlag(dwFlag: Integer): HRESULT; stdcall; function get_CopyrightFlag(out dwFlag: Integer): HRESULT; stdcall; function set_CopyrightFlag(dwFlag: Integer): HRESULT; stdcall; function get_EnforceVBRmin(out dwFlag: Integer): HRESULT; stdcall; function set_EnforceVBRmin(dwFlag: Integer): HRESULT; stdcall; function get_VoiceMode(out dwFlag: Integer): HRESULT; stdcall; function set_VoiceMode(dwFlag: Integer): HRESULT; stdcall; function get_KeepAllFreq(out dwFlag: Integer): HRESULT; stdcall; function set_KeepAllFreq(dwFlag: Integer): HRESULT; stdcall; function get_StrictISO(out dwFlag: Integer): HRESULT; stdcall; function set_StrictISO(dwFlag: Integer): HRESULT; stdcall; function get_NoShortBlock(out dwDisable: Integer): HRESULT; stdcall; function set_NoShortBlock(dwDisable: Integer): HRESULT; stdcall; function get_XingTag(out dwXingTag: Integer): HRESULT; stdcall; function set_XingTag(dwXingTag: Integer): HRESULT; stdcall; function get_ForceMS(out dwFlag: Integer): HRESULT; stdcall; function set_ForceMS(dwFlag: Integer): HRESULT; stdcall; function get_ModeFixed(out dwFlag: Integer): HRESULT; stdcall; function set_ModeFixed(dwFlag: Integer): HRESULT; stdcall; // Configuration Management function get_ParameterBlockSize(out pcBlock: Byte; out pdwSize: Integer): HRESULT; stdcall; function set_ParameterBlockSize(pcBlock: Byte; dwSize: Integer): HRESULT; stdcall; function DefaultAudioEncoderProperties: HRESULT; stdcall; function LoadAudioEncoderPropertiesFromRegistry: HRESULT; stdcall; function SaveAudioEncoderPropertiesToRegistry: HRESULT; stdcall; function InputTypeDefined: HRESULT; stdcall; end; ``` --- ## Methods Reference ### Bitrate Configuration #### set\_Bitrate / get\_Bitrate Sets or retrieves the target compression bitrate in Kbits/s. **Parameters**: - `dwBitrate`: Bitrate in kilobits per second **Common MP3 Bitrates**: - **320 kbps** - Highest quality, near-transparent - **256 kbps** - Very high quality - **192 kbps** - High quality (recommended for music) - **128 kbps** - Standard quality (acceptable for most content) - **96 kbps** - Lower quality, smaller files - **64 kbps** - Voice/podcast quality **Example (C#)**: ``` var lame = audioEncoder as IAudioEncoderProperties; if (lame != null) { // Set high quality 192 kbps lame.set_Bitrate(192); } ``` --- ### Variable Bitrate (VBR) #### set\_Variable / get\_Variable Enables or disables variable bitrate mode. **Parameters**: - `dwVariable`: 1 to enable VBR, 0 to disable (CBR mode) **Usage Notes**: - VBR provides better quality-to-size ratio than CBR - VBR allocates more bits to complex audio passages - CBR provides predictable file sizes - VBR is recommended for music archival #### set\_VariableMin / get\_VariableMin Sets the minimum bitrate for VBR mode. **Parameters**: - `dwmin`: Minimum bitrate in kbps #### set\_VariableMax / get\_VariableMax Sets the maximum bitrate for VBR mode. **Parameters**: - `dwmax`: Maximum bitrate in kbps **Example (C#)**: ``` // Enable VBR with 128-256 kbps range lame.set_Variable(1); lame.set_VariableMin(128); lame.set_VariableMax(256); lame.set_VariableQ(4); // VBR quality level ``` --- ### Quality Settings #### set\_Quality / get\_Quality Sets the encoding quality for CBR mode. **Parameters**: - `dwQuality`: Quality level (0-9) - **0** - Highest quality (slowest) - **2** - Near-highest quality (recommended) - **5** - Good quality/speed balance - **7** - Faster encoding, lower quality - **9** - Lowest quality (fastest) **Example (C++)**: ``` IAudioEncoderProperties* pLame = nullptr; pFilter->QueryInterface(IID_IAudioEncoderProperties, (void**)&pLame); // High quality CBR encoding pLame->set_Bitrate(192); pLame->set_Quality(2); pLame->Release(); ``` #### set\_VariableQ / get\_VariableQ Sets the quality level for VBR mode. **Parameters**: - `dwVBRq`: VBR quality (0-9) - **0** - Highest quality (~245 kbps) - **2** - Very high quality (~190 kbps) - **4** - High quality (~165 kbps) - recommended - **6** - Medium quality (~130 kbps) - **9** - Lowest quality (~65 kbps) --- ### Channel Mode #### set\_ChannelMode / get\_ChannelMode Sets the stereo encoding mode. **Parameters**: - `dwChannelMode`: Channel mode value - **0** - Stereo - **1** - Joint Stereo (recommended) - **2** - Dual Channel - **3** - Mono **Usage Notes**: - Joint Stereo provides best quality at lower bitrates - Use Stereo for critical listening at high bitrates - Mono reduces file size for speech/podcasts **Example (C#)**: ``` // Joint stereo for music at 192 kbps lame.set_ChannelMode(1); lame.set_Bitrate(192); ``` --- ### Encoding Flags #### set\_CRCFlag / get\_CRCFlag Enables CRC error protection. **Parameters**: - `dwFlag`: 1 to enable, 0 to disable **Usage**: Adds error detection, minimal size increase (~0.2%) #### set\_CopyrightFlag / get\_CopyrightFlag Sets the copyright flag in MP3 header. **Parameters**: - `dwFlag`: 1 if copyrighted, 0 otherwise #### set\_OriginalFlag / get\_OriginalFlag Sets the original/copy flag. **Parameters**: - `dwFlag`: 1 for original, 0 for copy #### set\_VoiceMode / get\_VoiceMode Optimizes encoding for voice content. **Parameters**: - `dwFlag`: 1 to enable voice optimization **Usage**: Improves quality for speech at lower bitrates **Example (C#)**: ``` // Optimize for podcast/voice content lame.set_VoiceMode(1); lame.set_Bitrate(64); lame.set_ChannelMode(3); // Mono ``` #### set\_XingTag / get\_XingTag Adds Xing VBR tag for accurate seeking. **Parameters**: - `dwFlag`: 1 to add tag (recommended for VBR) **Usage**: Essential for VBR files to enable proper seeking --- ## Configuration Management ### SaveAudioEncoderPropertiesToRegistry Saves the current encoder configuration to the registry. **Usage Notes**: - Must be called after changing properties - Settings persist between sessions - Requires appropriate registry permissions ### LoadAudioEncoderPropertiesFromRegistry Loads encoder configuration from the registry. ### DefaultAudioEncoderProperties Resets all encoder properties to default values based on input stream type. ### InputTypeDefined Checks if the input format has been specified. **Returns**: - `S_OK` - Input type is defined, encoder can be configured - `E_FAIL` - Input type not specified, configuration may fail --- ## Complete Examples ### Example 1: High Quality Music Encoding (C#) ``` using VisioForge.DirectShowAPI; public void ConfigureHighQualityMP3(IBaseFilter audioEncoder) { var lame = audioEncoder as IAudioEncoderProperties; if (lame == null) return; // Check if input is connected if (lame.InputTypeDefined() != 0) { Console.WriteLine("Warning: Input not connected, using defaults"); } // High quality VBR settings lame.set_Variable(1); // Enable VBR lame.set_VariableQ(2); // Very high quality lame.set_VariableMin(192); // Min 192 kbps lame.set_VariableMax(320); // Max 320 kbps // Joint stereo for efficiency lame.set_ChannelMode(1); // Quality flags lame.set_XingTag(1); // Add VBR tag lame.set_OriginalFlag(1); // Mark as original lame.set_CopyrightFlag(1); // Set copyright // Save settings lame.SaveAudioEncoderPropertiesToRegistry(); } ``` ### Example 2: Podcast/Voice Encoding (C++) ``` #include "LAME.h" HRESULT ConfigurePodcastMP3(IBaseFilter* pAudioEncoder) { HRESULT hr; IAudioEncoderProperties* pLame = nullptr; hr = pAudioEncoder->QueryInterface(IID_IAudioEncoderProperties, (void**)&pLame); if (FAILED(hr)) return hr; // Voice-optimized settings pLame->set_VoiceMode(1); // Voice optimization pLame->set_Bitrate(64); // 64 kbps for speech pLame->set_Quality(5); // Balanced quality pLame->set_ChannelMode(3); // Mono // Disable VBR for predictable file size pLame->set_Variable(0); // Add Xing tag for compatibility pLame->set_XingTag(1); // Save configuration pLame->SaveAudioEncoderPropertiesToRegistry(); pLame->Release(); return S_OK; } ``` ### Example 3: Standard Music Encoding (Delphi) ## ``` procedure ConfigureStandardMP3(AudioEncoder: IBaseFilter); var Lame: IAudioEncoderProperties; hr: HRESULT; begin if Succeeded(AudioEncoder.QueryInterface(IID_IAudioEncoderProperties, Lame)) then begin // Standard VBR music settings Lame.set_Variable(1); // Enable VBR Lame.set_VariableQ(4); // High quality (~165 kbps avg) Lame.set_VariableMin(128); // Min 128 kbps Lame.set_VariableMax(256); // Max 256 kbps // Joint stereo Lame.set_ChannelMode(1); // Essential flags Lame.set_XingTag(1); // VBR tag for seeking // Save to registry Lame.SaveAudioEncoderPropertiesToRegistry; Lame := nil; end; end; ``` ## Best Practices ### Quality Recommendations 1. **Music Archival**: VBR Q0-Q2 (245-190 kbps average) 2. **Music Distribution**: VBR Q4 (165 kbps) or CBR 192 kbps 3. **Streaming**: CBR 128 kbps 4. **Podcasts/Speech**: CBR 64 kbps mono with voice mode ### Performance Tips 1. **Use Joint Stereo** at bitrates below 192 kbps 2. **Enable VBR** for better quality-to-size ratio 3. **Add Xing Tag** for VBR files 4. **Use Voice Mode** for speech content at <96 kbps ### Configuration Workflow 1. Connect input pin before configuring 2. Check `InputTypeDefined()` before setting properties 3. Configure all desired properties 4. Call `SaveAudioEncoderPropertiesToRegistry()` 5. Verify settings with get methods --- ## Troubleshooting ### Issue: Settings Not Applied **Solution**: ``` // Ensure input is connected first if (lame.InputTypeDefined() == 0) { // Configure settings lame.set_Bitrate(192); lame.SaveAudioEncoderPropertiesToRegistry(); } else { // Connect input first, then configure } ``` ### Issue: Poor Quality Output **Solutions**: - Increase VBR quality: `set_VariableQ(2)` or lower - Increase CBR bitrate: `set_Bitrate(192)` or higher - Use better quality setting: `set_Quality(2)` - Disable voice mode for music: `set_VoiceMode(0)` ### Issue: Large File Sizes **Solutions**: ``` // Use VBR instead of high CBR pLame->set_Variable(1); pLame->set_VariableQ(4); // ~165 kbps average pLame->set_VariableMax(192); // Cap maximum bitrate ``` --- ## See Also - [Encoding Filters Pack Overview](../../) - [Audio Codecs Reference](../../codecs-reference/) - [AAC Encoder](../aac/) - [FLAC Encoder](../flac/) ---END OF PAGE--- ## MP4 Muxer DirectShow Filter - Timing and Live Streaming **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/mp4-muxer/ **Description:** MP4 muxer DirectShow interfaces with threading configuration, timing correction, and live streaming options for MP4 container output. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, MP4, C# **API:** MP4V10Flags, IBaseFilter, MP4MuxerStandardConfig, MP4MuxerDeterministicConfig, MP4V10LiveStreamingConfig # MP4 Muxer Interface Reference ## Overview The MP4 muxer DirectShow filters provide interfaces for configuring MP4 (MPEG-4 Part 14) container output. These interfaces allow developers to control threading behavior, timing correction, and special handling for live streaming scenarios. Two muxer interfaces are available: - **IMP4MuxerConfig**: Basic MP4 muxer configuration for threading and timing - **IMP4V10MuxerConfig**: Advanced configuration for version 10 muxer with timing flags and live streaming control ## IMP4MuxerConfig Interface ### Overview The **IMP4MuxerConfig** interface provides basic configuration for MP4 multiplexing, controlling single-threaded operation and timing correction behavior. **Interface GUID**: `{99DC9BE5-0AFA-45d4-8370-AB021FB07CF4}` **Inherits From**: `IUnknown` ### Interface Definitions #### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// MP4 muxer configuration interface. /// Controls threading and timing behavior for MP4 container creation. /// [ComImport] [Guid("99DC9BE5-0AFA-45d4-8370-AB021FB07CF4")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IMP4MuxerConfig { /// /// Gets the single-thread processing state. /// /// Receives true if single-threaded mode is enabled, false otherwise /// HRESULT (0 for success) [PreserveSig] int get_SingleThread([Out] [MarshalAs(UnmanagedType.Bool)] out bool pValue); /// /// Enables or disables single-threaded processing. /// When enabled, all muxer operations run on a single thread for deterministic behavior. /// /// True to enable single-threaded mode, false for multi-threaded /// HRESULT (0 for success) [PreserveSig] int put_SingleThread([In] [MarshalAs(UnmanagedType.Bool)] bool value); /// /// Gets the timing correction state. /// /// Receives true if timing correction is enabled, false otherwise /// HRESULT (0 for success) [PreserveSig] int get_CorrectTiming([Out] [MarshalAs(UnmanagedType.Bool)] out bool pValue); /// /// Enables or disables timing correction. /// When enabled, the muxer adjusts timestamps to correct timing drift and inconsistencies. /// /// True to enable timing correction, false to disable /// HRESULT (0 for success) [PreserveSig] int put_CorrectTiming([In] [MarshalAs(UnmanagedType.Bool)] bool value); } } ``` #### C++ Definition ``` #include // {99DC9BE5-0AFA-45d4-8370-AB021FB07CF4} DEFINE_GUID(IID_IMP4MuxerConfig, 0x99dc9be5, 0x0afa, 0x45d4, 0x83, 0x70, 0xab, 0x02, 0x1f, 0xb0, 0x7c, 0xf4); /// /// MP4 muxer configuration interface. /// Controls threading and timing behavior. /// DECLARE_INTERFACE_(IMP4MuxerConfig, IUnknown) { /// /// Gets the single-thread processing state. /// /// Pointer to receive single-thread enabled state /// S_OK for success STDMETHOD(get_SingleThread)(THIS_ BOOL* pValue ) PURE; /// /// Enables or disables single-threaded processing. /// /// TRUE to enable single-threaded mode, FALSE for multi-threaded /// S_OK for success STDMETHOD(put_SingleThread)(THIS_ BOOL value ) PURE; /// /// Gets the timing correction state. /// /// Pointer to receive timing correction enabled state /// S_OK for success STDMETHOD(get_CorrectTiming)(THIS_ BOOL* pValue ) PURE; /// /// Enables or disables timing correction. /// /// TRUE to enable timing correction, FALSE to disable /// S_OK for success STDMETHOD(put_CorrectTiming)(THIS_ BOOL value ) PURE; }; ``` #### Delphi Definition ``` uses ActiveX, ComObj; const IID_IMP4MuxerConfig: TGUID = '{99DC9BE5-0AFA-45d4-8370-AB021FB07CF4}'; type /// /// MP4 muxer configuration interface. /// IMP4MuxerConfig = interface(IUnknown) ['{99DC9BE5-0AFA-45d4-8370-AB021FB07CF4}'] /// /// Gets the single-thread processing state. /// function get_SingleThread(out pValue: BOOL): HRESULT; stdcall; /// /// Enables or disables single-threaded processing. /// function put_SingleThread(value: BOOL): HRESULT; stdcall; /// /// Gets the timing correction state. /// function get_CorrectTiming(out pValue: BOOL): HRESULT; stdcall; /// /// Enables or disables timing correction. /// function put_CorrectTiming(value: BOOL): HRESULT; stdcall; end; ``` ### Method Reference #### get\_SingleThread / put\_SingleThread Controls whether the muxer processes data using a single thread or multiple threads. **Single-Threaded Mode (enabled)**: - All muxing operations run on one thread - Deterministic, predictable behavior - Easier debugging and troubleshooting - Slightly lower performance on multi-core systems - **Recommended for**: Scenarios requiring consistent, reproducible output **Multi-Threaded Mode (disabled)**: - Muxer can use multiple threads for processing - Better performance on multi-core processors - Non-deterministic operation order - **Recommended for**: High-performance encoding with multiple streams **Default**: Typically multi-threaded (false) **Example**: ``` // Enable single-threaded mode for consistent output mp4Muxer.put_SingleThread(true); ``` #### get\_CorrectTiming / put\_CorrectTiming Enables or disables automatic timestamp correction for audio and video streams. **Timing Correction Enabled (true)**: - Muxer automatically adjusts timestamps to correct drift - Fixes timing inconsistencies from source filters - Ensures proper A/V synchronization - Adds small processing overhead - **Recommended for**: Most scenarios, especially with live sources **Timing Correction Disabled (false)**: - Timestamps passed through without modification - Assumes source filters provide accurate timestamps - Slightly better performance - **Use only when**: Source provides guaranteed accurate timestamps **Default**: Typically enabled (true) **Example**: ``` // Enable timing correction for A/V sync mp4Muxer.put_CorrectTiming(true); ``` --- ## IMP4V10MuxerConfig Interface ### Overview The **IMP4V10MuxerConfig** interface provides advanced configuration for the version 10 MP4 muxer, including timing override flags and live streaming control. **Interface GUID**: `{9E26CE8B-6708-4535-AAA4-23F9A97C7937}` **Inherits From**: `IUnknown` ### MP4V10Flags Enumeration ``` /// /// MP4 v10 muxer configuration flags. /// [Flags] public enum MP4V10Flags { /// /// No special flags. /// None = 0, /// /// Time override mode - allows manual timestamp control. /// TimeOverride = 0x00000001, /// /// Time adjust mode - enables automatic timestamp adjustment. /// TimeAdjust = 0x00000002 } ``` ### Interface Definitions #### C# Definition ``` using System; using System.Runtime.InteropServices; namespace VisioForge.DirectShowAPI { /// /// MP4 v10 muxer flags. /// [Flags] public enum MP4V10Flags { /// /// Default - no special flags. /// None = 0, /// /// Time override - allows manual timestamp control. /// TimeOverride = 0x00000001, /// /// Time adjust - enables automatic timestamp adjustment. /// TimeAdjust = 0x00000002 } /// /// MP4 version 10 muxer configuration interface. /// Provides advanced timing control and live streaming options. /// [ComImport] [Guid("9E26CE8B-6708-4535-AAA4-23F9A97C7937")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IMP4V10MuxerConfig { /// /// Sets the muxer configuration flags. /// /// Combination of MP4V10Flags values /// HRESULT (0 for success) [PreserveSig] int SetFlags([In] uint value); /// /// Gets the current muxer configuration flags. /// /// Receives the current flags /// HRESULT (0 for success) [PreserveSig] int GetFlags([Out] out uint pValue); /// /// Disables live streaming optimizations. /// When disabled, muxer uses standard file-based output mode. /// /// True to disable live mode, false to enable /// HRESULT (0 for success) [PreserveSig] int SetLiveDisabled([MarshalAs(UnmanagedType.Bool)] bool liveDisabled); } } ``` #### C++ Definition ``` #include // {9E26CE8B-6708-4535-AAA4-23F9A97C7937} DEFINE_GUID(IID_IMP4V10MuxerConfig, 0x9e26ce8b, 0x6708, 0x4535, 0xaa, 0xa4, 0x23, 0xf9, 0xa9, 0x7c, 0x79, 0x37); /// /// MP4 v10 muxer flags. /// enum MP4V10Flags { MP4V10_NONE = 0, MP4V10_TIME_OVERRIDE = 0x00000001, MP4V10_TIME_ADJUST = 0x00000002 }; /// /// MP4 version 10 muxer configuration interface. /// Provides advanced timing control and live streaming options. /// DECLARE_INTERFACE_(IMP4V10MuxerConfig, IUnknown) { /// /// Sets the muxer configuration flags. /// /// Combination of MP4V10Flags values /// S_OK for success STDMETHOD(SetFlags)(THIS_ unsigned long value ) PURE; /// /// Gets the current muxer configuration flags. /// /// Pointer to receive current flags /// S_OK for success STDMETHOD(GetFlags)(THIS_ unsigned long* pValue ) PURE; /// /// Disables live streaming optimizations. /// /// TRUE to disable live mode, FALSE to enable /// S_OK for success STDMETHOD(SetLiveDisabled)(THIS_ BOOL liveDisabled ) PURE; }; ``` #### Delphi Definition ``` uses ActiveX, ComObj; const IID_IMP4V10MuxerConfig: TGUID = '{9E26CE8B-6708-4535-AAA4-23F9A97C7937}'; // MP4V10Flags constants MP4V10_NONE = 0; MP4V10_TIME_OVERRIDE = $00000001; MP4V10_TIME_ADJUST = $00000002; type /// /// MP4 version 10 muxer configuration interface. /// IMP4V10MuxerConfig = interface(IUnknown) ['{9E26CE8B-6708-4535-AAA4-23F9A97C7937}'] /// /// Sets the muxer configuration flags. /// function SetFlags(value: Cardinal): HRESULT; stdcall; /// /// Gets the current muxer configuration flags. /// function GetFlags(out pValue: Cardinal): HRESULT; stdcall; /// /// Disables live streaming optimizations. /// function SetLiveDisabled(liveDisabled: BOOL): HRESULT; stdcall; end; ``` ### Method Reference #### SetFlags / GetFlags Sets or retrieves the muxer configuration flags that control timing behavior. **MP4V10Flags Values**: **None (0)**: - Standard operation - Default timestamp handling - No special timing modifications **TimeOverride (0x00000001)**: - Enables manual timestamp override - Allows application to control timestamps directly - Disables automatic timestamp generation - **Use when**: Application needs full control over timing **TimeAdjust (0x00000002)**: - Enables automatic timestamp adjustment - Muxer corrects timing drift and irregularities - Similar to IMP4MuxerConfig::CorrectTiming - **Use for**: Sources with inconsistent timestamps **Combining Flags**: ``` // Enable both time override and adjust uint flags = (uint)(MP4V10Flags.TimeOverride | MP4V10Flags.TimeAdjust); mp4V10Muxer.SetFlags(flags); ``` #### SetLiveDisabled Controls whether the muxer operates in live streaming mode or file-based mode. **Live Mode Enabled** (liveDisabled = false): - Optimized for live/real-time streaming - Minimal buffering - Lower latency - Progressive MP4 output (can be played while being written) - **Use for**: Live streaming to file, network streaming output **Live Mode Disabled** (liveDisabled = true): - Standard file-based muxing - Can perform multi-pass optimization - Complete MP4 structure written at end - May require seeking in output file - **Use for**: File-based encoding, post-processing scenarios **Example**: ``` // Enable file-based mode (disable live optimizations) mp4V10Muxer.SetLiveDisabled(true); ``` ## Usage Examples ### C# Example - Standard MP4 File Creation ``` using System; using DirectShowLib; using VisioForge.DirectShowAPI; public class MP4MuxerStandardConfig { public void ConfigureStandardMP4(IBaseFilter mp4Muxer) { // Query the standard MP4 muxer interface var muxerConfig = mp4Muxer as IMP4MuxerConfig; if (muxerConfig == null) { Console.WriteLine("Error: Filter does not support IMP4MuxerConfig"); return; } // Configure for standard file-based encoding muxerConfig.put_SingleThread(false); // Multi-threaded for performance muxerConfig.put_CorrectTiming(true); // Enable timing correction Console.WriteLine("MP4 muxer configured for standard file creation"); // Verify configuration muxerConfig.get_SingleThread(out bool singleThread); muxerConfig.get_CorrectTiming(out bool correctTiming); Console.WriteLine($" Single-threaded: {singleThread}"); Console.WriteLine($" Timing correction: {correctTiming}"); } } ``` ### C# Example - Deterministic Output ``` public class MP4MuxerDeterministicConfig { public void ConfigureDeterministicMP4(IBaseFilter mp4Muxer) { var muxerConfig = mp4Muxer as IMP4MuxerConfig; if (muxerConfig == null) return; // Configure for deterministic, reproducible output muxerConfig.put_SingleThread(true); // Single-threaded for consistency muxerConfig.put_CorrectTiming(true); // Enable timing correction Console.WriteLine("MP4 muxer configured for deterministic output"); Console.WriteLine(" Suitable for regression testing and validation"); } } ``` ### C# Example - Live Streaming to File (MP4 V10) ``` public class MP4V10LiveStreamingConfig { public void ConfigureLiveStreaming(IBaseFilter mp4V10Muxer) { // Query the MP4 v10 muxer interface var muxerV10Config = mp4V10Muxer as IMP4V10MuxerConfig; if (muxerV10Config == null) { Console.WriteLine("Error: Filter does not support IMP4V10MuxerConfig"); return; } // Configure for live streaming to file muxerV10Config.SetLiveDisabled(false); // Enable live mode // Enable timing adjustment for live sources uint flags = (uint)MP4V10Flags.TimeAdjust; muxerV10Config.SetFlags(flags); Console.WriteLine("MP4 v10 muxer configured for live streaming"); // Verify configuration muxerV10Config.GetFlags(out uint currentFlags); Console.WriteLine($" Flags: 0x{currentFlags:X8}"); Console.WriteLine($" Time Adjust: {((currentFlags & (uint)MP4V10Flags.TimeAdjust) != 0)}"); } } ``` ### C# Example - Manual Timestamp Control (MP4 V10) ``` public class MP4V10ManualTimestampConfig { public void ConfigureManualTimestamps(IBaseFilter mp4V10Muxer) { var muxerV10Config = mp4V10Muxer as IMP4V10MuxerConfig; if (muxerV10Config == null) return; // Configure for manual timestamp control muxerV10Config.SetLiveDisabled(true); // Disable live mode // Enable time override for manual control uint flags = (uint)MP4V10Flags.TimeOverride; muxerV10Config.SetFlags(flags); Console.WriteLine("MP4 v10 muxer configured for manual timestamp control"); Console.WriteLine(" Application must provide accurate timestamps"); } } ``` ### C++ Example - Standard Configuration ``` #include #include #include "IMP4MuxerConfig.h" void ConfigureMP4Muxer(IBaseFilter* pMp4Muxer) { IMP4MuxerConfig* pMuxerConfig = NULL; HRESULT hr = S_OK; // Query the MP4 muxer interface hr = pMp4Muxer->QueryInterface(IID_IMP4MuxerConfig, (void**)&pMuxerConfig); if (FAILED(hr) || !pMuxerConfig) { std::cout << "Error: Filter does not support IMP4MuxerConfig" << std::endl; return; } // Configure muxer pMuxerConfig->put_SingleThread(FALSE); // Multi-threaded pMuxerConfig->put_CorrectTiming(TRUE); // Enable timing correction // Verify configuration BOOL singleThread, correctTiming; pMuxerConfig->get_SingleThread(&singleThread); pMuxerConfig->get_CorrectTiming(&correctTiming); std::cout << "MP4 muxer configured:" << std::endl; std::cout << " Single-threaded: " << (singleThread ? "Yes" : "No") << std::endl; std::cout << " Timing correction: " << (correctTiming ? "Yes" : "No") << std::endl; pMuxerConfig->Release(); } ``` ### C++ Example - Live Streaming (MP4 V10) ``` #include "IMP4V10MuxerConfig.h" void ConfigureMP4V10LiveStreaming(IBaseFilter* pMp4V10Muxer) { IMP4V10MuxerConfig* pMuxerV10Config = NULL; HRESULT hr = pMp4V10Muxer->QueryInterface(IID_IMP4V10MuxerConfig, (void**)&pMuxerV10Config); if (SUCCEEDED(hr) && pMuxerV10Config) { // Configure for live streaming pMuxerV10Config->SetLiveDisabled(FALSE); // Enable live mode // Enable timing adjustment unsigned long flags = MP4V10_TIME_ADJUST; pMuxerV10Config->SetFlags(flags); std::cout << "MP4 v10 muxer configured for live streaming" << std::endl; pMuxerV10Config->Release(); } } ``` ### Delphi Example - Standard Configuration ``` uses DirectShow9, ActiveX; procedure ConfigureMP4Muxer(Mp4Muxer: IBaseFilter); var MuxerConfig: IMP4MuxerConfig; SingleThread, CorrectTiming: BOOL; hr: HRESULT; begin // Query the MP4 muxer interface hr := Mp4Muxer.QueryInterface(IID_IMP4MuxerConfig, MuxerConfig); if Failed(hr) or (MuxerConfig = nil) then begin WriteLn('Error: Filter does not support IMP4MuxerConfig'); Exit; end; try // Configure muxer MuxerConfig.put_SingleThread(False); // Multi-threaded MuxerConfig.put_CorrectTiming(True); // Enable timing correction // Verify configuration MuxerConfig.get_SingleThread(SingleThread); MuxerConfig.get_CorrectTiming(CorrectTiming); WriteLn('MP4 muxer configured:'); WriteLn(' Single-threaded: ', SingleThread); WriteLn(' Timing correction: ', CorrectTiming); finally MuxerConfig := nil; end; end; ``` ### Delphi Example - Live Streaming (MP4 V10) ``` procedure ConfigureMP4V10LiveStreaming(Mp4V10Muxer: IBaseFilter); var MuxerV10Config: IMP4V10MuxerConfig; Flags: Cardinal; begin if Succeeded(Mp4V10Muxer.QueryInterface(IID_IMP4V10MuxerConfig, MuxerV10Config)) then begin try // Configure for live streaming MuxerV10Config.SetLiveDisabled(False); // Enable live mode // Enable timing adjustment Flags := MP4V10_TIME_ADJUST; MuxerV10Config.SetFlags(Flags); WriteLn('MP4 v10 muxer configured for live streaming'); finally MuxerV10Config := nil; end; end; end; ``` ## Best Practices ### When to Use IMP4MuxerConfig **Use IMP4MuxerConfig when**: - You need basic muxer configuration - Working with standard MP4 output - Simple timing correction is sufficient - Don't need advanced live streaming features **Typical Configuration**: ``` mp4Muxer.put_SingleThread(false); // Multi-threaded for performance mp4Muxer.put_CorrectTiming(true); // Enable timing correction ``` ### When to Use IMP4V10MuxerConfig **Use IMP4V10MuxerConfig when**: - Need advanced timing control - Working with live streaming scenarios - Require manual timestamp override - Need progressive MP4 output **Live Streaming Configuration**: ``` mp4V10Muxer.SetLiveDisabled(false); // Enable live mode mp4V10Muxer.SetFlags((uint)MP4V10Flags.TimeAdjust); // Auto timing adjustment ``` ### Single-Threaded vs Multi-Threaded **Use Single-Threaded Mode when**: - Debugging muxer behavior - Need deterministic, reproducible output - Running automated tests - Troubleshooting timing issues **Use Multi-Threaded Mode when**: - Performance is critical - Encoding high-resolution video (1080p+) - System has multiple CPU cores available - Standard production encoding ### Timing Correction **Always Enable Timing Correction when**: - Working with live sources (cameras, capture devices) - Sources may have timestamp inconsistencies - Combining multiple streams (audio + video) - Need reliable A/V synchronization **Can Disable Timing Correction when**: - Source provides guaranteed accurate timestamps - File-based encoding with pre-validated timestamps - Performance is absolutely critical - Using manual timestamp control (TimeOverride flag) ### Live Streaming Optimization **Enable Live Mode** (SetLiveDisabled = false) **when**: - Encoding for real-time streaming - Output needs to be playable while being written - Creating progressive MP4 files - Low latency is important **Disable Live Mode** (SetLiveDisabled = true) **when**: - Creating files for post-processing - Need complete MP4 structure at end - Can perform multi-pass optimization - Output file will only be played after completion ## Troubleshooting ### Audio/Video Sync Issues **Symptoms**: Audio and video drift out of sync over time **Solutions**: 1. Enable timing correction: `put_CorrectTiming(true)` 2. For v10 muxer, use TimeAdjust flag: `SetFlags((uint)MP4V10Flags.TimeAdjust)` 3. Verify source filters provide accurate timestamps 4. Check that audio and video sample rates are correct ### File Cannot Be Played While Recording **Symptom**: MP4 file only playable after encoding completes **Cause**: Live mode is disabled **Solution**: - Use IMP4V10MuxerConfig interface - Enable live mode: `SetLiveDisabled(false)` - This creates progressive MP4 files playable during encoding ### Inconsistent File Output **Symptoms**: Same input produces different output files **Cause**: Multi-threaded operation with race conditions **Solutions**: 1. Enable single-threaded mode: `put_SingleThread(true)` 2. Enable timing correction: `put_CorrectTiming(true)` 3. Use TimeAdjust flag for v10 muxer ### Performance Issues **Symptoms**: Encoding slower than expected, high CPU usage **Possible Causes**: 1. Single-threaded mode on multi-core system 2. Excessive timing correction overhead **Solutions**: - Disable single-threaded mode: `put_SingleThread(false)` - If sources have accurate timestamps, can try disabling timing correction - Ensure video encoder (not muxer) is the performance bottleneck - Consider hardware encoding (NVENC, QuickSync) ### Corrupted MP4 Files **Symptoms**: MP4 file won't play or has errors **Possible Causes**: 1. Timing correction disabled with poor timestamps 2. Incorrect live mode setting for use case 3. Muxer stopped before proper finalization **Solutions**: - Enable timing correction for live sources - Match live mode setting to use case (live vs file-based) - Ensure proper filter graph shutdown and stream finalization - Verify all streams end properly (send EC\_COMPLETE event) --- ## See Also - [H.264 Encoder Interface](../h264/) - [AAC Encoder Interfaces](../aac/) - [Muxers Reference](../../muxers-reference/) - [Encoding Filters Pack Overview](../../) ---END OF PAGE--- ## NVIDIA NVENC Hardware Encoder Settings for DirectShow **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/interfaces/nvenc/ **Description:** Configure NVIDIA NVENC hardware encoding in DirectShow with INVEncConfig COM interface. H.264/H.265 codec settings, presets, and GPU selection for C++/C#. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, H.264, H.265, C# **API:** IBaseFilter # INVEncConfig Interface Reference ## Overview The `INVEncConfig` interface provides comprehensive control over NVIDIA NVENC hardware video encoding. This interface extends the standard DirectShow `IAMVideoCompression` interface with NVENC-specific configuration options for H.264 and H.265 encoding. NVENC is NVIDIA's dedicated hardware encoder available on GeForce, Quadro, and Tesla GPUs, offering high-performance video encoding with minimal CPU usage. ## Filter and Interface GUIDs - **Filter CLSID**: `CLSID_NVEncoder` `{6EEC9161-7276-430B-A197-0D4C3BCC87E5}` - **Interface**: `INVEncConfig` **GUID**: `{9A2AC42C-3E3D-4E6A-84E5-D097292D496B}` **Inherits From**: `IAMVideoCompression` **Header File**: `Intf.h` (C++) - **Interface**: `INVEncConfig2` **GUID**: `{2A741FB6-6DE1-460B-8FCA-76DB478C9357}` **Inherits From**: `IUnknown` **Header File**: `Intf2.h` (C++) ## Interface Definitions ### C++ Definition (INVEncConfig) ``` #include // {9A2AC42C-3E3D-4E6A-84E5-D097292D496B} static const GUID IID_INVEncConfig = { 0x9a2ac42c, 0x3e3d, 0x4e6a, { 0x84, 0xe5, 0xd0, 0x97, 0x29, 0x2d, 0x49, 0x6b } }; // {6EEC9161-7276-430B-A197-0D4C3BCC87E5} static const GUID CLSID_NVEncoder = { 0x6eec9161, 0x7276, 0x430b, { 0xa1, 0x97, 0xd, 0x4c, 0x3b, 0xcc, 0x87, 0xe5 } }; MIDL_INTERFACE("9A2AC42C-3E3D-4E6A-84E5-D097292D496B") INVEncConfig : public IAMVideoCompression { public: virtual HRESULT STDMETHODCALLTYPE SetDeviceType(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetDeviceType(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetPictureStructure(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetPictureStructure(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetNumBuffers(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetNumBuffers(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetRateControl(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetRateControl(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetPreset(GUID v) = 0; virtual HRESULT STDMETHODCALLTYPE GetPreset(GUID *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetQp(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetQp(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetBFrames(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetBFrames(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetGOP(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetGOP(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetBitrate(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetBitrate(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetVbvBitrate(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetVbvBitrate(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetVbvSize(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetVbvSize(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetProfile(GUID v) = 0; virtual HRESULT STDMETHODCALLTYPE GetProfile(GUID *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetLevel(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetLevel(int *v) = 0; virtual HRESULT STDMETHODCALLTYPE SetCodec(int v) = 0; virtual HRESULT STDMETHODCALLTYPE GetCodec(int *v) = 0; }; ``` ### C# Definition (INVEncConfig) ``` using System; using System.Runtime.InteropServices; using DirectShowLib; namespace VisioForge.DirectShowAPI { /// /// NVENC encoder configuration interface. /// Provides hardware-accelerated H.264/H.265 encoding on NVIDIA GPUs. /// [ComImport] [System.Security.SuppressUnmanagedCodeSecurity] [Guid("9A2AC42C-3E3D-4E6A-84E5-D097292D496B")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface INVEncConfig { // Note: Also inherits IAMVideoCompression methods // (put_KeyFrameRate, get_KeyFrameRate, put_PFramesPerKeyFrame, etc.) /// Sets the CUDA device index for encoding. /// Device index (0 for first GPU, 1 for second, etc.) [PreserveSig] int SetDeviceType(int v); /// Gets the CUDA device index. [PreserveSig] int GetDeviceType(out int v); /// Sets picture structure (progressive or interlaced). /// 0 = Progressive, 1 = Interlaced [PreserveSig] int SetPictureStructure(int v); /// Gets picture structure. [PreserveSig] int GetPictureStructure(out int v); /// Sets number of encoding buffers. /// Buffer count (typically 4-8) [PreserveSig] int SetNumBuffers(int v); /// Gets number of encoding buffers. [PreserveSig] int GetNumBuffers(out int v); /// Sets rate control mode. /// 0 = CQP, 1 = VBR, 2 = CBR [PreserveSig] int SetRateControl(int v); /// Gets rate control mode. [PreserveSig] int GetRateControl(out int v); /// Sets encoding preset. /// Preset GUID (P1-P7) [PreserveSig] int SetPreset(Guid v); /// Gets encoding preset. [PreserveSig] int GetPreset(out Guid v); /// Sets quantization parameter for CQP mode. /// QP value (0-51, lower = higher quality) [PreserveSig] int SetQp(int v); /// Gets quantization parameter. [PreserveSig] int GetQp(out int v); /// Sets number of B-frames. /// B-frame count (0-4) [PreserveSig] int SetBFrames(int v); /// Gets number of B-frames. [PreserveSig] int GetBFrames(out int v); /// Sets GOP (Group of Pictures) size. /// GOP size in frames [PreserveSig] int SetGOP(int v); /// Gets GOP size. [PreserveSig] int GetGOP(out int v); /// Sets target bitrate. /// Bitrate in bits per second [PreserveSig] int SetBitrate(int v); /// Gets target bitrate. [PreserveSig] int GetBitrate(out int v); /// Sets VBV buffer bitrate. /// VBV bitrate in bps [PreserveSig] int SetVbvBitrate(int v); /// Gets VBV buffer bitrate. [PreserveSig] int GetVbvBitrate(out int v); /// Sets VBV buffer size. /// VBV size in bits [PreserveSig] int SetVbvSize(int v); /// Gets VBV buffer size. [PreserveSig] int GetVbvSize(out int v); /// Sets encoding profile. /// Profile GUID (Baseline, Main, High, etc.) [PreserveSig] int SetProfile(Guid v); /// Gets encoding profile. [PreserveSig] int GetProfile(out Guid v); /// Sets profile level. /// Level value (30, 31, 40, 41, 50, 51, etc.) [PreserveSig] int SetLevel(int v); /// Gets profile level. [PreserveSig] int GetLevel(out int v); /// Sets video codec. /// 0 = H.264, 1 = H.265 [PreserveSig] int SetCodec(int v); /// Gets video codec. [PreserveSig] int GetCodec(out int v); } /// /// NVENC configuration interface 2 - availability check. /// [ComImport] [System.Security.SuppressUnmanagedCodeSecurity] [Guid("2A741FB6-6DE1-460B-8FCA-76DB478C9357")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface INVEncConfig2 { /// Checks if NVENC is available on the system. /// True if NVENC is available /// NVENC status code [PreserveSig] int CheckNVENCAvailable([MarshalAs(UnmanagedType.Bool)] out bool result, out int status); } } ``` ### Delphi Definition (INVEncConfig) ``` uses ActiveX, ComObj; const IID_INVEncConfig: TGUID = '{9A2AC42C-3E3D-4E6A-84E5-D097292D496B}'; IID_INVEncConfig2: TGUID = '{2A741FB6-6DE1-460B-8FCA-76DB478C9357}'; CLSID_NVEncoder: TGUID = '{6EEC9161-7276-430B-A197-0D4C3BCC87E5}'; type /// /// NVENC encoder configuration interface. /// Extends IAMVideoCompression with NVENC-specific settings. /// INVEncConfig = interface(IUnknown) ['{9A2AC42C-3E3D-4E6A-84E5-D097292D496B}'] // Note: Also inherits IAMVideoCompression methods function SetDeviceType(v: Integer): HRESULT; stdcall; function GetDeviceType(out v: Integer): HRESULT; stdcall; function SetPictureStructure(v: Integer): HRESULT; stdcall; function GetPictureStructure(out v: Integer): HRESULT; stdcall; function SetNumBuffers(v: Integer): HRESULT; stdcall; function GetNumBuffers(out v: Integer): HRESULT; stdcall; function SetRateControl(v: Integer): HRESULT; stdcall; function GetRateControl(out v: Integer): HRESULT; stdcall; function SetPreset(v: TGUID): HRESULT; stdcall; function GetPreset(out v: TGUID): HRESULT; stdcall; function SetQp(v: Integer): HRESULT; stdcall; function GetQp(out v: Integer): HRESULT; stdcall; function SetBFrames(v: Integer): HRESULT; stdcall; function GetBFrames(out v: Integer): HRESULT; stdcall; function SetGOP(v: Integer): HRESULT; stdcall; function GetGOP(out v: Integer): HRESULT; stdcall; function SetBitrate(v: Integer): HRESULT; stdcall; function GetBitrate(out v: Integer): HRESULT; stdcall; function SetVbvBitrate(v: Integer): HRESULT; stdcall; function GetVbvBitrate(out v: Integer): HRESULT; stdcall; function SetVbvSize(v: Integer): HRESULT; stdcall; function GetVbvSize(out v: Integer): HRESULT; stdcall; function SetProfile(v: TGUID): HRESULT; stdcall; function GetProfile(out v: TGUID): HRESULT; stdcall; function SetLevel(v: Integer): HRESULT; stdcall; function GetLevel(out v: Integer): HRESULT; stdcall; function SetCodec(v: Integer): HRESULT; stdcall; function GetCodec(out v: Integer): HRESULT; stdcall; end; /// /// NVENC configuration interface 2 - availability check. /// INVEncConfig2 = interface(IUnknown) ['{2A741FB6-6DE1-460B-8FCA-76DB478C9357}'] function CheckNVENCAvailable(out result: BOOL; out status: Integer): HRESULT; stdcall; end; ``` ## Hardware Requirements ### GPU Generations | GPU Generation | H.264 | H.265 | Quality | Notes | | --- | --- | --- | --- | --- | | **Kepler** (GTX 600/700) | ✓ | ✗ | Basic | 1st generation NVENC | | **Maxwell** (GTX 900) | ✓ | ✓ | Good | 2nd gen, HEVC support added | | **Pascal** (GTX 10XX) | ✓ | ✓ | Better | 3rd gen, improved quality | | **Turing** (RTX 20XX) | ✓ | ✓ | Excellent | 7th gen, B-frame support | | **Ampere** (RTX 30XX) | ✓ | ✓ | Excellent | 8th gen, AV1 support | | **Ada/Hopper** (RTX 40XX) | ✓ | ✓ | Best | Latest generation | ### Performance Capabilities - **1080p @ 60fps**: All NVENC generations - **4K @ 60fps**: Maxwell and newer - **8K @ 30fps**: Turing and newer - **Simultaneous Streams**: 3-5 (varies by GPU) --- ## Methods Reference All methods inherited from `IAMVideoCompression` are available. The following are NVENC-specific extensions: ### Device Configuration #### SetDeviceType / GetDeviceType Sets or retrieves the CUDA device index for encoding. **Syntax (C++)**: ``` HRESULT SetDeviceType(int v); HRESULT GetDeviceType(int *v); ``` **Syntax (C#)**: ``` [PreserveSig] int SetDeviceType(int v); [PreserveSig] int GetDeviceType(out int v); ``` **Parameters**: - `v`: CUDA device index (0 for first GPU, 1 for second GPU, etc.) **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** connecting the encoder filter - Use 0 for systems with single GPU - For multi-GPU systems, select the GPU to use for encoding - Query available CUDA devices using CUDA API or NVIDIA tools **Example (C++)**: ``` INVEncConfig* pNVEnc = nullptr; pFilter->QueryInterface(IID_INVEncConfig, (void**)&pNVEnc); // Use first GPU pNVEnc->SetDeviceType(0); pNVEnc->Release(); ``` --- ### Picture Structure #### SetPictureStructure / GetPictureStructure Sets the picture coding type (progressive or interlaced). **Syntax (C++)**: ``` HRESULT SetPictureStructure(int v); HRESULT GetPictureStructure(int *v); ``` **Parameters**: - `v`: Picture structure type - `0` - Progressive (frame-based) - `1` - Interlaced (field-based) **Returns**: `S_OK` on success. **Usage Notes**: - Default is progressive (0) - Use interlaced (1) only for broadcast/DVD content - Progressive is recommended for modern content **Example (C++)**: ``` // Set progressive encoding pNVEnc->SetPictureStructure(0); ``` --- ### Buffer Configuration #### SetNumBuffers / GetNumBuffers Sets the number of encoding buffers. **Syntax (C++)**: ``` HRESULT SetNumBuffers(int v); HRESULT GetNumBuffers(int *v); ``` **Parameters**: - `v`: Number of buffers (typically 4-8) **Returns**: `S_OK` on success. **Usage Notes**: - More buffers = higher latency but smoother encoding - Fewer buffers = lower latency but potential frame drops - Recommended values: - Low latency: 4 buffers - Normal: 6 buffers - High quality: 8 buffers **Example (C++)**: ``` // Low latency configuration pNVEnc->SetNumBuffers(4); ``` --- ### Rate Control #### SetRateControl / GetRateControl Sets the rate control mode for bitrate management. **Syntax (C++)**: ``` HRESULT SetRateControl(int v); HRESULT GetRateControl(int *v); ``` **Parameters**: - `v`: Rate control mode - `0` - **CQP** (Constant Quantization Parameter) - Fixed quality - `1` - **VBR** (Variable Bitrate) - Variable bitrate, target quality - `2` - **CBR** (Constant Bitrate) - Fixed bitrate for streaming **Returns**: `S_OK` on success. **Rate Control Mode Details**: | Mode | Bitrate Behavior | Use Case | Quality | File Size | | --- | --- | --- | --- | --- | | **CQP** | Varies widely | Archival, highest quality | Excellent | Unpredictable | | **VBR** | Varies moderately | File storage, YouTube | Very Good | Moderate | | **CBR** | Constant | Live streaming, broadcasting | Good | Predictable | **Example (C++)**: ``` // Use CBR for live streaming pNVEnc->SetRateControl(2); pNVEnc->SetBitrate(5000000); // 5 Mbps ``` **Example (C#)**: ``` // Use VBR for file recording nvenc.SetRateControl(1); nvenc.SetBitrate(8000000); // 8 Mbps target ``` --- ### Preset Configuration #### SetPreset / GetPreset Sets the encoding preset which balances speed and quality. **Syntax (C++)**: ``` HRESULT SetPreset(GUID v); HRESULT GetPreset(GUID *v); ``` **Parameters**: - `v`: Preset GUID from NVENC SDK **Preset Options** (typical values): | Preset | Description | Speed | Quality | Use Case | |--------|-------------|-------|---------|----------| | **P1** | Fastest | ★★★★★ | ★☆☆☆☆ | Real-time low-latency | | **P2** | Faster | ★★★★☆ | ★★☆☆☆ | Live streaming | | **P3** | Fast | ★★★☆☆ | ★★★☆☆ | Standard streaming | | **P4** | Medium | ★★☆☆☆ | ★★★★☆ | Balanced (recommended) | | **P5** | Slow | ★☆☆☆☆ | ★★★★☆ | High quality streaming | | **P6** | Slower | ☆☆☆☆☆ | ★★★★★ | Archive quality | | **P7** | Slowest | ☆☆☆☆☆ | ★★★★★ | Maximum quality | **Usage Notes**: - P4 is recommended for most use cases - P1-P2 for low-latency applications - P6-P7 for maximum quality (slower encoding) - Preset affects: motion estimation, lookahead, subpixel motion **Example (C++)**: ``` // Use P4 preset (balanced) GUID presetP4 = /* GUID for P4 preset */; pNVEnc->SetPreset(presetP4); ``` --- ### Quality Parameter (QP) #### SetQp / GetQp Sets the quantization parameter for CQP mode. **Syntax (C++)**: ``` HRESULT SetQp(int v); HRESULT GetQp(int *v); ``` **Parameters**: - `v`: QP value (0-51) - Lower values = higher quality, larger files - Higher values = lower quality, smaller files - Typical range: 18-28 **Returns**: `S_OK` on success. **Usage Notes**: - Only effective when using CQP rate control mode - Ignored in CBR/VBR modes - Recommended values: - High quality: 18-22 - Medium quality: 23-26 - Low quality: 27-30 **Example (C++)**: ``` // High quality CQP encoding pNVEnc->SetRateControl(0); // CQP mode pNVEnc->SetQp(20); // High quality ``` --- ### B-Frames Configuration #### SetBFrames / GetBFrames Sets the number of B-frames between I and P frames. **Syntax (C++)**: ``` HRESULT SetBFrames(int v); HRESULT GetBFrames(int *v); ``` **Parameters**: - `v`: Number of B-frames (0-4) - `0` - No B-frames (lowest latency) - `1-2` - Moderate compression improvement - `3-4` - Best compression (higher latency) **Returns**: `S_OK` on success. **Usage Notes**: - B-frames improve compression efficiency - More B-frames = higher latency - Requires Turing (RTX 20XX) or newer for full support - Recommended values: - Low latency: 0 - Streaming: 2 - Recording: 3 **Example (C++)**: ``` // Low latency - disable B-frames pNVEnc->SetBFrames(0); // High quality recording - use B-frames pNVEnc->SetBFrames(3); ``` --- ### GOP Configuration #### SetGOP / GetGOP Sets the Group of Pictures (keyframe interval) size. **Syntax (C++)**: ``` HRESULT SetGOP(int v); HRESULT GetGOP(int *v); ``` **Parameters**: - `v`: GOP size in frames - Typical values: 30-300 frames - Frame rate × seconds = GOP size - Example: 60 fps × 2 seconds = 120 GOP size **Returns**: `S_OK` on success. **Usage Notes**: - Smaller GOP = better seeking, larger file - Larger GOP = better compression, poor seeking - For streaming: 2-4 seconds (fps × 2-4) - For recording: 5-10 seconds **Example (C++)**: ``` // 2-second GOP for 30fps streaming pNVEnc->SetGOP(60); // 5-second GOP for 60fps recording pNVEnc->SetGOP(300); ``` --- ### Bitrate Configuration #### SetBitrate / GetBitrate Sets the target bitrate for encoding. **Syntax (C++)**: ``` HRESULT SetBitrate(int v); HRESULT GetBitrate(int *v); ``` **Parameters**: - `v`: Bitrate in bits per second (bps) **Returns**: `S_OK` on success. **Recommended Bitrates**: | Resolution | Framerate | Bitrate (H.264) | Bitrate (H.265) | |------------|-----------|-----------------|-----------------| | 720p | 30 fps | 2.5-4 Mbps | 1.5-2.5 Mbps | | 720p | 60 fps | 4-6 Mbps | 2.5-4 Mbps | | 1080p | 30 fps | 4-6 Mbps | 2.5-4 Mbps | | 1080p | 60 fps | 8-12 Mbps | 5-8 Mbps | | 1440p | 30 fps | 10-15 Mbps | 6-10 Mbps | | 1440p | 60 fps | 15-25 Mbps | 10-15 Mbps | | 4K | 30 fps | 25-40 Mbps | 15-25 Mbps | | 4K | 60 fps | 45-70 Mbps | 30-45 Mbps | **Example (C++)**: ``` // 1080p @ 60fps streaming pNVEnc->SetBitrate(10000000); // 10 Mbps ``` --- ### VBV Buffer Configuration #### SetVbvBitrate / GetVbvBitrate Sets the VBV (Video Buffering Verifier) buffer bitrate. **Syntax (C++)**: ``` HRESULT SetVbvBitrate(int v); HRESULT GetVbvBitrate(int *v); ``` **Parameters**: - `v`: VBV bitrate in bps (usually same as or higher than target bitrate) **Usage Notes**: - Controls maximum bitrate spikes - Typically set to 1.0-1.5× target bitrate - Important for streaming to prevent buffer underruns --- #### SetVbvSize / GetVbvSize Sets the VBV buffer size. **Syntax (C++)**: ``` HRESULT SetVbvSize(int v); HRESULT GetVbvSize(int *v); ``` **Parameters**: - `v`: VBV buffer size in bits **Usage Notes**: - Larger buffer = smoother bitrate but higher latency - Smaller buffer = lower latency but more bitrate variance - Typical: 1-2 seconds of video at target bitrate **Example (C++)**: ``` // 10 Mbps stream with 2-second buffer pNVEnc->SetBitrate(10000000); pNVEnc->SetVbvBitrate(12000000); // 1.2× bitrate pNVEnc->SetVbvSize(20000000); // 2 seconds ``` --- ### Profile Configuration #### SetProfile / GetProfile Sets the H.264/H.265 encoding profile. **Syntax (C++)**: ``` HRESULT SetProfile(GUID v); HRESULT GetProfile(GUID *v); ``` **Parameters**: - `v`: Profile GUID **H.264 Profiles**: - **Baseline** - Basic features, mobile compatibility - **Main** - Standard features, most devices - **High** - Advanced features, HD/4K content **H.265 Profiles**: - **Main** - 8-bit, 4:2:0 - **Main 10** - 10-bit, HDR support **Usage Notes**: - Use High profile for H.264 in most cases - Use Main profile for maximum compatibility - HEVC Main 10 for HDR content --- ### Level Configuration #### SetLevel / GetLevel Sets the profile level (resolution/bitrate constraints). **Syntax (C++)**: ``` HRESULT SetLevel(int v); HRESULT GetLevel(int *v); ``` **Parameters**: - `v`: Level value (see H.264/H.265 level table) **Common H.264 Levels**: - **30** (3.0) - SD video - **31** (3.1) - 720p @ 30fps - **40** (4.0) - 1080p @ 30fps - **41** (4.1) - 1080p @ 60fps - **50** (5.0) - 4K @ 30fps - **51** (5.1) - 4K @ 60fps **Example (C++)**: ``` // 1080p @ 60fps pNVEnc->SetLevel(41); ``` --- ### Codec Selection #### SetCodec / GetCodec Sets the video codec to use. **Syntax (C++)**: ``` HRESULT SetCodec(int v); HRESULT GetCodec(int *v); ``` **Parameters**: - `v`: Codec type - `0` - H.264/AVC - `1` - H.265/HEVC **Returns**: `S_OK` on success. **Usage Notes**: - H.264 for maximum compatibility - H.265 for better compression (40-50% smaller files) - H.265 requires Maxwell (GTX 900) or newer GPU **Example (C++)**: ``` // Use H.265 pNVEnc->SetCodec(1); ``` --- ## INVEncConfig2 Methods ### CheckNVENCAvailable Checks if NVENC hardware encoding is available on the system. **Syntax (C++)**: ``` HRESULT CheckNVENCAvailable(BOOL* result, int* status); ``` **Syntax (C#)**: ``` [PreserveSig] int CheckNVENCAvailable([MarshalAs(UnmanagedType.Bool)] out bool result, out int status); ``` **Parameters**: - `result`: Receives `TRUE` if NVENC is available, `FALSE` otherwise - `status`: Receives NVENC status code (vendor-specific) **Returns**: `S_OK` (0) on success. **Usage Notes**: - Call this before attempting to use NVENC encoder - Returns `FALSE` if: - No NVIDIA GPU is present - GPU doesn't support NVENC (pre-Kepler) - NVIDIA drivers are not installed - NVENC library is not available - The status code provides additional diagnostic information **Example (C++)**: ``` #include "Intf2.h" HRESULT CheckNVENCSupport(IBaseFilter* pEncoder) { HRESULT hr; INVEncConfig2* pNVEnc2 = nullptr; hr = pEncoder->QueryInterface(IID_INVEncConfig2, (void**)&pNVEnc2); if (FAILED(hr)) { // INVEncConfig2 not supported by this filter return hr; } BOOL available = FALSE; int status = 0; hr = pNVEnc2->CheckNVENCAvailable(&available, &status); if (SUCCEEDED(hr)) { if (available) { printf("NVENC is available (status: %d)\n", status); // Proceed with NVENC configuration } else { printf("NVENC not available (status: %d)\n", status); // Fall back to software encoder } } pNVEnc2->Release(); return hr; } ``` **Example (C#)**: ``` using VisioForge.DirectShowAPI; public bool IsNVENCAvailable(IBaseFilter encoder) { var nvenc2 = encoder as INVEncConfig2; if (nvenc2 == null) { // INVEncConfig2 not supported return false; } bool available; int status; int hr = nvenc2.CheckNVENCAvailable(out available, out status); if (hr == 0) { if (available) { Console.WriteLine($"NVENC is available (status: {status})"); return true; } else { Console.WriteLine($"NVENC not available (status: {status})"); return false; } } return false; } ``` **Example (Delphi)**: ``` function CheckNVENCSupport(Encoder: IBaseFilter): Boolean; var NVEnc2: INVEncConfig2; Available: BOOL; Status: Integer; hr: HRESULT; begin Result := False; if Succeeded(Encoder.QueryInterface(IID_INVEncConfig2, NVEnc2)) then begin hr := NVEnc2.CheckNVENCAvailable(Available, Status); if Succeeded(hr) then begin if Available then begin WriteLn(Format('NVENC is available (status: %d)', [Status])); Result := True; end else begin WriteLn(Format('NVENC not available (status: %d)', [Status])); end; end; NVEnc2 := nil; end; end; ``` --- ## Complete Configuration Examples ### Example 1: Low Latency Streaming (C++) ``` #include "Intf.h" HRESULT ConfigureLowLatencyNVENC(IBaseFilter* pEncoder) { HRESULT hr; INVEncConfig* pNVEnc = nullptr; hr = pEncoder->QueryInterface(IID_INVEncConfig, (void**)&pNVEnc); if (FAILED(hr)) return hr; // Basic configuration pNVEnc->SetDeviceType(0); // First GPU pNVEnc->SetCodec(0); // H.264 pNVEnc->SetPictureStructure(0); // Progressive // Low latency settings pNVEnc->SetRateControl(2); // CBR pNVEnc->SetBitrate(5000000); // 5 Mbps pNVEnc->SetBFrames(0); // No B-frames pNVEnc->SetGOP(60); // 2-second GOP (30fps) pNVEnc->SetNumBuffers(4); // Minimal buffering // Fast preset GUID presetP2 = /* P2 GUID */; pNVEnc->SetPreset(presetP2); // Profile/Level for 1080p30 GUID highProfile = /* High Profile GUID */; pNVEnc->SetProfile(highProfile); pNVEnc->SetLevel(40); // Level 4.0 pNVEnc->Release(); return S_OK; } ``` ### Example 2: High Quality Recording (C#) ``` using System; using DirectShowLib; using VisioForge.DirectShowAPI; public class NVENCHighQualityRecording { public void ConfigureNVENC(IBaseFilter encoder) { var nvenc = encoder as INVEncConfig; if (nvenc == null) throw new NotSupportedException("NVENC not available"); // Basic configuration nvenc.SetDeviceType(0); // First GPU nvenc.SetCodec(1); // H.265 for better compression nvenc.SetPictureStructure(0); // Progressive // High quality VBR settings nvenc.SetRateControl(1); // VBR nvenc.SetBitrate(15000000); // 15 Mbps average nvenc.SetBFrames(3); // Use B-frames nvenc.SetGOP(300); // 5-second GOP (60fps) nvenc.SetNumBuffers(8); // More buffering for quality // Quality preset Guid presetP6 = /* P6 GUID */; nvenc.SetPreset(presetP6); // HEVC Main profile for 4K Guid hevcMain = /* HEVC Main GUID */; nvenc.SetProfile(hevcMain); nvenc.SetLevel(51); // Level 5.1 for 4K60 // VBV configuration nvenc.SetVbvBitrate(20000000); // 20 Mbps max nvenc.SetVbvSize(30000000); // 2-second buffer } } ``` ### Example 3: Balanced Streaming (C++) ``` HRESULT ConfigureBalancedStreaming(IBaseFilter* pEncoder) { INVEncConfig* pNVEnc = nullptr; pEncoder->QueryInterface(IID_INVEncConfig, (void**)&pNVEnc); // Device and codec pNVEnc->SetDeviceType(0); pNVEnc->SetCodec(0); // H.264 for compatibility // Balanced CBR streaming pNVEnc->SetRateControl(2); // CBR pNVEnc->SetBitrate(8000000); // 8 Mbps pNVEnc->SetBFrames(2); // Moderate B-frames pNVEnc->SetGOP(120); // 2-second GOP (60fps) pNVEnc->SetNumBuffers(6); // Standard buffering // Balanced preset P4 GUID presetP4 = /* P4 GUID */; pNVEnc->SetPreset(presetP4); // 1080p60 profile/level GUID highProfile = /* High Profile GUID */; pNVEnc->SetProfile(highProfile); pNVEnc->SetLevel(41); // VBV for streaming pNVEnc->SetVbvBitrate(10000000); // 1.25× bitrate pNVEnc->SetVbvSize(16000000); // 2-second buffer pNVEnc->Release(); return S_OK; } ``` --- ## Best Practices ### General Recommendations 1. **Use P4 preset as default** - Best balance of quality and performance 2. **CBR for streaming** - Predictable bitrate for network delivery 3. **VBR for recording** - Better quality for file storage 4. **Disable B-frames for low latency** - Reduces encoding delay 5. **Match GOP to framerate** - 2-4 seconds typical (fps × 2-4) ### Quality Optimization 1. **Higher preset = better quality** - Use P5-P7 when encoding time allows 2. **More B-frames = better compression** - Use 3 for recording 3. **Appropriate bitrate** - Don't go too low, quality suffers significantly 4. **VBV buffer size** - 1-2 seconds at target bitrate ### Performance Optimization 1. **Lower preset = faster encoding** - Use P1-P3 for real-time 2. **Disable B-frames** - Reduces latency and complexity 3. **Fewer encoding buffers** - Lower latency but potential drops 4. **Select appropriate GPU** - Use SetDeviceType() for multi-GPU systems ### Compatibility 1. **Use H.264 High profile** - Maximum compatibility 2. **Set correct level** - Match resolution and framerate 3. **CBR for streaming** - More compatible with players/servers 4. **Standard GOP size** - 2-4 seconds --- ## Troubleshooting ### Issue: NVENC Not Available **Symptoms**: QueryInterface fails for INVEncConfig **Solutions**: - Verify NVIDIA GPU is installed - Check GPU generation (Kepler or newer required) - Update NVIDIA drivers to latest version - Verify DirectShow filter is registered ### Issue: Poor Quality Output **Solutions**: ``` // Increase bitrate pNVEnc->SetBitrate(15000000); // Higher bitrate // Use better preset pNVEnc->SetPreset(presetP6); // Slower but better // Add B-frames pNVEnc->SetBFrames(3); // Better compression ``` ### Issue: High Latency **Solutions**: ``` // Disable B-frames pNVEnc->SetBFrames(0); // Use faster preset pNVEnc->SetPreset(presetP1); // Reduce buffers pNVEnc->SetNumBuffers(4); // Smaller GOP pNVEnc->SetGOP(30); // 1 second at 30fps ``` ### Issue: Bitrate Spikes **Solutions**: ``` // Use CBR instead of VBR pNVEnc->SetRateControl(2); // Configure VBV properly pNVEnc->SetVbvBitrate(bitrate * 1.2); pNVEnc->SetVbvSize(bitrate * 2); ``` --- ## Performance Benchmarks ### Typical Encoding Performance | Resolution | Preset | GPU Generation | FPS (approx) | | --- | --- | --- | --- | | 1080p | P1 | Pascal+ | 200-300 | | 1080p | P4 | Pascal+ | 150-200 | | 1080p | P7 | Pascal+ | 60-100 | | 4K | P1 | Turing+ | 90-120 | | 4K | P4 | Turing+ | 60-90 | | 4K | P7 | Turing+ | 30-50 | | ### Quality Comparison (PSNR) | | | | | Preset | Quality vs x264 | Speed vs x264 | | | -------- | ----------------- | --------------- | | | P1 | -2 dB | 100× faster | | | P4 | -0.5 dB | 50× faster | | | P7 | ≈ equal | 20× faster | | | --- | | | | ## Related Interfaces - **IAMVideoCompression** - Base DirectShow compression interface - **IBaseFilter** - DirectShow filter base interface - **IMediaControl** - Graph control (run, stop) ## See Also - [Encoding Filters Pack Overview](../../) - [Codecs Reference](../../codecs-reference/) - [Code Examples](../../examples/) - [NVIDIA NVENC Documentation](https://developer.nvidia.com/video-codec-sdk) ---END OF PAGE--- ## DirectShow Muxer and Container Format Reference Guide **URL:** https://www.visioforge.com/help/docs/directshow/filters-enc/muxers-reference/ **Description:** Container format reference for VisioForge DirectShow muxers — MP4, MKV, WebM, MPEG-TS, AVI with codec compatibility and streaming configuration. **Tags:** DirectShow, C++, Windows, Streaming, Encoding, Decoding, Metadata, HLS, MPEG-DASH, WebRTC, MP4, MKV, WebM, AVI, FLV, TS, OGG, H.264, H.265, VP8, VP9, MPEG-2, AAC, MP3, Opus, FLAC, Vorbis, WAV, AC-3, Speex # Encoding Filters Pack - Muxers Reference ## Overview This document provides comprehensive information about all container formats (muxers) supported by the DirectShow Encoding Filters Pack. Muxers combine video and audio streams into container files for storage and streaming. --- ## MP4 Container ### Overview MPEG-4 Part 14 (MP4) is the most widely used container format for video distribution. **File Extensions**: `.mp4`, `.m4v`, `.m4a` (audio only) **MIME Type**: `video/mp4`, `audio/mp4` ### Supported Codecs #### Video Codecs - H.264/AVC ✓ (Primary) - H.265/HEVC ✓ - MPEG-4 Part 2 ✓ - MPEG-2 ✗ (use MPEG-TS instead) - VP8/VP9 ✗ (use WebM instead) #### Audio Codecs - AAC ✓ (Primary) - MP3 ✓ - Opus ✗ - Vorbis ✗ - FLAC ✓ - PCM ✓ ### Features **Streaming Support**: - **Progressive Download**: ✓ (with proper moov atom placement) - **Adaptive Streaming**: ✓ (DASH, HLS with fragmented MP4) - **Live Streaming**: ✓ (fragmented MP4) **Metadata Support**: - **Basic Tags**: Title, artist, album, year - **Cover Art**: ✓ - **Chapters**: ✓ - **Subtitles**: ✓ (VTT, SRT, various text formats) **Technical Features**: - **Multiple Audio Tracks**: ✓ - **Multiple Subtitle Tracks**: ✓ - **Fast Start**: ✓ (moov atom at beginning) - **Fragmented MP4**: ✓ (for streaming) ### Best Practices **For Progressive Download (Web)**: ``` - Place moov atom at beginning (fast start) - Use H.264 Baseline/Main profile - AAC-LC audio - Keyframe interval: 2-4 seconds ``` **For Local Playback**: ``` - H.264 High profile or H.265 - AAC-LC or HE-AAC - Any keyframe interval ``` **For Streaming (DASH/HLS)**: ``` - Fragmented MP4 - H.264 Main/High profile - AAC-LC audio - Short fragments (2-6 seconds) ``` ### Compatibility | Platform/Device | Compatibility | | --- | --- | | **Windows Media Player** | ✓ | | **VLC** | ✓ | | **Web Browsers** | ✓ | | **iOS/iPhone** | ✓ | | **Android** | ✓ | | **Smart TVs** | ✓ | | **Game Consoles** | ✓ | | ### Common Issues | | | **Issue**: Video not seekable on web | | | - **Solution**: Enable fast start (moov at beginning) | | | **Issue**: Audio sync problems | | | - **Solution**: Use constant frame rate, check audio sample rate | | | --- | | ## MKV (Matroska) Container ### Overview Matroska is an open-standard, feature-rich container format. **File Extensions**: `.mkv` (video), `.mka` (audio), `.mks` (subtitles) **MIME Type**: `video/x-matroska`, `audio/x-matroska` ### Supported Codecs #### Video Codecs - H.264/AVC ✓ - H.265/HEVC ✓ - VP8 ✓ - VP9 ✓ - MPEG-4 Part 2 ✓ - MPEG-2 ✓ - AV1 ✓ #### Audio Codecs - AAC ✓ - MP3 ✓ - Opus ✓ - Vorbis ✓ - FLAC ✓ - DTS ✓ - AC-3 ✓ - PCM ✓ ### Features **Advanced Features**: - **Multiple Video Tracks**: ✓ - **Multiple Audio Tracks**: ✓ (unlimited) - **Multiple Subtitle Tracks**: ✓ (unlimited) - **Attachments**: ✓ (fonts, cover art) - **Chapters**: ✓ (with nesting) - **Tags/Metadata**: ✓ (extensive) - **Segmenting**: ✓ (linked segments) **Technical Capabilities**: - **Variable Frame Rate**: ✓ - **Lossless Audio**: ✓ - **3D/Stereoscopic**: ✓ - **HDR Metadata**: ✓ ### Best Practices **For Archival**: ``` - Use FLAC or PCM for lossless audio - Include all audio/subtitle tracks - Add chapter markers - Include metadata tags ``` **For Distribution**: ``` - H.264/H.265 video - AAC audio (most compatible) - Embedded soft subtitles - Reasonable file size ``` **For Streaming**: ``` - Not ideal for streaming - Consider MP4 or WebM instead - If used: disable complex features ``` ### Compatibility | Platform/Device | Compatibility | | --- | --- | | **Windows Media Player** | ✗ (codec pack required) | | **VLC** | ✓ | | **Web Browsers** | ✗ (no native support) | | **iOS/iPhone** | ✗ (3rd party apps only) | | **Android** | Limited (app-dependent) | | **Smart TVs** | Limited (model-dependent) | | **Media Players** | ✓ (Kodi, Plex, etc.) | ### Common Issues **Issue**: Seeking is slow - **Solution**: Enable cues (index) during muxing **Issue**: Playback stuttering with high-quality audio - **Solution**: Check decoder performance, consider AAC instead of lossless --- ## WebM Container ### Overview WebM is an open, royalty-free format designed for web use. **File Extensions**: `.webm` **MIME Type**: `video/webm`, `audio/webm` ### Supported Codecs #### Video Codecs - VP8 ✓ (WebM 1.0) - VP9 ✓ (WebM 2.0) - AV1 ✓ (experimental) - H.264 ✗ - H.265 ✗ #### Audio Codecs - Vorbis ✓ (Primary) - Opus ✓ (Recommended) - AAC ✗ - MP3 ✗ ### Features **Web Optimized**: - **HTML5 Video**: ✓ (native browser support) - **Streaming**: ✓ - **Adaptive Streaming**: ✓ (DASH) - **Low Latency**: ✓ **Metadata Support**: - **Basic Tags**: ✓ - **Chapters**: ✓ - **Subtitles**: ✓ (WebVTT) ### Best Practices **For YouTube/Web**: ``` - VP9 video codec - Opus audio codec (96-160 kbps) - Keyframe interval: 2-4 seconds - Two-pass encoding for best quality ``` **For Live Streaming**: ``` - VP8 for better encoder performance - Opus audio (low latency mode) - CBR bitrate - Short GOP ``` **For High Quality**: ``` - VP9 with high bitrate - Opus 128-256 kbps - Two-pass encoding - Quality-based rate control ``` ### Compatibility | Platform/Device | Compatibility | | --- | --- | | **Chrome** | ✓ | | **Firefox** | ✓ | | **Edge** | ✓ | | **Safari** | Limited (VP8 only) | | **Android** | ✓ | | **iOS** | Limited | | ### Common Issues | | | **Issue**: Safari won't play WebM | | | - **Solution**: Provide MP4 fallback with H.264 | | | **Issue**: Encoding too slow | | | - **Solution**: Use VP8 instead of VP9, or hardware-accelerated VP9 if available | | | --- | | ## MPEG-TS (Transport Stream) ### Overview MPEG Transport Stream is designed for broadcast and streaming, especially where error resilience is important. **File Extensions**: `.ts`, `.mts`, `.m2ts` **MIME Type**: `video/mp2t` ### Supported Codecs #### Video Codecs - H.264/AVC ✓ - H.265/HEVC ✓ - MPEG-2 ✓ - VP8/VP9 ✗ #### Audio Codecs - AAC ✓ - MP3 ✓ - AC-3 ✓ - PCM ✓ ### Features **Broadcast Features**: - **Error Resilience**: ✓ (built-in error recovery) - **Time-shifting**: ✓ - **Program Multiplexing**: ✓ (multiple programs in one stream) - **Encryption**: ✓ (conditional access) **Streaming Features**: - **HLS Streaming**: ✓ (Apple HTTP Live Streaming) - **DVB Broadcasting**: ✓ - **IPTV**: ✓ ### Best Practices **For HLS Streaming**: ``` - H.264 video - AAC audio - Segment duration: 6-10 seconds - CBR encoding - Closed GOP ``` **For Broadcasting**: ``` - MPEG-2 or H.264 - AC-3 or AAC audio - Constant bitrate - Fixed packet size (188 bytes) ``` ### Compatibility | Platform/Device | Compatibility | | --- | --- | | **HLS Players** | ✓ | | **Set-top Boxes** | ✓ | | **Smart TVs** | ✓ | | **VLC** | ✓ | | **Web Browsers** | Via HLS support | --- ## FLV (Flash Video) ### Overview Legacy format formerly used for web video (YouTube, Flash players). **File Extensions**: `.flv`, `.f4v` **MIME Type**: `video/x-flv` **Status**: ⚠️ Deprecated - Use MP4 or WebM instead ### Supported Codecs #### Video Codecs - H.264 ✓ - VP6 ✓ (legacy) - Sorenson Spark ✓ (legacy) #### Audio Codecs - AAC ✓ - MP3 ✓ - Speex ✓ ### Features - **Streaming**: ✓ (RTMP) - **Metadata**: Basic (onMetaData) - **Cue Points**: ✓ **Not Recommended**: Flash Player end-of-life (2020) makes FLV obsolete --- ## OGG Container ### Overview Open-source container primarily for Vorbis audio. **File Extensions**: `.ogg`, `.oga` (audio), `.ogv` (video) **MIME Type**: `audio/ogg`, `video/ogg` ### Supported Codecs #### Video Codecs - Theora ✓ (legacy quality) - VP8 ✗ (use WebM) #### Audio Codecs - Vorbis ✓ (Primary) - Opus ✓ - FLAC ✓ - Speex ✓ ### Features - **Streaming**: ✓ - **Chaining**: ✓ (multiple files in sequence) - **Metadata**: ✓ (Vorbis comments) ### Best Practices **For Audio**: ``` - Vorbis or Opus codec - Quality-based encoding - Vorbis comments for metadata ``` **For Video**: ``` - Not recommended - Use WebM (VP8/VP9) instead ``` ### Compatibility | Platform/Device | Compatibility | | --- | --- | | **Firefox** | ✓ | | **Chrome** | ✓ | | **VLC** | ✓ | | **Most mobile devices** | Limited | --- ## AVI (Audio Video Interleave) ### Overview Legacy Microsoft container format. **File Extensions**: `.avi` **MIME Type**: `video/x-msvideo` **Status**: ⚠️ Legacy - Use MP4 or MKV for new projects ### Supported Codecs #### Video Codecs - H.264 ✓ (limited support) - MPEG-4 Part 2 ✓ - MPEG-2 ✓ - Various legacy codecs ✓ #### Audio Codecs - MP3 ✓ - PCM ✓ - AC-3 ✓ - AAC Limited ### Limitations - **Max File Size**: 2 GB (without OpenDML) - **Limited Metadata**: Very basic - **No Streaming**: Not designed for streaming - **No Chapters**: Not supported ### When to Use - Legacy system compatibility - Capture from old hardware - Specific software requirements **Recommendation**: Use MP4 or MKV for new projects --- ## WAV Container ### Overview Uncompressed audio container. **File Extensions**: `.wav` **MIME Type**: `audio/wav`, `audio/x-wav` ### Features - **Lossless**: ✓ (PCM) - **Compressed**: ✓ (MP3, AAC in WAV wrapper) - **Metadata**: Limited (RIFF tags) ### Common Formats - **PCM 44.1 kHz 16-bit**: CD quality - **PCM 48 kHz 24-bit**: Professional audio - **PCM 96 kHz 24-bit**: High-resolution audio ### Best Practices **For Audio Production**: ``` - 48 kHz, 24-bit PCM - Mono or stereo - Avoid compression ``` **For Distribution**: ``` - Use FLAC or AAC instead - WAV files are large ``` --- ## Container Selection Guide ### For Web Delivery **Primary**: MP4 (H.264 + AAC) - **Reason**: Universal compatibility - **Fallback**: WebM (VP9 + Opus) for modern browsers ### For Professional Archival **Primary**: MKV (H.265 + FLAC) - **Reason**: Feature-rich, lossless audio support - **Alternative**: MP4 (H.265 + AAC) for better compatibility ### For Broadcast/IPTV **Primary**: MPEG-TS (H.264 + AAC) - **Reason**: Error resilience, industry standard - **Alternative**: MPEG-TS (MPEG-2 + AC-3) for legacy systems ### For Live Streaming **HLS**: MPEG-TS segments (H.264 + AAC) **DASH**: Fragmented MP4 (H.264 + AAC) **WebRTC**: Opus audio, VP8/H.264 video ### For Audio-Only **High Quality**: FLAC (.flac) or MP3 VBR (.mp3) **Streaming**: AAC in MP4 (.m4a) or Opus in WebM **Voice**: Opus in OGG or Speex --- ## Format Comparison Table | Feature | MP4 | MKV | WebM | MPEG-TS | FLV | OGG | | --- | --- | --- | --- | --- | --- | --- | | **Web Compatibility** | ★★★★★ | ★☆☆☆☆ | ★★★★☆ | ★★☆☆☆ | ☆☆☆☆☆ | ★★☆☆☆ | | **Mobile Compatibility** | ★★★★★ | ★★☆☆☆ | ★★★☆☆ | ★★★★☆ | ☆☆☆☆☆ | ★☆☆☆☆ | | **Streaming Support** | ★★★★★ | ★★☆☆☆ | ★★★★★ | ★★★★★ | ★★★☆☆ | ★★★☆☆ | | **Feature Richness** | ★★★★☆ | ★★★★★ | ★★★☆☆ | ★★★☆☆ | ★★☆☆☆ | ★★☆☆☆ | | **Codec Support** | ★★★★☆ | ★★★★★ | ★★☆☆☆ | ★★★☆☆ | ★★☆☆☆ | ★★★☆☆ | | **File Size Efficiency** | ★★★★☆ | ★★★★☆ | ★★★★★ | ★★★☆☆ | ★★★☆☆ | ★★★★☆ | | **Error Resilience** | ★★☆☆☆ | ★★☆☆☆ | ★★☆☆☆ | ★★★★★ | ★★★☆☆ | ★★☆☆☆ | --- ## Technical Specifications ### MP4 Structure ``` ftyp (file type) moov (metadata - place at beginning for fast start) ├── mvhd (movie header) ├── trak (video track) ├── trak (audio track) └── udta (user data/metadata) mdat (media data) ``` ### Fragmented MP4 (for streaming) ``` ftyp moov └── mvex (movie extends) moof (movie fragment) └── traf (track fragment) mdat (fragment data) [repeat moof/mdat for each fragment] ``` ### MKV Structure ## ``` EBML Header Segment ├── SeekHead (index) ├── Info (segment information) ├── Tracks (track definitions) ├── Chapters (optional) ├── Attachments (optional) ├── Tags (metadata) └── Cluster (media data) ``` ## See Also - [Encoding Filters Pack Overview](../) - [Codecs Reference](../codecs-reference/) - [Code Examples](../examples/) - [NVENC Interface Reference](../interfaces/nvenc/) ---END OF PAGE--- ## Register DirectShow Filters in C++, C#, and Delphi **URL:** https://www.visioforge.com/help/docs/directshow/how-to-register/ **Description:** Register DirectShow filters and SDKs in C++, C#, and Delphi with IVFRegister interface and alternative registration code examples. **Tags:** DirectShow, C++, Windows, C# **API:** IVFRegister # SDK Registration Guide DirectShow filters and SDK components often require proper registration to function correctly within your applications. This guide provides detailed implementation methods for registering DirectShow filters across multiple programming languages. ## Registration Overview Most DirectShow filters in the SDK can be registered using the IVFRegister interface. This standardized approach works consistently across development environments. However, some specialized filters (like RGB2YUV converters) are designed to work without explicit registration. ## Registration Methods by Language ### C++ Implementation The following C++ code demonstrates how to access the registration interface: ``` // {59E82754-B531-4A8E-A94D-57C75F01DA30} DEFINE_GUID(IID_IVFRegister, 0x59E82754, 0xB531, 0x4A8E, 0xA9, 0x4D, 0x57, 0xC7, 0x5F, 0x01, 0xDA, 0x30); /// /// Filter registration interface. /// DECLARE_INTERFACE_(IVFRegister, IUnknown) { /// /// Sets registered. /// /// /// License Key. /// STDMETHOD(SetLicenseKey) (THIS_ WCHAR * licenseKey )PURE; }; ``` ### C# Implementation For .NET developers, the registration interface can be imported using the following C# code: ``` /// /// Public filter registration interface. /// [ComImport] [System.Security.SuppressUnmanagedCodeSecurity] [Guid("59E82754-B531-4A8E-A94D-57C75F01DA30")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFRegister { /// /// Sets registered. /// /// /// License Key. /// [PreserveSig] void SetLicenseKey([In, MarshalAs(UnmanagedType.LPWStr)] string licenseKey); } ``` ### Delphi Implementation For Delphi developers, implement the registration interface as follows: ``` const IID_IVFRegister: TGUID = '{59E82754-B531-4A8E-A94D-57C75F01DA30}'; type /// /// Public filter registration interface. /// IVFRegister = interface(IUnknown) /// /// Sets registered. /// /// /// License Key. /// procedure SetLicenseKey(licenseKey: PWideChar); stdcall; end; ``` ---END OF PAGE--- ## DirectShow Filters for Video Playback, Encoding & Effects **URL:** https://www.visioforge.com/help/docs/directshow/ **Description:** DirectShow filters for FFmpeg/VLC playback, H.264/H.265/NVENC encoding, 35+ video effects, chroma key, virtual camera, and AES-256 encryption. **Tags:** DirectShow, C++, Windows # DirectShow SDKs and Filters for Video Development ## Introduction to DirectShow Technology DirectShow technology enables developers to create robust multimedia applications for capturing, processing, and playing video content. Our comprehensive suite of DirectShow filters and SDKs provides the essential building blocks for developing sophisticated video processing and playback applications with minimal effort. ## Playback and Decoding Solutions ### High-Performance Source Filters Our powerful source filters enable seamless playback of diverse video formats in your custom applications. Built upon industry-standard libraries, these filters ensure maximum compatibility and performance. #### VLC Source DirectShow Filter The VLC Source filter delivers exceptional playback capabilities for numerous media formats, leveraging the versatile VLC media framework for optimal performance and format support. - [Explore VLC Source DirectShow Filter](vlc-source-filter/) #### FFMPEG Source DirectShow Filter Our FFMPEG-based filters provide unparalleled media format compatibility, utilizing the widely-adopted FFMPEG libraries to handle virtually any video or audio format in your applications. - [Discover FFMPEG Source DirectShow Filter](ffmpeg-source-filters/) ## Advanced Encoding Solutions ### Professional Encoding Filters Our encoding filters enable developers to implement high-quality video and audio encoding directly within applications. The suite supports numerous industry-standard codecs for maximum flexibility. - [Browse the Complete Encoding Filters Pack](filters-enc/) ## Video Processing and Enhancement ### Specialized Processing Filters Transform and enhance video content with our processing filters that enable rotation, scaling, color grading, overlay capabilities, and numerous other visual effects to create professional-quality video output. - [Explore Video Processing Filters Pack](proc-filters/) ## Virtual Camera Implementation ### Virtual Camera Development SDK Create and integrate virtual camera devices into your applications with our specialized SDK. The virtual camera seamlessly interfaces with any DirectShow-compatible application, including popular video conferencing software. - [Learn about Virtual Camera SDK](virtual-camera-sdk/) ## Secure Video Solutions ### Video Content Encryption SDK Implement robust video content protection with our encryption SDK. Secure your video assets while maintaining playback compatibility with standard DirectShow players such as Windows Media Player and MPC-BE. - [Discover Video Encryption SDK](video-encryption-sdk/) ## Implementation Guides ### Technical Documentation and Tutorials Get started quickly with our detailed technical tutorials designed specifically for developers implementing DirectShow components: - [DirectShow Filter and SDK Registration Guide](how-to-register/) ---END OF PAGE--- ## DirectShow Video Effects Reference - 35+ Filters Guide **URL:** https://www.visioforge.com/help/docs/directshow/proc-filters/effects-reference/ **Description:** Complete reference for 35+ DirectShow video effects including color filters, deinterlacing, denoising, and artistic effects. **Tags:** DirectShow, C++, Windows, Streaming, Effects, Mixing, Webcam, C# **API:** CVFEffectType, CVFEffect, CVFGraphicLogoMain, CVFStretchMode, CVFTextLogoMain # Video Effects Complete Reference ## Overview The DirectShow Processing Filters Pack provides 35+ real-time video effects that can be applied individually or chained together. This reference documents all available effects, their parameters, and usage. ## Effect Categories - **Text and Graphics** - Text logos, graphic overlays - **Color Filters** - Red, green, blue, greyscale filters - **Image Adjustment** - Brightness, contrast, saturation - **Spatial Effects** - Flip, mirror, rotate - **Artistic Effects** - Marble, solarize, posterize, mosaic - **Noise and Quality** - Denoising algorithms (CAST, adaptive, mosquito) - **Deinterlacing** - Blend, triangle, CAVT methods - **Creative Effects** - Blur, shake, spray, invert --- ## Text and Graphics Effects ### ef\_text\_logo Renders text overlay on video with extensive customization options. **Effect Type**: `CVFEffectType.ef_text_logo` **Parameters** (`CVFTextLogoMain` structure): | Parameter | Type | Description | Default | |-----------|------|-------------|---------| | `x` | int | X position (pixels) | 0 | | `y` | int | Y position (pixels) | 0 | | `text` | BSTR | Text to display | "" | | `font_name` | BSTR | Font family name | "Arial" | | `font_size` | int | Font size (points) | 12 | | `font_color` | COLORREF | Text color (RGB) | 0xFFFFFF (white) | | `font_italic` | BOOL | Italic style | FALSE | | `font_bold` | BOOL | Bold style | FALSE | | `font_underline` | BOOL | Underline style | FALSE | | `font_strikeout` | BOOL | Strikethrough style | FALSE | | `transparent_bg` | BOOL | Transparent background | TRUE | | `bg_color` | COLORREF | Background color | 0x000000 (black) | | `transp` | DWORD | Transparency level (0-255) | 255 (opaque) | | `align` | CVFTextAlign | Text alignment | `al_left` | | `antialiasing` | CVFTextAntialiasingMode | Anti-aliasing mode | `am_AntiAlias` | | `gradient` | BOOL | Enable gradient | FALSE | | `gradientMode` | CVFTextGradientMode | Gradient direction | `gm_horizontal` | | `gradientColor1` | COLORREF | Gradient start color | 0xFFFFFF | | `gradientColor2` | COLORREF | Gradient end color | 0x000000 | | `borderMode` | CVFTextBorderMode | Border/outline style | `bm_none` | | `innerBorderColor` | COLORREF | Inner border color | 0x000000 | | `outerBorderColor` | COLORREF | Outer border color | 0xFFFFFF | | `innerBorderSize` | int | Inner border width | 1 | | `outerBorderSize` | int | Outer border width | 1 | | `DateMode` | BOOL | Display current date/time | FALSE | | `DateMask` | BSTR | Date format string | "" | **Text Alignment Options**: - `al_left` - Left-aligned - `al_center` - Center-aligned - `al_right` - Right-aligned **Border Modes**: - `bm_none` - No border - `bm_inner` - Inner outline - `bm_outer` - Outer outline - `bm_inner_and_outer` - Both sides - `bm_embossed` - 3D embossed effect - `bm_outline` - Standard outline - `bm_filled_outline` - Solid outline - `bm_halo` - Glow effect **Example (C++)**: ``` CVFEffect effect; effect.Type = ef_text_logo; effect.Enabled = TRUE; effect.TextLogo.x = 10; effect.TextLogo.y = 10; effect.TextLogo.text = SysAllocString(L"Live Stream"); effect.TextLogo.font_name = SysAllocString(L"Arial"); effect.TextLogo.font_size = 32; effect.TextLogo.font_color = RGB(255, 255, 255); effect.TextLogo.font_bold = TRUE; effect.TextLogo.borderMode = bm_outline; effect.TextLogo.outerBorderColor = RGB(0, 0, 0); effect.TextLogo.outerBorderSize = 2; pEffects->add_effect(effect); ``` --- ### ef\_graphic\_logo Overlays an image (logo, watermark) on video. **Effect Type**: `CVFEffectType.ef_graphic_logo` **Parameters** (`CVFGraphicLogoMain` structure): | Parameter | Type | Description | | --- | --- | --- | | `x` | UINT32 | X position (pixels) | | `y` | UINT32 | Y position (pixels) | | `Filename` | BSTR | Path to image file (BMP, PNG, JPG) | | `hBmp` | int | Handle to bitmap (alternative to filename) | | `StretchMode` | CVFStretchMode | How to scale image | | `TranspLevel` | int | Transparency level (0-255) | | `UseColorKey` | BOOL | Enable color key transparency | | `ColorKey` | COLORREF | Color to make transparent | **Stretch Modes**: - `sm_none` - Original size - `sm_stretch` - Stretch to fit - `sm_letterbox` - Fit with aspect ratio - `sm_crop` - Crop to fit **Example (C#)**: ``` var effect = new CVFEffect { Type = (int)CVFEffectType.ef_graphic_logo, Enabled = true, GraphicLogo = new CVFGraphicLogoMain { Filename = @"C:\Images\logo.png", x = 20, y = 20, StretchMode = (int)CVFStretchMode.sm_none, TranspLevel = 200, UseColorKey = false } }; effectsInterface.add_effect(effect); ``` --- ## Color Filter Effects ### ef\_blue Applies blue color filter (enhances blue, reduces other colors). **Effect Type**: `CVFEffectType.ef_blue` **Parameters**: - `pAmountI` - Filter intensity (0-100, default: 50) **Use Cases**: - Artistic blue tint - Cold atmosphere - Water/ocean scenes --- ### ef\_green Applies green color filter. **Effect Type**: `CVFEffectType.ef_green` **Parameters**: - `pAmountI` - Filter intensity (0-100) **Use Cases**: - Night vision effect - Forest/nature scenes - Matrix-style effect --- ### ef\_red Applies red color filter. **Effect Type**: `CVFEffectType.ef_red` **Parameters**: - `pAmountI` - Filter intensity (0-100) **Use Cases**: - Warm atmosphere - Sunset effect - Alert/danger scenes --- ### ef\_filter\_blue / ef\_filter\_blue\_2 Advanced blue filtering with different algorithms. **Effect Type**: `CVFEffectType.ef_filter_blue` or `ef_filter_blue_2` **Difference**: `ef_filter_blue_2` uses alternative color math for different visual results. --- ### ef\_filter\_green / ef\_filter\_green2 Advanced green filtering (two variants). **Effect Types**: `CVFEffectType.ef_filter_green`, `ef_filter_green2` --- ### ef\_filter\_red / ef\_filter\_red2 Advanced red filtering (two variants). **Effect Types**: `CVFEffectType.ef_filter_red`, `ef_filter_red2` --- ### ef\_greyscale Converts video to black and white. **Effect Type**: `CVFEffectType.ef_greyscale` **Parameters**: None (full greyscale conversion) **Use Cases**: - Classic film look - Artistic effect - Reduce color noise **Example (C++)**: ``` CVFEffect effect; effect.Type = ef_greyscale; effect.Enabled = TRUE; pEffects->add_effect(effect); ``` --- ### ef\_invert Inverts all colors (negative image). **Effect Type**: `CVFEffectType.ef_invert` **Parameters**: None **Use Cases**: - Artistic effect - X-ray appearance - Special visual effects --- ## Image Adjustment Effects ### ef\_contrast Adjusts image contrast. **Effect Type**: `CVFEffectType.ef_contrast` **Parameters**: - `pAmountI` - Contrast adjustment (-100 to +100) - Negative: Decrease contrast - Positive: Increase contrast - Default: 0 (no change) **Example (C#)**: ``` var effect = new CVFEffect { Type = (int)CVFEffectType.ef_contrast, Enabled = true, pAmountI = 25 // Increase contrast by 25% }; ``` --- ### ef\_lightness Adjusts overall brightness. **Effect Type**: `CVFEffectType.ef_lightness` **Parameters**: - `pAmountI` - Brightness adjustment (-100 to +100) - Negative: Darken - Positive: Brighten - Default: 0 --- ### ef\_darkness Darkens the image (opposite of lightness). **Effect Type**: `CVFEffectType.ef_darkness` **Parameters**: - `pAmountI` - Darkness amount (0-100) --- ### ef\_saturation Adjusts color saturation. **Effect Type**: `CVFEffectType.ef_saturation` **Parameters**: - `pAmountI` - Saturation adjustment (-100 to +100) - -100: Greyscale - 0: Original colors - +100: Hyper-saturated **Use Cases**: - Vivid colors for promotional content - Desaturate for muted look - Color grading --- ## Spatial Effects ### ef\_flip\_down Flips video vertically (upside down). **Effect Type**: `CVFEffectType.ef_flip_down` **Parameters**: None **Use Cases**: - Correct upside-down camera - Mirror effect with rotation - Special effects --- ### ef\_flip\_right Flips video horizontally (mirror). **Effect Type**: `CVFEffectType.ef_flip_right` **Parameters**: None **Use Cases**: - Webcam mirror mode - Correct mirrored camera - Symmetry effects --- ### ef\_mirror\_down Creates vertical mirror effect (top reflects to bottom). **Effect Type**: `CVFEffectType.ef_mirror_down` --- ### ef\_mirror\_right Creates horizontal mirror effect (left reflects to right). **Effect Type**: `CVFEffectType.ef_mirror_right` --- ## Artistic Effects ### ef\_blur Applies Gaussian blur to the image. **Effect Type**: `CVFEffectType.ef_blur` **Parameters**: - `pAmountI` - Blur amount (0-100) - `pSizeI` - Blur kernel size (1-20) **Use Cases**: - Background blur (depth of field simulation) - Soften image - Privacy (blur faces, license plates) **Example (C++)**: ``` CVFEffect effect; effect.Type = ef_blur; effect.Enabled = TRUE; effect.pAmountI = 50; // 50% blur strength effect.pSizeI = 10; // 10-pixel blur radius pEffects->add_effect(effect); ``` --- ### ef\_marble Creates marble/swirl texture effect. **Effect Type**: `CVFEffectType.ef_marble` **Parameters**: - `pAmountD` - Effect intensity (0.0-1.0) - `pTurbulenceI` - Turbulence amount (0-100) - `pScaleD` - Scale factor (0.1-10.0) **Use Cases**: - Artistic background - Transition effects - Psychedelic visuals --- ### ef\_posterize Reduces number of colors (poster art effect). **Effect Type**: `CVFEffectType.ef_posterize` **Parameters**: - `pAmountI` - Color levels (2-256) - Lower values: Fewer colors, more dramatic - Higher values: More colors, subtle effect **Use Cases**: - Pop art style - Comic book effect - Reduce color depth --- ### ef\_mosaic Creates pixelated/mosaic effect. **Effect Type**: `CVFEffectType.ef_mosaic` **Parameters**: - `pSizeI` - Mosaic block size (2-100 pixels) **Use Cases**: - Privacy (blur faces/identities) - Retro pixel art style - Censorship **Example (C#)**: ``` var effect = new CVFEffect { Type = (int)CVFEffectType.ef_mosaic, Enabled = true, pSizeI = 15 // 15x15 pixel blocks }; ``` --- ### ef\_solorize Creates solarization effect (partial color inversion). **Effect Type**: `CVFEffectType.ef_solorize` (legacy spelling preserved in the API — use this exact identifier) **Parameters**: - `pAmountI` - Solarization threshold (0-255) **Use Cases**: - Artistic photography effect - Retro look - Creative transitions --- ### ef\_spray Creates paint spray/splatter effect. **Effect Type**: `CVFEffectType.ef_spray` **Parameters**: - `pAmountI` - Spray intensity (0-100) --- ### ef\_shake\_down Simulates camera shake effect vertically. **Effect Type**: `CVFEffectType.ef_shake_down` **Parameters**: - `pAmountI` - Shake intensity (0-100) **Use Cases**: - Earthquake effect - Impact vibration - Handheld camera simulation --- ## Noise Processing Effects ### ef\_denoise\_cast CAST (Combined Adaptive Spatial-Temporal) denoising algorithm. **Effect Type**: `CVFEffectType.ef_denoise_cast` **Parameters** (`CVFDenoiseCAST` structure): | Parameter | Range | Default | Description | | --- | --- | --- | --- | | `TemporalDifferenceThreshold` | 0-255 | 16 | Motion detection threshold | | `NumberOfMotionPixelsThreshold` | 0-16 | 0 | Min pixels for motion | | `StrongEdgeThreshold` | 0-255 | 8 | Edge preservation | | `BlockWidth` | 1-16 | 4 | Processing block width | | `BlockHeight` | 1-16 | 4 | Processing block height | | `EdgePixelWeight` | 0-255 | 128 | Edge blending weight | | `NonEdgePixelWeight` | 0-255 | 16 | Smooth area weight | | `GaussianThresholdY` | int | 12 | Luma noise threshold | | `GaussianThresholdUV` | int | 6 | Chroma noise threshold | | `HistoryWeight` | 0-255 | 192 | Temporal filtering strength | **Use Cases**: - Low-light video cleanup - Webcam noise reduction - Compression artifact removal **Example (C++)**: ``` CVFEffect effect; effect.Type = ef_denoise_cast; effect.Enabled = TRUE; // Moderate noise reduction effect.DenoiseCAST.TemporalDifferenceThreshold = 20; effect.DenoiseCAST.StrongEdgeThreshold = 10; effect.DenoiseCAST.GaussianThresholdY = 15; effect.DenoiseCAST.GaussianThresholdUV = 8; pEffects->add_effect(effect); ``` --- ### ef\_denoise\_adaptive Adaptive noise reduction that adjusts to image content. **Effect Type**: `CVFEffectType.ef_denoise_adaptive` **Parameters**: - `pDenoiseAdaptiveThreshold` - Noise threshold (0-100) - `pDenoiseAdaptiveBlurMode` - Blur method (0-2) **Use Cases**: - General noise reduction - Video cleanup - Quality enhancement --- ### ef\_denoise\_mosquito Reduces mosquito noise (compression artifacts around edges). **Effect Type**: `CVFEffectType.ef_denoise_mosquito` **Parameters**: - `pAmountI` - Reduction strength (0-100) **Use Cases**: - Clean up heavily compressed video - Remove MPEG/H.264 artifacts - Post-processing for streaming --- ### ef\_color\_noise Adds color noise (grain) to image. **Effect Type**: `CVFEffectType.ef_color_noise` **Parameters**: - `pAmountI` - Noise amount (0-100) **Use Cases**: - Film grain effect - Retro/vintage look - Artistic texture --- ### ef\_mono\_noise Adds monochrome (black & white) noise. **Effect Type**: `CVFEffectType.ef_mono_noise` **Parameters**: - `pAmountI` - Noise amount (0-100) --- ## Deinterlacing Effects ### ef\_deint\_blend Blends interlaced fields together. **Effect Type**: `CVFEffectType.ef_deint_blend` **Parameters** (`CVFDeintBlend` structure): | Parameter | Range | Default | Description | |-----------|-------|---------|-------------| | `blendThresh1` | 0-255 | 5 | First blend threshold | | `blendThresh2` | 0-255 | 9 | Second blend threshold | | `blendConstants1` | 0.0-1.0 | 0.3 | First blend weight | | `blendConstants2` | 0.0-1.0 | 0.7 | Second blend weight | **Use Cases**: - Deinterlace analog video - Remove comb artifacts - Convert interlaced to progressive --- ### ef\_deint\_triangle Triangle interpolation deinterlacing. **Effect Type**: `CVFEffectType.ef_deint_triangle` **Parameters**: - `pDeintTriangleWeight` - Interpolation weight (0-100) **Quality**: Better edge preservation than blend --- ### ef\_deint\_cavt CAVT (Content Adaptive Vertical Temporal) deinterlacing. **Effect Type**: `CVFEffectType.ef_deint_cavt` **Parameters**: - `pDeintCAVTThreshold` - Motion threshold (0-100) **Quality**: Best quality, most CPU intensive **Use Cases**: - High-quality deinterlacing - Broadcast video conversion - Archival processing --- ## Effect Chaining Multiple effects can be applied simultaneously. Effects are processed in the order they were added. **Example: Professional Stream Enhancement**: ``` // 1. Denoise CVFEffect denoise; denoise.Type = ef_denoise_adaptive; denoise.Enabled = TRUE; denoise.pDenoiseAdaptiveThreshold = 15; pEffects->add_effect(denoise); // 2. Color correction CVFEffect saturation; saturation.Type = ef_saturation; saturation.Enabled = TRUE; saturation.pAmountI = 15; // Slight saturation boost pEffects->add_effect(saturation); // 3. Add branding CVFEffect logo; logo.Type = ef_graphic_logo; logo.Enabled = TRUE; logo.GraphicLogo.Filename = SysAllocString(L"logo.png"); logo.GraphicLogo.x = 20; logo.GraphicLogo.y = 20; pEffects->add_effect(logo); // 4. Add timestamp CVFEffect timestamp; timestamp.Type = ef_text_logo; timestamp.Enabled = TRUE; timestamp.TextLogo.DateMode = TRUE; timestamp.TextLogo.DateMask = SysAllocString(L"%Y-%m-%d %H:%M:%S"); timestamp.TextLogo.x = 20; timestamp.TextLogo.y = 1050; // Bottom left pEffects->add_effect(timestamp); ``` --- ## Performance Considerations ### CPU Usage by Effect **Low Impact** (< 5% CPU): - Color filters - Greyscale - Invert - Flip/Mirror **Medium Impact** (5-15% CPU): - Text/graphic overlays - Contrast/brightness - Posterize - Simple deinterlacing **High Impact** (15-40% CPU): - Blur (large radius) - Denoise (CAST, adaptive) - Mosaic (small blocks) - Marble/artistic effects ### Optimization Tips 1. **Limit simultaneous effects** - Each effect adds processing time 2. **Use appropriate parameters** - Larger blur radius = more CPU 3. **Disable unused effects** - Set `Enabled = FALSE` instead of removing 4. **Process at lower resolution** - Downscale, apply effects, upscale 5. **Use GPU rendering when possible** - Check for GPU-accelerated effects --- ## Common Effect Combinations ### Webcam Enhancement ``` 1. ef_denoise_adaptive (threshold: 15) 2. ef_contrast (amount: +10) 3. ef_saturation (amount: +15) 4. ef_flip_right (mirror mode) ``` ### Vintage Film Look ``` 1. ef_greyscale 2. ef_contrast (amount: +20) 3. ef_mono_noise (amount: 15) ``` ### Broadcast Quality ``` 1. ef_deint_cavt 2. ef_denoise_mosquito (amount: 20) 3. ef_saturation (amount: +5) ``` ### Privacy Mode ``` 1. ef_mosaic (size: 20) on specific region 2. ef_blur (amount: 80) as alternative ``` --- ## See Also - [Processing Filters Pack Overview](../) - [Video Effects Interface Reference](../interfaces/effects-interface/) - [Chroma Key Interface](../interfaces/chroma-key/) - [Video Mixer Interface](../interfaces/video-mixer/) - [Code Examples](../examples/) ---END OF PAGE--- ## DirectShow Video Effects, Mixer, and Chroma Key Examples **URL:** https://www.visioforge.com/help/docs/directshow/proc-filters/examples/ **Description:** Code examples for Video Effects, Video Mixer, and Chroma Key filters in C++, C#, and VB.NET with DirectShow integration. **Tags:** DirectShow, C++, Windows, Effects, Mixing, C# **API:** IBaseFilter, IVFChromaKey, IVFVideoMixer # Processing Filters Pack - Code Examples ## Overview This page provides practical code examples for using the Processing Filters Pack, which includes: - **Video Effects** - 35+ real-time effects (text, graphics, color adjustments, denoise) - **Video Mixer** - 2-16 source mixing with PIP, alpha blending, chroma key - **Chroma Key** - Green/blue screen compositing --- ## Prerequisites ### C++ Projects ``` #include #include #include "IVFEffects45.h" #include "IVFVideoMixer.h" #include "IVFChromaKey.h" #pragma comment(lib, "strmiids.lib") ``` ### C# Projects ``` using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; using System.Runtime.InteropServices; using System.Drawing; ``` **NuGet Packages**: - VisioForge.DirectShowAPI - MediaFoundationCore --- ## Video Effects Examples ### Example 1: Basic Video Effect Apply a single video effect to a source. #### C# Implementation ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VideoEffectsBasicExample { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; private IBaseFilter sourceFilter; private IBaseFilter effectFilter; public void PlayWithEffect(string filename, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); mediaControl = (IMediaControl)filterGraph; // Add source filter (e.g., File Source) filterGraph.AddSourceFilter(filename, "Source", out sourceFilter); // Add Video Effects filter effectFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVideoEffects, "Video Effects"); // Configure effect using IVFEffects45 interface var effects = effectFilter as IVFEffects45; if (effects != null) { // Enable Greyscale effect via VideoEffectSimple struct var eff = new VideoEffectSimple { Type = (int)VideoEffectType.Greyscale, Enabled = true }; effects.add_effect(eff); } captureGraph.SetFiltergraph(filterGraph); // Render through effect filter captureGraph.RenderStream(null, MediaType.Video, sourceFilter, effectFilter, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Set up video window var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); // Run mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } public void Stop() { mediaControl?.Stop(); FilterGraphTools.RemoveAllFilters(filterGraph); if (sourceFilter != null) Marshal.ReleaseComObject(sourceFilter); if (effectFilter != null) Marshal.ReleaseComObject(effectFilter); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } ``` #### C++ Implementation ``` HRESULT ApplyVideoEffect(LPCWSTR filename) { IGraphBuilder* pGraph = NULL; IBaseFilter* pSource = NULL; IBaseFilter* pEffect = NULL; IVFEffects45* pEffects = NULL; // Create filter graph HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph); if (FAILED(hr)) return hr; // Add source hr = pGraph->AddSourceFilter(filename, L"Source", &pSource); if (FAILED(hr)) goto cleanup; // Create Video Effects filter hr = CoCreateInstance(CLSID_VFVideoEffects, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pEffect); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pEffect, L"Video Effects"); if (FAILED(hr)) goto cleanup; // Configure effect hr = pEffect->QueryInterface(IID_IVFEffects45, (void**)&pEffects); if (SUCCEEDED(hr)) { // Enable greyscale via VideoEffectSimple struct VideoEffectSimple effect; ZeroMemory(&effect, sizeof(effect)); effect.Type = ef_greyscale; effect.Enabled = TRUE; pEffects->add_effect(&effect); pEffects->Release(); } // Connect filters and render... // (Use RenderStream or ConnectFilters) cleanup: if (pEffect) pEffect->Release(); if (pSource) pSource->Release(); if (pGraph) pGraph->Release(); return hr; } ``` --- ### Example 2: Multiple Effects Chain Apply multiple effects simultaneously. #### C# Multiple Effects ## ``` public class MultipleEffectsExample { public void ApplyMultipleEffects(IBaseFilter effectFilter) { var effects = effectFilter as IVFEffects45; if (effects != null) { // Add darkness/brightness effect (VideoEffectType.Darkness, AmountI controls level) effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Darkness, Enabled = true, AmountI = 50 // 0 = darkest, 100 = brightest }); // Add contrast effect (AmountI controls intensity) effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Contrast, Enabled = true, AmountI = 75 // Contrast intensity }); // Add saturation effect (AmountI controls saturation level) effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Saturation, Enabled = true, AmountI = 120 // Saturation level }); } } } ``` ### Example 3: Text Overlay Add text logo overlay to video. #### C# Text Overlay ``` public void ApplyTextOverlay(IBaseFilter effectFilter) { var effects = effectFilter as IVFEffects45; if (effects != null) { var eff = new VideoEffectSimple { Type = (int)VideoEffectType.TextLogo, Enabled = true, TextLogo = new MFPTextLogo { X = 50, Y = 50, Text = "My Video Title", FontName = "Arial", FontSize = 36, FontColor = 0xFFFFFF, // White FontBold = true, TransparentBg = true, Transp = 255, // Fully opaque BorderMode = 4, // bm_outline OuterBorderColor = 0x000000, // Black outline OuterBorderSize = 2 } }; effects.add_effect(eff); } } ``` See [effects-reference.md](../effects-reference/) for the full `MFPTextLogo` structure (text alignment, gradient, date/time display, anti-aliasing, etc.). --- ### Example 4: Image Overlay Add graphic watermark or logo. #### C# Image Overlay ``` public void ApplyImageOverlay(IBaseFilter effectFilter, string imagePath) { var effects = effectFilter as IVFEffects45; if (effects != null) { var eff = new VideoEffectSimple { Type = (int)VideoEffectType.ImageLogo, Enabled = true, GraphicalLogo = new MFPGraphicalLogo { X = 10, // X position in pixels Y = 10, // Y position in pixels Filename = imagePath, TranspLevel = 200, // Semi-transparent (0-255) StretchMode = 2 // 0=None, 1=Stretch, 2=Proportional fit } }; effects.add_effect(eff); } } ``` ## See [effects-reference.md](../effects-reference/) for the full `MFPGraphicalLogo` structure. ### Example 5: Denoise Filters Apply noise reduction for cleaner video. #### C# Denoise Examples ``` public void ApplyDenoise(IBaseFilter effectFilter, VideoEffectType denoiseType) { var effects = effectFilter as IVFEffects45; if (effects != null) { var eff = new VideoEffectSimple { Type = (int)denoiseType, Enabled = true }; switch (denoiseType) { case VideoEffectType.DenoiseCAST: // CAST denoise — configure via DenoiseCAST sub-struct eff.DenoiseCAST = new MFPDenoiseCAST { TemporalDifferenceThreshold = 16, StrongEdgeThreshold = 8 }; break; case VideoEffectType.DenoiseAdaptive: // Adaptive denoise — threshold controls sensitivity eff.DenoiseAdaptiveThreshold = 20; // 0-255 eff.DenoiseAdaptiveBlurMode = 0; // 0-3 break; case VideoEffectType.DenoiseMosquito: // Mosquito denoise — AmountI controls reduction strength eff.AmountI = 30; break; } effects.add_effect(eff); } } ``` --- ### Example 6: All Available Effects Complete list of effects with basic configuration. #### C# All Effects Reference ``` public class AllEffectsExample { public void DemonstrateAllEffects(IBaseFilter effectFilter) { var effects = effectFilter as IVFEffects45; if (effects == null) return; // Color Filters effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Greyscale, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Invert, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.FilterRed, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.FilterGreen, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.FilterBlue, Enabled = true }); // Image Adjustment (AmountI controls intensity) effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Darkness, Enabled = true, AmountI = 50 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Contrast, Enabled = true, AmountI = 75 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Saturation, Enabled = true, AmountI = 120 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Lightness, Enabled = true, AmountI = 45 }); // Spatial Transforms effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.FlipRight, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.FlipDown, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.MirrorHorizontal, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Rotate, Enabled = true, AmountI = 90 }); // Artistic Effects effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Blur, Enabled = true, AmountI = 5 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Sharpen, Enabled = true, AmountI = 2 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Posterize, Enabled = true, AmountI = 8 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Solorize, Enabled = true, AmountI = 128 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Mosaic, Enabled = true, SizeI = 10 }); // Noise Reduction effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.DenoiseCAST, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.DenoiseAdaptive, Enabled = true, DenoiseAdaptiveThreshold = 20 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.DenoiseMosquito, Enabled = true, AmountI = 30 }); // Deinterlacing effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.DeinterlaceBlend, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.DeinterlaceTriangle, Enabled = true }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.DeinterlaceCAVT, Enabled = true }); // Overlays (TextLogo/ImageLogo need sub-struct — see Examples 3 & 4) // To disable/remove an effect: // effects.remove_effect(effectId); // effects.clear_effects(); } } ``` > **Note:** For the full list of `VideoEffectType` members and sub-struct parameters, see [effects-reference.md](../effects-reference/). --- ## Video Mixer Examples ### Example 7: Picture-in-Picture (PIP) Mix two video sources with PIP layout. #### C# Picture-in-Picture ``` public class VideoMixerPIPExample { private IFilterGraph2 filterGraph; private IBaseFilter mixerFilter; public void CreatePIP(string mainVideoPath, string pipVideoPath, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); // Add main video source filterGraph.AddSourceFilter(mainVideoPath, "Main Source", out IBaseFilter mainSource); // Add PIP video source filterGraph.AddSourceFilter(pipVideoPath, "PIP Source", out IBaseFilter pipSource); // Add Video Mixer filter mixerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVideoMixer, "Video Mixer"); // Configure mixer — real IVFVideoMixer interface var mixer = mixerFilter as IVFVideoMixer; if (mixer != null) { // Set output size mixer.SetOutputParam(new VFPIPVideoOutputParam { Width = 1920, Height = 1080, FrameRateTime = 30 }); // Configure main video (input 0) - fullscreen mixer.SetInputParam(0, new VFPIPVideoInputParam { X = 0, Y = 0, Width = 1920, Height = 1080, Alpha = 255 }); // Configure PIP video (input 1) - bottom-right corner mixer.SetInputParam(1, new VFPIPVideoInputParam { X = 1440, // 1920 - 480 Y = 810, // 1080 - 270 Width = 480, Height = 270, Alpha = 255 }); // Set Z-order (layering) — per-pin, not bulk array mixer.SetInputOrder(0, 0); // Main behind mixer.SetInputOrder(1, 1); // PIP on top } // Connect filters ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); // Connect main source to mixer input 0 captureGraph.RenderStream(null, MediaType.Video, mainSource, null, mixerFilter); // Connect PIP source to mixer input 1 // Note: Requires connecting to specific input pin IPin mixerInput1 = DsFindPin.ByDirection(mixerFilter, PinDirection.Input, 1); captureGraph.RenderStream(null, MediaType.Video, pipSource, null, null); // Connect to mixerInput1 explicitly... // Render mixer output captureGraph.RenderStream(null, MediaType.Video, mixerFilter, null, null); // Setup video window var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); // Run var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } ``` --- ### Example 8: Multi-Source Mixing (4 inputs) Create a 2x2 grid layout with 4 video sources. #### C# 2x2 Grid Layout ## ``` public class VideoMixerGridExample { public void Create2x2Grid(string[] videoPaths, IntPtr videoWindowHandle) { if (videoPaths.Length != 4) { throw new ArgumentException("Requires exactly 4 video sources"); } var filterGraph = (IFilterGraph2)new FilterGraph(); // Add all source filters IBaseFilter[] sources = new IBaseFilter[4]; for (int i = 0; i < 4; i++) { filterGraph.AddSourceFilter(videoPaths[i], $"Source {i}", out sources[i]); } // Add Video Mixer var mixerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVideoMixer, "Video Mixer"); var mixer = mixerFilter as IVFVideoMixer; if (mixer != null) { // Set output size mixer.SetOutputParam(new VFPIPVideoOutputParam { Width = 1920, Height = 1080, FrameRateTime = 30 }); int halfWidth = 960; // 1920 / 2 int halfHeight = 540; // 1080 / 2 // Top-left (Input 0) mixer.SetInputParam(0, new VFPIPVideoInputParam { X = 0, Y = 0, Width = halfWidth, Height = halfHeight, Alpha = 255 }); // Top-right (Input 1) mixer.SetInputParam(1, new VFPIPVideoInputParam { X = halfWidth, Y = 0, Width = halfWidth, Height = halfHeight, Alpha = 255 }); // Bottom-left (Input 2) mixer.SetInputParam(2, new VFPIPVideoInputParam { X = 0, Y = halfHeight, Width = halfWidth, Height = halfHeight, Alpha = 255 }); // Bottom-right (Input 3) mixer.SetInputParam(3, new VFPIPVideoInputParam { X = halfWidth, Y = halfHeight, Width = halfWidth, Height = halfHeight, Alpha = 255 }); // Set Z-order (per-pin) for (int i = 0; i < 4; i++) { mixer.SetInputOrder(i, i); } } // Connect sources to mixer and render... // (Similar to PIP example) var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); } } ``` ### Example 9: Video Mixer with Chroma Key Mix sources with transparent background. #### C# Mixer with Chroma Key ``` public void CreateMixerWithChromaKey(string backgroundPath, string foregroundPath) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add sources filterGraph.AddSourceFilter(backgroundPath, "Background", out IBaseFilter bgSource); filterGraph.AddSourceFilter(foregroundPath, "Foreground", out IBaseFilter fgSource); // Add mixer var mixerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVideoMixer, "Video Mixer"); var mixer = mixerFilter as IVFVideoMixer; if (mixer != null) { // Configure output mixer.SetOutputParam(new VFPIPVideoOutputParam { Width = 1920, Height = 1080 }); // Background (fullscreen) mixer.SetInputParam(0, new VFPIPVideoInputParam { X = 0, Y = 0, Width = 1920, Height = 1080 }); // Foreground (centered, smaller) mixer.SetInputParam(1, new VFPIPVideoInputParam { X = 480, Y = 270, Width = 960, Height = 540 }); // Enable chroma key — mixer-wide, 4 args mixer.SetChromaSettings( enabled: true, color: ColorTranslator.ToWin32(Color.FromArgb(0, 255, 0)), // Green tolerance1: 50, tolerance2: 10); } // Connect and run... } ``` --- ## Chroma Key Examples ### Example 10: Green Screen Effect Standalone chroma key filter for green screen removal. #### C# Chroma Key Filter ``` public class ChromaKeyExample { public void ApplyGreenScreen(string videoPath, string backgroundImagePath, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); // Add video source (with green screen) filterGraph.AddSourceFilter(videoPath, "Source", out IBaseFilter sourceFilter); // Add Chroma Key filter var chromaFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFChromaKey, "Chroma Key"); // Configure chroma key — real IVFChromaKey API var chromaKey = chromaFilter as IVFChromaKey; if (chromaKey != null) { // Set key color (green) — single int using RGB macro chromaKey.put_color(ColorTranslator.ToWin32(Color.FromArgb(0, 255, 0))); // Set contrast range (low, high bounds) chromaKey.put_contrast(50, 100); // Set background image (optional) if (!string.IsNullOrEmpty(backgroundImagePath)) { chromaKey.put_image(backgroundImagePath); } } // Connect filters: Source → Chroma Key → Renderer ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, chromaFilter, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Setup video window var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); // Run var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } ``` #### C++ Chroma Key ## ``` HRESULT ApplyChromaKey(IBaseFilter* pChromaFilter) { IVFChromaKey* pChromaKey = NULL; HRESULT hr = pChromaFilter->QueryInterface(IID_IVFChromaKey, (void**)&pChromaKey); if (FAILED(hr)) return hr; // Set green color — single COLORREF argument: RGB(0, 255, 0) hr = pChromaKey->put_color(RGB(0, 255, 0)); if (FAILED(hr)) goto cleanup; // Set contrast range (low, high) hr = pChromaKey->put_contrast(40, 90); if (FAILED(hr)) goto cleanup; // Optional: Set background image hr = pChromaKey->put_image(L"C:\\backgrounds\\studio.jpg"); cleanup: pChromaKey->Release(); return hr; } ``` ### Example 11: Blue Screen with Fine Tuning Configure blue screen chroma key with optimal settings. #### C# Blue Screen ``` public void ApplyBlueScreen(IBaseFilter chromaFilter) { var chromaKey = chromaFilter as IVFChromaKey; if (chromaKey != null) { // Set blue color — single int via RGB chromaKey.put_color(ColorTranslator.ToWin32(Color.FromArgb(0, 0, 255))); // Fine-tuned contrast range for blue screen // Lower low = more strict (less tolerance) // Higher high = more loose (more tolerance) chromaKey.put_contrast(30, 80); } } ``` --- ### Example 12: Custom Color Chroma Key Use any custom color for keying. #### C# Custom Color Key ## ``` public void ApplyCustomColorKey(IBaseFilter chromaFilter, Color keyColor) { var chromaKey = chromaFilter as IVFChromaKey; if (chromaKey != null) { // Use any custom color — single int via RGB chromaKey.put_color(ColorTranslator.ToWin32(keyColor)); // Standard contrast range chromaKey.put_contrast(50, 100); } } // Example usage: // ApplyCustomColorKey(chromaFilter, Color.Magenta); // Magenta screen // ApplyCustomColorKey(chromaFilter, Color.FromArgb(255, 180, 0, 220)); // Custom purple ``` ## Complete Processing Pipeline ### Example 13: Combined Effects, Mixing, and Chroma Key Complete example combining all processing filters. #### C# Complete Pipeline ``` public class CompleteProcessingPipeline { public void CreateCompleteSetup( string mainVideoPath, string greenScreenVideoPath, string backgroundImagePath, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); // 1. Main video source filterGraph.AddSourceFilter(mainVideoPath, "Main Video", out IBaseFilter mainSource); // 2. Green screen video source filterGraph.AddSourceFilter(greenScreenVideoPath, "Green Screen", out IBaseFilter gsSource); // 3. Add Chroma Key filter for green screen var chromaFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFChromaKey, "Chroma Key"); var chromaKey = chromaFilter as IVFChromaKey; if (chromaKey != null) { chromaKey.put_color(ColorTranslator.ToWin32(Color.FromArgb(0, 255, 0))); // Green chromaKey.put_contrast(40, 90); } // 4. Add Video Effects filter var effectsFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVideoEffects, "Video Effects"); var effects = effectsFilter as IVFEffects45; if (effects != null) { // Apply effects via VideoEffectSimple structs effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Darkness, Enabled = true, AmountI = 60 }); effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.Contrast, Enabled = true, AmountI = 80 }); // Add text overlay effects.add_effect(new VideoEffectSimple { Type = (int)VideoEffectType.TextLogo, Enabled = true, TextLogo = new MFPTextLogo { Text = "LIVE", FontSize = 48, X = 50, Y = 50, FontColor = 0xFFFFFF, FontBold = true } }); } // 5. Add Video Mixer var mixerFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVideoMixer, "Video Mixer"); var mixer = mixerFilter as IVFVideoMixer; if (mixer != null) { mixer.SetOutputParam(new VFPIPVideoOutputParam { Width = 1920, Height = 1080, FrameRateTime = 30 }); // Main video (fullscreen background) mixer.SetInputParam(0, new VFPIPVideoInputParam { X = 0, Y = 0, Width = 1920, Height = 1080 }); // Chroma-keyed video (PIP) mixer.SetInputParam(1, new VFPIPVideoInputParam { X = 1200, Y = 700, Width = 640, Height = 360 }); // Set Z-order (per-pin) mixer.SetInputOrder(0, 0); mixer.SetInputOrder(1, 1); } // Connect the pipeline: // Main Source → Effects → Mixer Input 0 // GS Source → Chroma Key → Mixer Input 1 // Mixer → Renderer ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); // Connect main path captureGraph.RenderStream(null, MediaType.Video, mainSource, effectsFilter, mixerFilter); // Connect chroma key path // (Requires pin-level connections to specific mixer input) // Render mixer output captureGraph.RenderStream(null, MediaType.Video, mixerFilter, null, null); // Audio captureGraph.RenderStream(null, MediaType.Audio, mainSource, null, null); // Setup video window var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); // Run var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } ``` --- ## Troubleshooting ### Issue: Effect Not Visible **Solution**: Ensure effect is enabled and parameters are set on the VideoEffectSimple struct: ``` var eff = new VideoEffectSimple { Type = (int)VideoEffectType.Darkness, Enabled = true, AmountI = 75 }; effects.add_effect(eff); ``` ### Issue: Chroma Key Not Working Well **Solution**: Adjust contrast thresholds: ``` // For difficult green screens: chromaKey.put_contrast(30, 70); // Tighter range // For well-lit green screens: chromaKey.put_contrast(50, 110); // Wider range ``` ### Issue: Video Mixer Inputs Not Showing **Solution**: Verify input parameters and Z-order: ``` // Ensure inputs are on-screen via VFPIPVideoInputParam struct mixer.SetInputParam(0, new VFPIPVideoInputParam { X = 0, Y = 0, Width = 640, Height = 480 }); // Set Z-order per-pin mixer.SetInputOrder(0, 0); // Input 0 at layer 0 mixer.SetInputOrder(1, 1); // Input 1 at layer 1 ``` --- ## See Also ### Documentation - [Effects Reference](../effects-reference/) - Complete effects list - [Video Mixer Interface](../interfaces/video-mixer/) - Full API reference - [Chroma Key Interface](../interfaces/chroma-key/) - Complete interface docs ### External Resources - [DirectShow Filter Graph](https://learn.microsoft.com/en-us/windows/win32/directshow/building-the-filter-graph) ---END OF PAGE--- ## Real-Time Video Processing Filters for DirectShow Apps **URL:** https://www.visioforge.com/help/docs/directshow/proc-filters/ **Description:** Add 35+ real-time video effects, multi-source video mixer (2-16 inputs), chroma key, deinterlacing, and noise reduction to Windows apps. VisioForge COM filters. **Tags:** DirectShow, C++, Windows # DirectShow Processing Filters for Media Applications ## Introduction to DirectShow Processing Filters The DirectShow Processing Filters Pack delivers a powerful collection of specialized filters built for sophisticated audio and video manipulation in Windows applications. These filters enable developers to implement professional-grade media processing capabilities without developing complex algorithms from scratch. Designed for developers seeking to enhance their applications with advanced media functionality, this toolkit offers a streamlined approach to implementing robust audio-visual features with minimal code overhead. --- ## Installation Before using the code samples and integrating the filters into your application, you must first install the DirectShow Processing Filters Pack from the [product page](https://www.visioforge.com/processing-filters-pack). **Installation Steps**: 1. Download the Processing Filters Pack installer from the product page 2. Run the installer with administrative privileges 3. The installer will register all processing filters 4. Sample applications and source code will be available in the installation directory **Note**: All filters must be properly registered on the system before they can be used in your applications. The installer handles this automatically. --- ## Key Capabilities and Benefits ### Video Processing Capabilities #### Advanced Visual Effects - **Dynamic Effects Processing**: Apply real-time effects to video streams including blur, sharpen, sepia, grayscale, and numerous artistic filters - **Custom Effect Chaining**: Combine multiple effects sequentially for complex visual transformations - **Adjustable Parameters**: Fine-tune effect intensity and characteristics for precise control #### Professional Video Mixing - **Multi-Source Blending**: Seamlessly combine multiple video streams into a unified output - **Transition Effects**: Implement smooth transitions between video sources - **Picture-in-Picture**: Create overlay configurations with customizable positioning and scaling #### Image and Text Overlay System - **Dynamic Text Rendering**: Overlay customizable text with font control and animation - **Image Integration**: Add logos, watermarks, and informational graphics to video content - **Alpha Channel Support**: Maintain transparency information for professional compositing #### High-Quality Resize Functionality - **Multiple Algorithms**: Choose from nearest neighbor, bilinear, bicubic, and Lanczos scaling - **Aspect Ratio Control**: Maintain or adjust aspect ratios as needed - **Resolution Optimization**: Scale content for specific output requirements while preserving quality #### Video Manipulation Tools - **Rotation and Cropping**: Adjust video orientation and framing with precise control - **Deinterlacing Options**: Multiple modes available for converting interlaced content - **Noise Reduction**: Advanced algorithms for improving video clarity and quality ### Audio Processing Capabilities #### Audio Enhancement Suite - **Effect Processing**: Apply various audio effects for sound enhancement and creative manipulation - **Channel Management**: Control stereo imaging and multi-channel configurations #### Advanced Audio Controls - **Volume Optimization**: Precise volume adjustment with normalization options - **Balance Adjustment**: Fine-tune left/right channel balance for optimal sound distribution - **Pitch Modification**: Alter pitch while maintaining or changing tempo - **Delay Implementation**: Add customizable delay effects with feedback control #### Professional Sound Effects - **Echo Generation**: Create spatial echo effects with adjustable parameters - **Equalizer System**: Multi-band equalization for frequency adjustment - **Chorus Effects**: Add richness and depth to audio streams - **Flanger Processing**: Create sweeping, psychedelic audio effects ## System Requirements ### Compatible Operating Systems - Windows 11, 10, 8.1, 8, and 7 (both 32-bit and 64-bit versions) ### Development Environment Support - **Microsoft Visual Studio**: Versions 2022, 2019, 2017, 2015, 2013, 2012, and 2010 - **Embarcadero Tools**: Compatible with Delphi and C++ Builder - **Additional Environments**: Works with any development platform supporting DirectShow filters ### Technical Prerequisites - DirectX 9 or later installation - Minimum 4GB RAM (8GB+ recommended for high-resolution processing) - Multi-core processor recommended for optimal performance ## Additional Resources - [Complete Product Information](https://www.visioforge.com/processing-filters-pack) - [API Documentation](https://api.visioforge.org/proc_filters/api/index.html) - [Licensing Information](../../eula/) ## Version History and Updates ### Version 15.1 Enhancements - Integration with .Net SDKs 15.1 architecture - Significant improvements to audio and video mixing engines - Enhanced multithreading support for better performance on multi-core systems - Expanded video effects library with new processing options - Resolution of audio click artifacts in mixer component - Optimized support for ultra-high-definition 4K and 8K content processing ### Version 15.0 Improvements - Full alignment with .Net SDKs 15.0 framework - Optimized high-resolution processing for brightness, contrast, saturation, and hue filters ### Version 14.0 Updates - Complete compatibility with .Net SDKs 14.0 - Performance optimization for video resize operations - Enhanced bicubic video resize algorithm for superior quality ### Version 12.0 Refinements - Integration with .Net SDKs 12.0 infrastructure - Redesigned audio mixer with improved performance - Fixed stability issues when using crop or resize with incorrect parameters ### Version 11.0 Features - Updated to match .Net SDKs 11.0 specifications - Improved audio tempo and pitch manipulation algorithms - Optimized video balance performance for smoother processing ### Version 10.0 Developments - Alignment with .Net SDKs 10.0 architecture - Completely revamped Video Mixer component ### Version 9.0 Advancements - Integration with .Net SDKs 9.2 framework - Enhanced video effects library - Specific optimizations for 4K content processing ### Version 8.5 Initial Release - First public release, featuring filters from .Net SDKs 8.5 - Introduction of Lanczos support in video resize filter for superior quality scaling ---END OF PAGE--- ## Chroma Key DirectShow Filter - IVFChromaKey Interface **URL:** https://www.visioforge.com/help/docs/directshow/proc-filters/interfaces/chroma-key/ **Description:** IVFChromaKey interface for green screen and blue screen compositing with tolerance control and background replacement in DirectShow. **Tags:** DirectShow, C++, Windows, Effects, Mixing, C# **API:** IVFChromaKey, CVFChromaColor, IBaseFilter, IVFVideoMixer, IVFEffectsPro # IVFChromaKey Interface Reference ## Overview The `IVFChromaKey` interface provides professional chroma key (green screen/blue screen) compositing capabilities for DirectShow applications. This interface enables real-time background replacement by making specific colors transparent, allowing subjects filmed in front of colored backdrops to be composited over different backgrounds. Chroma keying is essential for virtual production, weather forecasting, video effects, and any scenario where background replacement is needed. ## Interface Definition - **Interface Name**: `IVFChromaKey` - **GUID**: `{AF6E8208-30E3-44f0-AAFE-787A6250BAB3}` - **Inherits From**: `IUnknown` - **Header File**: `vf_eff_intf.h` (C++), `IVFChromaKey.cs` (.NET) ## Capabilities - **Color Keys**: Green, blue, red, or custom RGB colors - **Contrast Adjustment**: Separate low/high contrast thresholds - **Background Replacement**: Static image or video background - **Real-Time Processing**: Hardware-accelerated when available - **Edge Quality**: Adjustable tolerance for smooth edges --- ## Methods Reference ### Contrast Threshold Configuration #### chroma\_put\_contrast Sets the contrast threshold range for chroma keying. **Syntax (C++)**: ``` HRESULT chroma_put_contrast(int low, int high); ``` **Syntax (C#)**: ``` [PreserveSig] int chroma_put_contrast(int low, int high); ``` **Parameters**: - `low`: Low contrast threshold (0-255) - Lower values = remove more similar colors - Higher values = stricter color matching - `high`: High contrast threshold (0-255) - Defines the upper bound for color matching - Creates a range of acceptable key colors **Returns**: `S_OK` (0) on success. **Usage Notes**: - These values define the color similarity range for keying - The range between `low` and `high` creates a gradient for edge smoothing - Typical ranges: - Tight keying: low=10, high=30 - Standard keying: low=30, high=70 - Loose keying: low=50, high=120 - Adjust based on lighting conditions and backdrop quality **How It Works**: ``` Pixels with chroma distance < low → Fully transparent Pixels with chroma distance > high → Fully opaque Pixels between low and high → Partially transparent (gradient) ``` **Example (C++)**: ``` IVFChromaKey* pChroma = nullptr; pFilter->QueryInterface(IID_IVFChromaKey, (void**)&pChroma); // Standard green screen configuration pChroma->chroma_put_contrast(40, 80); pChroma->Release(); ``` **Example (C#)**: ``` var chroma = filter as IVFChromaKey; if (chroma != null) { // Tight keying for clean green screen chroma.chroma_put_contrast(20, 50); } ``` --- ### Color Selection #### chroma\_put\_color Sets the chroma key color to be made transparent. **Syntax (C++)**: ``` HRESULT chroma_put_color(int color); ``` **Syntax (C#)**: ``` [PreserveSig] int chroma_put_color(int color); ``` **Parameters**: - `color`: Chroma key color value **Color Values** (CVFChromaColor enumeration): | Value | Color | RGB Equivalent | Use Case | | --- | --- | --- | --- | | `0` (Chroma\_Green) | Green | 0x00FF00 | Standard chroma key (most common) | | `1` (Chroma\_Blue) | Blue | 0x0000FF | Alternative to green | | `2` (Chroma\_Red) | Red | 0xFF0000 | Special cases | | Custom RGB | Any color | 0xRRGGBB | Specific color matching | **Returns**: `S_OK` (0) on success. **Usage Notes**: - Green is standard for chroma keying (human skin has least green) - Blue used when green objects are in scene - Can use custom RGB value for specific color matching - Color should be uniform across backdrop for best results **Example (C++)**: ``` // Use green chroma key pChroma->chroma_put_color(Chroma_Green); // Use blue chroma key pChroma->chroma_put_color(Chroma_Blue); // Use custom color (e.g., magenta) pChroma->chroma_put_color(0xFF00FF); ``` **Example (C#)**: ``` // Standard green screen chroma.chroma_put_color((int)CVFChromaColor.Chroma_Green); // Blue screen chroma.chroma_put_color((int)CVFChromaColor.Chroma_Blue); // Custom yellow-green chroma.chroma_put_color(0x88FF00); ``` --- ### Background Image #### chroma\_put\_image Sets a replacement background image for transparent areas. **Syntax (C++)**: ``` HRESULT chroma_put_image(BSTR filename); ``` **Syntax (C#)**: ``` [PreserveSig] int chroma_put_image([MarshalAs(UnmanagedType.BStr)] string filename); ``` **Parameters**: - `filename`: Path to background image file (BMP, PNG, JPG, etc.) **Returns**: `S_OK` (0) on success. **Usage Notes**: - Image is stretched to fill entire frame - Use NULL or empty string to use video background instead - Static image is more efficient than video background - Image is loaded once and cached - Supported formats: BMP, PNG, JPEG, GIF, TIFF **Example (C++)**: ``` // Set office background image pChroma->chroma_put_image(L"C:\\Backgrounds\\office.jpg"); // Remove background image (use video input instead) pChroma->chroma_put_image(NULL); ``` **Example (C#)**: ``` // Virtual studio background chroma.chroma_put_image(@"C:\Backgrounds\studio.png"); // Remove static background chroma.chroma_put_image(null); ``` --- ## Complete Configuration Examples ### Example 1: Basic Green Screen Setup (C++) ``` #include "vf_eff_intf.h" HRESULT ConfigureBasicGreenScreen(IBaseFilter* pChromaFilter) { HRESULT hr; IVFChromaKey* pChroma = nullptr; hr = pChromaFilter->QueryInterface(IID_IVFChromaKey, (void**)&pChroma); if (FAILED(hr)) return hr; // Set green as key color pChroma->chroma_put_color(Chroma_Green); // Standard contrast thresholds pChroma->chroma_put_contrast(40, 80); // Set background image pChroma->chroma_put_image(L"C:\\Backgrounds\\office_background.jpg"); pChroma->Release(); return S_OK; } ``` ### Example 2: Weather Forecast Studio (C#) ``` using System; using VisioForge.DirectShowAPI; public class WeatherStudioSetup { public void ConfigureWeatherChromaKey(IBaseFilter chromaFilter) { var chroma = chromaFilter as IVFChromaKey; if (chroma == null) throw new NotSupportedException("IVFChromaKey not available"); // Blue screen for weather maps chroma.chroma_put_color((int)CVFChromaColor.Chroma_Blue); // Tighter thresholds for clean keying chroma.chroma_put_contrast(25, 60); // Weather map background chroma.chroma_put_image(@"C:\Weather\maps\current_radar.png"); } public void UpdateWeatherMap(IVFChromaKey chroma, string mapPath) { // Dynamically update background during broadcast chroma.chroma_put_image(mapPath); } } ``` ### Example 3: Virtual Production with Custom Color (C++) ``` HRESULT ConfigureVirtualProduction(IVFChromaKey* pChroma) { // Use specific green matching your physical backdrop // Measure actual color with color picker COLORREF customGreen = RGB(60, 220, 40); // Specific green shade pChroma->chroma_put_color(customGreen); // Professional-grade thresholds // Lower values for clean, well-lit green screen pChroma->chroma_put_contrast(15, 45); // Use pre-rendered virtual environment pChroma->chroma_put_image(L"D:\\VirtualSets\\studio_environment.png"); return S_OK; } ``` ### Example 4: Adaptive Chroma Key Settings (C#) ``` public class AdaptiveChromaKey { private IVFChromaKey _chroma; public void SetupForLightingConditions(string condition) { switch (condition.ToLower()) { case "perfect": // Clean, evenly lit green screen _chroma.chroma_put_color((int)CVFChromaColor.Chroma_Green); _chroma.chroma_put_contrast(15, 40); break; case "good": // Standard lighting _chroma.chroma_put_color((int)CVFChromaColor.Chroma_Green); _chroma.chroma_put_contrast(30, 70); break; case "challenging": // Uneven lighting or wrinkled backdrop _chroma.chroma_put_color((int)CVFChromaColor.Chroma_Green); _chroma.chroma_put_contrast(50, 110); break; case "outdoor": // Natural light, harder to control _chroma.chroma_put_color((int)CVFChromaColor.Chroma_Blue); _chroma.chroma_put_contrast(60, 130); break; } } public void TestThresholds() { // Start with tight keying for (int low = 10; low <= 60; low += 10) { int high = low + 40; _chroma.chroma_put_contrast(low, high); // User reviews result and selects best setting Console.WriteLine($"Testing: Low={low}, High={high}"); System.Threading.Thread.Sleep(2000); } } } ``` --- ## Chroma Keying Best Practices ### Lighting Setup 1. **Even Illumination** 2. Use multiple light sources 3. Avoid hotspots and shadows on backdrop 4. Maintain consistent color across entire screen 5. **Subject Separation** 6. Position subject 6-10 feet from backdrop 7. Prevents green spill on subject 8. Allows independent lighting control 9. **Backdrop Quality** 10. Use proper chroma key fabric or paint 11. Keep backdrop wrinkle-free 12. Maintain consistent color saturation ### Configuration Strategy 1. **Start Conservative** ``` // Begin with tight thresholds pChroma->chroma_put_contrast(20, 50); // Gradually increase if needed pChroma->chroma_put_contrast(30, 70); ``` 2. **Test Different Lighting** 3. Adjust thresholds for your specific setup 4. Save presets for different conditions 5. Document working values 6. **Color Selection** 7. Green: Standard choice (least in skin tones) 8. Blue: When green objects in scene 9. Custom: Match actual backdrop color for best results ### Quality Optimization 1. **Camera Settings** 2. Disable auto white balance 3. Manual focus 4. Reduce sharpening (prevents edge artifacts) 5. **Threshold Tuning** 6. Low value: Controls transparency threshold 7. High value: Controls edge softness 8. Wider range = softer edges 9. **Edge Quality** ``` Tight range (low=20, high=40): - Sharp edges - May show green fringe - Best for clean backdrops Wide range (low=30, high=90): - Softer edges - Better color bleeding tolerance - More forgiving of imperfect lighting ``` --- ## Common Chroma Key Scenarios ### Scenario 1: Corporate Video Production ``` // Clean studio environment pChroma->chroma_put_color(Chroma_Green); pChroma->chroma_put_contrast(25, 55); pChroma->chroma_put_image(L"corporate_office.jpg"); ``` **Characteristics**: - Controlled lighting - Professional green screen - Static office background - High quality requirements ### Scenario 2: Gaming Streamer ``` // Home studio setup pChroma->chroma_put_color(Chroma_Green); pChroma->chroma_put_contrast(35, 75); pChroma->chroma_put_image(NULL); // Use game video as background ``` **Characteristics**: - Consumer green screen - Variable lighting - Dynamic video background - Real-time performance critical ### Scenario 3: Weather Broadcasting ``` // Blue screen with weather maps pChroma->chroma_put_color(Chroma_Blue); pChroma->chroma_put_contrast(30, 65); pChroma->chroma_put_image(L"weather_map_current.png"); ``` **Characteristics**: - Blue screen (green used in weather maps) - Dynamically changing backgrounds - Professional lighting - Presenter clothing considerations ### Scenario 4: Virtual Event Hosting ``` // Virtual conference background pChroma->chroma_put_color(Chroma_Green); pChroma->chroma_put_contrast(40, 85); pChroma->chroma_put_image(L"conference_hall.jpg"); ``` **Characteristics**: - Home/office setup - Variable quality backdrops - Forgiving settings needed - Professional appearance desired --- ## Troubleshooting ### Issue: Green Spill on Subject **Symptoms**: Green halo or tint on subject edges **Solutions**: 1. Increase subject distance from backdrop 2. Adjust lighting to reduce reflection 3. Use tighter contrast range: ``` pChroma->chroma_put_contrast(15, 35); ``` 4. Consider color correction in post ### Issue: Uneven Keying **Symptoms**: Parts of backdrop not transparent **Solutions**: 1. Check backdrop lighting uniformity 2. Increase high threshold: ``` pChroma->chroma_put_contrast(30, 100); ``` 3. Verify backdrop color consistency 4. Consider using custom color matching: ``` // Sample actual backdrop color and use it pChroma->chroma_put_color(0x40DC28); // Measured color ``` ### Issue: Subject Parts Disappearing **Symptoms**: Subject clothing or features becoming transparent **Solutions**: 1. Avoid green/blue clothing 2. Reduce contrast range: ``` pChroma->chroma_put_contrast(50, 90); ``` 3. Switch key color if needed: ``` pChroma->chroma_put_color(Chroma_Blue); // If wearing green ``` ### Issue: Rough, Jagged Edges **Symptoms**: Poor edge quality, visible pixelation **Solutions**: 1. Widen contrast range for smoother gradient: ``` pChroma->chroma_put_contrast(25, 85); ``` 2. Improve lighting quality 3. Use higher quality video source 4. Ensure subject is well-separated from backdrop ### Issue: Performance Problems **Symptoms**: Dropped frames, stuttering **Solutions**: 1. Use static image background instead of video 2. Reduce output resolution 3. Optimize threshold values (don't make too wide) 4. Consider hardware-accelerated alternatives --- ## Parameter Reference Table ### Contrast Threshold Guidelines | Lighting Quality | Backdrop | Low | High | Edge Quality | Performance | | --- | --- | --- | --- | --- | --- | | **Excellent** | Clean, even | 15-25 | 35-50 | Sharp | Best | | **Good** | Minor variations | 25-35 | 50-75 | Good | Good | | **Fair** | Some unevenness | 35-50 | 75-100 | Soft | Moderate | | **Poor** | Uneven/wrinkled | 50-70 | 100-140 | Very soft | Lower | ### Color Selection Guide | Color | RGB | Pros | Cons | Best For | | --- | --- | --- | --- | --- | | **Green** | 0x00FF00 | Least in skin, bright | Not for green objects | General use | | **Blue** | 0x0000FF | Alternative to green | Denim/blue clothing | Special cases | | **Custom** | Varies | Exact match to backdrop | Requires calibration | Professional | --- ## Integration with Video Mixer Chroma key filter is often used with Video Mixer for advanced compositing: ``` // Chroma key filter removes green IVFChromaKey* pChroma = /* ... */; pChroma->chroma_put_color(Chroma_Green); pChroma->chroma_put_contrast(30, 70); // Video mixer combines subject with background IVFVideoMixer* pMixer = /* ... */; // Input 0: Background video // Input 1: Chroma-keyed subject (transparent background) ``` See [Video Mixer Interface](../video-mixer/) for details. --- ## Related Interfaces - **IVFVideoMixer** - Combine chroma-keyed video with backgrounds - **IVFEffects45** - Additional video effects - **IVFEffectsPro** - Advanced effect processing ## See Also - [Processing Filters Pack Overview](../../) - [Video Mixer Interface](../video-mixer/) - [Effects Reference](../../effects-reference/) - [Code Examples](../../examples/) ---END OF PAGE--- ## DirectShow Video Effects and Processing Filter API Reference **URL:** https://www.visioforge.com/help/docs/directshow/proc-filters/interfaces/effects-interface/ **Description:** DirectShow Processing Filters API reference for video effects, audio enhancement, resize, chroma key, and video mixing interfaces. **Tags:** DirectShow, C++, Windows, Effects, Mixing, Screen Capture, C# **API:** VideoEffectType, IVFEffectsPro, IVFResize, IBaseFilter, IVFAudioEnhancer # Processing Filters - Effects Interfaces Reference ## Overview This document provides comprehensive API reference for all interfaces in the DirectShow Processing Filters Pack. These interfaces enable video effects, audio enhancement, chroma keying, video mixing, screen capture, and advanced processing capabilities. --- ## Interface Quick Reference | Interface | GUID | Purpose | | --- | --- | --- | | **IVFEffects45** | {5E767DA8-97AF-4607-B95F-8CC6010B84CA} | Simple video effects | | **IVFEffectsPro** | {9A794ABE-98AD-45AF-BBB0-042172C74C79} | Advanced effects with sample grabber | | **IVFResize** | {12BC6F20-2812-4660-8684-10F3FD3B4487} | Video resize and crop | | **IVFVideoMixer** | {3318300E-F6F1-4d81-8BC3-9DB06B09F77A} | Multi-source video mixing | | **IVFChromaKey** | {AF6E8208-30E3-44f0-AAFE-787A6250BAB3} | Chroma keying (green screen) | | **IVFAudioEnhancer** | {C2C0512A-AE91-4B4D-B4E0-913A0227DCD7} | Audio channel gains | | **IVFAudioEnhancer3** | {915E95CE-70F6-4FA5-B608-9B0BCDBE06B3} | IEEE float audio output | | **IVFAudioChannelMapper** | {EDB8F865-0A81-4E98-866F-B6F5F17C8FC2} | Audio channel mapping | | **IVFScreenCapture3** | {259E0009-9963-4a71-91AE-34B96D754899} | Screen capture configuration | | **IVFMotDetConfig** | {B10E9A0C-3D99-46D4-A397-6E0BC5BC3D76} | Motion detection | | **IVFPushConfig** | {F1876E64-C7AC-4B5B-8F64-67B5BB8CEAE4} | Push source configuration | | --- | | | ## Video Effects Interfaces ### IVFEffects45 Simple interface for adding and managing video effects. **GUID**: `{5E767DA8-97AF-4607-B95F-8CC6010B84CA}` **C# Definition**: ``` [ComImport] [Guid("5E767DA8-97AF-4607-B95F-8CC6010B84CA")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFEffects45 { /// /// Adds video effect. /// [PreserveSig] void add_effect([In] VFVideoEffectSimple effect); /// /// Sets video effects settings. /// [PreserveSig] void set_effect_settings([In] VFVideoEffectSimple effect); /// /// Removes effect. /// [PreserveSig] void remove_effect([In] int id); /// /// Clears effects. /// [PreserveSig] void clear_effects(); } ``` **Methods**: | Method | Description | | --- | --- | | `add_effect` | Adds a new video effect to the processing chain | | `set_effect_settings` | Updates parameters of an existing effect | | `remove_effect` | Removes effect by its ID | | `clear_effects` | Removes all effects | **Example (C#)**: ``` var effects = filter as IVFEffects45; if (effects != null) { // Add blur effect var blur = new VFVideoEffectSimple { EffectType = VideoEffectType.Blur, Enabled = true, Id = 1 }; effects.add_effect(blur); // Add grayscale effect var gray = new VFVideoEffectSimple { EffectType = VideoEffectType.Greyscale, Enabled = true, Id = 2 }; effects.add_effect(gray); } ``` **VFVideoEffectSimple Structure**: ``` public struct VFVideoEffectSimple { public VideoEffectType EffectType; // Effect type public bool Enabled; // Enable/disable public int Id; // Unique identifier public VFTextLogo TextLogo; // Text logo parameters public VFGraphicalLogo GraphicalLogo; // Image logo parameters (also called ImageLogo) } ``` --- ### IVFEffectsPro Advanced effects interface with sample grabber callback support. **GUID**: `{9A794ABE-98AD-45AF-BBB0-042172C74C79}` **C# Definition**: ``` [ComImport] [Guid("9A794ABE-98AD-45AF-BBB0-042172C74C79")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFEffectsPro { /// /// Sets filter parts state. /// [PreserveSig] void set_enabled( [In, MarshalAs(UnmanagedType.Bool)] bool effects, [In, MarshalAs(UnmanagedType.Bool)] bool motdet, [In, MarshalAs(UnmanagedType.Bool)] bool chroma, [In, MarshalAs(UnmanagedType.Bool)] bool sg); /// /// Sets callback for RGB24 buffer. /// [PreserveSig] int set_sg_callback_24([MarshalAs(UnmanagedType.FunctionPtr)] BufferCBProc callback); /// /// Sets callback for RGB32 buffer. /// [PreserveSig] int set_sg_callback_32([MarshalAs(UnmanagedType.FunctionPtr)] BufferCBProc callback); /// /// Sets sample grabber handle. /// [PreserveSig] int put_sg_app_handle(object handle); /// /// Sets sample grabber unique handle id. /// [PreserveSig] int put_sg_app_handle_id([MarshalAs(UnmanagedType.U4)] uint handle_id); } ``` **Buffer Callback Delegate**: ``` public delegate int BufferCBProc( [In] IntPtr handle, [In] uint handle_id, [In] IntPtr pBuffer, int bufferLen, int width, int height, long startTime, long stopTime, [MarshalAs(UnmanagedType.Bool)] ref bool updateFrame); ``` **Methods**: | Method | Description | |--------|-------------| | `set_enabled` | Enable/disable filter components (effects, motion detection, chroma key, sample grabber) | | `set_sg_callback_24` | Set callback for RGB24 format frames | | `set_sg_callback_32` | Set callback for RGB32 format frames | | `put_sg_app_handle` | Set application handle for callbacks | | `put_sg_app_handle_id` | Set unique identifier for callbacks | **Example (C#)**: ``` var effectsPro = filter as IVFEffectsPro; if (effectsPro != null) { // Enable effects and sample grabber effectsPro.set_enabled( effects: true, motdet: false, chroma: false, sg: true); // Set up frame callback effectsPro.put_sg_app_handle(this.Handle); effectsPro.put_sg_app_handle_id(12345); effectsPro.set_sg_callback_32(OnFrameCallback); } private int OnFrameCallback( IntPtr handle, uint handle_id, IntPtr pBuffer, int bufferLen, int width, int height, long startTime, long stopTime, ref bool updateFrame) { // Process frame data // pBuffer points to RGB32 data return 0; } ``` --- ## Video Resize Interface ### IVFResize Controls video resizing, cropping, rotation, and resize quality. **GUID**: `{12BC6F20-2812-4660-8684-10F3FD3B4487}` **C# Definition**: ``` [ComImport] [Guid("12BC6F20-2812-4660-8684-10F3FD3B4487")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFResize { /// /// Sets resolution. /// [PreserveSig] int put_Resolution([In] uint x, [In] uint y); /// /// Sets resize mode. /// [PreserveSig] int put_ResizeMode([In] VFResizeMode mode, [In] bool letterbox); /// /// Sets crop coordinates. /// [PreserveSig] int put_Crop([In] uint left, [In] uint top, [In] uint right, [In] uint bottom); /// /// Sets filter mode. /// [PreserveSig] int put_FilterMode([In] VFResizeFilterMode mode); /// /// Sets rotate mode. /// [PreserveSig] int put_RotateMode([In] VFRotateMode mode); } ``` **VFResizeMode Enumeration**: ``` public enum VFResizeMode { rmStretch = 0, // Stretch to fit (may distort) rmLetterbox = 1, // Maintain aspect ratio with letterbox rmCrop = 2 // Crop to fit } ``` **VFResizeFilterMode Enumeration**: ``` public enum VFResizeFilterMode { NearestNeighbor = 0, // Fastest, lowest quality Bilinear = 1, // Good quality, fast Bicubic = 2, // High quality (default) Lanczos = 3 // Highest quality, slower } ``` **VFRotateMode Enumeration**: ``` public enum VFRotateMode { RM_0 = 0, // No rotation RM_90 = 1, // 90 degrees clockwise RM_180 = 2, // 180 degrees RM_270 = 3 // 270 degrees clockwise (90 CCW) } ``` **Example (C#)**: ``` var resize = filter as IVFResize; if (resize != null) { // Resize to 1280x720 with letterbox resize.put_Resolution(1280, 720); resize.put_ResizeMode(VFResizeMode.rmLetterbox, true); // Use high quality bicubic resize resize.put_FilterMode(VFResizeFilterMode.Bicubic); // Rotate 90 degrees resize.put_RotateMode(VFRotateMode.RM_90); // Crop 10 pixels from each side resize.put_Crop(10, 10, 10, 10); } ``` --- ## Audio Enhancement Interfaces ### IVFAudioEnhancer Controls audio channel gains, auto gain, and normalization. **GUID**: `{C2C0512A-AE91-4B4D-B4E0-913A0227DCD7}` **C# Definition**: ``` [ComImport] [Guid("C2C0512A-AE91-4B4D-B4E0-913A0227DCD7")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFAudioEnhancer { [PreserveSig] int get_auto_gain([Out, MarshalAs(UnmanagedType.Bool)] out bool auto_gain); [PreserveSig] int set_auto_gain([MarshalAs(UnmanagedType.Bool)] bool auto_gain); [PreserveSig] int get_normalize([Out, MarshalAs(UnmanagedType.Bool)] out bool normalize); [PreserveSig] int set_normalize([MarshalAs(UnmanagedType.Bool)] bool normalize); [PreserveSig] int get_input_gains(out float l, out float c, out float r, out float sl, out float sr, out float lfe); [PreserveSig] int set_input_gains(float l, float c, float r, float sl, float sr, float lfe); [PreserveSig] int get_output_gains(out float l, out float c, out float r, out float sl, out float sr, out float lfe); [PreserveSig] int set_output_gains(float l, float c, float r, float sl, float sr, float lfe); [PreserveSig] int get_time_shift(out int time_shift); [PreserveSig] int set_time_shift(int time_shift); } ``` **Channel Parameters**: - `l` - Left channel - `c` - Center channel - `r` - Right channel - `sl` - Surround left - `sr` - Surround right - `lfe` - Low frequency effects (subwoofer) **Example (C#)**: ``` var audio = filter as IVFAudioEnhancer; if (audio != null) { // Enable auto gain and normalization audio.set_auto_gain(true); audio.set_normalize(true); // Boost left and right channels by 20% audio.set_output_gains( l: 1.2f, c: 1.0f, r: 1.2f, sl: 1.0f, sr: 1.0f, lfe: 1.0f); } ``` --- ### IVFAudioEnhancer3 Enables IEEE floating-point audio output format. **GUID**: `{915E95CE-70F6-4FA5-B608-9B0BCDBE06B3}` **C# Definition**: ``` [ComImport] [Guid("915E95CE-70F6-4FA5-B608-9B0BCDBE06B3")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFAudioEnhancer3 { [PreserveSig] int get_ieee_output_enabled([Out, MarshalAs(UnmanagedType.Bool)] out bool enabled); [PreserveSig] int set_ieee_output_enabled([MarshalAs(UnmanagedType.Bool)] bool enabled); } ``` **Example (C#)**: ``` var audio3 = filter as IVFAudioEnhancer3; if (audio3 != null) { // Enable IEEE float output for professional audio processing audio3.set_ieee_output_enabled(true); } ``` --- ## Screen Capture Interface ### IVFScreenCapture3 Controls screen capture mode, region, frame rate, and mouse cursor visibility. **GUID**: `{259E0009-9963-4a71-91AE-34B96D754899}` **C# Definition**: ``` [ComImport] [Guid("259E0009-9963-4a71-91AE-34B96D754899")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFScreenCapture3 { [PreserveSig] int init(); [PreserveSig] int set_fps([In] double fps); [PreserveSig] int set_rect([In] VFRect rect); [PreserveSig] int set_mouse([In] bool draw); [PreserveSig] int set_display_index([In] int index); [PreserveSig] int set_mode([In] VFScreenCaptureMode mode); [PreserveSig] int refresh_pic(); [PreserveSig] int set_stream([In] IStream stream, [In] long length); [PreserveSig] int set_window_handle([In] IntPtr handle); [PreserveSig] int get_window_size([In] IntPtr handle, [Out] out int width, [Out] out int height); } ``` **VFScreenCaptureMode Enumeration**: ``` public enum VFScreenCaptureMode { scmScreen = 0, // Capture entire screen or region scmWindow = 1, // Capture specific window scmMemory = 2 // Use memory stream as source } ``` **VFRect Structure**: ``` public struct VFRect { public int Left; public int Top; public int Right; public int Bottom; } ``` **Example (C#)**: ``` var capture = filter as IVFScreenCapture3; if (capture != null) { // Initialize capture capture.init(); // Capture at 30 FPS capture.set_fps(30.0); // Capture specific region var rect = new VFRect { Left = 100, Top = 100, Right = 1920, Bottom = 1080 }; capture.set_rect(rect); // Show mouse cursor capture.set_mouse(true); // Capture primary display capture.set_display_index(0); // Set screen capture mode capture.set_mode(VFScreenCaptureMode.scmScreen); } ``` **Example: Window Capture**: ``` // Capture specific window IntPtr windowHandle = FindWindow(null, "Calculator"); if (windowHandle != IntPtr.Zero) { capture.set_mode(VFScreenCaptureMode.scmWindow); capture.set_window_handle(windowHandle); // Get window size capture.get_window_size(windowHandle, out int width, out int height); Console.WriteLine($"Window size: {width}x{height}"); } ``` --- ## Common Structures and Enumerations ### VFVideoEffectType Complete enumeration of all available video effects. ``` public enum VideoEffectType { Undefined = -1, // Undefined effect // Text and Graphics TextLogo = 0, // Text overlay ImageLogo = 1, // Image/logo overlay // Color Filters Blue, // Blue color filter FilterBlue, // Blue channel filter FilterGreen, // Green channel filter FilterRed, // Red channel filter Green, // Green color filter Red, // Red color filter Greyscale, // Convert to grayscale // Image Adjustments Blur, // Blur effect Contrast, // Contrast adjustment Darkness, // Darken effect Lightness, // Brighten effect Saturation, // Saturation adjustment Sharpen, // Sharpen effect Smooth, // Smooth/soften effect // Spatial Transformations FlipDown, // Flip vertically (deprecated: use FlipVertical) FlipRight, // Flip horizontally (deprecated: use FlipHorizontal) MirrorHorizontal, // Mirror horizontally MirrorVertical, // Mirror vertically Rotate, // Rotate effect Zoom, // Zoom effect Pan, // Pan/position effect // Artistic Effects ColorNoise, // Color noise MonoNoise, // Monochrome noise Mosaic, // Mosaic/pixelate effect Posterize, // Posterize effect ShakeDown, // Shake effect Solorize, // Solarize effect Spray, // Spray effect Invert, // Invert colors // Denoising DenoiseCAST, // CAST denoising algorithm DenoiseAdaptive, // Adaptive denoising DenoiseMosquito, // Mosquito noise reduction DenoiseSNR, // SNR-based denoising MaxineDenoise, // NVIDIA Maxine AI denoising // Deinterlacing DeinterlaceBlend, // Deinterlace (blend method) DeinterlaceTriangle, // Deinterlace (triangle method) DeinterlaceCAVT, // Deinterlace (CAVT method) // Transitions FadeIn, // Fade-in transition FadeOut, // Fade-out transition // Advanced Effects ScrollingTextLogo, // Scrolling text overlay MaxineArtifactReduction, // NVIDIA Maxine artifact reduction LUT, // Look-Up Table color grading } ``` **Effect Categories**: | Category | Effects | | --- | --- | | **Text & Graphics** | TextLogo, ImageLogo, ScrollingTextLogo | | **Color Filters** | Blue, FilterBlue, FilterGreen, FilterRed, Green, Red, Greyscale | | **Image Adjustments** | Blur, Contrast, Darkness, Lightness, Saturation, Sharpen, Smooth | | **Spatial** | FlipDown, FlipRight, MirrorHorizontal, MirrorVertical, Rotate, Zoom, Pan | | **Artistic** | ColorNoise, MonoNoise, Mosaic, Posterize, ShakeDown, Solorize, Spray, Invert | | **Denoising** | DenoiseCAST, DenoiseAdaptive, DenoiseMosquito, DenoiseSNR, MaxineDenoise | | **Deinterlacing** | DeinterlaceBlend, DeinterlaceTriangle, DeinterlaceCAVT | | **Transitions** | FadeIn, FadeOut | | **Advanced** | LUT, MaxineArtifactReduction | **NVIDIA Maxine Effects** (require NVIDIA RTX GPU): - `MaxineDenoise` - AI-powered video denoising - `MaxineArtifactReduction` - Reduce compression artifacts --- ### VFTextLogo Comprehensive text logo configuration structure. ``` [StructLayout(LayoutKind.Sequential)] public struct VFTextLogo { public int X; // X position public int Y; // Y position public bool TransparentBg; // Transparent background public int FontSize; // Font size (points) public bool FontItalic; // Italic style public bool FontBold; // Bold style public bool FontUnderline; // Underline style public bool FontStrikeout; // Strikeout style public int FontColor; // Font color (RGB) public int BGColor; // Background color public bool RightToLeft; // RTL text direction public bool Vertical; // Vertical text public int Align; // Text alignment public int DrawQuality; // Draw quality public int Antialiasing; // Antialiasing mode public int RectWidth; // Bounding rect width public int RectHeight; // Bounding rect height public int RotationMode; // Text rotation public int FlipMode; // Text flip mode public int Transp; // Transparency (0-255) public bool Gradient; // Enable gradient public int GradientMode; // Gradient direction public int GradientColor1; // Gradient start color public int GradientColor2; // Gradient end color public int InnerBorderColor; // Inner border color public int OuterBorderColor; // Outer border color public int InnerBorderSize; // Inner border width public int OuterBorderSize; // Outer border width public int DrawMode; // Draw mode public int BorderMode; // Border style public int EffectMode; // Effect mode public int ShapeType; // Text shape } ``` --- ### VFGraphicalLogo Image logo configuration structure. ``` [StructLayout(LayoutKind.Sequential)] public struct VFGraphicalLogo { public int X; // X position public int Y; // Y position public int Width; // Image width public int Height; // Image height public int Transp; // Transparency (0-255) public int RotationMode; // Rotation angle public int FlipMode; // Flip mode public VFVideoEffectStretchMode StretchMode; // Stretch mode } ``` --- ## Complete Configuration Examples ### Example 1: Professional Text Overlay (C#) ``` using VisioForge.DirectShowAPI; public void AddProfessionalTextOverlay(IBaseFilter effectsFilter) { var effects = effectsFilter as IVFEffects45; if (effects == null) return; var textEffect = new VFVideoEffectSimple { EffectType = VideoEffectType.TextLogo, Enabled = true, Id = 1, TextLogo = new VFTextLogo { X = 50, Y = 50, FontSize = 36, FontBold = true, FontColor = 0xFFFFFF, // White TransparentBg = true, Antialiasing = 2, // High quality Transp = 230, // Slightly transparent Gradient = true, GradientMode = 0, // Horizontal GradientColor1 = 0xFFFFFF, // White GradientColor2 = 0x0080FF, // Orange BorderMode = 6, // Filled outline OuterBorderColor = 0x000000, // Black OuterBorderSize = 2 } }; effects.add_effect(textEffect); } ``` ### Example 2: Multi-Effect Chain (C#) ``` public void ApplyMultipleEffects(IBaseFilter effectsFilter) { var effects = effectsFilter as IVFEffects45; if (effects == null) return; // 1. Deinterlace effects.add_effect(new VFVideoEffectSimple { EffectType = VideoEffectType.DeinterlaceBlend, Enabled = true, Id = 1 }); // 2. Denoise effects.add_effect(new VFVideoEffectSimple { EffectType = VideoEffectType.DenoiseAdaptive, Enabled = true, Id = 2 }); // 3. Adjust contrast effects.add_effect(new VFVideoEffectSimple { EffectType = VideoEffectType.Contrast, Enabled = true, Id = 3 }); // 4. Add watermark effects.add_effect(new VFVideoEffectSimple { EffectType = VideoEffectType.ImageLogo, Enabled = true, Id = 4, GraphicalLogo = new VFGraphicalLogo { X = 1800, Y = 50, Width = 100, Height = 100, Transp = 200, StretchMode = VFVideoEffectStretchMode.Stretch } }); } ``` ### Example 3: High-Quality Resize with Rotation (C#) ``` public void ConfigureResizeAndRotate(IBaseFilter resizeFilter) { var resize = resizeFilter as IVFResize; if (resize == null) return; // Resize to 4K resize.put_Resolution(3840, 2160); // Maintain aspect ratio with letterbox resize.put_ResizeMode(VFResizeMode.rmLetterbox, true); // Use highest quality Lanczos algorithm resize.put_FilterMode(VFResizeFilterMode.Lanczos); // Rotate 90 degrees clockwise resize.put_RotateMode(VFRotateMode.RM_90); // No cropping resize.put_Crop(0, 0, 0, 0); } ``` ### Example 4: Sample Grabber with Effects (C#) ## ``` public class EffectsWithFrameCapture { private IVFEffectsPro _effectsPro; public void Setup(IBaseFilter effectsFilter) { _effectsPro = effectsFilter as IVFEffectsPro; if (_effectsPro == null) return; // Enable effects and sample grabber _effectsPro.set_enabled( effects: true, motdet: false, chroma: false, sg: true); // Set up callback _effectsPro.put_sg_app_handle(IntPtr.Zero); _effectsPro.put_sg_app_handle_id(1); _effectsPro.set_sg_callback_32(OnFrameReceived); } private int OnFrameReceived( IntPtr handle, uint handle_id, IntPtr pBuffer, int bufferLen, int width, int height, long startTime, long stopTime, ref bool updateFrame) { // Process frame Console.WriteLine($"Frame: {width}x{height}, {bufferLen} bytes"); // Can modify frame data in pBuffer // Set updateFrame = true to update the frame return 0; } } ``` ## See Also - [Video Mixer Interface](../video-mixer/) - Multi-source video mixing - [Chroma Key Interface](../chroma-key/) - Green screen compositing - [Effects Reference](../../effects-reference/) - Complete effects catalog - [Processing Filters Pack Overview](../../) - [Code Examples](../../examples/) ---END OF PAGE--- ## DirectShow Video Mixer Filter - PIP and Chroma Key API **URL:** https://www.visioforge.com/help/docs/directshow/proc-filters/interfaces/video-mixer/ **Description:** IVFVideoMixer interface for mixing 2-16 video sources with PIP, chroma keying, transparency, and customizable layout configurations. **Tags:** DirectShow, C++, Windows, Effects, Mixing, Webcam, C# **API:** IVFVideoMixer, IBaseFilter, IVFChromaKey # IVFVideoMixer Interface Reference ## Overview The `IVFVideoMixer` interface provides comprehensive control over multi-source video mixing in DirectShow applications. This interface enables Picture-in-Picture (PIP), video compositing, chroma keying, and flexible layout management for combining multiple video streams into a single output. The Video Mixer filter can handle 2-16 input video sources, each with independent position, size, transparency, and z-order configuration. ## Interface Definition - **Interface Name**: `IVFVideoMixer` - **GUID**: `{3318300E-F6F1-4d81-8BC3-9DB06B09F77A}` - **Inherits From**: `IUnknown` - **Header File**: `yk_video_mixer_filter_define.h` (C++), `IVFVideoMixer.cs` (.NET) ## Capabilities - **Input Pins**: 2-16 simultaneous video sources - **Chroma Keying**: Green/blue screen support per input - **Resize Quality**: Multiple interpolation algorithms - **Z-Order**: Independent layering control - **Transparency**: Per-input alpha blending - **Position/Size**: Pixel-accurate placement --- ## Methods Reference ### Input Parameter Management #### SetInputParam Configures parameters for a specific input pin. **Syntax (C++)**: ``` int SetInputParam(int pin_index, VFPIPVideoInputParam param); ``` **Syntax (C#)**: ``` [PreserveSig] int SetInputParam([In] int pin_index, [In] VFPIPVideoInputParam param); ``` **Parameters**: - `pin_index`: Zero-based input pin index (0 = first input, 1 = second, etc.) - `param`: Structure containing input configuration (see below) **Returns**: `0` on success, error code otherwise. **VFPIPVideoInputParam Structure**: | Field | Type | Description | |-------|------|-------------| | `Enabled` | bool | Enable/disable this input | | `Left` | int | X position (pixels) | | `Top` | int | Y position (pixels) | | `Width` | int | Width (pixels) | | `Height` | int | Height (pixels) | | `Alpha` | int | Transparency (0-255, 255=opaque) | | `Visible` | bool | Visibility flag | | `ZOrder` | int | Layer order (higher = foreground) | | `StretchMode` | VFPIPResizeQuality | Resize quality | **Usage Notes**: - Pin 0 is typically the background/main source - Pins 1+ are overlay sources - Position (0,0) is top-left corner - Size can differ from source resolution (automatic scaling) - Alpha blending requires some GPU overhead **Example (C++)**: ``` IVFVideoMixer* pMixer = nullptr; pFilter->QueryInterface(IID_IVFVideoMixer, (void**)&pMixer); // Configure second input (overlay) VFPIPVideoInputParam param; param.Enabled = true; param.Visible = true; param.Left = 50; param.Top = 50; param.Width = 640; param.Height = 360; param.Alpha = 255; // Fully opaque param.ZOrder = 10; // On top of background pMixer->SetInputParam(1, param); pMixer->Release(); ``` **Example (C#)**: ``` var mixer = filter as IVFVideoMixer; // Configure PIP in bottom-right corner var param = new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = 1600, // Assuming 1920x1080 output Top = 820, Width = 320, // Small PIP Height = 180, Alpha = 255, ZOrder = 100 // Top layer }; mixer.SetInputParam(1, param); ``` --- #### GetInputParam Retrieves current parameters for a specific input pin. **Syntax (C++)**: ``` int GetInputParam(int pin_index, VFPIPVideoInputParam *param); ``` **Syntax (C#)**: ``` [PreserveSig] int GetInputParam([In] int pin_index, [Out] out VFPIPVideoInputParam param); ``` **Parameters**: - `pin_index`: Zero-based input pin index - `param`: [out] Receives current input configuration **Returns**: `0` on success. **Example (C++)**: ``` VFPIPVideoInputParam param; pMixer->GetInputParam(1, ¶m); printf("Input 1 position: %d,%d\n", param.Left, param.Top); printf("Input 1 size: %dx%d\n", param.Width, param.Height); ``` --- #### GetInputParam2 Retrieves parameters by pin interface reference instead of index. **Syntax (C++)**: ``` int GetInputParam2(IPin *pin, VFPIPVideoInputParam *param); ``` **Syntax (C#)**: ``` [PreserveSig] int GetInputParam2([In] object pin, [Out] out VFPIPVideoInputParam param); ``` **Parameters**: - `pin`: DirectShow IPin interface pointer - `param`: [out] Receives input configuration **Returns**: `0` on success. **Usage Notes**: - Alternative to GetInputParam when you have pin reference - Useful when enumerating pins dynamically --- ### Output Configuration #### SetOutputParam Configures the mixer's output video format. **Syntax (C++)**: ``` int SetOutputParam(VFPIPVideoOutputParam param); ``` **Syntax (C#)**: ``` [PreserveSig] int SetOutputParam([In] VFPIPVideoOutputParam param); ``` **Parameters**: - `param`: Output configuration structure **VFPIPVideoOutputParam Structure**: | Field | Type | Description | | --- | --- | --- | | `Width` | int | Output width (pixels) | | `Height` | int | Output height (pixels) | | `FrameRate` | double | Output frame rate (fps) | | `BackgroundColor` | COLORREF | Background color (RGB) | **Usage Notes**: - Must be called before connecting downstream filters - All inputs are scaled/positioned relative to output size - Frame rate can differ from inputs (mixer handles timing) **Example (C++)**: ``` VFPIPVideoOutputParam output; output.Width = 1920; output.Height = 1080; output.FrameRate = 30.0; output.BackgroundColor = RGB(0, 0, 0); // Black background pMixer->SetOutputParam(output); ``` **Example (C#)**: ``` var output = new VFPIPVideoOutputParam { Width = 1280, Height = 720, FrameRate = 60.0, BackgroundColor = 0x003300 // Dark green }; mixer.SetOutputParam(output); ``` --- #### GetOutputParam Retrieves current output configuration. **Syntax (C++)**: ``` int GetOutputParam(VFPIPVideoOutputParam *param); ``` **Syntax (C#)**: ``` [PreserveSig] int GetOutputParam([Out] out VFPIPVideoOutputParam param); ``` **Parameters**: - `param`: [out] Receives output configuration **Returns**: `0` on success. --- ### Chroma Key Configuration #### SetChromaSettings Configures chroma key (green/blue screen) settings for compositing. **Syntax (C++)**: ``` int SetChromaSettings(bool enabled, int color, int tolerance1, int tolerance2); ``` **Syntax (C#)**: ``` [PreserveSig] int SetChromaSettings([In, MarshalAs(UnmanagedType.Bool)] bool enabled, int color, int tolerance1, int tolerance2); ``` **Parameters**: - `enabled`: Enable/disable chroma keying - `color`: Key color (0=green, 1=blue, 2=red, or custom RGB) - `tolerance1`: Color matching tolerance (0-255) - `tolerance2`: Edge tolerance (0-255) **Returns**: `0` on success. **Usage Notes**: - Applies to all inputs that have chroma color - Lower tolerance = stricter color matching - Higher tolerance = more colors removed (may affect subject) - tolerance2 helps with edge smoothing **Chroma Color Values**: - `0` - Green (most common) - `1` - Blue - `2` - Red - Custom RGB value **Example (C++)**: ``` // Enable green screen with moderate tolerance pMixer->SetChromaSettings(true, 0, 50, 30); ``` **Example (C#)**: ``` // Blue screen with tight tolerance mixer.SetChromaSettings(true, 1, 30, 20); // Disable chroma keying mixer.SetChromaSettings(false, 0, 0, 0); ``` --- ### Layer Order Management #### SetInputOrder Sets the z-order (layer order) for a specific input. **Syntax (C++)**: ``` int SetInputOrder(int pin_index, int order); ``` **Syntax (C#)**: ``` [PreserveSig] int SetInputOrder(int pin_index, int order); ``` **Parameters**: - `pin_index`: Zero-based input pin index - `order`: Z-order value (higher = foreground) **Returns**: `0` on success. **Usage Notes**: - Higher order values render on top - Typical range: 0-100 - Can be changed dynamically during playback - Alternative to setting ZOrder in VFPIPVideoInputParam **Example (C++)**: ``` // Background pMixer->SetInputOrder(0, 0); // Middle layer pMixer->SetInputOrder(1, 50); // Top overlay pMixer->SetInputOrder(2, 100); ``` --- ### Quality Configuration #### SetResizeQuality Sets the resize quality/algorithm for all inputs. **Syntax (C++)**: ``` int SetResizeQuality(VFPIPResizeQuality quality); ``` **Syntax (C#)**: ``` [PreserveSig] int SetResizeQuality(VFPIPResizeQuality quality); ``` **Parameters**: - `quality`: Resize quality mode **VFPIPResizeQuality Enumeration**: | Value | Algorithm | Quality | Speed | Use Case | | --- | --- | --- | --- | --- | | **NearestNeighbor** | Nearest pixel | Low | ★★★★★ | Pixel art, fast preview | | **Bilinear** | Linear interpolation | Medium | ★★★★☆ | Standard quality | | **Bicubic** | Cubic interpolation | High | ★★★☆☆ | High quality (default) | | **Lanczos** | Lanczos-3 | Highest | ★★☆☆☆ | Professional quality | **Usage Notes**: - Bicubic is recommended for most use cases - Lanczos for maximum quality when performance allows - Bilinear for real-time performance - NearestNeighbor only for special cases **Example (C++)**: ``` // High quality mixing pMixer->SetResizeQuality(VFPIPResizeQuality::Lanczos); // Performance mode pMixer->SetResizeQuality(VFPIPResizeQuality::Bilinear); ``` --- ## Complete Configuration Examples ### Example 1: Picture-in-Picture (C++) ``` #include "yk_video_mixer_filter_define.h" HRESULT ConfigurePIPLayout(IBaseFilter* pMixerFilter) { HRESULT hr; IVFVideoMixer* pMixer = nullptr; hr = pMixerFilter->QueryInterface(IID_IVFVideoMixer, (void**)&pMixer); if (FAILED(hr)) return hr; // Set 1080p output VFPIPVideoOutputParam output; output.Width = 1920; output.Height = 1080; output.FrameRate = 30.0; output.BackgroundColor = RGB(0, 0, 0); pMixer->SetOutputParam(output); // Configure main video (input 0 - background) VFPIPVideoInputParam main; main.Enabled = true; main.Visible = true; main.Left = 0; main.Top = 0; main.Width = 1920; main.Height = 1080; main.Alpha = 255; main.ZOrder = 0; // Background pMixer->SetInputParam(0, main); // Configure PIP (input 1 - bottom-right corner) VFPIPVideoInputParam pip; pip.Enabled = true; pip.Visible = true; pip.Left = 1560; // 1920 - 360 (width) + margin pip.Top = 860; // 1080 - 220 (height) + margin pip.Width = 360; pip.Height = 202; // 16:9 aspect pip.Alpha = 255; pip.ZOrder = 100; // Foreground pMixer->SetInputParam(1, pip); // High quality resize pMixer->SetResizeQuality(VFPIPResizeQuality::Bicubic); pMixer->Release(); return S_OK; } ``` ### Example 2: Split Screen (C#) ``` using VisioForge.DirectShowAPI; public class SplitScreenMixer { public void ConfigureSplitScreen(IBaseFilter mixerFilter) { var mixer = mixerFilter as IVFVideoMixer; if (mixer == null) throw new NotSupportedException("IVFVideoMixer not available"); // 1920x1080 output var output = new VFPIPVideoOutputParam { Width = 1920, Height = 1080, FrameRate = 30.0, BackgroundColor = 0x000000 }; mixer.SetOutputParam(output); // Left half - Input 0 var leftInput = new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = 0, Top = 0, Width = 960, // Half width Height = 1080, Alpha = 255, ZOrder = 0 }; mixer.SetInputParam(0, leftInput); // Right half - Input 1 var rightInput = new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = 960, // Offset by half Top = 0, Width = 960, Height = 1080, Alpha = 255, ZOrder = 0 }; mixer.SetInputParam(1, rightInput); mixer.SetResizeQuality(VFPIPResizeQuality.Bicubic); } } ``` ### Example 3: Chroma Key Overlay (C++) ``` HRESULT ConfigureChromaKeyOverlay(IVFVideoMixer* pMixer) { // 1080p output VFPIPVideoOutputParam output; output.Width = 1920; output.Height = 1080; output.FrameRate = 30.0; output.BackgroundColor = RGB(0, 0, 0); pMixer->SetOutputParam(output); // Background scene (input 0) VFPIPVideoInputParam background; background.Enabled = true; background.Visible = true; background.Left = 0; background.Top = 0; background.Width = 1920; background.Height = 1080; background.Alpha = 255; background.ZOrder = 0; pMixer->SetInputParam(0, background); // Person in front of green screen (input 1) VFPIPVideoInputParam subject; subject.Enabled = true; subject.Visible = true; subject.Left = 400; subject.Top = 100; subject.Width = 1120; subject.Height = 880; subject.Alpha = 255; subject.ZOrder = 10; pMixer->SetInputParam(1, subject); // Enable green screen chroma keying pMixer->SetChromaSettings( true, // Enable 0, // Green 60, // Color tolerance 40 // Edge tolerance ); // High quality for best chroma key edges pMixer->SetResizeQuality(VFPIPResizeQuality::Lanczos); return S_OK; } ``` ### Example 4: Multi-Camera Grid (C#) ## ``` public void Configure2x2Grid(IVFVideoMixer mixer) { // 1920x1080 output var output = new VFPIPVideoOutputParam { Width = 1920, Height = 1080, FrameRate = 30.0, BackgroundColor = 0x101010 // Dark gray }; mixer.SetOutputParam(output); int cellWidth = 960; int cellHeight = 540; int gap = 10; // Top-left camera (input 0) mixer.SetInputParam(0, new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = gap, Top = gap, Width = cellWidth - gap * 2, Height = cellHeight - gap * 2, Alpha = 255, ZOrder = 0 }); // Top-right camera (input 1) mixer.SetInputParam(1, new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = cellWidth + gap, Top = gap, Width = cellWidth - gap * 2, Height = cellHeight - gap * 2, Alpha = 255, ZOrder = 0 }); // Bottom-left camera (input 2) mixer.SetInputParam(2, new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = gap, Top = cellHeight + gap, Width = cellWidth - gap * 2, Height = cellHeight - gap * 2, Alpha = 255, ZOrder = 0 }); // Bottom-right camera (input 3) mixer.SetInputParam(3, new VFPIPVideoInputParam { Enabled = true, Visible = true, Left = cellWidth + gap, Top = cellHeight + gap, Width = cellWidth - gap * 2, Height = cellHeight - gap * 2, Alpha = 255, ZOrder = 0 }); mixer.SetResizeQuality(VFPIPResizeQuality.Bicubic); } ``` ## Common Mixing Scenarios ### Scenario 1: News Broadcast Style ``` +------------------------------------------+ | | | Main Camera (full screen) | | | | +-----------+ | | | Guest | | | | Camera | | | +-----------+ | +------------------------------------------+ ``` **Configuration**: - Input 0: Main camera (1920x1080) - Input 1: Guest PIP (320x180, bottom-right) - Z-Order: Guest on top - Resize Quality: Bicubic ### Scenario 2: Gaming Stream ``` +------------------------------------------+ | | | Game Capture (main) | | | | +----------+ | | | Webcam | | | +----------+ | +------------------------------------------+ ``` **Configuration**: - Input 0: Game capture (1920x1080) - Input 1: Webcam (280x210, top-left) - Optional: Chroma key if webcam has green screen - Z-Order: Webcam on top ### Scenario 3: Virtual Production ``` +------------------------------------------+ | | | Background Scene (pre-rendered) | | | | [Person with green screen | | composited on top] | | | +------------------------------------------+ ``` **Configuration**: - Input 0: Virtual background - Input 1: Camera with green screen - Chroma key: Enabled, green, tolerance 60/40 - Resize Quality: Lanczos for best edge quality --- ## Performance Considerations ### CPU/GPU Usage **Low Impact Configurations**: - 2-4 inputs - Bilinear resize - No chroma keying - No transparency (Alpha = 255) **Medium Impact**: - 5-8 inputs - Bicubic resize - Basic chroma keying - Some transparency **High Impact**: - 9+ inputs - Lanczos resize - Complex chroma keying - Multiple transparent layers ### Optimization Tips 1. **Use appropriate resize quality**: 2. Preview: Bilinear 3. Production: Bicubic 4. Maximum quality: Lanczos (if performance allows) 5. **Minimize chroma keying overhead**: 6. Only enable when needed 7. Use tight tolerance values 8. Consider hardware-accelerated alternative 9. **Limit number of inputs**: 10. Each input adds processing overhead 11. Disable unused inputs (Enabled = false) 12. **Match source resolutions**: 13. Less scaling = better performance 14. Pre-scale sources if possible --- ## Best Practices ### Layout Design 1. **Plan z-order carefully** - Background lowest, overlays highest 2. **Leave margins** - Don't position elements at exact edges 3. **Maintain aspect ratios** - Avoid distortion 4. **Test at target resolution** - Verify positioning accuracy ### Chroma Keying 1. **Proper lighting** - Even lighting on green screen 2. **Adjust tolerance** - Start low, increase gradually 3. **Quality setting** - Use Lanczos for best edges 4. **Test conditions** - Different lighting scenarios ### Dynamic Changes 1. **Update parameters smoothly** - Avoid abrupt position changes 2. **Cache configurations** - Store presets for quick switching 3. **Validate parameters** - Check bounds before applying 4. **Handle errors** - Check return values --- ## Troubleshooting ### Issue: Video Not Appearing **Check**: - `Enabled = true` - `Visible = true` - `Alpha > 0` - Position within output bounds - Source filter is running ### Issue: Poor Quality Scaling **Solution**: ``` pMixer->SetResizeQuality(VFPIPResizeQuality::Lanczos); ``` ### Issue: Chroma Key Not Working **Check**: - Chroma settings enabled - Correct color selected (0=green, 1=blue) - Increase tolerance values - Verify source has uniform green screen **Example**: ``` // Try higher tolerance pMixer->SetChromaSettings(true, 0, 80, 60); ``` ### Issue: Performance Problems **Solutions**: - Reduce number of active inputs - Use faster resize quality - Disable chroma keying if not needed - Pre-scale input sources --- ## Related Interfaces - **IBaseFilter** - DirectShow filter interface - **IPin** - DirectShow pin interface (for GetInputParam2) - **IVFEffects45** - Video effects (can combine with mixer) - **IVFChromaKey** - Dedicated chroma key interface ## See Also - [Processing Filters Pack Overview](../../) - [Effects Reference](../../effects-reference/) - [Chroma Key Interface](../chroma-key/) - [Code Examples](../../examples/) ---END OF PAGE--- ## DirectShow Video Encryption Examples - C#, C++, Delphi **URL:** https://www.visioforge.com/help/docs/directshow/video-encryption-sdk/examples/ **Description:** Encrypt and decrypt MP4 video files using VisioForge DirectShow filters. AES-256 examples with password protection and binary key modes. **Tags:** Video Encryption SDK, DirectShow, C++, Windows, Encoding, MP4, H.264, AAC, C# **API:** IBaseFilter, IVFCryptoConfig, IFileSinkFilter, SourceFilter, VideoEncoder # Video Encryption SDK - Code Examples ## Overview This page provides comprehensive, working code examples for encrypting and decrypting video files using the Video Encryption SDK. Examples cover: - **Basic Encryption** - Encrypt video files with password protection - **File Decryption** - Decrypt and play encrypted video files - **Advanced Scenarios** - Binary keys, file-based keys, custom encoding settings - **Error Handling** - Robust error checking and recovery All examples include complete implementations in C++, C#, and Delphi. Interface naming across language wrappers The native C++ header (`encryptor_intf.h`) declares this interface as `ICryptoConfig` with `IID_ICryptoConfig`. The C# and Delphi wrappers expose the same interface as `IVFCryptoConfig` (and the password provider as `IVFPasswordProvider`). Both names share GUID `{BAA5BD1E-3B30-425e-AB3B-CC20764AC253}` and refer to the same COM interface — the C++ snippets below use `ICryptoConfig` while the C#/Delphi snippets use `IVFCryptoConfig`. --- ## Prerequisites ### C++ Projects ``` #include #include #include "encryptor_intf.h" #pragma comment(lib, "strmiids.lib") #pragma comment(lib, "quartz.lib") ``` ### C# Projects ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; ``` **Required NuGet Packages**: - VisioForge.DirectShowAPI - VisioForge.DirectShowLib ### Delphi Projects ## ``` uses DirectShow9, EncryptorIntf; ``` ## Example 1: Basic Video Encryption Encrypt a video file with string password. ### C# Implementation ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class BasicVideoEncryption { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; private IMediaEventEx mediaEvent; public void EncryptVideo(string inputFile, string outputFile, string password) { try { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); mediaControl = (IMediaControl)filterGraph; mediaEvent = (IMediaEventEx)filterGraph; // Add source filter int hr = filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); DsError.ThrowExceptionForHR(hr); // Add video encoder (H.264) var videoEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFH264Encoder, "H.264 Encoder" ); // Add audio encoder (AAC) var audioEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFAACEncoder, "AAC Encoder" ); // Add encrypt muxer filter var encryptMuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("F1D3727A-88DE-49ab-A635-280BEFEFF902")) ); hr = filterGraph.AddFilter(encryptMuxer, "Encrypt Muxer"); DsError.ThrowExceptionForHR(hr); // Configure encryption password var cryptoConfig = encryptMuxer as IVFCryptoConfig; if (cryptoConfig != null) { // Apply password using helper method cryptoConfig.ApplyString(password); // Verify password is set hr = cryptoConfig.HavePassword(); if (hr != 0) { throw new Exception("Failed to set encryption password"); } Console.WriteLine("Encryption password configured successfully"); } else { throw new Exception("IVFCryptoConfig interface not available"); } // Set output file var fileSink = encryptMuxer as IFileSinkFilter; if (fileSink != null) { hr = fileSink.SetFileName(outputFile, null); DsError.ThrowExceptionForHR(hr); } // Build filter graph connections ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Connect video path: Source → H.264 Encoder → Encrypt Muxer hr = captureGraph.RenderStream( null, MediaType.Video, sourceFilter, videoEncoder, encryptMuxer ); DsError.ThrowExceptionForHR(hr); // Connect audio path: Source → AAC Encoder → Encrypt Muxer hr = captureGraph.RenderStream( null, MediaType.Audio, sourceFilter, audioEncoder, encryptMuxer ); DsError.ThrowExceptionForHR(hr); Console.WriteLine("Filter graph built successfully"); Console.WriteLine("Starting encryption..."); // Start encoding hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); // Wait for completion EventCode eventCode; do { hr = mediaEvent.WaitForCompletion(1000, out eventCode); } while (eventCode == 0); Console.WriteLine("Encryption completed successfully!"); // Cleanup Marshal.ReleaseComObject(captureGraph); } catch (Exception ex) { Console.WriteLine($"ERROR: {ex.Message}"); throw; } finally { Stop(); } } public void Stop() { if (mediaControl != null) { mediaControl.Stop(); } if (filterGraph != null) { FilterGraphTools.RemoveAllFilters(filterGraph); } if (mediaEvent != null) Marshal.ReleaseComObject(mediaEvent); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } // Usage: // var encryptor = new BasicVideoEncryption(); // encryptor.EncryptVideo(@"C:\input.mp4", @"C:\output.encrypted.mp4", "MySecurePassword123"); ``` ### C++ Implementation ``` #include #include #include "encryptor_intf.h" class BasicVideoEncryption { private: IGraphBuilder* pGraph; IMediaControl* pControl; IMediaEvent* pEvent; public: BasicVideoEncryption() : pGraph(NULL), pControl(NULL), pEvent(NULL) {} HRESULT EncryptVideo(LPCWSTR inputFile, LPCWSTR outputFile, LPCWSTR password) { HRESULT hr; // Create filter graph hr = CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph ); if (FAILED(hr)) return hr; // Get control and event interfaces pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); pGraph->QueryInterface(IID_IMediaEvent, (void**)&pEvent); // Add source filter IBaseFilter* pSource = NULL; hr = pGraph->AddSourceFilter(inputFile, L"Source", &pSource); if (FAILED(hr)) goto cleanup; // Add video encoder (H.264) IBaseFilter* pVideoEncoder = NULL; hr = CoCreateInstance( CLSID_VFH264Encoder, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pVideoEncoder ); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pVideoEncoder, L"H.264 Encoder"); // Add audio encoder (AAC) IBaseFilter* pAudioEncoder = NULL; hr = CoCreateInstance( CLSID_VFAACEncoder, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pAudioEncoder ); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pAudioEncoder, L"AAC Encoder"); // Add encrypt muxer IBaseFilter* pMuxer = NULL; hr = CoCreateInstance( CLSID_EncryptMuxer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pMuxer ); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pMuxer, L"Encrypt Muxer"); // Configure encryption ICryptoConfig* pCrypto = NULL; hr = pMuxer->QueryInterface(IID_ICryptoConfig, (void**)&pCrypto); if (SUCCEEDED(hr)) { // Set password hr = pCrypto->put_Password( (LPBYTE)password, wcslen(password) * sizeof(wchar_t) ); if (SUCCEEDED(hr)) { // Verify password is set HRESULT hrPassword = pCrypto->HavePassword(); if (hrPassword == S_OK) { wprintf(L"Encryption password configured successfully\n"); } else { wprintf(L"WARNING: Password not set\n"); } } pCrypto->Release(); } // Set output file IFileSinkFilter* pFileSink = NULL; hr = pMuxer->QueryInterface(IID_IFileSinkFilter, (void**)&pFileSink); if (SUCCEEDED(hr)) { hr = pFileSink->SetFileName(outputFile, NULL); pFileSink->Release(); } // Build graph using Intelligent Connect ICaptureGraphBuilder2* pBuilder = NULL; hr = CoCreateInstance( CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuilder ); if (SUCCEEDED(hr)) { pBuilder->SetFiltergraph(pGraph); // Connect video path pBuilder->RenderStream( NULL, &MEDIATYPE_Video, pSource, pVideoEncoder, pMuxer ); // Connect audio path pBuilder->RenderStream( NULL, &MEDIATYPE_Audio, pSource, pAudioEncoder, pMuxer ); pBuilder->Release(); } wprintf(L"Starting encryption...\n"); // Run the graph hr = pControl->Run(); if (FAILED(hr)) goto cleanup; // Wait for completion long evCode; pEvent->WaitForCompletion(INFINITE, &evCode); wprintf(L"Encryption completed successfully!\n"); cleanup: if (pMuxer) pMuxer->Release(); if (pVideoEncoder) pVideoEncoder->Release(); if (pAudioEncoder) pAudioEncoder->Release(); if (pSource) pSource->Release(); Stop(); return hr; } void Stop() { if (pControl) { pControl->Stop(); } if (pEvent) pEvent->Release(); if (pControl) pControl->Release(); if (pGraph) pGraph->Release(); pEvent = NULL; pControl = NULL; pGraph = NULL; } }; // Usage: // BasicVideoEncryption encryptor; // encryptor.EncryptVideo(L"C:\\input.mp4", L"C:\\output.encrypted.mp4", L"MySecurePassword123"); ``` ### Delphi Implementation ``` uses DirectShow9, ActiveX, EncryptorIntf; type TBasicVideoEncryption = class private FFilterGraph: IGraphBuilder; FMediaControl: IMediaControl; FMediaEvent: IMediaEvent; public function EncryptVideo(const InputFile, OutputFile, Password: WideString): HRESULT; procedure Stop; end; function TBasicVideoEncryption.EncryptVideo(const InputFile, OutputFile, Password: WideString): HRESULT; var SourceFilter: IBaseFilter; VideoEncoder: IBaseFilter; AudioEncoder: IBaseFilter; EncryptMuxer: IBaseFilter; CryptoConfig: IVFCryptoConfig; FileSink: IFileSinkFilter; CaptureGraph: ICaptureGraphBuilder2; EventCode: Integer; begin Result := E_FAIL; try // Create filter graph Result := CoCreateInstance(CLSID_FilterGraph, nil, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, FFilterGraph); if Failed(Result) then Exit; // Get control and event interfaces FFilterGraph.QueryInterface(IID_IMediaControl, FMediaControl); FFilterGraph.QueryInterface(IID_IMediaEvent, FMediaEvent); // Add source filter Result := FFilterGraph.AddSourceFilter(PWideChar(InputFile), 'Source', SourceFilter); if Failed(Result) then Exit; // Add video encoder (H.264) Result := CoCreateInstance(CLSID_VFH264Encoder, nil, CLSCTX_INPROC_SERVER, IID_IBaseFilter, VideoEncoder); if Succeeded(Result) then FFilterGraph.AddFilter(VideoEncoder, 'H.264 Encoder'); // Add audio encoder (AAC) Result := CoCreateInstance(CLSID_VFAACEncoder, nil, CLSCTX_INPROC_SERVER, IID_IBaseFilter, AudioEncoder); if Succeeded(Result) then FFilterGraph.AddFilter(AudioEncoder, 'AAC Encoder'); // Add encrypt muxer Result := CoCreateInstance(CLSID_EncryptMuxer, nil, CLSCTX_INPROC_SERVER, IID_IBaseFilter, EncryptMuxer); if Failed(Result) then Exit; FFilterGraph.AddFilter(EncryptMuxer, 'Encrypt Muxer'); // Configure encryption if Supports(EncryptMuxer, IVFCryptoConfig, CryptoConfig) then begin // Set password // pBuffer is opaque binary data (PByte); cast through PWideChar to reuse // the wide-string buffer, length in bytes = char count * 2. Result := CryptoConfig.put_Password(PByte(PWideChar(Password)), Length(Password) * 2); if Succeeded(Result) then begin // Verify password is set if CryptoConfig.HavePassword = S_OK then WriteLn('Encryption password configured successfully') else WriteLn('WARNING: Password not set'); end; end; // Set output file if Supports(EncryptMuxer, IFileSinkFilter, FileSink) then FileSink.SetFileName(PWideChar(OutputFile), nil); // Build graph connections Result := CoCreateInstance(CLSID_CaptureGraphBuilder2, nil, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, CaptureGraph); if Succeeded(Result) then begin CaptureGraph.SetFiltergraph(FFilterGraph); // Connect video path CaptureGraph.RenderStream(nil, @MEDIATYPE_Video, SourceFilter, VideoEncoder, EncryptMuxer); // Connect audio path CaptureGraph.RenderStream(nil, @MEDIATYPE_Audio, SourceFilter, AudioEncoder, EncryptMuxer); end; WriteLn('Starting encryption...'); // Run the graph Result := FMediaControl.Run; if Failed(Result) then Exit; // Wait for completion repeat FMediaEvent.WaitForCompletion(1000, EventCode); until EventCode <> 0; WriteLn('Encryption completed successfully!'); finally Stop; end; end; procedure TBasicVideoEncryption.Stop; begin if Assigned(FMediaControl) then FMediaControl.Stop; FMediaEvent := nil; FMediaControl := nil; FFilterGraph := nil; end; // Usage: // var // Encryptor: TBasicVideoEncryption; // begin // Encryptor := TBasicVideoEncryption.Create; // try // Encryptor.EncryptVideo('C:\input.mp4', 'C:\output.encrypted.mp4', 'MySecurePassword123'); // finally // Encryptor.Free; // end; // end; ``` --- ## Example 2: Video Decryption and Playback Decrypt an encrypted video file and play it. ### C# Implementation ## ``` public class VideoDecryption { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; private IMediaEventEx mediaEvent; private IVideoWindow videoWindow; public void DecryptAndPlay(string encryptedFile, string password, IntPtr windowHandle) { try { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); mediaControl = (IMediaControl)filterGraph; mediaEvent = (IMediaEventEx)filterGraph; videoWindow = (IVideoWindow)filterGraph; // Add decrypt demuxer filter var decryptDemuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("D2C761F0-9988-4f79-9B0E-FB2B79C65851")) ); int hr = filterGraph.AddFilter(decryptDemuxer, "Decrypt Demuxer"); DsError.ThrowExceptionForHR(hr); // Configure decryption (MUST use same password as encryption) var cryptoConfig = decryptDemuxer as IVFCryptoConfig; if (cryptoConfig != null) { // Apply password cryptoConfig.ApplyString(password); // Verify password is set hr = cryptoConfig.HavePassword(); if (hr != 0) { throw new Exception("Failed to set decryption password"); } Console.WriteLine("Decryption password configured successfully"); } else { throw new Exception("IVFCryptoConfig interface not available"); } // Load encrypted file var fileSource = decryptDemuxer as IFileSourceFilter; if (fileSource != null) { hr = fileSource.Load(encryptedFile, null); DsError.ThrowExceptionForHR(hr); } // Build graph - render video and audio outputs ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Render video output hr = captureGraph.RenderStream( null, MediaType.Video, decryptDemuxer, null, null ); DsError.ThrowExceptionForHR(hr); // Render audio output hr = captureGraph.RenderStream( null, MediaType.Audio, decryptDemuxer, null, null ); // Audio is optional, don't fail if not present // Configure video window hr = videoWindow.put_Owner(windowHandle); hr = videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings); hr = videoWindow.put_MessageDrain(windowHandle); Console.WriteLine("Starting playback..."); // Start playback hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); Console.WriteLine("Decryption and playback started successfully!"); Marshal.ReleaseComObject(captureGraph); } catch (Exception ex) { Console.WriteLine($"ERROR: {ex.Message}"); throw; } } public void Stop() { if (mediaControl != null) { mediaControl.Stop(); } if (videoWindow != null) { videoWindow.put_Visible(OABool.False); videoWindow.put_Owner(IntPtr.Zero); } if (filterGraph != null) { FilterGraphTools.RemoveAllFilters(filterGraph); } if (videoWindow != null) Marshal.ReleaseComObject(videoWindow); if (mediaEvent != null) Marshal.ReleaseComObject(mediaEvent); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } public void SetVideoWindowSize(int width, int height) { if (videoWindow != null) { videoWindow.SetWindowPosition(0, 0, width, height); } } } // Usage: // var decryptor = new VideoDecryption(); // decryptor.DecryptAndPlay(@"C:\output.encrypted.mp4", "MySecurePassword123", this.Handle); ``` ## Example 3: Using File as Encryption Key Use a file's content as the encryption key instead of a password. ### C# Implementation ``` public class FileKeyEncryption { public void EncryptWithFileKey(string inputFile, string outputFile, string keyFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); var mediaControl = (IMediaControl)filterGraph; try { // Setup filter graph (source, encoders, muxer) // ... (same as Example 1) // Add encrypt muxer var encryptMuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("F1D3727A-88DE-49ab-A635-280BEFEFF902")) ); filterGraph.AddFilter(encryptMuxer, "Encrypt Muxer"); // Configure encryption using file as key var cryptoConfig = encryptMuxer as IVFCryptoConfig; if (cryptoConfig != null) { // Use file content as encryption key (SHA-256 hash of file) cryptoConfig.ApplyFile(keyFile); Console.WriteLine($"Using key file: {keyFile}"); Console.WriteLine("File content hashed with SHA-256 for encryption"); // Verify int hr = cryptoConfig.HavePassword(); if (hr == 0) { Console.WriteLine("Encryption key configured successfully"); } } // Continue with filter graph setup and encoding... } finally { // Cleanup } } public void DecryptWithFileKey(string encryptedFile, string keyFile) { var filterGraph = (IFilterGraph2)new FilterGraph(); try { // Add decrypt demuxer var decryptDemuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("D2C761F0-9988-4f79-9B0E-FB2B79C65851")) ); filterGraph.AddFilter(decryptDemuxer, "Decrypt Demuxer"); // Configure decryption using same key file var cryptoConfig = decryptDemuxer as IVFCryptoConfig; if (cryptoConfig != null) { // MUST use same key file as encryption cryptoConfig.ApplyFile(keyFile); Console.WriteLine($"Using key file for decryption: {keyFile}"); } // Continue with playback setup... } finally { // Cleanup } } } // Usage: // var encryptor = new FileKeyEncryption(); // encryptor.EncryptWithFileKey(@"C:\input.mp4", @"C:\output.encrypted.mp4", @"C:\keys\encryption.key"); // encryptor.DecryptWithFileKey(@"C:\output.encrypted.mp4", @"C:\keys\encryption.key"); ``` --- ## Example 4: Using Binary Key Data Generate and use binary key data for encryption. ### C# Implementation ## ``` using System.Security.Cryptography; using System.IO; public class BinaryKeyEncryption { public byte[] GenerateRandomKey(int keySize = 32) { // Generate cryptographically secure random key byte[] key = new byte[keySize]; using (var rng = new RNGCryptoServiceProvider()) { rng.GetBytes(key); } return key; } public void SaveKeyToFile(byte[] key, string keyFile) { File.WriteAllBytes(keyFile, key); Console.WriteLine($"Key saved to: {keyFile}"); } public byte[] LoadKeyFromFile(string keyFile) { return File.ReadAllBytes(keyFile); } public void EncryptWithBinaryKey(string inputFile, string outputFile, byte[] keyData) { var filterGraph = (IFilterGraph2)new FilterGraph(); try { // Setup filter graph and add encrypt muxer var encryptMuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("F1D3727A-88DE-49ab-A635-280BEFEFF902")) ); filterGraph.AddFilter(encryptMuxer, "Encrypt Muxer"); // Configure encryption with binary key var cryptoConfig = encryptMuxer as IVFCryptoConfig; if (cryptoConfig != null) { // Apply binary key (will be hashed with SHA-256) cryptoConfig.ApplyBinary(keyData); Console.WriteLine($"Binary key applied (length: {keyData.Length} bytes)"); // Verify int hr = cryptoConfig.HavePassword(); if (hr == 0) { Console.WriteLine("Encryption key configured successfully"); } } // Continue with encoding... } finally { // Cleanup } } public void CompleteWorkflow() { // Generate random encryption key byte[] encryptionKey = GenerateRandomKey(32); Console.WriteLine($"Generated {encryptionKey.Length * 8}-bit encryption key"); // Save key securely string keyFile = @"C:\keys\video_encryption_key.bin"; SaveKeyToFile(encryptionKey, keyFile); // Encrypt video with binary key EncryptWithBinaryKey( @"C:\input.mp4", @"C:\output.encrypted.mp4", encryptionKey ); Console.WriteLine("Video encrypted successfully!"); Console.WriteLine($"Key file: {keyFile}"); Console.WriteLine("Keep this key file secure - it's required for decryption!"); // Later, for decryption: // byte[] key = LoadKeyFromFile(keyFile); // DecryptWithBinaryKey(@"C:\output.encrypted.mp4", key); } } // Usage: // var encryptor = new BinaryKeyEncryption(); // encryptor.CompleteWorkflow(); ``` ## Example 5: Encryption with Custom Encoder Settings Encrypt video with specific H.264 encoding parameters. ### C# Implementation ``` public class CustomEncodingEncryption { public void EncryptWithCustomSettings( string inputFile, string outputFile, string password, int videoBitrate = 5000000, int audioBitrate = 192000) { var filterGraph = (IFilterGraph2)new FilterGraph(); var mediaControl = (IMediaControl)filterGraph; try { // Add source filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); // Add and configure H.264 encoder var videoEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFH264Encoder, "H.264 Encoder" ); // Configure H.264 encoder (if interface available) var h264Config = videoEncoder as IH264Encoder; if (h264Config != null) { h264Config.put_Bitrate(videoBitrate); h264Config.put_Profile(77); // Main profile h264Config.put_Level(41); // Level 4.1 (1080p) h264Config.put_RateControl(1); // CBR h264Config.put_GOP(60); // 2 seconds at 30fps Console.WriteLine($"H.264 configured: {videoBitrate / 1000000.0} Mbps, Main profile, Level 4.1"); } // Add and configure AAC encoder var audioEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFAACEncoder, "AAC Encoder" ); // Configure AAC encoder (if interface available) var aacConfig = audioEncoder as IVFAACEncoder; if (aacConfig != null) { aacConfig.SetBitrate((uint)audioBitrate); aacConfig.SetProfile(2); // AAC-LC aacConfig.SetOutputFormat(0); // Raw AAC for MP4 Console.WriteLine($"AAC configured: {audioBitrate / 1000} kbps, AAC-LC profile"); } // Add encrypt muxer var encryptMuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("F1D3727A-88DE-49ab-A635-280BEFEFF902")) ); filterGraph.AddFilter(encryptMuxer, "Encrypt Muxer"); // Configure encryption var cryptoConfig = encryptMuxer as IVFCryptoConfig; if (cryptoConfig != null) { cryptoConfig.ApplyString(password); Console.WriteLine("Encryption configured"); } // Set output file var fileSink = encryptMuxer as IFileSinkFilter; fileSink?.SetFileName(outputFile, null); // Build connections ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, videoEncoder, encryptMuxer); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, audioEncoder, encryptMuxer); Console.WriteLine("Starting encoding with custom settings..."); // Run encoding int hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); // Wait for completion var mediaEvent = (IMediaEventEx)filterGraph; EventCode eventCode; do { hr = mediaEvent.WaitForCompletion(1000, out eventCode); } while (eventCode == 0); Console.WriteLine("Encoding and encryption completed!"); Marshal.ReleaseComObject(captureGraph); } finally { // Cleanup mediaControl?.Stop(); FilterGraphTools.RemoveAllFilters(filterGraph); } } } // Usage: // var encryptor = new CustomEncodingEncryption(); // encryptor.EncryptWithCustomSettings( // @"C:\input.mp4", // @"C:\output.encrypted.mp4", // "MySecurePassword123", // videoBitrate: 8000000, // 8 Mbps // audioBitrate: 256000 // 256 kbps // ); ``` --- ## Example 6: Error Handling and Validation Comprehensive error handling for encryption/decryption. ### C# Implementation ## ``` public class RobustEncryption { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; public enum EncryptionResult { Success, FileNotFound, InvalidPassword, InterfaceNotAvailable, FilterGraphError, EncodingError, Unknown } public EncryptionResult EncryptVideoSafely( string inputFile, string outputFile, string password) { try { // Validate inputs if (string.IsNullOrEmpty(inputFile)) { Console.WriteLine("ERROR: Input file path is empty"); return EncryptionResult.FileNotFound; } if (!File.Exists(inputFile)) { Console.WriteLine($"ERROR: Input file not found: {inputFile}"); return EncryptionResult.FileNotFound; } if (string.IsNullOrEmpty(password)) { Console.WriteLine("ERROR: Password is empty"); return EncryptionResult.InvalidPassword; } if (password.Length < 8) { Console.WriteLine("WARNING: Password is less than 8 characters (not recommended)"); } Console.WriteLine("Input validation passed"); // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); if (filterGraph == null) { Console.WriteLine("ERROR: Failed to create filter graph"); return EncryptionResult.FilterGraphError; } mediaControl = (IMediaControl)filterGraph; // Add source filter int hr = filterGraph.AddSourceFilter(inputFile, "Source", out IBaseFilter sourceFilter); if (hr != 0 || sourceFilter == null) { Console.WriteLine($"ERROR: Failed to add source filter (HRESULT: 0x{hr:X8})"); return EncryptionResult.FilterGraphError; } // Add encoders var videoEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFH264Encoder, "H.264 Encoder" ); if (videoEncoder == null) { Console.WriteLine("ERROR: Failed to create video encoder"); return EncryptionResult.FilterGraphError; } var audioEncoder = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFAACEncoder, "AAC Encoder" ); // Add encrypt muxer var encryptMuxer = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("F1D3727A-88DE-49ab-A635-280BEFEFF902")) ); if (encryptMuxer == null) { Console.WriteLine("ERROR: Failed to create encrypt muxer"); return EncryptionResult.FilterGraphError; } hr = filterGraph.AddFilter(encryptMuxer, "Encrypt Muxer"); if (hr != 0) { Console.WriteLine($"ERROR: Failed to add encrypt muxer (HRESULT: 0x{hr:X8})"); return EncryptionResult.FilterGraphError; } // Configure encryption var cryptoConfig = encryptMuxer as IVFCryptoConfig; if (cryptoConfig == null) { Console.WriteLine("ERROR: IVFCryptoConfig interface not available"); return EncryptionResult.InterfaceNotAvailable; } try { cryptoConfig.ApplyString(password); } catch (Exception ex) { Console.WriteLine($"ERROR: Failed to apply password: {ex.Message}"); return EncryptionResult.InvalidPassword; } // Verify password is set hr = cryptoConfig.HavePassword(); if (hr != 0) { Console.WriteLine("ERROR: Password verification failed"); return EncryptionResult.InvalidPassword; } Console.WriteLine("Encryption password configured successfully"); // Set output file var fileSink = encryptMuxer as IFileSinkFilter; if (fileSink != null) { hr = fileSink.SetFileName(outputFile, null); if (hr != 0) { Console.WriteLine($"ERROR: Failed to set output file (HRESULT: 0x{hr:X8})"); return EncryptionResult.FilterGraphError; } } // Build filter graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); hr = captureGraph.SetFiltergraph(filterGraph); hr = captureGraph.RenderStream( null, MediaType.Video, sourceFilter, videoEncoder, encryptMuxer ); if (hr != 0) { Console.WriteLine($"WARNING: Video connection failed (HRESULT: 0x{hr:X8})"); } hr = captureGraph.RenderStream( null, MediaType.Audio, sourceFilter, audioEncoder, encryptMuxer ); if (hr != 0) { Console.WriteLine($"WARNING: Audio connection failed (HRESULT: 0x{hr:X8}) - continuing without audio"); } Console.WriteLine("Filter graph built successfully"); Console.WriteLine("Starting encryption..."); // Start encoding hr = mediaControl.Run(); if (hr != 0) { Console.WriteLine($"ERROR: Failed to start encoding (HRESULT: 0x{hr:X8})"); return EncryptionResult.EncodingError; } // Monitor progress var mediaEvent = (IMediaEventEx)filterGraph; EventCode eventCode; long param1, param2; do { hr = mediaEvent.GetEvent(out eventCode, out param1, out param2, 1000); if (hr == 0) { mediaEvent.FreeEventParams(eventCode, param1, param2); if (eventCode == EventCode.Complete) { break; } else if (eventCode == EventCode.ErrorAbort) { Console.WriteLine($"ERROR: Encoding aborted (event code: {eventCode})"); return EncryptionResult.EncodingError; } } } while (true); Console.WriteLine("Encryption completed successfully!"); // Verify output file exists if (File.Exists(outputFile)) { FileInfo fi = new FileInfo(outputFile); Console.WriteLine($"Output file created: {outputFile}"); Console.WriteLine($"File size: {fi.Length / (1024.0 * 1024.0):F2} MB"); } else { Console.WriteLine("WARNING: Output file not found after encoding"); } Marshal.ReleaseComObject(captureGraph); return EncryptionResult.Success; } catch (Exception ex) { Console.WriteLine($"EXCEPTION: {ex.Message}"); Console.WriteLine($"Stack trace: {ex.StackTrace}"); return EncryptionResult.Unknown; } finally { Cleanup(); } } private void Cleanup() { try { if (mediaControl != null) { mediaControl.Stop(); Marshal.ReleaseComObject(mediaControl); } if (filterGraph != null) { FilterGraphTools.RemoveAllFilters(filterGraph); Marshal.ReleaseComObject(filterGraph); } } catch (Exception ex) { Console.WriteLine($"Cleanup error: {ex.Message}"); } } } // Usage: // var encryptor = new RobustEncryption(); // var result = encryptor.EncryptVideoSafely( // @"C:\input.mp4", // @"C:\output.encrypted.mp4", // "MySecurePassword123" // ); // // if (result == RobustEncryption.EncryptionResult.Success) // { // Console.WriteLine("SUCCESS!"); // } // else // { // Console.WriteLine($"FAILED: {result}"); // } ``` ## Best Practices ### Password Security 1. **Use Strong Passwords** 2. Minimum 16 characters 3. Mix of uppercase, lowercase, numbers, symbols 4. Avoid dictionary words 5. Use password managers to generate/store 6. **Key Storage** 7. Never hardcode passwords in source code 8. Use secure key storage (Windows DPAPI, KeyVault, etc.) 9. Implement proper access controls 10. **Key Distribution** 11. Use secure channels for key distribution 12. Consider public-key encryption for key exchange 13. Implement key rotation policies ### Implementation Security **GOOD: Secure password handling** ``` public void SetEncryptionPassword(IVFCryptoConfig config) { // Get password from secure storage string password = SecureStorage.GetPassword(); try { config.ApplyString(password); } finally { // Clear password from memory password = null; GC.Collect(); } } ``` **BAD: Hardcoded password** ``` public void SetEncryptionPassword(IVFCryptoConfig config) { config.ApplyString("MyPassword123"); // DON'T DO THIS! } ``` ### File Security - Use appropriate file permissions for encrypted files - Implement secure deletion for temporary files - Consider encrypting key files with additional encryption - Log access to encrypted content for audit trails ### Implementation Guidelines 1. **Always Validate Inputs** 2. Check file existence before processing 3. Validate password is not empty 4. Verify filter interfaces are available 5. **Error Handling** 6. Check HRESULT values from COM calls 7. Use try-catch blocks for exceptions 8. Provide meaningful error messages 9. **Resource Management** 10. Always release COM objects 11. Use `finally` blocks for cleanup 12. Stop filter graph before releasing 13. **Testing** 14. Test with various input formats 15. Verify encrypted files can be decrypted 16. Test error conditions (wrong password, etc.) --- ## Troubleshooting ### Common Error Codes | HRESULT | Description | Solution | | --- | --- | --- | | `E_INVALIDARG` | Invalid buffer or size | Check buffer pointer and size parameters | | `E_POINTER` | Null pointer | Ensure pointers are valid before calling | | `E_FAIL` | General failure | Check filter state and configuration | | `S_FALSE` | No password set | Call `put_Password` before `HavePassword` | | ### Error Handling Example | | | | ``` public bool ConfigureEncryption(IBaseFilter muxer, string password) { var cryptoConfig = muxer as IVFCryptoConfig; if (cryptoConfig == null) { Console.WriteLine("ERROR: Filter does not support IVFCryptoConfig"); return false; } try { // Set password cryptoConfig.ApplyString(password); // Verify int hr = cryptoConfig.HavePassword(); if (hr != 0) { Console.WriteLine("ERROR: Password not set correctly"); return false; } Console.WriteLine("Encryption configured successfully"); return true; } catch (Exception ex) { Console.WriteLine($"ERROR: Failed to configure encryption: {ex.Message}"); return false; } } ``` | | | | --- | | | ### Common Issues #### "Filter not registered" Error **Problem**: CLSID not found **Solution**: ``` # Register filters (run as Administrator) regsvr32 "C:\Path\To\EncryptMuxer.ax" regsvr32 "C:\Path\To\DecryptDemuxer.ax" ``` #### "Interface not available" Error **Problem**: Cannot query IVFCryptoConfig **Solution**: - Verify filter version is correct - Check filter is properly registered - Ensure COM interfaces are compatible #### Decryption Fails with Garbled Video **Problem**: Wrong password used for decryption **Solution**: - Verify same password is used for encryption and decryption - Check password encoding (Unicode vs. ANSI) - Ensure no typos in password #### Output File is Empty or Corrupt **Problem**: Encoding failed silently **Solution**: - Check all encoder filters are properly connected - Verify encoder configurations are valid - Monitor IMediaEventEx for error events - Check disk space is available --- ## See Also - [Video Encryption SDK Overview](../) - Product features - [Interface Reference](../interface-reference/) - Complete API documentation - [DirectShow Encoding Filters Pack](../../filters-enc/) - Compatible encoders - [GitHub Samples](https://github.com/visioforge/directshow-samples/tree/main/Video%20Encryption%20SDK) - Complete source code ---END OF PAGE--- ## AES-256 Video Encryption Using DirectShow COM Filters **URL:** https://www.visioforge.com/help/docs/directshow/video-encryption-sdk/ **Description:** Encrypt H.264/AAC MP4 video with AES-256 using DirectShow filters. VisioForge SDK with password and binary key modes for C++, C#, and Delphi. **Tags:** Video Encryption SDK, DirectShow, C++, Windows **API:** IVFCryptoConfig, IVFPasswordProvider # Video Encryption SDK ## Introduction to Video Encryption The [Video Encryption SDK](https://www.visioforge.com/video-encryption-sdk) provides robust tools for encoding video files into MP4 H264/AAC format with advanced encryption capabilities. Developers can secure their media content using custom passwords or binary data encryption methods. The SDK integrates seamlessly with any DirectShow application through a complete set of filters. These filters come with extensive interfaces allowing developers to fine-tune settings according to specific security requirements and implementation needs. --- ## Installation Before using the code samples and integrating the SDK into your application, you must first install the Video Encryption SDK from the [product page](https://www.visioforge.com/video-encryption-sdk). **Installation Steps**: 1. Download the SDK installer from the product page 2. Run the installer with administrative privileges 3. The installer will register all necessary DirectShow filters 4. Sample applications and source code will be available in the installation directory **Note**: The SDK filters must be properly registered on the system before they can be used in your applications. The installer handles this automatically. --- ## Integration Flexibility You can implement the SDK in various DirectShow applications as filters for both encryption and decryption processes. The system works effectively with: - Live video sources - File-based video sources - Software video encoders - GPU-accelerated video encoders from the [DirectShow Encoding Filters pack](https://www.visioforge.com/encoding-filters-pack) (available separately) - Third-party DirectShow filters for additional video encoding options ## Key Features and Capabilities ### Core Functionality - **Secure Encryption/Decryption**: Process video files or capture streams with robust security algorithms - **Format Support**: Full H264 encoder support for video content - **Audio Handling**: Complete AAC encoder support for audio streams - **Flexible Security Options**: Implement encryption using either binary data or string passwords ### Performance Optimization - AES-256 encryption engine for maximum security - CPU hardware acceleration support - GPU acceleration compatibility - Optimized for high-speed encryption processes ## Development Resources ### Code Samples and Documentation The SDK includes comprehensive code samples for multiple programming languages: - C# implementation examples - C++ reference code - Delphi sample projects These samples provide practical implementation guidance for developers building secure video applications. ### Demo Application Explore the included Video Encryptor application for a hands-on demonstration of the SDK's capabilities in a working environment. --- ## API Reference ### Core Interfaces The SDK provides comprehensive COM interfaces for encryption and decryption: #### IVFCryptoConfig Primary interface for configuring encryption settings on the muxer filter (encryption) and demuxer filter (decryption). **GUID**: `{BAA5BD1E-3B30-425e-AB3B-CC20764AC253}` **Methods**: - `put_Provider` - Set password provider for advanced scenarios (binary keys, dynamic passwords) - `get_Provider` - Get password provider interface - `put_Password` - Set encryption password or key directly (binary data) - `HavePassword` - Check if password is set #### IVFPasswordProvider Callback interface for advanced password provision scenarios such as binary data keys, dynamic password generation, or custom key derivation. **GUID**: `{6F8162B5-778D-42b5-9242-1BBABB24FFC4}` **Methods**: - `QueryPassword` - Query password for specific file **Use Cases**: - Binary key data provision - Dynamic password generation - File-specific encryption keys - Custom key derivation functions #### Helper Classes The SDK includes helper extension methods for .NET developers: - `ApplyString` - Apply string password (hashed with SHA-256) - `ApplyFile` - Use file as encryption key (SHA-256 hash of file content) - `ApplyBinary` - Apply binary key data (hashed with SHA-256) ### Filter CLSIDs | Filter | CLSID | Purpose | | --- | --- | --- | | **Encrypt Muxer** | `{F1D3727A-88DE-49ab-A635-280BEFEFF902}` | Muxer with encryption | | **Decrypt Demuxer** | `{D2C761F0-9988-4f79-9B0E-FB2B79C65851}` | Demuxer with decryption | For detailed interface documentation and code examples, see the [Interface Reference](interface-reference/). --- ## Code Examples ### Quick Start - Encryption #### C# Example ``` using VisioForge.DirectShowAPI; // Get crypto config interface from encrypt muxer var cryptoConfig = muxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { // Apply string password cryptoConfig.ApplyString("MySecurePassword123"); // Or use file as key // cryptoConfig.ApplyFile(@"C:\keys\mykey.bin"); // Or use binary data // byte[] keyData = new byte[] { 0x01, 0x02, 0x03, ... }; // cryptoConfig.ApplyBinary(keyData); } ``` #### C++ Example ``` #include "encryptor_intf.h" ICryptoConfig* pCrypto = nullptr; hr = pMuxer->QueryInterface(IID_ICryptoConfig, (void**)&pCrypto); if (SUCCEEDED(hr)) { // Set password const wchar_t* password = L"MySecurePassword123"; hr = pCrypto->put_Password( (LPBYTE)password, wcslen(password) * sizeof(wchar_t) ); pCrypto->Release(); } ``` ### Decryption #### C# Example ``` // Get crypto config interface from decrypt demuxer var cryptoConfig = demuxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { // Must use same password/key as encryption cryptoConfig.ApplyString("MySecurePassword123"); } ``` For complete examples including filter graph setup, see the [Examples Page](examples/). --- ## Sample Applications The SDK includes working sample applications demonstrating encryption and decryption workflows: ### Included Samples - **Encryption Demo** - Demonstrates video file encryption with H.264/AAC encoding - **Player Demo** - Shows decryption and playback of encrypted video files ### GitHub Repository Complete source code for all samples is available: - [Video Encryption SDK Samples](https://github.com/visioforge/directshow-samples/tree/main/Video%20Encryption%20SDK) - C#, C++, and Delphi examples These samples include: - Complete filter graph construction - Encryption configuration - Decryption and playback - Error handling - Best practices implementation --- ## Licensing Information - [End User License Agreement](../../eula/) ## Version History ### Version 11.4 - Full compatibility with VisioForge .Net SDKs 11.4 - Enhanced Nvidia NVENC support for H264 and H265 video encoders - Improved Intel QuickSync support for H264 video encoder - Added NV12 colorspace support for enhanced performance ### Version 11.0 - Complete compatibility with VisioForge .Net SDKs 11.0 - Enhanced GPU encoders support - Upgraded AAC encoder functionality ### Version 10.0 - Full compatibility with VisioForge .Net SDKs 10.0 - Enhanced compatibility with H264 and H265 video formats - Integrated AMD AMF acceleration support - Added Intel QuickSync technology support ### Version 9.0 - Significantly improved encryption processing speed - Added CPU hardware acceleration capabilities - Implemented new engine based on AES-256 encryption - Added file usage as a key (with binary array support) - Integrated NVENC support for GPU acceleration - Enhanced AAC HE encoder support ### Version 8.0 - Updated video and audio encoders - Improved filter encryption performance ### Version 7.0 - Initial release as a standalone product - Previously integrated within Video Capture SDK, Video Edit SDK, and Media Player SDK - Compatible with any DirectShow application without requiring additional VisioForge SDKs --- ## Resources - [Product Page](https://www.visioforge.com/video-encryption-sdk) - Purchase, licensing, and product information - [Sample Applications](https://github.com/visioforge/directshow-samples/tree/main/Video%20Encryption%20SDK) - Complete source code examples --- ## See Also - [Interface Reference](interface-reference/) - Complete API documentation - [Examples](examples/) - Comprehensive code examples for encryption and decryption - [DirectShow Encoding Filters Pack](../filters-enc/) - Compatible video encoders (H.264, H.265, AAC) ---END OF PAGE--- ## IVFCryptoConfig COM Interface - Video Encryption API **URL:** https://www.visioforge.com/help/docs/directshow/video-encryption-sdk/interface-reference/ **Description:** IVFCryptoConfig and IVFPasswordProvider COM interfaces for AES-256 video encryption in DirectShow. Methods, GUIDs, and usage for C++, C#, Delphi. **Tags:** Video Encryption SDK, DirectShow, C++, Windows, C# **API:** IVFCryptoConfig, IVFPasswordProvider, IBaseFilter, MuxerFilter # Video Encryption SDK - Interface Reference ## Overview The Video Encryption SDK provides COM interfaces for encrypting and decrypting MP4 video files with AES-256 encryption. This reference covers all interfaces, methods, and helper classes for C++, C#, and Delphi developers. --- ## IVFCryptoConfig Interface Primary interface for configuring encryption passwords and keys on both the encryption muxer and decryption demuxer filters. ### Interface GUID ``` {BAA5BD1E-3B30-425e-AB3B-CC20764AC253} ``` ### Inheritance ## Inherits from `IUnknown` ### Interface Definitions #### C++ Definition ``` #include "encryptor_intf.h" // {BAA5BD1E-3B30-425e-AB3B-CC20764AC253} DEFINE_GUID(IID_ICryptoConfig, 0xbaa5bd1e, 0x3b30, 0x425e, 0xab, 0x3b, 0xcc, 0x20, 0x76, 0x4a, 0xc2, 0x53); DECLARE_INTERFACE_(ICryptoConfig, IUnknown) { STDMETHOD(put_Provider)(THIS_ IPasswordProvider* pProvider) PURE; STDMETHOD(get_Provider)(THIS_ IPasswordProvider** ppProvider) PURE; STDMETHOD(put_Password)(THIS_ LPBYTE pBuffer, LONG lSize) PURE; STDMETHOD(HavePassword)(THIS_) PURE; }; ``` #### C# Definition ``` using System; using System.Runtime.InteropServices; [ComImport] [Guid("BAA5BD1E-3B30-425e-AB3B-CC20764AC253")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFCryptoConfig { // NOTE: put_Provider / get_Provider are stubs in the managed wrapper — // the parameter is literally named `passwordProviderNotUsed` because the // .NET marshaling for IVFPasswordProvider is not wired up. From C# call // put_Password directly with the binary key bytes. [PreserveSig] int put_Provider([In] IVFPasswordProvider passwordProviderNotUsed); [PreserveSig] int get_Provider([Out] IVFPasswordProvider passwordProviderNotUsed); [PreserveSig] int put_Password(IntPtr buffer, [In] int size); [PreserveSig] int HavePassword(); } ``` C# password provider not supported The managed `put_Provider` / `get_Provider` wrappers are **non-functional stubs** (note the `passwordProviderNotUsed` parameter name). To set passwords from C#, call `put_Password` with the raw key bytes via `IntPtr` (or use the `ApplyString` helper). Custom `IVFPasswordProvider` callbacks must be implemented from C++ or Delphi. #### Delphi Definition ``` type IVFCryptoConfig = interface(IUnknown) ['{BAA5BD1E-3B30-425e-AB3B-CC20764AC253}'] function put_Provider(pProvider: IUnknown): HRESULT; stdcall; function get_Provider(out pProvider: IUnknown): HRESULT; stdcall; function put_Password(pBuffer: PByte; lSize: Integer): HRESULT; stdcall; function HavePassword(): HRESULT; stdcall; end; ``` Naming across language wrappers The native C++ header (`encryptor_intf.h`) uses `ICryptoConfig` / `IPasswordProvider`. The C# and Delphi wrappers expose the same interface as `IVFCryptoConfig` / `IVFPasswordProvider`. Both names refer to the **same** GUID `{BAA5BD1E-3B30-425e-AB3B-CC20764AC253}`. --- ### Methods #### put\_Provider Sets a password provider callback interface for advanced encryption scenarios. **C++ Syntax**: ``` HRESULT put_Provider(IPasswordProvider* pProvider); ``` **C# Syntax**: ``` int put_Provider(IVFPasswordProvider passwordProvider); ``` **Parameters**: - `pProvider` / `passwordProvider` - Password provider interface that implements `IVFPasswordProvider` **Return Value**: - `S_OK` (0) on success - Error HRESULT on failure **Remarks**: Use this method for advanced scenarios where you need: - Dynamic password generation based on file name - Binary key data provision through a callback - Custom key derivation functions - File-specific encryption keys - Per-file password policies For simple string passwords, using `put_Password` directly is more straightforward. The password provider is useful when you need runtime password determination or when implementing a custom key management system. **Example Use Cases**: 1. **Binary Key Provider**: Provide 256-bit encryption keys from a key management system 2. **Dynamic Passwords**: Generate different passwords based on file names or metadata 3. **Key Derivation**: Implement custom key derivation functions (PBKDF2, Argon2, etc.) 4. **Secure Storage Integration**: Retrieve keys from hardware security modules (HSM) or key vaults --- #### get\_Provider Gets the currently set password provider interface. **C++ Syntax**: ``` HRESULT get_Provider(IPasswordProvider** ppProvider); ``` **C# Syntax**: ``` int get_Provider(IVFPasswordProvider passwordProvider); ``` **Parameters**: - `ppProvider` / `passwordProvider` - Pointer to receive password provider interface **Return Value**: - `S_OK` (0) on success - `E_POINTER` if ppProvider is NULL - Error HRESULT on failure **Remarks**: Retrieves the password provider interface that was previously set with `put_Provider`. Returns NULL if no provider has been set. --- #### put\_Password Sets the encryption password or binary key data. **C++ Syntax**: ``` HRESULT put_Password(LPBYTE pBuffer, LONG lSize); ``` **C# Syntax**: ``` int put_Password(IntPtr buffer, int size); ``` **Delphi Syntax**: ``` function put_Password(pBuffer: PByte; lSize: Integer): HRESULT; stdcall; ``` **Parameters**: - `pBuffer` / `buffer` - Pointer to password or binary key data - `lSize` / `size` - Size of buffer in bytes **Return Value**: - `S_OK` (0) on success - `E_INVALIDARG` if buffer is null or size is invalid - Error HRESULT on failure **Remarks**: - The SDK uses AES-256 encryption, which requires a 256-bit (32-byte) key - If you provide a password string, it should be hashed to 256 bits (use SHA-256) - The same password/key must be used for both encryption and decryption - For string passwords, use the helper methods (C# only) or hash manually - Binary data is hashed with SHA-256 internally to generate the encryption key **Example (C++)**: ``` ICryptoConfig* pCrypto = nullptr; hr = pMuxer->QueryInterface(IID_ICryptoConfig, (void**)&pCrypto); if (SUCCEEDED(hr)) { // Using string password (must convert to proper format) const wchar_t* password = L"MySecurePassword123"; hr = pCrypto->put_Password( (LPBYTE)password, wcslen(password) * sizeof(wchar_t) ); pCrypto->Release(); } ``` **Example (C#)**: ``` var cryptoConfig = muxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { // Using helper method (recommended) cryptoConfig.ApplyString("MySecurePassword123"); // Or manually with IntPtr string password = "MySecurePassword123"; IntPtr ptr = Marshal.StringToCoTaskMemUni(password); try { cryptoConfig.put_Password(ptr, password.Length * 2); } finally { Marshal.FreeCoTaskMem(ptr); } } ``` **Example (Delphi)**: ``` var CryptoConfig: IVFCryptoConfig; Password: WideString; begin if Supports(MuxerFilter, IVFCryptoConfig, CryptoConfig) then begin Password := 'MySecurePassword123'; // pBuffer is opaque binary data (LPBYTE); cast the wide-string pointer to PByte // and pass byte length (UTF-16 chars * 2). CryptoConfig.put_Password(PByte(PWideChar(Password)), Length(Password) * 2); end; end; ``` --- #### HavePassword Checks whether a password has been set on the filter. **C++ Syntax**: ``` HRESULT HavePassword(); ``` **C# Syntax**: ``` int HavePassword(); ``` **Delphi Syntax**: ``` function HavePassword(): HRESULT; stdcall; ``` **Parameters**: None **Return Value**: - `S_OK` (0) if password is set - `S_FALSE` (1) if no password is set - Error HRESULT on failure **Remarks**: Use this method to verify that a password has been configured before starting the filter graph. **Example (C++)**: ``` ICryptoConfig* pCrypto = nullptr; hr = pMuxer->QueryInterface(IID_ICryptoConfig, (void**)&pCrypto); if (SUCCEEDED(hr)) { HRESULT hrPassword = pCrypto->HavePassword(); if (hrPassword == S_OK) { // Password is set, can start encoding } else { // No password set MessageBox(NULL, L"Please set encryption password", L"Error", MB_OK); } pCrypto->Release(); } ``` **Example (C#)**: ``` var cryptoConfig = muxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { int hr = cryptoConfig.HavePassword(); if (hr == 0) // S_OK { // Password is set Console.WriteLine("Password configured successfully"); } else { // No password Console.WriteLine("Warning: No password set"); } } ``` --- ## IVFPasswordProvider Interface Callback interface for advanced password provision scenarios including binary key data, dynamic password generation, and custom key derivation functions. ### Interface GUID ``` {6F8162B5-778D-42b5-9242-1BBABB24FFC4} ``` ### Inheritance ## Inherits from `IUnknown` ### Interface Definitions #### C++ Definition ``` // {6F8162B5-778D-42b5-9242-1BBABB24FFC4} DEFINE_GUID(IID_IPasswordProvider, 0x6f8162b5, 0x778d, 0x42b5, 0x92, 0x42, 0x1b, 0xba, 0xbb, 0x24, 0xff, 0xc4); DECLARE_INTERFACE_(IPasswordProvider, IUnknown) { STDMETHOD(QueryPassword)( THIS_ LPCWSTR pszFileName, LPBYTE pBuffer, LONG* plSize ) PURE; }; ``` #### C# Definition ``` [ComImport] [Guid("6F8162B5-778D-42b5-9242-1BBABB24FFC4")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFPasswordProvider { [PreserveSig] int QueryPassword( [MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pBuffer, [In, Out] ref int plSize ); } ``` --- ### Methods #### QueryPassword Called by the filter to query the password or binary key data for a specific file. **C++ Syntax**: ``` HRESULT QueryPassword( LPCWSTR pszFileName, LPBYTE pBuffer, LONG* plSize ); ``` **C# Syntax**: ``` int QueryPassword( string pszFileName, byte[] pBuffer, ref int plSize ); ``` **Parameters**: - `pszFileName` - File name for which password is requested (can be used to determine file-specific keys) - `pBuffer` - Buffer to receive password data or binary key - `plSize` - Pointer to buffer size (input: max buffer size, output: actual data size returned) **Return Value**: - `S_OK` (0) if password provided successfully - `E_OUTOFMEMORY` if buffer is too small (set plSize to required size) - Error HRESULT on failure **Remarks**: Implement this interface to: - Provide binary key data (256-bit keys for AES-256) - Generate file-specific encryption keys based on file name - Retrieve keys from external key management systems - Implement custom password derivation logic For simple scenarios with a single password for all files, using `IVFCryptoConfig::put_Password` directly is more straightforward. **Implementation Example (C#)**: ``` public class CustomPasswordProvider : IVFPasswordProvider { public int QueryPassword(string pszFileName, byte[] pBuffer, ref int plSize) { // Generate file-specific key byte[] key = GenerateKeyForFile(pszFileName); if (pBuffer == null || plSize < key.Length) { plSize = key.Length; return unchecked((int)0x8007000E); // E_OUTOFMEMORY } Array.Copy(key, pBuffer, key.Length); plSize = key.Length; return 0; // S_OK } private byte[] GenerateKeyForFile(string fileName) { // Custom key generation logic using (var sha256 = SHA256.Create()) { string seed = "MySalt" + fileName; return sha256.ComputeHash(Encoding.UTF8.GetBytes(seed)); } } } ``` --- ## C# Helper Methods The SDK provides convenient extension methods for C# developers in the `VFCryptoConfigHelper` class. ### ApplyString Applies a string password with automatic SHA-256 hashing. **Syntax**: ``` public static int ApplyString(this IVFCryptoConfig cryptoConfig, string key) ``` **Parameters**: - `cryptoConfig` - The IVFCryptoConfig interface instance - `key` - String password to apply **Return Value**: - `0` on success - Throws `Exception` if key is null or empty **Remarks**: - Automatically converts string to Unicode and applies SHA-256 hashing - Most common method for setting passwords - Ensures consistent password format across encryption/decryption **Example**: ``` var cryptoConfig = muxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { cryptoConfig.ApplyString("MySecurePassword123"); } ``` --- ### ApplyFile Uses a file's content as the encryption key (SHA-256 hash of file). **Syntax**: ``` public static int ApplyFile(this IVFCryptoConfig cryptoConfig, string key) ``` **Parameters**: - `cryptoConfig` - The IVFCryptoConfig interface instance - `key` - Path to file to use as encryption key **Return Value**: - `0` on success - Throws `FileNotFoundException` if file doesn't exist - Throws `Exception` if key is null or empty **Remarks**: - Reads entire file content and computes SHA-256 hash - Useful for using key files or certificates as encryption keys - File content is never stored, only the hash - Same file must be used for both encryption and decryption **Example**: ``` var cryptoConfig = muxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { cryptoConfig.ApplyFile(@"C:\keys\encryption.key"); } ``` **Security Note**: - Store key files securely - Use appropriate file permissions - Consider using dedicated key storage systems for production --- ### ApplyBinary Applies binary key data with automatic SHA-256 hashing. **Syntax**: ``` public static int ApplyBinary(this IVFCryptoConfig cryptoConfig, byte[] key) ``` **Parameters**: - `cryptoConfig` - The IVFCryptoConfig interface instance - `key` - Binary key data (any length) **Return Value**: - `0` on success - Throws `Exception` if key is null or empty **Remarks**: - Accepts binary key data of any length - Automatically computes SHA-256 hash to generate 256-bit key - Useful for programmatically generated keys or key derivation **Example**: ``` var cryptoConfig = muxerFilter as IVFCryptoConfig; if (cryptoConfig != null) { // Generate random key byte[] keyData = new byte[32]; using (var rng = new RNGCryptoServiceProvider()) { rng.GetBytes(keyData); } // Apply binary key cryptoConfig.ApplyBinary(keyData); // Store keyData securely for later decryption SaveKeyToSecureStorage(keyData); } ``` --- ## Filter CLSIDs ### Encrypt Muxer Filter Muxes video and audio streams into encrypted format. **CLSID**: ``` // {F1D3727A-88DE-49ab-A635-280BEFEFF902} DEFINE_GUID(CLSID_EncryptMuxer, 0xf1d3727a, 0x88de, 0x49ab, 0xa6, 0x35, 0x28, 0xb, 0xef, 0xef, 0xf9, 0x2); ``` **Usage (C++)**: ``` IBaseFilter* pMuxer = nullptr; hr = CoCreateInstance( CLSID_EncryptMuxer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pMuxer ); ``` **Usage (C#)**: ``` var muxerFilter = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("F1D3727A-88DE-49ab-A635-280BEFEFF902")) ); ``` --- ### Decrypt Demuxer Filter Demuxes and decrypts encrypted files. **CLSID**: ``` // {D2C761F0-9988-4f79-9B0E-FB2B79C65851} DEFINE_GUID(CLSID_EncryptDemuxer, 0xd2c761f0, 0x9988, 0x4f79, 0x9b, 0xe, 0xfb, 0x2b, 0x79, 0xc6, 0x58, 0x51); ``` **Usage (C++)**: ``` IBaseFilter* pDemuxer = nullptr; hr = CoCreateInstance( CLSID_EncryptDemuxer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pDemuxer ); ``` **Usage (C#)**: ``` var demuxerFilter = (IBaseFilter)Activator.CreateInstance( Type.GetTypeFromCLSID(new Guid("D2C761F0-9988-4f79-9B0E-FB2B79C65851")) ); ``` --- ## See Also - [Video Encryption SDK Overview](../) - Product features and capabilities - [Examples](../examples/) - Complete code examples - [DirectShow Encoding Filters Pack](../../filters-enc/) - Compatible encoders ---END OF PAGE--- ## Virtual Camera DirectShow Examples - C++, C#, VB.NET **URL:** https://www.visioforge.com/help/docs/directshow/virtual-camera-sdk/examples/ **Description:** Stream video to virtual camera devices and capture from them in DirectShow. Code examples for frame rendering, real-time effects, and multi-instance setup. **Tags:** Virtual Camera SDK, DirectShow, C++, Windows, WinForms, Streaming, Virtual Camera, Webcam, C# **API:** IBaseFilter, IVFLiveVideoSource, IVFVirtualCameraSink, IVFVirtualCameraSource # Virtual Camera SDK - Code Examples ## Overview This page provides practical code examples for using the Virtual Camera SDK. The SDK enables you to: - **Write TO virtual camera**: Stream video from files, real cameras, or individual frames to virtual camera devices - **Read FROM virtual camera**: Capture video from virtual camera devices (appears as regular webcam to applications) - Apply real-time video effects and processing - Support multiple virtual camera instances The virtual camera appears as a standard webcam to applications like Zoom, Teams, OBS, and other video conferencing software. --- ## Architecture Overview The Virtual Camera SDK provides three main filter types: 1. **CLSID\_VFVirtualCameraSource**: Reads FROM virtual camera device (acts as a video capture source) 2. **CLSID\_VFVirtualCameraSink**: Writes TO virtual camera device (acts as a renderer) 3. **CLSID\_VFVideoPushSource**: Push source for frame-by-frame rendering (image sequences, custom rendering) **Typical workflows**: - File/Camera → VirtualCameraSink → Virtual Camera Device → Other Applications - Virtual Camera Device → VirtualCameraSource → Your Application - PushSource (frames) → VirtualCameraSink → Virtual Camera Device → Other Applications --- ## Prerequisites ### C# Projects ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; ``` **Required NuGet Packages**: - `VisioForge.DirectShowAPI` - DirectShow wrapper library **Key CLSIDs**: ``` // Filter CLSIDs (available in Consts class) public static readonly Guid CLSID_VFVirtualCameraSource = new Guid("AA4DA14E-644B-487a-A7CB-517A390B4BB8"); // Read from virtual camera public static readonly Guid CLSID_VFVirtualCameraSink = new Guid("AA6AB4DF-9670-4913-88BB-2CB381C19340"); // Write to virtual camera public static readonly Guid CLSID_VFVirtualAudioCardSource = new Guid("B5A463DF-4016-4C34-AA4F-48EC1B51C73F"); // Audio source public static readonly Guid CLSID_VFVirtualAudioCardSink = new Guid("1A2673B0-553E-4027-AECC-839405468950"); // Audio sink // Push source for frame-by-frame rendering public static readonly Guid CLSID_VFVideoPushSource = new Guid("38D15306-BBC6-4D6C-A89C-9621604D9FC1"); ``` ### C++ Projects ``` #include #include #include "ivirtualcamera.h" #pragma comment(lib, "strmiids.lib") // Filter CLSIDs DEFINE_GUID(CLSID_VFVirtualCameraSource, 0xAA4DA14E, 0x644B, 0x487a, 0xA7, 0xCB, 0x51, 0x7A, 0x39, 0x0B, 0x4B, 0xB8); DEFINE_GUID(CLSID_VFVirtualCameraSink, 0xAA6AB4DF, 0x9670, 0x4913, 0x88, 0xBB, 0x2C, 0xB3, 0x81, 0xC1, 0x93, 0x40); DEFINE_GUID(CLSID_VFVirtualAudioCardSource, 0xB5A463DF, 0x4016, 0x4C34, 0xAA, 0x4F, 0x48, 0xEC, 0x1B, 0x51, 0xC7, 0x3F); DEFINE_GUID(CLSID_VFVirtualAudioCardSink, 0x1A2673B0, 0x553E, 0x4027, 0xAE, 0xCC, 0x83, 0x94, 0x05, 0x46, 0x89, 0x50); DEFINE_GUID(CLSID_VFVideoPushSource, 0x38D15306, 0xBBC6, 0x4D6C, 0xA8, 0x9C, 0x96, 0x21, 0x60, 0x4D, 0x9F, 0xC1); ``` --- ## Example 1: Stream Video File to Virtual Camera This example demonstrates streaming a video file to a virtual camera device. ### C# Implementation ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VirtualCameraFileStreaming { private IFilterGraph2 filterGraphSource; private ICaptureGraphBuilder2 captureGraphSource; private IMediaControl mediaControlSource; private IMediaEventEx mediaEventExSource; private IBaseFilter sourceVideoFilter; private IBaseFilter sinkVideoFilter; private IBaseFilter sinkAudioFilter; public void StreamFileToVirtualCamera(string videoFile) { try { // Create filter graph filterGraphSource = (IFilterGraph2)new FilterGraph(); captureGraphSource = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControlSource = (IMediaControl)filterGraphSource; mediaEventExSource = (IMediaEventEx)filterGraphSource; // Attach the filter graph to the capture graph int hr = captureGraphSource.SetFiltergraph(filterGraphSource); DsError.ThrowExceptionForHR(hr); // Add Virtual Camera Sink for video sinkVideoFilter = FilterGraphTools.AddFilterFromClsid( filterGraphSource, Consts.CLSID_VFVirtualCameraSink, "VisioForge Virtual Camera Sink - Video"); // Optional: Set license key for purchased version var sinkIntf = sinkVideoFilter as IVFVirtualCameraSink; sinkIntf?.set_license("YOUR-LICENSE-KEY"); // Use "TRIAL" for trial version // Add Virtual Camera Sink for audio sinkAudioFilter = FilterGraphTools.AddFilterFromClsid( filterGraphSource, Consts.CLSID_VFVirtualAudioCardSink, "VisioForge Virtual Camera Sink - Audio"); // Add source filter for the video file // DirectShow automatically selects appropriate source filter filterGraphSource.AddSourceFilter(videoFile, "Source file", out sourceVideoFilter); // Render video stream: Source → Virtual Camera Sink hr = captureGraphSource.RenderStream(null, null, sourceVideoFilter, null, sinkVideoFilter); DsError.ThrowExceptionForHR(hr); // Render audio stream: Source → Virtual Camera Sink hr = captureGraphSource.RenderStream(null, null, sourceVideoFilter, null, sinkAudioFilter); // Note: Audio errors are not critical, better to check if audio is available // Start playback hr = mediaControlSource.Run(); DsError.ThrowExceptionForHR(hr); Console.WriteLine("Streaming to virtual camera. Press any key to stop..."); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Cleanup(); throw; } } public void Cleanup() { // Stop playback if (mediaControlSource != null) { mediaControlSource.Stop(); } // Stop receiving events mediaEventExSource?.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); // Remove all filters FilterGraphTools.RemoveAllFilters(filterGraphSource); // Release DirectShow interfaces if (mediaControlSource != null) { Marshal.ReleaseComObject(mediaControlSource); mediaControlSource = null; } if (mediaEventExSource != null) { Marshal.ReleaseComObject(mediaEventExSource); mediaEventExSource = null; } if (sourceVideoFilter != null) { Marshal.ReleaseComObject(sourceVideoFilter); sourceVideoFilter = null; } if (sinkVideoFilter != null) { Marshal.ReleaseComObject(sinkVideoFilter); sinkVideoFilter = null; } if (sinkAudioFilter != null) { Marshal.ReleaseComObject(sinkAudioFilter); sinkAudioFilter = null; } if (captureGraphSource != null) { Marshal.ReleaseComObject(captureGraphSource); captureGraphSource = null; } if (filterGraphSource != null) { Marshal.ReleaseComObject(filterGraphSource); filterGraphSource = null; } } } ``` ### C++ Implementation ## ``` #include #include "ivirtualcamera.h" HRESULT StreamFileToVirtualCamera(LPCWSTR videoFile) { HRESULT hr = S_OK; IGraphBuilder* pGraph = NULL; ICaptureGraphBuilder2* pBuild = NULL; IMediaControl* pControl = NULL; IBaseFilter* pSourceFilter = NULL; IBaseFilter* pSinkVideoFilter = NULL; IBaseFilter* pSinkAudioFilter = NULL; // Initialize COM CoInitialize(NULL); // Create the filter graph manager hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph); if (FAILED(hr)) return hr; // Create the Capture Graph Builder hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild); if (FAILED(hr)) goto cleanup; // Set the filter graph hr = pBuild->SetFiltergraph(pGraph); if (FAILED(hr)) goto cleanup; // Create Virtual Camera Sink filter for video hr = CoCreateInstance(CLSID_VFVirtualCameraSink, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pSinkVideoFilter); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pSinkVideoFilter, L"VisioForge Virtual Camera Sink - Video"); if (FAILED(hr)) goto cleanup; // Create Virtual Camera Sink filter for audio hr = CoCreateInstance(CLSID_VFVirtualAudioCardSink, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pSinkAudioFilter); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pSinkAudioFilter, L"VisioForge Virtual Camera Sink - Audio"); if (FAILED(hr)) goto cleanup; // Add source filter for the file hr = pGraph->AddSourceFilter(videoFile, L"Source File", &pSourceFilter); if (FAILED(hr)) goto cleanup; // Render video stream hr = pBuild->RenderStream(NULL, NULL, pSourceFilter, NULL, pSinkVideoFilter); if (FAILED(hr)) goto cleanup; // Render audio stream (errors not critical) pBuild->RenderStream(NULL, NULL, pSourceFilter, NULL, pSinkAudioFilter); // Get media control interface hr = pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); if (SUCCEEDED(hr)) { // Start playback hr = pControl->Run(); } cleanup: // Release interfaces if (pControl) pControl->Release(); if (pSinkAudioFilter) pSinkAudioFilter->Release(); if (pSinkVideoFilter) pSinkVideoFilter->Release(); if (pSourceFilter) pSourceFilter->Release(); if (pBuild) pBuild->Release(); if (pGraph) pGraph->Release(); return hr; } ``` ## Example 2: Stream Physical Camera to Virtual Camera This example demonstrates capturing from a physical webcam and streaming it to a virtual camera device. ### C# Implementation ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VirtualCameraFromPhysicalCamera { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IBaseFilter cameraFilter; private IBaseFilter virtualCameraSink; public void StreamCameraToVirtualCamera(string physicalCameraName) { try { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; // Attach filter graph to capture graph int hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Add physical camera filter cameraFilter = FilterGraphTools.AddFilterByName( filterGraph, FilterCategory.VideoInputDevice, physicalCameraName); if (cameraFilter == null) { throw new Exception($"Camera '{physicalCameraName}' not found"); } // Add Virtual Camera Sink virtualCameraSink = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVirtualCameraSink, "Virtual Camera Sink"); // Optional: Set license var sinkIntf = virtualCameraSink as IVFVirtualCameraSink; sinkIntf?.set_license("TRIAL"); // Render stream: Physical Camera → Virtual Camera Sink hr = captureGraph.RenderStream( null, MediaType.Video, cameraFilter, null, virtualCameraSink); DsError.ThrowExceptionForHR(hr); // Start capture hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); Console.WriteLine("Streaming physical camera to virtual camera..."); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Cleanup(); throw; } } public void Cleanup() { if (mediaControl != null) { mediaControl.Stop(); } FilterGraphTools.RemoveAllFilters(filterGraph); if (cameraFilter != null) { Marshal.ReleaseComObject(cameraFilter); cameraFilter = null; } if (virtualCameraSink != null) { Marshal.ReleaseComObject(virtualCameraSink); virtualCameraSink = null; } if (mediaControl != null) { Marshal.ReleaseComObject(mediaControl); mediaControl = null; } if (captureGraph != null) { Marshal.ReleaseComObject(captureGraph); captureGraph = null; } if (filterGraph != null) { Marshal.ReleaseComObject(filterGraph); filterGraph = null; } } } ``` --- ## Example 3: Stream Image Sequence to Virtual Camera (Frame-by-Frame) This example demonstrates rendering individual frames (image sequence or slideshow) to a virtual camera device. ### C# Implementation ## ``` using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VirtualCameraFrameByFrame { private IFilterGraph2 filterGraphSource; private ICaptureGraphBuilder2 captureGraphSource; private IMediaControl mediaControlSource; private IBaseFilter sourceVideoFilter; private IBaseFilter sinkVideoFilter; private IVFLiveVideoSource pushSource; private System.Windows.Forms.Timer framePushTimer; private int currentFrameIndex = 0; private Bitmap[] frames; public void StreamImageSequenceToVirtualCamera(string[] imageFiles, float frameRate = 10) { try { // Load images into memory frames = new Bitmap[imageFiles.Length]; for (int i = 0; i < imageFiles.Length; i++) { frames[i] = new Bitmap(imageFiles[i]); } if (frames.Length == 0) { throw new Exception("No images to display"); } int width = frames[0].Width; int height = frames[0].Height; // Create filter graph filterGraphSource = (IFilterGraph2)new FilterGraph(); captureGraphSource = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControlSource = (IMediaControl)filterGraphSource; int hr = captureGraphSource.SetFiltergraph(filterGraphSource); DsError.ThrowExceptionForHR(hr); // Add Virtual Camera Sink sinkVideoFilter = FilterGraphTools.AddFilterFromClsid( filterGraphSource, Consts.CLSID_VFVirtualCameraSink, "VisioForge Virtual Camera Sink - Video"); var sinkIntf = sinkVideoFilter as IVFVirtualCameraSink; sinkIntf?.set_license("TRIAL"); // Add push source filter Guid CLSID_VFVideoPushSource = new Guid("38D15306-BBC6-4D6C-A89C-9621604D9FC1"); sourceVideoFilter = FilterGraphTools.AddFilterFromClsid( filterGraphSource, CLSID_VFVideoPushSource, "VisioForge Video Push Source"); if (sourceVideoFilter == null) { throw new Exception("Unable to create VisioForge Push Source filter."); } // Get IVFLiveVideoSource interface pushSource = sourceVideoFilter as IVFLiveVideoSource; if (pushSource == null) { throw new Exception("Unable to get IVFLiveVideoSource interface."); } // Configure bitmap format var bmiHeader = new BitmapInfoHeader { BitCount = 24, Compression = 0, Width = width, Height = height, Planes = 1, Size = Marshal.SizeOf(typeof(BitmapInfoHeader)), ImageSize = GetStrideRGB24(width) * height }; pushSource.SetBitmapInfo(bmiHeader); pushSource.SetFrameRate(frameRate); // Connect filters: Push Source → Virtual Camera Sink hr = captureGraphSource.RenderStream(null, null, sourceVideoFilter, null, sinkVideoFilter); DsError.ThrowExceptionForHR(hr); // Start the graph hr = mediaControlSource.Run(); DsError.ThrowExceptionForHR(hr); // Setup timer to push frames framePushTimer = new System.Windows.Forms.Timer(); framePushTimer.Interval = (int)(1000 / frameRate); framePushTimer.Tick += PushFrame; framePushTimer.Start(); Console.WriteLine("Streaming image sequence to virtual camera..."); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Cleanup(); throw; } } private void PushFrame(object sender, EventArgs e) { if (frames == null || frames.Length == 0 || pushSource == null) return; // Get current frame Bitmap frame = frames[currentFrameIndex]; // Lock bitmap data BitmapData bmpData = frame.LockBits( new Rectangle(0, 0, frame.Width, frame.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); try { // AddFrame takes an AVFrameData (LPStruct), NOT a raw IntPtr. // Build it from the locked bitmap before pushing. int frameSize = bmpData.Stride * frame.Height; long durationTicks = (long)(10_000_000.0 / frameRate); // 100ns units var avFrame = new AVFrameData { Data = bmpData.Scan0, Size = frameSize, StartTime = currentFrameIndex * durationTicks, StopTime = (currentFrameIndex + 1) * durationTicks }; pushSource.AddFrame(avFrame); } finally { frame.UnlockBits(bmpData); } // Move to next frame (loop) currentFrameIndex = (currentFrameIndex + 1) % frames.Length; } private int GetStrideRGB24(int width) { return ((width * 24 + 31) / 32) * 4; } public void Cleanup() { // Stop timer if (framePushTimer != null) { framePushTimer.Stop(); framePushTimer.Dispose(); framePushTimer = null; } // Stop playback if (mediaControlSource != null) { mediaControlSource.Stop(); } // Release frames if (frames != null) { foreach (var frame in frames) { frame?.Dispose(); } frames = null; } // Release DirectShow interfaces pushSource = null; FilterGraphTools.RemoveAllFilters(filterGraphSource); if (sourceVideoFilter != null) { Marshal.ReleaseComObject(sourceVideoFilter); sourceVideoFilter = null; } if (sinkVideoFilter != null) { Marshal.ReleaseComObject(sinkVideoFilter); sinkVideoFilter = null; } if (mediaControlSource != null) { Marshal.ReleaseComObject(mediaControlSource); mediaControlSource = null; } if (captureGraphSource != null) { Marshal.ReleaseComObject(captureGraphSource); captureGraphSource = null; } if (filterGraphSource != null) { Marshal.ReleaseComObject(filterGraphSource); filterGraphSource = null; } } } ``` ## Example 4: Read From Virtual Camera This example demonstrates capturing video from a virtual camera device (useful for testing or monitoring what's being sent to the virtual camera). ### C# Implementation ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; using MediaFoundation; using MediaFoundation.EVR; public class VirtualCameraCapture { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IBaseFilter virtualCameraSource; private IBaseFilter videoRenderer; public void CaptureFromVirtualCamera(IntPtr videoWindowHandle) { try { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; int hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Add Virtual Camera Source filter virtualCameraSource = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVirtualCameraSource, "VisioForge Virtual Camera"); if (virtualCameraSource == null) { throw new Exception("Unable to create Virtual Camera Source filter"); } // NOTE: IVFVirtualCameraSource exposes only SetCustomVideoSize() and // FixResolution(). Licensing lives on the SINK side (IVFVirtualCameraSink::set_license) // because that is the filter that publishes content to the virtual camera; the source // filter shown here only consumes it. // Create Enhanced Video Renderer (EVR) Guid CLSID_EVR = new Guid("FA10746C-9B63-4B6C-BC49-FC300EA5F256"); videoRenderer = FilterGraphTools.AddFilterFromClsid(filterGraph, CLSID_EVR, "EVR"); // Configure EVR var evrConfig = videoRenderer as IEVRFilterConfig; evrConfig?.SetNumberOfStreams(1); // Set video window var getService = videoRenderer as MediaFoundation.IMFGetService; if (getService != null) { getService.GetService( MediaFoundation.MFServices.MR_VIDEO_RENDER_SERVICE, typeof(MediaFoundation.IMFVideoDisplayControl).GUID, out var videoDisplayControlObj); var videoDisplayControl = videoDisplayControlObj as MediaFoundation.IMFVideoDisplayControl; videoDisplayControl?.SetVideoWindow(videoWindowHandle); } // Render stream: Virtual Camera Source → EVR hr = captureGraph.RenderStream( null, MediaType.Video, virtualCameraSource, null, videoRenderer); DsError.ThrowExceptionForHR(hr); // Start playback hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); Console.WriteLine("Capturing from virtual camera..."); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Cleanup(); throw; } } public void Cleanup() { if (mediaControl != null) { mediaControl.Stop(); } FilterGraphTools.RemoveAllFilters(filterGraph); if (virtualCameraSource != null) { Marshal.ReleaseComObject(virtualCameraSource); virtualCameraSource = null; } if (videoRenderer != null) { Marshal.ReleaseComObject(videoRenderer); videoRenderer = null; } if (mediaControl != null) { Marshal.ReleaseComObject(mediaControl); mediaControl = null; } if (captureGraph != null) { Marshal.ReleaseComObject(captureGraph); captureGraph = null; } if (filterGraph != null) { Marshal.ReleaseComObject(filterGraph); filterGraph = null; } } } ``` --- ## Additional Resources For more detailed information, see: - [Virtual Camera SDK Product Page](https://www.visioforge.com/virtual-camera-sdk) - [End User License Agreement](../../../eula/) - [Sample Code Repository](https://github.com/visioforge/directshow-samples/tree/main/Virtual%20Camera%20SDK) ## Support - **Technical Support**: https://support.visioforge.com/ - **Discord Community**: https://discord.com/invite/yvXUG56WCH ---END OF PAGE--- ## Windows Virtual Camera SDK — DirectShow for Zoom, Teams, OBS **URL:** https://www.visioforge.com/help/docs/directshow/virtual-camera-sdk/ **Description:** Create virtual webcams recognized by Zoom, Teams, OBS, and browsers. VisioForge DirectShow SDK streams any video source with audio to virtual camera devices. **Tags:** Virtual Camera SDK, DirectShow, C++, Windows, Streaming, Virtual Camera **API:** IVFVirtualCameraSink, SinkFilter, IBaseFilter # DirectShow Virtual Camera SDK ## Overview Our robust DirectShow-based Virtual Camera SDK enables developers to implement powerful virtual camera functionality in their applications. The SDK provides sink filters that can be utilized as output in Video Capture SDK or Video Edit SDK environments, while the source filters can be employed as video sources for various capture applications. With this versatile toolkit, you can stream video content from virtually any source directly to a virtual camera device. These virtual devices are fully compatible with popular communication platforms such as `Skype`, `Zoom`, `Microsoft Teams`, web browsers, and numerous other applications that support DirectShow virtual cameras. The SDK also includes comprehensive audio streaming capabilities for complete multimedia solutions. To help you get started quickly, the SDK package includes a fully-functional sample application that demonstrates how to stream video content from files to virtual camera devices. Download the SDK from our [product page](https://www.visioforge.com/virtual-camera-sdk) to start integrating virtual camera functionality into your applications today. --- ## Installation Before using the code samples and integrating the SDK into your application, you must first install the Virtual Camera SDK from the [product page](https://www.visioforge.com/virtual-camera-sdk). **Installation Steps**: 1. Download the SDK installer from the product page 2. Run the installer with administrative privileges 3. The installer will register the virtual camera driver and all necessary DirectShow filters 4. Sample applications and source code will be available in the installation directory **Note**: The virtual camera driver and filters must be properly registered on the system before they can be used in your applications. The installer handles this automatically. --- ## Key Features and Capabilities - **Multiple Source Support**: Stream video to virtual camera from files, network streams, or capture devices - **Architecture Compatibility**: Full x86/x64 architecture support - **High-Resolution Support**: Stream video content up to 4K resolution - **Customization Options**: Define and implement custom camera names - **SDK Integration**: Seamless integration with other development tools - **Audio Support**: Complete audio streaming capabilities - **Professional Applications**: Perfect for teleconferencing, streaming, and professional video applications ## Technical Implementation ### Sample DirectShow Graph Architecture The diagram below illustrates the standard DirectShow graph implementation when using the Virtual Camera SDK: ### License Registration via Registry You can register the filter with your valid license key using the Windows registry system. Configure licensing using the following registry key: ``` HKEY_LOCAL_MACHINE\SOFTWARE\VisioForge\Virtual Camera SDK\License ``` Set your purchased license key as a string value in this registry location. ### Deployment Guidelines For proper deployment, copy and COM-register the SDK DirectShow filters - these are the files in the `Redist` folder with .ax extension. Registration can be performed using `regsvr32.exe` or through COM registration in your application installer. Please note that administrative privileges are required for successful registration. ### No-Signal Application Configuration You can configure an application to run automatically when the virtual camera is not connected to any video source. Configure the no-signal application using this registry key: ``` HKEY_LOCAL_MACHINE\SOFTWARE\VisioForge\Virtual Camera SDK\StartupEXE ``` Set the executable file name as a string value. ### No-Signal Image Configuration Instead of displaying a black screen when no video source is available, you can configure a custom image to be shown. Configure the no-signal image using this registry key: ``` HKEY_LOCAL_MACHINE\SOFTWARE\VisioForge\Virtual Camera SDK\BackgroundImage ``` Set the image file path as a string value. ## Interface Reference ### IVFVirtualCameraSink Interface The `IVFVirtualCameraSink` interface is used to configure the virtual camera sink filter, primarily for license registration. **Interface GUID**: `{A96631D2-4AC9-4F09-9F34-FF8229087DEB}` **Inherits From**: `IUnknown` #### C# Definition ``` using System; using System.Runtime.InteropServices; /// /// Virtual camera sink interface for license configuration. /// [ComImport] [System.Security.SuppressUnmanagedCodeSecurity] [Guid("A96631D2-4AC9-4F09-9F34-FF8229087DEB")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IVFVirtualCameraSink { /// /// Sets the license key for the virtual camera sink filter. /// /// License key string ("TRIAL" for trial version) /// HRESULT (0 for success) [PreserveSig] int set_license([MarshalAs(UnmanagedType.LPStr)] string license); } ``` Native C++/Delphi take ANSI; the SDK's bundled C# demo uses LPWStr The native `IVFVirtualCameraSink::set_license` parameter is `LPCSTR` (ANSI) in C++ and `PAnsiChar` in Delphi. The C# demo wrapper bundled with the SDK declares `[MarshalAs(UnmanagedType.LPWStr)]` — a known marshaling discrepancy in the demo. Pure-ASCII license keys (e.g., `"TRIAL"`, hex-encoded license strings) round-trip cleanly either way; if you need to match the native ABI exactly, use `LPStr` as shown above. **Usage Example (C#)**: ``` // Add Virtual Camera Sink filter var sinkFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVirtualCameraSink, "VisioForge Virtual Camera Sink"); // Set license var sinkIntf = sinkFilter as IVFVirtualCameraSink; if (sinkIntf != null) { sinkIntf.set_license("YOUR-LICENSE-KEY"); // or "TRIAL" for trial version } ``` #### C++ Definition ``` #include // {A96631D2-4AC9-4F09-9F34-FF8229087DEB} DEFINE_GUID(IID_IVFVirtualCameraSink, 0xa96631d2, 0x4ac9, 0x4f09, 0x9f, 0x34, 0xff, 0x82, 0x29, 0x8, 0x7d, 0xeb); /// /// Virtual camera sink interface for license configuration. /// DECLARE_INTERFACE_(IVFVirtualCameraSink, IUnknown) { /// /// Sets the license key for the virtual camera sink filter. /// /// License key ANSI string ("TRIAL" for trial version) /// HRESULT (S_OK for success) STDMETHOD(set_license) (THIS_ LPCSTR license ) PURE; }; ``` **Usage Example (C++)**: ``` IBaseFilter* pSinkFilter = nullptr; IVFVirtualCameraSink* pSinkIntf = nullptr; // Create Virtual Camera Sink filter hr = CoCreateInstance(CLSID_VFVirtualCameraSink, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pSinkFilter); if (SUCCEEDED(hr)) { // Query interface hr = pSinkFilter->QueryInterface(IID_IVFVirtualCameraSink, (void**)&pSinkIntf); if (SUCCEEDED(hr)) { // Set license — LPCSTR (ANSI), not wide string hr = pSinkIntf->set_license("YOUR-LICENSE-KEY"); // or "TRIAL" pSinkIntf->Release(); } } ``` #### Delphi Definition ``` uses ActiveX, ComObj; const IID_IVFVirtualCameraSink: TGUID = '{A96631D2-4AC9-4F09-9F34-FF8229087DEB}'; type /// /// Virtual camera sink interface for license configuration. /// IVFVirtualCameraSink = interface(IUnknown) ['{A96631D2-4AC9-4F09-9F34-FF8229087DEB}'] /// /// Sets the license key for the virtual camera sink filter. /// /// License key ANSI string ('TRIAL' for trial version) /// HRESULT (S_OK for success) function set_license(license: PAnsiChar): HRESULT; stdcall; end; ``` **Usage Example (Delphi)**: ``` var SinkFilter: IBaseFilter; SinkIntf: IVFVirtualCameraSink; begin // Create Virtual Camera Sink filter if Succeeded(CoCreateInstance(CLSID_VFVirtualCameraSink, nil, CLSCTX_INPROC_SERVER, IID_IBaseFilter, SinkFilter)) then begin // Query interface if Succeeded(SinkFilter.QueryInterface(IID_IVFVirtualCameraSink, SinkIntf)) then begin // Set license — PAnsiChar (ANSI string) SinkIntf.set_license(PAnsiChar(AnsiString('YOUR-LICENSE-KEY'))); // or AnsiString('TRIAL') SinkIntf := nil; end; end; end; ``` --- ## Third-Party Libraries and Integration The Virtual Camera SDK contains third-party components that are used in the demo applications. These components are not required for the core SDK functionality. The Delphi and .NET demonstration applications utilize third-party libraries to simplify DirectShow development. The C++ demo applications are built without external dependencies. ### .NET Integration .NET applications leverage [DirectShowLib.Net (LGPL)](https://sourceforge.net/projects/directshownet/) to implement DirectShow functionality in managed code environments. Developers can create console applications, WinForms, or WPF applications using .NET. The included demo applications utilize WinForms for the user interface. ### Delphi Integration Delphi applications use [DSPack (MPL)](https://code.google.com/archive/p/dspack/) to implement DirectShow functionality. While modern Delphi versions include built-in DirectShow support, DSPack is utilized in the demo applications to maintain compatibility with older Delphi versions. ### C++ Integration The C++ demo applications do not require third-party libraries and are built using the standard DirectShow SDK (part of Windows SDK). Developers can utilize MFC, ATL, or other C++ frameworks to build their applications. The included demo applications are built with MFC. ## System Requirements The SDK is compatible with the following Microsoft Windows operating systems: - Windows 7, 8, 8.1, 10, and 11 - Windows Server 2008, 2012, 2016, 2019, and 2022 ## Version History and Updates ### Version 14.0 - Performance optimizations and enhancements - Improved Windows 11 compatibility - Enhanced support for modern web browsers - Minor updates and bug fixes ### Version 12.0 - Windows 10 support improvements - Performance enhancements - 8K resolution support added - Improved Mozilla Firefox and Microsoft Edge compatibility - Various minor updates ### Version 11.0 - Critical bug fixes implemented - Updated Google Chrome compatibility - Resolved audio clicks issues in various web browsers and applications ### Version 10.0 - High frame rate support added - Significant performance improvements - Minor updates and bug fixes ### Version 9.0 - 4K video resolution support added - Updated support for contemporary web browsers - Various minor updates and improvements ### Version 8.0 - Added background image functionality for no-signal scenarios - Implemented application auto-run for no-signal conditions - Enhanced Skype compatibility ### Version 7.1 - Audio streaming support via virtual audio output and virtual microphone input - PCM audio format support with customizable sample rates and channel configuration - Bug fixes and performance improvements - Additional video resolutions added ### Version 7.0 - Initial release as a standalone product - Previously included in Video Edit SDK and Video Capture SDK - Compatible with any DirectShow application ## Additional Resources - [End User License Agreement](../../eula/) ---END OF PAGE--- ## VLC Source DirectShow Filter Integration Code Examples **URL:** https://www.visioforge.com/help/docs/directshow/vlc-source-filter/examples/ **Description:** Code examples for VLC Source Filter with multi-track audio, subtitles, 360° video, and custom VLC parameters in DirectShow. **Tags:** DirectShow, C++, Windows, WinForms, Playback, Streaming, Decoding, RTSP, HLS, MP4, MKV, AVI, MOV, C#, VB.NET **API:** IBaseFilter, IVFRegister # Code Examples ## Overview This page provides practical code examples for using the VLC Source Filter in DirectShow applications. The VLC Source Filter supports multi-audio tracks, subtitles, 360° video, and custom VLC command-line options. --- ## Prerequisites ### C++ Projects ``` #include #include #include "ivlcsrc.h" // Single header from SDK — declares IVlcSrc, IVlcSrc2, IVlcSrc3 + CLSID/IID GUIDs #pragma comment(lib, "strmiids.lib") ``` ### C# Projects ``` using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; using System.Runtime.InteropServices; using System.Text; ``` **NuGet Packages**: - VisioForge.DirectShowAPI - MediaFoundationCore --- ## Example 1: Basic File Playback Play a local media file with VLC Source Filter. ### C++ Implementation ``` #include #include "ivlcsrc.h" // CLSID for VLC Source Filter DEFINE_GUID(CLSID_VFVLCSource, 0x3fc97748, 0x7cb6, 0x4195, 0x89, 0xde, 0x07, 0x17, 0x58, 0x2a, 0x48, 0x63); HRESULT PlayVLCFile(LPCWSTR filename, HWND hVideoWindow) { IGraphBuilder* pGraph = NULL; IMediaControl* pControl = NULL; IBaseFilter* pSourceFilter = NULL; IVlcSrc* pVlcSrc = NULL; HRESULT hr = S_OK; // Create Filter Graph hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&pGraph); if (FAILED(hr)) return hr; // Create VLC Source Filter hr = CoCreateInstance(CLSID_VFVLCSource, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pSourceFilter); if (FAILED(hr)) goto cleanup; // Add filter to graph hr = pGraph->AddFilter(pSourceFilter, L"VLC Source"); if (FAILED(hr)) goto cleanup; // Get VLC interface hr = pSourceFilter->QueryInterface(IID_IVlcSrc, (void**)&pVlcSrc); if (FAILED(hr)) goto cleanup; // Load file hr = pVlcSrc->SetFile((WCHAR*)filename); if (FAILED(hr)) goto cleanup; // Build and render graph ICaptureGraphBuilder2* pBuild = NULL; hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild); if (SUCCEEDED(hr)) { hr = pBuild->SetFiltergraph(pGraph); // Render video and audio hr = pBuild->RenderStream(NULL, &MEDIATYPE_Video, pSourceFilter, NULL, NULL); hr = pBuild->RenderStream(NULL, &MEDIATYPE_Audio, pSourceFilter, NULL, NULL); pBuild->Release(); } // Run graph hr = pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); if (SUCCEEDED(hr)) { hr = pControl->Run(); } cleanup: if (pVlcSrc) pVlcSrc->Release(); if (pControl) pControl->Release(); if (pSourceFilter) pSourceFilter->Release(); if (pGraph) pGraph->Release(); return hr; } ``` ### C# Implementation ``` using System; using System.Runtime.InteropServices; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VLCSourceBasicExample { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; private IVideoWindow videoWindow; private IBaseFilter sourceFilter; public void PlayFile(string filename, IntPtr videoWindowHandle) { try { // Create filter graph filterGraph = (IFilterGraph2)new FilterGraph(); mediaControl = (IMediaControl)filterGraph; videoWindow = (IVideoWindow)filterGraph; // Create and add VLC Source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Load file using IVlcSrc interface var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { int hr = vlcSrc.SetFile(filename); DsError.ThrowExceptionForHR(hr); } // Render streams ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); int result = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(result); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Set video window videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); videoWindow.put_Visible(OABool.True); // Run graph mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } } public void Stop() { if (mediaControl != null) { mediaControl.Stop(); } if (videoWindow != null) { videoWindow.put_Visible(OABool.False); videoWindow.put_Owner(IntPtr.Zero); } FilterGraphTools.RemoveAllFilters(filterGraph); if (sourceFilter != null) Marshal.ReleaseComObject(sourceFilter); if (videoWindow != null) Marshal.ReleaseComObject(videoWindow); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } ``` ### VB.NET Implementation ``` Imports System.Runtime.InteropServices Imports VisioForge.DirectShowAPI Imports VisioForge.DirectShowLib Public Class VLCSourceBasicExample Private filterGraph As IFilterGraph2 Private mediaControl As IMediaControl Private videoWindow As IVideoWindow Private sourceFilter As IBaseFilter Public Sub PlayFile(filename As String, videoWindowHandle As IntPtr) Try ' Create filter graph filterGraph = DirectCast(New FilterGraph(), IFilterGraph2) mediaControl = DirectCast(filterGraph, IMediaControl) videoWindow = DirectCast(filterGraph, IVideoWindow) ' Create and add VLC Source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source") ' Load file Dim vlcSrc = DirectCast(sourceFilter, IVlcSrc) If vlcSrc IsNot Nothing Then Dim hr As Integer = vlcSrc.SetFile(filename) DsError.ThrowExceptionForHR(hr) End If ' Render streams Dim captureGraph As ICaptureGraphBuilder2 = DirectCast(New CaptureGraphBuilder2(), ICaptureGraphBuilder2) captureGraph.SetFiltergraph(filterGraph) captureGraph.RenderStream(Nothing, MediaType.Video, sourceFilter, Nothing, Nothing) captureGraph.RenderStream(Nothing, MediaType.Audio, sourceFilter, Nothing, Nothing) ' Set video window videoWindow.put_Owner(videoWindowHandle) videoWindow.put_WindowStyle(WindowStyle.Child Or WindowStyle.ClipSiblings) videoWindow.put_Visible(OABool.True) ' Run graph mediaControl.Run() Marshal.ReleaseComObject(captureGraph) Catch ex As Exception Console.WriteLine($"Error: {ex.Message}") End Try End Sub Public Sub [Stop]() If mediaControl IsNot Nothing Then mediaControl.Stop() End If If videoWindow IsNot Nothing Then videoWindow.put_Visible(OABool.False) videoWindow.put_Owner(IntPtr.Zero) End If FilterGraphTools.RemoveAllFilters(filterGraph) If sourceFilter IsNot Nothing Then Marshal.ReleaseComObject(sourceFilter) If videoWindow IsNot Nothing Then Marshal.ReleaseComObject(videoWindow) If mediaControl IsNot Nothing Then Marshal.ReleaseComObject(mediaControl) If filterGraph IsNot Nothing Then Marshal.ReleaseComObject(filterGraph) End Sub End Class ``` --- ## Example 2: Audio Track Selection List and select audio tracks from multi-audio files. ### C# Audio Track Management ``` public class VLCAudioTrackExample { private IFilterGraph2 filterGraph; private IMediaControl mediaControl; private IBaseFilter sourceFilter; public void PlayWithAudioTrackSelection(string filename, IntPtr videoWindowHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); mediaControl = (IMediaControl)filterGraph; // Create VLC Source filter sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Load file var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { vlcSrc.SetFile(filename); // Get audio track count int audioCount = 0; vlcSrc.GetAudioTracksCount(out audioCount); Console.WriteLine($"Total audio tracks: {audioCount}"); // List all audio tracks for (int i = 0; i < audioCount; i++) { int trackId; StringBuilder trackName = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(i, out trackId, trackName); Console.WriteLine($"Track {i}: ID={trackId}, Name={trackName}"); } // Get currently active track int currentTrackId; vlcSrc.GetAudioTrack(out currentTrackId); Console.WriteLine($"Currently active track ID: {currentTrackId}"); // Select a specific track (e.g., track index 1) if (audioCount > 1) { int desiredTrackId; StringBuilder name = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(1, out desiredTrackId, name); vlcSrc.SetAudioTrack(desiredTrackId); Console.WriteLine($"Switched to track: {name}"); } } // Build and run graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } // Method to switch audio track during playback public void SwitchAudioTrack(int trackIndex) { var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { int trackId; StringBuilder trackName = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(trackIndex, out trackId, trackName); vlcSrc.SetAudioTrack(trackId); Console.WriteLine($"Switched to audio track: {trackName}"); } } } ``` ### C++ Audio Track Management ## ``` void ListAndSelectAudioTracks(IVlcSrc* pVlcSrc) { int audioCount = 0; pVlcSrc->GetAudioTracksCount(&audioCount); wprintf(L"Total audio tracks: %d\n", audioCount); // List all tracks for (int i = 0; i < audioCount; i++) { int trackId = 0; WCHAR trackName[256] = {0}; pVlcSrc->GetAudioTrackInfo(i, &trackId, trackName); wprintf(L"Track %d: ID=%d, Name=%s\n", i, trackId, trackName); } // Get current track int currentId = 0; pVlcSrc->GetAudioTrack(¤tId); wprintf(L"Current track ID: %d\n", currentId); // Select track by index (e.g., track 1) if (audioCount > 1) { int trackId = 0; WCHAR name[256] = {0}; pVlcSrc->GetAudioTrackInfo(1, &trackId, name); pVlcSrc->SetAudioTrack(trackId); wprintf(L"Switched to track: %s\n", name); } } ``` ## Example 3: Subtitle Management Select and manage subtitle tracks. ### C# Subtitle Management ``` public class VLCSubtitleExample { private IBaseFilter sourceFilter; public void ManageSubtitles(string filename) { // Assume filter is already created and added to graph var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { vlcSrc.SetFile(filename); // Get subtitle count int subtitleCount = 0; vlcSrc.GetSubtitlesCount(out subtitleCount); Console.WriteLine($"Total subtitle tracks: {subtitleCount}"); // List all subtitles for (int i = 0; i < subtitleCount; i++) { int subtitleId; StringBuilder subtitleName = new StringBuilder(256); vlcSrc.GetSubtitleInfo(i, out subtitleId, subtitleName); Console.WriteLine($"Subtitle {i}: ID={subtitleId}, Name={subtitleName}"); } // Enable subtitle (e.g., subtitle index 0) if (subtitleCount > 0) { int subtitleId; StringBuilder name = new StringBuilder(256); vlcSrc.GetSubtitleInfo(0, out subtitleId, name); vlcSrc.SetSubtitle(subtitleId); Console.WriteLine($"Enabled subtitle: {name}"); } // Disable subtitles (use ID -1) // vlcSrc.SetSubtitle(-1); } } // Method to switch subtitles during playback public void SwitchSubtitle(int subtitleIndex) { var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { if (subtitleIndex < 0) { // Disable subtitles vlcSrc.SetSubtitle(-1); Console.WriteLine("Subtitles disabled"); } else { int subtitleId; StringBuilder name = new StringBuilder(256); vlcSrc.GetSubtitleInfo(subtitleIndex, out subtitleId, name); vlcSrc.SetSubtitle(subtitleId); Console.WriteLine($"Switched to subtitle: {name}"); } } } } ``` ### C++ Subtitle Management ``` void ManageSubtitles(IVlcSrc* pVlcSrc) { int subtitleCount = 0; pVlcSrc->GetSubtitlesCount(&subtitleCount); wprintf(L"Total subtitles: %d\n", subtitleCount); // List all subtitles for (int i = 0; i < subtitleCount; i++) { int subtitleId = 0; WCHAR subtitleName[256] = {0}; pVlcSrc->GetSubtitleInfo(i, &subtitleId, subtitleName); wprintf(L"Subtitle %d: ID=%d, Name=%s\n", i, subtitleId, subtitleName); } // Enable first subtitle if (subtitleCount > 0) { int id = 0; WCHAR name[256] = {0}; pVlcSrc->GetSubtitleInfo(0, &id, name); pVlcSrc->SetSubtitle(id); wprintf(L"Enabled subtitle: %s\n", name); } // Disable subtitles // pVlcSrc->SetSubtitle(-1); } ``` --- ## Example 4: Custom VLC Command-Line Options Pass custom VLC parameters using IVlcSrc2 interface. ### C# Custom VLC Parameters ``` using System; using System.Collections.Generic; using System.Runtime.InteropServices; using VisioForge.Core.Helpers; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VLCCustomOptionsExample { public void PlayWithCustomVLCOptions(string filename, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); var sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Set custom VLC command-line options using IVlcSrc2 var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { // Create list of VLC command-line parameters var parameters = new List(); parameters.Add("--avcodec-hw=any"); // Enable hardware decoding parameters.Add("--network-caching=1000"); // 1 second network cache parameters.Add("--live-caching=300"); // 300ms for live streams parameters.Add("--file-caching=300"); // 300ms for files parameters.Add("--sout-mux-caching=2000"); // Output muxing cache parameters.Add("--vout=direct3d11"); // Use Direct3D11 renderer parameters.Add("--verbose=2"); // Logging level // Convert strings to native UTF-8 IntPtr array var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { // Call SetCustomCommandLine with IntPtr array int hr = vlcSrc2.SetCustomCommandLine(array, parameters.Count); DsError.ThrowExceptionForHR(hr); } finally { // Free allocated unmanaged memory for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } // Load file using IVlcSrc var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { vlcSrc.SetFile(filename); } // Build and run graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } ``` ### Common VLC Options Here are common VLC parameter combinations. Remember to use the proper marshaling pattern shown above. ``` // Network streaming options var networkOptions = new List { "--network-caching=3000", // 3 seconds for network streams "--rtsp-tcp", // Force TCP for RTSP "--http-reconnect" // Auto-reconnect HTTP streams }; // Hardware decoding options var hwDecodeOptions = new List { "--avcodec-hw=any" // Auto-detect hardware // Alternative options: // "--avcodec-hw=dxva2" // Use DXVA2 // "--avcodec-hw=d3d11va" // Use D3D11VA // "--avcodec-hw=nvdec" // Use NVIDIA NVDEC }; // Low latency options var lowLatencyOptions = new List { "--network-caching=0", "--live-caching=0", "--file-caching=0", "--sout-mux-caching=0", "--clock-jitter=0", "--drop-late-frames", "--skip-frames" }; // 360° video options var video360Options = new List { "--video-filter=transform", "--transform-type=hflip", "--vout-filter=rotate" }; // Subtitle options var subtitleOptions = new List { "--sub-autodetect-file", // Auto-detect subtitle files "--sub-language=eng", // Preferred subtitle language "--freetype-fontsize=20" // Subtitle font size }; // Audio options var audioOptions = new List { "--audio-desync=0", // Audio synchronization "--audiotrack-language=eng", // Preferred audio language "--audio-filter=normvol" // Volume normalization }; // Complete example with multiple options var completeOptions = new List { "--avcodec-hw=any", "--network-caching=1000", "--rtsp-tcp", "--sub-autodetect-file", "--verbose=1" }; // Helper method to apply VLC parameters private void ApplyVLCParameters(IVlcSrc2 vlcSrc2, List parameters) { if (vlcSrc2 == null || parameters == null || parameters.Count == 0) return; var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { int hr = vlcSrc2.SetCustomCommandLine(array, parameters.Count); DsError.ThrowExceptionForHR(hr); } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } ``` --- ## Example 5: Frame Rate Override Override source frame rate using IVlcSrc3 interface. ### C# Frame Rate Override ``` public class VLCFrameRateExample { public void PlayWithCustomFrameRate(string filename, double fps, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); var sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Set custom frame rate using IVlcSrc3 var vlcSrc3 = sourceFilter as IVlcSrc3; if (vlcSrc3 != null) { // Override frame rate (e.g., 30.0, 25.0, 60.0) int hr = vlcSrc3.SetDefaultFrameRate(fps); DsError.ThrowExceptionForHR(hr); Console.WriteLine($"Frame rate set to: {fps} fps"); } // Load file var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { vlcSrc.SetFile(filename); } // Build and run graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } ``` ### C++ Frame Rate Override ``` #include "ivlcsrc.h" void SetCustomFrameRate(IBaseFilter* pFilter, double fps) { IVlcSrc3* pVlcSrc3 = nullptr; HRESULT hr = pFilter->QueryInterface(IID_IVlcSrc3, (void**)&pVlcSrc3); if (SUCCEEDED(hr)) { hr = pVlcSrc3->SetDefaultFrameRate(fps); if (SUCCEEDED(hr)) { wprintf(L"Frame rate set to: %.2f fps\n", fps); } pVlcSrc3->Release(); } } ``` --- ## Example 6: Network Streaming (RTSP/HLS) Stream from network sources. ### C# Network Streaming ## ``` public class VLCNetworkStreamingExample { public void PlayRTSPStream(string rtspUrl, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); var sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Configure for RTSP streaming var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { var parameters = new List { "--rtsp-tcp", // Use TCP transport "--network-caching=300", // Low latency (300ms) "--rtsp-frame-buffer-size=500000", // Frame buffer size "--drop-late-frames", // Drop late frames "--skip-frames" // Skip frames if needed }; var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { vlcSrc2.SetCustomCommandLine(array, parameters.Count); } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } // Load RTSP stream var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { // Example: "rtsp://camera.example.com:554/stream" vlcSrc.SetFile(rtspUrl); } // Build and run graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } public void PlayHLSStream(string hlsUrl, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); var sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Configure for HLS streaming var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { var parameters = new List { "--http-reconnect", // Auto-reconnect "--network-caching=3000", // 3 second buffer for HLS "--hls-segment-threads=3", // Parallel segment download "--avcodec-hw=any" // Hardware decoding }; var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { vlcSrc2.SetCustomCommandLine(array, parameters.Count); } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } // Load HLS stream var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { // Example: "https://example.com/stream/playlist.m3u8" vlcSrc.SetFile(hlsUrl); } // Build and run graph ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } } ``` ## Example 7: License Activation Activate purchased license. ### C# License Activation ``` public void PlayWithLicense(string filename, string licenseKey, IntPtr videoWindowHandle) { var filterGraph = (IFilterGraph2)new FilterGraph(); var sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Activate license var registration = sourceFilter as IVFRegister; if (registration != null) { int hr = registration.SetLicenseKey(licenseKey); if (hr != 0) { throw new Exception("License activation failed"); } } // Load and play file var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { vlcSrc.SetFile(filename); } ICaptureGraphBuilder2 captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); captureGraph.SetFiltergraph(filterGraph); captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); var videoWindow = (IVideoWindow)filterGraph; videoWindow.put_Owner(videoWindowHandle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); var mediaControl = (IMediaControl)filterGraph; mediaControl.Run(); Marshal.ReleaseComObject(captureGraph); } ``` --- ## Example 8: Complete Multi-Track Player Full-featured media player with all VLC Source features. ### C# Complete Example ``` using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; public class VLCMediaPlayer : IDisposable { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IMediaSeeking mediaSeeking; private IVideoWindow videoWindow; private IMediaEventEx mediaEventEx; private IBaseFilter sourceFilter; private const int WM_GRAPHNOTIFY = 0x8000 + 1; public event EventHandler PlaybackComplete; public List AudioTracks { get; private set; } = new List(); public List Subtitles { get; private set; } = new List(); public class AudioTrackInfo { public int Index { get; set; } public int Id { get; set; } public string Name { get; set; } } public class SubtitleInfo { public int Index { get; set; } public int Id { get; set; } public string Name { get; set; } } public void Initialize(IntPtr windowHandle, IntPtr notifyHandle) { filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; mediaSeeking = (IMediaSeeking)filterGraph; videoWindow = (IVideoWindow)filterGraph; mediaEventEx = (IMediaEventEx)filterGraph; int hr = mediaEventEx.SetNotifyWindow(notifyHandle, WM_GRAPHNOTIFY, IntPtr.Zero); DsError.ThrowExceptionForHR(hr); hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); } public void LoadFile(string filename, string licenseKey = null, string vlcOptions = null, double? frameRate = null) { sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Register license if (!string.IsNullOrEmpty(licenseKey)) { var registration = sourceFilter as IVFRegister; registration?.SetLicenseKey(licenseKey); } // Set custom VLC options if (!string.IsNullOrEmpty(vlcOptions)) { var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { // Parse space-separated options into list var parameters = new List(vlcOptions.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { vlcSrc2.SetCustomCommandLine(array, parameters.Count); } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } } // Set frame rate override if (frameRate.HasValue) { var vlcSrc3 = sourceFilter as IVlcSrc3; vlcSrc3?.SetDefaultFrameRate(frameRate.Value); } // Load file var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { int hr = vlcSrc.SetFile(filename); DsError.ThrowExceptionForHR(hr); // Enumerate audio tracks LoadAudioTracks(vlcSrc); // Enumerate subtitles LoadSubtitles(vlcSrc); } // Build graph int result = captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, null); result = captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); } private void LoadAudioTracks(IVlcSrc vlcSrc) { AudioTracks.Clear(); int count = 0; vlcSrc.GetAudioTracksCount(out count); for (int i = 0; i < count; i++) { int id; StringBuilder name = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(i, out id, name); AudioTracks.Add(new AudioTrackInfo { Index = i, Id = id, Name = name.ToString() }); } } private void LoadSubtitles(IVlcSrc vlcSrc) { Subtitles.Clear(); int count = 0; vlcSrc.GetSubtitlesCount(out count); for (int i = 0; i < count; i++) { int id; StringBuilder name = new StringBuilder(256); vlcSrc.GetSubtitleInfo(i, out id, name); Subtitles.Add(new SubtitleInfo { Index = i, Id = id, Name = name.ToString() }); } } public void SetVideoWindow(IntPtr handle, int width, int height) { if (videoWindow != null) { videoWindow.put_Owner(handle); videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings); videoWindow.SetWindowPosition(0, 0, width, height); videoWindow.put_Visible(OABool.True); } } public void Play() => mediaControl?.Run(); public void Pause() => mediaControl?.Pause(); public void Stop() => mediaControl?.Stop(); public void SelectAudioTrack(int trackIndex) { var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null && trackIndex >= 0 && trackIndex < AudioTracks.Count) { vlcSrc.SetAudioTrack(AudioTracks[trackIndex].Id); } } public void SelectSubtitle(int subtitleIndex) { var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { if (subtitleIndex < 0) { vlcSrc.SetSubtitle(-1); // Disable } else if (subtitleIndex < Subtitles.Count) { vlcSrc.SetSubtitle(Subtitles[subtitleIndex].Id); } } } public void Seek(long timeInSeconds) { if (mediaSeeking != null) { long seekPos = timeInSeconds * 10000000; mediaSeeking.SetPositions(ref seekPos, AMSeekingSeekingFlags.AbsolutePositioning, IntPtr.Zero, AMSeekingSeekingFlags.NoPositioning); } } public long GetPosition() { if (mediaSeeking != null) { mediaSeeking.GetCurrentPosition(out long position); return position / 10000000; } return 0; } public long GetDuration() { if (mediaSeeking != null) { mediaSeeking.GetDuration(out long duration); return duration / 10000000; } return 0; } public void HandleGraphEvent() { if (mediaEventEx != null) { while (mediaEventEx.GetEvent(out EventCode eventCode, out IntPtr param1, out IntPtr param2, 0) == 0) { mediaEventEx.FreeEventParams(eventCode, param1, param2); if (eventCode == EventCode.Complete) { PlaybackComplete?.Invoke(this, EventArgs.Empty); } } } } public void Dispose() { if (mediaControl != null) { mediaControl.Stop(); } if (mediaEventEx != null) { mediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); } if (videoWindow != null) { videoWindow.put_Visible(OABool.False); videoWindow.put_Owner(IntPtr.Zero); } FilterGraphTools.RemoveAllFilters(filterGraph); if (sourceFilter != null) Marshal.ReleaseComObject(sourceFilter); if (videoWindow != null) Marshal.ReleaseComObject(videoWindow); if (mediaSeeking != null) Marshal.ReleaseComObject(mediaSeeking); if (mediaEventEx != null) Marshal.ReleaseComObject(mediaEventEx); if (captureGraph != null) Marshal.ReleaseComObject(captureGraph); if (mediaControl != null) Marshal.ReleaseComObject(mediaControl); if (filterGraph != null) Marshal.ReleaseComObject(filterGraph); } } ``` ### Usage Example ## ``` public partial class MainForm : Form { private VLCMediaPlayer player; public MainForm() { InitializeComponent(); player = new VLCMediaPlayer(); } private void btnLoad_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Video Files|*.mp4;*.mkv;*.avi;*.mov|All Files|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { player.Initialize(panelVideo.Handle, this.Handle); // Custom VLC options for hardware decoding string vlcOptions = "--avcodec-hw=any --network-caching=1000"; player.LoadFile(dlg.FileName, vlcOptions: vlcOptions); player.SetVideoWindow(panelVideo.Handle, panelVideo.Width, panelVideo.Height); // Populate audio track combo box comboAudioTracks.Items.Clear(); foreach (var track in player.AudioTracks) { comboAudioTracks.Items.Add(track.Name); } if (comboAudioTracks.Items.Count > 0) { comboAudioTracks.SelectedIndex = 0; } // Populate subtitle combo box comboSubtitles.Items.Clear(); comboSubtitles.Items.Add("None"); foreach (var subtitle in player.Subtitles) { comboSubtitles.Items.Add(subtitle.Name); } comboSubtitles.SelectedIndex = 0; player.Play(); } } private void comboAudioTracks_SelectedIndexChanged(object sender, EventArgs e) { player.SelectAudioTrack(comboAudioTracks.SelectedIndex); } private void comboSubtitles_SelectedIndexChanged(object sender, EventArgs e) { player.SelectSubtitle(comboSubtitles.SelectedIndex - 1); // -1 because of "None" item } protected override void WndProc(ref Message m) { if (m.Msg == 0x8000 + 1) { player?.HandleGraphEvent(); } base.WndProc(ref m); } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { player?.Dispose(); } } ``` ## Troubleshooting ### Issue: "Class not registered" Error **Solution**: Ensure VLC Source filter is registered: ``` regsvr32 VisioForge_VLC_Source.ax ``` ### Issue: Audio/Subtitle Track Count Returns 0 **Cause**: Tracks not yet available (filter graph not built yet) **Solution**: Audio and subtitle information is only available after the file is loaded and the graph is built. Call track enumeration methods after `SetFile()` and building the graph. ``` // Load file first pVlcSrc->SetFile(L"movie.mkv"); // Build filter graph pGraph->RenderFile(L"movie.mkv", nullptr); // NOW query tracks int count = 0; pVlcSrc->GetAudioTracksCount(&count); ``` ### Issue: Custom VLC Options Not Working **Solution**: Ensure VLC options are set before loading the file, and use the correct marshaling: ``` // Correct order and usage: var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { var parameters = new List { "--network-caching=1000", "--rtsp-tcp" }; var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { vlcSrc2.SetCustomCommandLine(array, parameters.Count); // 1. Set options first } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } var vlcSrc = sourceFilter as IVlcSrc; vlcSrc?.SetFile(filename); // 2. Then load file // Build and run graph... ``` ### Issue: RTSP Stream Has High Latency **Solution**: Configure VLC for minimal network buffering and use TCP transport: ``` // C++ example IVlcSrc2* pVlcSrc2 = nullptr; hr = pFilter->QueryInterface(IID_IVlcSrc2, (void**)&pVlcSrc2); if (SUCCEEDED(hr)) { const char* params[] = { "--network-caching=50", "--live-caching=50", "--rtsp-tcp", "--no-audio-time-stretch" }; // Convert to wide strings and then to IntPtr equivalents // (In C++, you can pass ANSI/UTF-8 strings directly in some cases, // but for consistency with the interface, use proper conversion) pVlcSrc2->Release(); } ``` ``` // C# example var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { var lowLatencyOptions = new List { "--network-caching=50", "--live-caching=50", "--rtsp-tcp", "--no-audio-time-stretch" }; var array = new IntPtr[lowLatencyOptions.Count]; for (int i = 0; i < lowLatencyOptions.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(lowLatencyOptions[i]); } try { vlcSrc2.SetCustomCommandLine(array, lowLatencyOptions.Count); } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } ``` ### Issue: Hardware Acceleration Not Working **Solution**: Explicitly specify the hardware decoder to use: ``` // C++ example - Try explicit hardware decoder IVlcSrc2* pVlcSrc2 = nullptr; hr = pFilter->QueryInterface(IID_IVlcSrc2, (void**)&pVlcSrc2); if (SUCCEEDED(hr)) { const char* params[] = { "--avcodec-hw=d3d11va" // For Windows 8+ // or "--avcodec-hw=dxva2" for Windows 7 }; // Proper conversion and calling required pVlcSrc2->Release(); } ``` ``` // C# example var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { var hwOptions = new List { "--avcodec-hw=dxva2" // or d3d11va, nvdec, any }; var array = new IntPtr[hwOptions.Count]; for (int i = 0; i < hwOptions.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(hwOptions[i]); } try { vlcSrc2.SetCustomCommandLine(array, hwOptions.Count); } finally { for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } ``` --- ## See Also ### Documentation - [Interface Reference](../interface-reference/) - Complete API reference - [Deployment Guide](../../deployment/) - Filter deployment ### External Resources - [VLC Command-Line Documentation](https://www.videolan.org/doc/) - [DirectShow Programming Guide](https://learn.microsoft.com/en-us/windows/win32/DirectShow/directshow) ---END OF PAGE--- ## VLC Source DirectShow Filter - 200+ Formats & Streams **URL:** https://www.visioforge.com/help/docs/directshow/vlc-source-filter/ **Description:** DirectShow source filter powered by libVLC for playing 200+ formats, 4K/8K video, and RTSP/HLS/UDP network streams with hardware decoding. C++, C#, Delphi. **Tags:** DirectShow, C++, Windows, Streaming, Editing **API:** IFileSourceFilter, IBaseFilter, IVFRegister # VLC Source DirectShow Filter ## Overview The VLC Source DirectShow filter empowers developers to seamlessly integrate advanced media playback capabilities into any DirectShow-based application. This powerful component enables smooth playback of various video files and network streams across multiple formats and protocols. Our SDK package delivers a complete solution with all necessary VLC player DLLs bundled alongside a flexible DirectShow filter. The package provides both standard file-selection interfaces and extensive options for custom filter configurations to match your specific development requirements. For complete product details and licensing options, visit the [product page](https://www.visioforge.com/vlc-source-directshow-filter). --- ## Installation Before using the code samples and integrating the filter into your application, you must first install the VLC Source DirectShow Filter from the [product page](https://www.visioforge.com/vlc-source-directshow-filter). **Installation Steps**: 1. Download the SDK installer from the product page 2. Run the installer with administrative privileges 3. The installer will register the VLC Source filter and deploy all necessary VLC DLLs 4. Sample applications and source code will be available in the installation directory **Note**: The filter must be properly registered on the system before it can be used in your applications. The installer handles this automatically. --- ## Technical Specifications ### Supported DirectShow Interfaces The filter implements these standard DirectShow interfaces for maximum compatibility: - **IAMStreamSelect** - Comprehensive video and audio stream selection capabilities - **IAMStreamConfig** - Advanced video and audio configuration settings - **IFileSourceFilter** - Flexible specification of filename or URL sources - **IMediaSeeking** - Robust timeline seeking and positioning support ### Key Features - Hardware-accelerated decoding for optimal performance - Support for 4K and 8K video playback - Extensive format compatibility including modern codecs - Network stream handling (RTSP, HLS, DASH, etc.) - Subtitle rendering and management - Multi-language audio track support - 360° video playback capabilities - HDR content support ## Implementation Examples ### C++ Integration Example ``` #include #include #include #include "ivlcsrc.h" // VLC Source Filter CLSID DEFINE_GUID(CLSID_VlcSource, 0x3fc97748, 0x7cb6, 0x4195, 0x89, 0xde, 0x07, 0x17, 0x58, 0x2a, 0x48, 0x63); HRESULT InitializeVLCSource(HWND hVideoWindow) { HRESULT hr = S_OK; IFilterGraph2* pGraph = NULL; ICaptureGraphBuilder2* pBuild = NULL; IMediaControl* pControl = NULL; IBaseFilter* pVLCSource = NULL; IBaseFilter* pVideoRenderer = NULL; IFileSourceFilter* pFileSource = NULL; // Initialize COM CoInitialize(NULL); // Create the filter graph manager hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IFilterGraph2, (void**)&pGraph); if (FAILED(hr)) return hr; // Create the Capture Graph Builder hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild); if (FAILED(hr)) goto cleanup; // Set the filter graph to the capture graph builder hr = pBuild->SetFiltergraph(pGraph); if (FAILED(hr)) goto cleanup; // Create the VLC Source filter hr = CoCreateInstance(CLSID_VlcSource, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pVLCSource); if (FAILED(hr)) goto cleanup; // Add the filter to the graph hr = pGraph->AddFilter(pVLCSource, L"VLC Source"); if (FAILED(hr)) goto cleanup; // Load the media file using IFileSourceFilter interface hr = pVLCSource->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSource); if (SUCCEEDED(hr) && pFileSource) { hr = pFileSource->Load(L"C:\\media\\sample.mp4", NULL); pFileSource->Release(); if (FAILED(hr)) goto cleanup; } // Create Enhanced Video Renderer (EVR) CLSID CLSID_EVR = { 0xFA10746C, 0x9B63, 0x4B6C, { 0xBC, 0x49, 0xFC, 0x30, 0x0E, 0xA5, 0xF2, 0x56 } }; hr = CoCreateInstance(CLSID_EVR, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pVideoRenderer); if (FAILED(hr)) goto cleanup; hr = pGraph->AddFilter(pVideoRenderer, L"EVR"); if (FAILED(hr)) goto cleanup; // Configure EVR IEVRFilterConfig* pConfig = NULL; hr = pVideoRenderer->QueryInterface(IID_IEVRFilterConfig, (void**)&pConfig); if (SUCCEEDED(hr) && pConfig) { pConfig->SetNumberOfStreams(1); pConfig->Release(); } // Set video window IMFGetService* pGetService = NULL; hr = pVideoRenderer->QueryInterface(IID_IMFGetService, (void**)&pGetService); if (SUCCEEDED(hr) && pGetService) { IMFVideoDisplayControl* pDisplayControl = NULL; hr = pGetService->GetService(MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pDisplayControl); if (SUCCEEDED(hr) && pDisplayControl) { pDisplayControl->SetVideoWindow(hVideoWindow); pDisplayControl->Release(); } pGetService->Release(); } // Render the streams hr = pBuild->RenderStream(NULL, &MEDIATYPE_Video, pVLCSource, NULL, pVideoRenderer); if (FAILED(hr)) goto cleanup; hr = pBuild->RenderStream(NULL, &MEDIATYPE_Audio, pVLCSource, NULL, NULL); // Audio errors are not critical // Get the media control interface for playback control hr = pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl); if (SUCCEEDED(hr)) { // Start playback hr = pControl->Run(); } cleanup: // Release interfaces if (pControl) pControl->Release(); if (pVideoRenderer) pVideoRenderer->Release(); if (pVLCSource) pVLCSource->Release(); if (pBuild) pBuild->Release(); if (pGraph) pGraph->Release(); return hr; } ``` ### C# Integration (.NET) ``` using System; using System.Runtime.InteropServices; using MediaFoundation; using MediaFoundation.EVR; using VisioForge.DirectShowAPI; using VisioForge.DirectShowLib; // Initialize the VLC Source filter in C# using DirectShowLib public class VLCSourcePlayer { private IFilterGraph2 filterGraph; private ICaptureGraphBuilder2 captureGraph; private IMediaControl mediaControl; private IMediaSeeking mediaSeeking; private IMediaEventEx mediaEventEx; private IBaseFilter sourceFilter; private IBaseFilter videoRenderer; public void Initialize(string filename, IntPtr videoWindowHandle) { try { // Create the filter graph manager filterGraph = (IFilterGraph2)new FilterGraph(); captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2(); mediaControl = (IMediaControl)filterGraph; mediaSeeking = (IMediaSeeking)filterGraph; mediaEventEx = (IMediaEventEx)filterGraph; // Attach the filter graph to the capture graph int hr = captureGraph.SetFiltergraph(filterGraph); DsError.ThrowExceptionForHR(hr); // Create the VLC Source filter using the correct CLSID sourceFilter = FilterGraphTools.AddFilterFromClsid( filterGraph, Consts.CLSID_VFVLCSource, "VLC Source"); // Optional: Register purchased version // var reg = sourceFilter as IVFRegister; // reg?.SetLicenseKey("your-license-key-here"); // Load the media file or URL using IFileSourceFilter interface var sourceFilterIntf = sourceFilter as IFileSourceFilter; hr = sourceFilterIntf.Load(filename, null); DsError.ThrowExceptionForHR(hr); // Create video renderer (EVR - Enhanced Video Renderer) Guid CLSID_EVR = new Guid("FA10746C-9B63-4B6C-BC49-FC300EA5F256"); videoRenderer = FilterGraphTools.AddFilterFromClsid(filterGraph, CLSID_EVR, "EVR"); // Configure EVR var evrConfig = videoRenderer as IEVRFilterConfig; evrConfig?.SetNumberOfStreams(1); // Set video window for rendering var getService = videoRenderer as MediaFoundation.IMFGetService; if (getService != null) { getService.GetService( MediaFoundation.MFServices.MR_VIDEO_RENDER_SERVICE, typeof(MediaFoundation.IMFVideoDisplayControl).GUID, out var videoDisplayControlObj); var videoDisplayControl = videoDisplayControlObj as MediaFoundation.IMFVideoDisplayControl; videoDisplayControl?.SetVideoWindow(videoWindowHandle); } // Render the streams hr = captureGraph.RenderStream(null, MediaType.Video, sourceFilter, null, videoRenderer); DsError.ThrowExceptionForHR(hr); hr = captureGraph.RenderStream(null, MediaType.Audio, sourceFilter, null, null); // Note: Audio rendering errors are not critical for video-only playback // Start playback hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); } catch (Exception ex) { Console.WriteLine($"Error initializing VLC Source: {ex.Message}"); Cleanup(); throw; } } public void Cleanup() { // Stop playback if (mediaControl != null) { mediaControl.StopWhenReady(); mediaControl.Stop(); } // Stop receiving events mediaEventEx?.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero); // Remove all filters FilterGraphTools.RemoveAllFilters(filterGraph); // Release DirectShow interfaces if (mediaControl != null) { Marshal.ReleaseComObject(mediaControl); mediaControl = null; } if (mediaSeeking != null) { Marshal.ReleaseComObject(mediaSeeking); mediaSeeking = null; } if (mediaEventEx != null) { Marshal.ReleaseComObject(mediaEventEx); mediaEventEx = null; } if (sourceFilter != null) { Marshal.ReleaseComObject(sourceFilter); sourceFilter = null; } if (videoRenderer != null) { Marshal.ReleaseComObject(videoRenderer); videoRenderer = null; } if (captureGraph != null) { Marshal.ReleaseComObject(captureGraph); captureGraph = null; } if (filterGraph != null) { Marshal.ReleaseComObject(filterGraph); filterGraph = null; } } } ``` **Key CLSIDs and GUIDs:** ``` // VLC Source Filter CLSID public static readonly Guid CLSID_VFVLCSource = new Guid("3FC97748-7CB6-4195-89DE-0717582A4863"); // IVlcSrc Interface IID [Guid("77493EB7-6D00-41C5-9535-7C593824E892")] public interface IVlcSrc { /* ... */ } // IVlcSrc2 Interface IID (for custom command-line parameters) [Guid("CCE122C0-172C-4626-B4B6-42B039E541CB")] public interface IVlcSrc2 : IVlcSrc { /* ... */ } // IVlcSrc3 Interface IID (for frame rate override) [Guid("3DFBED0C-E4A8-401C-93EF-CBBFB65223DD")] public interface IVlcSrc3 : IVlcSrc2 { /* ... */ } // IVFRegister Interface IID (for licensing) [Guid("59E82754-B531-4A8E-A94D-57C75F01DA30")] public interface IVFRegister { /* ... */ } ``` **Required NuGet Packages:** - `VisioForge.DirectShowAPI` - DirectShow wrapper library - `MediaFoundation.Net` - Media Foundation wrapper for EVR renderer **Audio Track Selection Example:** ``` // Enumerate and select audio tracks var vlcSrc = sourceFilter as IVlcSrc; if (vlcSrc != null) { int audioCount = 0; vlcSrc.GetAudioTracksCount(out audioCount); for (int i = 0; i < audioCount; i++) { int trackId; var trackName = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(i, out trackId, trackName); Console.WriteLine($"Track {i}: {trackName} (ID: {trackId})"); } // Select specific audio track if (audioCount > 1) { int desiredTrackId; var name = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(1, out desiredTrackId, name); vlcSrc.SetAudioTrack(desiredTrackId); } } ``` **Custom VLC Options Example:** `IVlcSrc2::SetCustomCommandLine` takes an array of UTF-8 native strings (`char* params[]` in `ivlcsrc.h`), not a managed `string[]`. The C# wrapper marshals the parameters as `IntPtr[]` of unmanaged UTF-8 buffers — allocate with `StringHelper.NativeUtf8FromString()` and free with `Marshal.FreeHGlobal()` after the call. Passing a raw `string[]` would marshal as ANSI and corrupt non-ASCII flags. ``` // Configure VLC for low-latency RTSP streaming var vlcSrc2 = sourceFilter as IVlcSrc2; if (vlcSrc2 != null) { var parameters = new[] { "--network-caching=300", // Low network buffer "--rtsp-tcp", // Force TCP for RTSP "--avcodec-hw=any", // Enable hardware decoding "--live-caching=300" // Low live stream buffer }; // Convert managed strings to native UTF-8 IntPtr array var array = new IntPtr[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { int hr = vlcSrc2.SetCustomCommandLine(array, parameters.Length); DsError.ThrowExceptionForHR(hr); } finally { // Free unmanaged UTF-8 buffers for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } // Then load the stream var vlcSrc = vlcSrc2 as IVlcSrc; vlcSrc?.SetFile("rtsp://192.168.1.100/stream"); } ``` See [examples.md](examples/) for the canonical helper pattern reused across multiple scenarios (Example 4 binary key with custom flags, low-latency variants, etc.). ## Version History ### Version 2026.3.4 - Updated to VLC v3.0.23 core - Upgraded build toolset to MSVC v143 (Visual Studio 2022) - Fixed crash on graph teardown during `libvlc_media_player_stop()` - Replaced Boost dependencies with C++ standard library equivalents ### Version 15.0 - Enhanced playback quality across numerous formats - Improved subtitle rendering engine - Updated codec implementations including dav1d, ffmpeg, and libvpx - Added Super Resolution scaling with nVidia and Intel GPU acceleration ### Version 14.0 - Updated to VLC v3.0.18 core - Fixed DxVA/D3D11 compatibility issues with HEVC content - Resolved OpenGL resizing problems for smoother playback ### Version 12.0 - Upgraded to VLC v3.0.16 engine - Added support for new Fourcc formats (E-AC3 and AV1) - Fixed stability issues with VP9 streams ### Version 11.1 - Incorporated VLC v3.0.11 - Optimized HLS playlist update mechanism - Enhanced WebVTT subtitle handling and display ### Version 11.0 - Built on VLC v3.0.10 foundation - Fixed critical regression issues with HLS streams ### Version 10.4 - Major update to VLC 3.0 architecture - Enabled hardware decoding by default for 4K and 8K content - Added 10-bit color depth and HDR support - Implemented 360-degree video and 3D audio capabilities - Introduced Blu-Ray Java menu support ### Version 10.0 - Initial release as a standalone DirectShow filter - For earlier version history, please refer to Video Capture SDK .Net changelog ## Additional Resources - [End User License Agreement](../../eula/) - [Code Samples](https://github.com/visioforge/) ---END OF PAGE--- ## VLC Source DirectShow Filter Full Interface Reference **URL:** https://www.visioforge.com/help/docs/directshow/vlc-source-filter/interface-reference/ **Description:** IVlcSrc family interfaces for multi-track audio, subtitle support, and custom VLC command-line options in DirectShow applications. **Tags:** DirectShow, C++, Windows, IP Camera, RTSP, HLS, MP4, MKV, C# **API:** IBaseFilter # VLC Source Filter Interface Reference ## Overview The VLC Source DirectShow filter exposes three progressive interfaces (`IVlcSrc`, `IVlcSrc2`, `IVlcSrc3`) that provide comprehensive control over media playback, audio/subtitle track selection, and VLC configuration. These interfaces enable developers to leverage VLC's powerful media framework within DirectShow applications. ## Interface Hierarchy ``` IUnknown └── IVlcSrc └── IVlcSrc2 └── IVlcSrc3 ``` Each interface extends the previous one, adding new capabilities while maintaining backward compatibility. --- ## IVlcSrc Interface The base interface providing essential file loading and track selection capabilities. ### Interface Definition - **Interface Name**: `IVlcSrc` - **GUID**: `{77493EB7-6D00-41C5-9535-7C593824E892}` - **Inherits From**: `IUnknown` - **Header File**: `ivlcsrc.h` (C++), `IVlcSrc.cs` (.NET) ### Methods #### SetFile Sets the media file or URL to play. **Syntax (C++)**: ``` HRESULT SetFile(WCHAR *file); ``` **Syntax (C#)**: ``` [PreserveSig] int SetFile([MarshalAs(UnmanagedType.LPWStr)] string file); ``` **Parameters**: - `file`: Wide-character string containing the file path or URL. **Returns**: `S_OK` (0) on success, error code otherwise. **Supported Sources**: - Local files: `C:\Videos\movie.mp4` - HTTP streams: `https://example.com/stream.m3u8` - RTSP streams: `rtsp://example.com/live` - HLS playlists: `https://example.com/playlist.m3u8` - DASH streams: `https://example.com/manifest.mpd` - DVB-T/C/S broadcasts - Network shares: `\\server\share\video.mkv` **Example (C++)**: ``` IVlcSrc* pVlcSrc = nullptr; pFilter->QueryInterface(IID_IVlcSrc, (void**)&pVlcSrc); pVlcSrc->SetFile(L"C:\\Videos\\movie.mkv"); pVlcSrc->Release(); ``` **Example (C#)**: ``` var vlcSrc = filter as IVlcSrc; if (vlcSrc != null) { vlcSrc.SetFile(@"C:\Videos\movie.mkv"); } ``` --- ### Audio Track Management #### GetAudioTracksCount Retrieves the total number of available audio tracks. **Syntax (C++)**: ``` HRESULT GetAudioTracksCount(int *count); ``` **Syntax (C#)**: ``` [PreserveSig] int GetAudioTracksCount(out int count); ``` **Parameters**: - `count`: [out] Receives the number of audio tracks. **Returns**: `S_OK` (0) on success. **Usage Notes**: - Call after the file is loaded and the filter graph is built - Returns 0 if no audio tracks are available or file not loaded **Example (C++)**: ``` int audioCount = 0; pVlcSrc->GetAudioTracksCount(&audioCount); printf("Audio tracks: %d\n", audioCount); ``` --- #### GetAudioTrackInfo Retrieves information about a specific audio track. **Syntax (C++)**: ``` HRESULT GetAudioTrackInfo(int number, int *id, WCHAR *name); ``` **Syntax (C#)**: ``` [PreserveSig] int GetAudioTrackInfo(int number, out int id, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder name); ``` **Parameters**: - `number`: Zero-based track index (0 to count-1). - `id`: [out] Receives the track ID. - `name`: [out] Buffer to receive the track name (must be pre-allocated, minimum 256 characters). **Returns**: `S_OK` (0) on success. **Usage Notes**: - Pre-allocate name buffer with at least 256 wide characters - Track names typically include language and codec information - Track ID is used with SetAudioTrack() **Example (C++)**: ``` int audioCount = 0; pVlcSrc->GetAudioTracksCount(&audioCount); for (int i = 0; i < audioCount; i++) { int id = 0; WCHAR name[256] = {0}; pVlcSrc->GetAudioTrackInfo(i, &id, name); wprintf(L"Track %d - ID: %d, Name: %s\n", i, id, name); } ``` **Example (C#)**: ``` int count = 0; vlcSrc.GetAudioTracksCount(out count); for (int i = 0; i < count; i++) { int id; var name = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(i, out id, name); Console.WriteLine($"Track {i} - ID: {id}, Name: {name}"); } ``` --- #### GetAudioTrack Retrieves the ID of the currently active audio track. **Syntax (C++)**: ``` HRESULT GetAudioTrack(int *id); ``` **Syntax (C#)**: ``` [PreserveSig] int GetAudioTrack(out int id); ``` **Parameters**: - `id`: [out] Receives the current audio track ID. **Returns**: `S_OK` (0) on success. **Example (C++)**: ``` int currentTrack = 0; pVlcSrc->GetAudioTrack(¤tTrack); printf("Current audio track ID: %d\n", currentTrack); ``` --- #### SetAudioTrack Sets the active audio track by ID. **Syntax (C++)**: ``` HRESULT SetAudioTrack(int id); ``` **Syntax (C#)**: ``` [PreserveSig] int SetAudioTrack(int id); ``` **Parameters**: - `id`: The track ID to activate (obtained from GetAudioTrackInfo). **Returns**: `S_OK` (0) on success, error code if track ID is invalid. **Usage Notes**: - Can be called during playback to switch tracks dynamically - Use -1 to disable all audio tracks - Track switching may cause brief audio interruption **Example (C++)**: ``` // Switch to second audio track int trackId = 0; pVlcSrc->GetAudioTrackInfo(1, &trackId, nullptr); pVlcSrc->SetAudioTrack(trackId); ``` **Example (C#)**: ``` // Switch to first audio track int trackId; var name = new StringBuilder(256); vlcSrc.GetAudioTrackInfo(0, out trackId, name); vlcSrc.SetAudioTrack(trackId); ``` --- ### Subtitle Track Management #### GetSubtitlesCount Retrieves the total number of available subtitle tracks. **Syntax (C++)**: ``` HRESULT GetSubtitlesCount(int *count); ``` **Syntax (C#)**: ``` [PreserveSig] int GetSubtitlesCount(out int count); ``` **Parameters**: - `count`: [out] Receives the number of subtitle tracks. **Returns**: `S_OK` (0) on success. **Example (C++)**: ``` int subtitleCount = 0; pVlcSrc->GetSubtitlesCount(&subtitleCount); printf("Subtitle tracks: %d\n", subtitleCount); ``` --- #### GetSubtitleInfo Retrieves information about a specific subtitle track. **Syntax (C++)**: ``` HRESULT GetSubtitleInfo(int number, int *id, WCHAR *name); ``` **Syntax (C#)**: ``` [PreserveSig] int GetSubtitleInfo(int number, out int id, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder name); ``` **Parameters**: - `number`: Zero-based track index (0 to count-1). - `id`: [out] Receives the subtitle track ID. - `name`: [out] Buffer to receive the subtitle track name (minimum 256 characters). **Returns**: `S_OK` (0) on success. **Example (C++)**: ``` int subCount = 0; pVlcSrc->GetSubtitlesCount(&subCount); for (int i = 0; i < subCount; i++) { int id = 0; WCHAR name[256] = {0}; pVlcSrc->GetSubtitleInfo(i, &id, name); wprintf(L"Subtitle %d - ID: %d, Name: %s\n", i, id, name); } ``` --- #### GetSubtitle Retrieves the ID of the currently active subtitle track. **Syntax (C++)**: ``` HRESULT GetSubtitle(int *id); ``` **Syntax (C#)**: ``` [PreserveSig] int GetSubtitle(out int id); ``` **Parameters**: - `id`: [out] Receives the current subtitle track ID. **Returns**: `S_OK` (0) on success. --- #### SetSubtitle Sets the active subtitle track by ID. **Syntax (C++)**: ``` HRESULT SetSubtitle(int id); ``` **Syntax (C#)**: ``` [PreserveSig] int SetSubtitle(int id); ``` **Parameters**: - `id`: The subtitle track ID to activate. **Returns**: `S_OK` (0) on success. **Usage Notes**: - Use -1 to disable subtitles - Subtitle rendering is performed by VLC's internal renderer - Can be switched during playback **Example (C++)**: ``` // Enable first subtitle track int subtitleId = 0; pVlcSrc->GetSubtitleInfo(0, &subtitleId, nullptr); pVlcSrc->SetSubtitle(subtitleId); // Disable subtitles pVlcSrc->SetSubtitle(-1); ``` --- ## IVlcSrc2 Interface Extends `IVlcSrc` with custom VLC command-line parameter support. ### Interface Definition - **Interface Name**: `IVlcSrc2` - **GUID**: `{CCE122C0-172C-4626-B4B6-42B039E541CB}` - **Inherits From**: `IVlcSrc` - **Header File**: `ivlcsrc.h` (C++), `IVlcSrc.cs` (.NET) ### Methods #### SetCustomCommandLine Sets custom VLC command-line parameters. **Syntax (C++)**: ``` HRESULT SetCustomCommandLine(char* params[], int length); ``` **Syntax (C#)**: ``` [PreserveSig] int SetCustomCommandLine([In][Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr)] IntPtr[] params_, int size); ``` **Parameters**: - `params_`: Array of IntPtr pointers to UTF-8 encoded strings containing VLC command-line parameters. - `size`: Number of parameters in the array. **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the media file with SetFile() - Parameters must be converted to native UTF-8 IntPtr using StringHelper.NativeUtf8FromString() - Memory allocated for IntPtr parameters must be freed after the call using Marshal.FreeHGlobal() - Parameters are passed directly to libVLC initialization - Invalid parameters are ignored with warnings in VLC log - Use standard VLC command-line syntax (see VLC documentation) **Common VLC Parameters**: | Parameter | Description | Example Value | | --- | --- | --- | | `--network-caching` | Network caching in ms | `1000` | | `--file-caching` | File caching in ms | `300` | | `--live-caching` | Live stream caching in ms | `300` | | `--avcodec-hw` | Hardware acceleration | `any`, `dxva2`, `d3d11va` | | `--verbose` | Logging verbosity | `2` | | `--rtsp-tcp` | Force RTSP over TCP | (flag, no value) | | `--no-audio` | Disable audio | (flag, no value) | | `--sout-mux-caching` | Output muxer caching | `1000` | **Example (C++)**: ``` IVlcSrc2* pVlcSrc2 = nullptr; pFilter->QueryInterface(IID_IVlcSrc2, (void**)&pVlcSrc2); // Configure for low-latency RTSP char* params[] = { "--network-caching=300", "--rtsp-tcp", "--avcodec-hw=d3d11va", "--verbose=2" }; pVlcSrc2->SetCustomCommandLine(params, 4); pVlcSrc2->SetFile(L"rtsp://192.168.1.100/stream"); pVlcSrc2->Release(); ``` **Example (C#)**: ``` using System; using System.Collections.Generic; using System.Runtime.InteropServices; using VisioForge.Core.Helpers; var vlcSrc2 = filter as IVlcSrc2; if (vlcSrc2 != null) { // Enable hardware acceleration and adjust caching var parameters = new List { "--avcodec-hw=any", "--network-caching=1000", "--file-caching=300" }; // Convert strings to native UTF-8 IntPtr array var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { vlcSrc2.SetCustomCommandLine(array, parameters.Count); vlcSrc2.SetFile(@"C:\Videos\movie.mkv"); } finally { // Free allocated unmanaged memory for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } } ``` **Example (Delphi)**: libVLC parses the command line as **UTF-8**, not the system ANSI codepage. `PAnsiChar` literals are ASCII-safe but corrupt non-ASCII characters; encode each parameter to UTF-8 explicitly via `UTF8Encode` (or store an `AnsiString` with `CP_UTF8`). For a pure-ASCII parameter set, `PAnsiChar` literals happen to round-trip cleanly, but the snippet below uses the safe pattern. ``` var VlcSrc2: IVlcSrc2; P0, P1, P2: AnsiString; Params: array[0..2] of PAnsiChar; begin if Succeeded(Filter.QueryInterface(IID_IVlcSrc2, VlcSrc2)) then begin P0 := UTF8Encode('--network-caching=500'); P1 := UTF8Encode('--rtsp-tcp'); P2 := UTF8Encode('--avcodec-hw=dxva2'); Params[0] := PAnsiChar(P0); Params[1] := PAnsiChar(P1); Params[2] := PAnsiChar(P2); VlcSrc2.SetCustomCommandLine(@Params, 3); VlcSrc2.SetFile('rtsp://example.com/stream'); end; end; ``` --- ## IVlcSrc3 Interface Extends `IVlcSrc2` with frame rate override capability. ### Interface Definition - **Interface Name**: `IVlcSrc3` - **GUID**: `{3DFBED0C-E4A8-401C-93EF-CBBFB65223DD}` - **Inherits From**: `IVlcSrc2` - **Header File**: `ivlcsrc.h` (C++), `IVlcSrc.cs` (.NET) ### Methods #### SetDefaultFrameRate Sets a default frame rate for media without frame rate information. **Syntax (C++)**: ``` HRESULT SetDefaultFrameRate(double frameRate); ``` **Syntax (C#)**: ``` [PreserveSig] int SetDefaultFrameRate(double frameRate); ``` **Parameters**: - `frameRate`: Frame rate in frames per second (e.g., 29.97, 30.0, 25.0, 60.0). **Returns**: `S_OK` (0) on success. **Usage Notes**: - Must be called **before** loading the media file - Used when source media doesn't specify frame rate - Particularly useful for network streams without timing information - Common values: 23.976, 24.0, 25.0, 29.97, 30.0, 50.0, 59.94, 60.0 **Example (C++)**: ``` IVlcSrc3* pVlcSrc3 = nullptr; pFilter->QueryInterface(IID_IVlcSrc3, (void**)&pVlcSrc3); // Set default frame rate for MJPEG IP camera stream pVlcSrc3->SetDefaultFrameRate(30.0); pVlcSrc3->SetFile(L"http://192.168.1.50/video.mjpg"); pVlcSrc3->Release(); ``` **Example (C#)**: ``` var vlcSrc3 = filter as IVlcSrc3; if (vlcSrc3 != null) { // Set PAL frame rate for DV stream vlcSrc3.SetDefaultFrameRate(25.0); vlcSrc3.SetFile(@"dv://0"); } ``` --- ## Complete Usage Examples ### Example 1: Multi-Language Movie Playback (C++) ``` #include #include "ivlcsrc.h" void PlayMovieWithAudioSelection(IBaseFilter* pVlcFilter) { HRESULT hr; IVlcSrc* pVlcSrc = nullptr; hr = pVlcFilter->QueryInterface(IID_IVlcSrc, (void**)&pVlcSrc); if (FAILED(hr)) return; // Load movie pVlcSrc->SetFile(L"C:\\Movies\\multilang_movie.mkv"); // Build and run the graph here... // (IGraphBuilder::RenderFile, IMediaControl::Run, etc.) // Enumerate audio tracks int audioCount = 0; pVlcSrc->GetAudioTracksCount(&audioCount); wprintf(L"Available audio tracks:\n"); for (int i = 0; i < audioCount; i++) { int id = 0; WCHAR name[256] = {0}; pVlcSrc->GetAudioTrackInfo(i, &id, name); wprintf(L" [%d] %s (ID: %d)\n", i, name, id); } // Select English audio track (assuming it's track 1) int englishTrackId = 0; pVlcSrc->GetAudioTrackInfo(1, &englishTrackId, nullptr); pVlcSrc->SetAudioTrack(englishTrackId); // Enable subtitles int subCount = 0; pVlcSrc->GetSubtitlesCount(&subCount); if (subCount > 0) { int subId = 0; pVlcSrc->GetSubtitleInfo(0, &subId, nullptr); pVlcSrc->SetSubtitle(subId); } pVlcSrc->Release(); } ``` ### Example 2: Low-Latency RTSP Stream (C#) ``` using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using DirectShowLib; using VisioForge.Core.Helpers; using VisioForge.DirectShowAPI; public class VLCRTSPPlayer { public void SetupLowLatencyRTSP(IBaseFilter vlcFilter) { // Get IVlcSrc3 interface (highest version) var vlcSrc3 = vlcFilter as IVlcSrc3; if (vlcSrc3 == null) throw new NotSupportedException("IVlcSrc3 not available"); // Configure VLC for minimal latency var parameters = new List { "--network-caching=50", // Minimal network buffer "--live-caching=50", // Minimal live buffer "--rtsp-tcp", // Use TCP transport "--no-audio-time-stretch", // Disable audio stretching "--avcodec-hw=d3d11va", // Hardware decoding "--verbose=0" // Reduce logging }; // Convert to IntPtr array var array = new IntPtr[parameters.Count]; for (int i = 0; i < parameters.Count; i++) { array[i] = StringHelper.NativeUtf8FromString(parameters[i]); } try { int hr = vlcSrc3.SetCustomCommandLine(array, parameters.Count); DsError.ThrowExceptionForHR(hr); // Set frame rate for IP camera hr = vlcSrc3.SetDefaultFrameRate(25.0); DsError.ThrowExceptionForHR(hr); // Load RTSP stream hr = vlcSrc3.SetFile("rtsp://admin:password@192.168.1.100:554/stream1"); DsError.ThrowExceptionForHR(hr); } finally { // Free allocated memory for (int i = 0; i < array.Length; i++) { Marshal.FreeHGlobal(array[i]); } } // Build filter graph and start playback... } } ``` ### Example 3: Subtitle Track Switching UI (Delphi) ``` unit VLCSubtitles; interface uses Winapi.Windows, System.Classes, Vcl.Controls, Vcl.StdCtrls, DSPack, ivlcsrc; type TSubtitleForm = class(TForm) ComboBoxSubtitles: TComboBox; procedure FormCreate(Sender: TObject); procedure ComboBoxSubtitlesChange(Sender: TObject); private FVlcSrc: IVlcSrc; FSubtitleIDs: TArray; procedure LoadSubtitleTracks; public procedure SetVLCFilter(Filter: IBaseFilter); end; implementation procedure TSubtitleForm.SetVLCFilter(Filter: IBaseFilter); begin if Succeeded(Filter.QueryInterface(IID_IVlcSrc, FVlcSrc)) then begin LoadSubtitleTracks; end; end; procedure TSubtitleForm.LoadSubtitleTracks; var Count, I, ID: Integer; Name: array[0..255] of WideChar; begin ComboBoxSubtitles.Clear; ComboBoxSubtitles.Items.Add('Disabled'); if FVlcSrc.GetSubtitlesCount(Count) = S_OK then begin SetLength(FSubtitleIDs, Count + 1); FSubtitleIDs[0] := -1; // Disabled for I := 0 to Count - 1 do begin if FVlcSrc.GetSubtitleInfo(I, ID, Name) = S_OK then begin FSubtitleIDs[I + 1] := ID; ComboBoxSubtitles.Items.Add(Name); end; end; end; ComboBoxSubtitles.ItemIndex := 0; end; procedure TSubtitleForm.ComboBoxSubtitlesChange(Sender: TObject); var Index: Integer; begin Index := ComboBoxSubtitles.ItemIndex; if (Index >= 0) and (Index < Length(FSubtitleIDs)) then begin FVlcSrc.SetSubtitle(FSubtitleIDs[Index]); end; end; end. ``` ## Best Practices ### Track Management 1. **Always enumerate tracks after building the filter graph** - Track information is not available until the source is loaded 2. **Handle files with no audio/subtitles gracefully** - Check count before accessing tracks 3. **Pre-allocate name buffers with 256 characters** - Prevents buffer overruns 4. **Cache track IDs** - Don't repeatedly call GetAudioTrackInfo/GetSubtitleInfo ### VLC Configuration 1. **Use IVlcSrc3 when available** - Provides full feature set 2. **Set custom parameters before loading file** - Parameters only apply at initialization 3. **Test VLC parameters independently** - Use VLC command-line to verify parameters work 4. **Use appropriate caching values**: 5. Local files: 300ms 6. Network streams: 1000-3000ms 7. Low-latency streams: 50-300ms ### Hardware Acceleration 1. **Enable hardware decoding for H.264/H.265**: ``` "--avcodec-hw=any" // Auto-detect best method ``` 1. **Platform-specific options**: 2. Windows: `d3d11va`, `dxva2` 3. All platforms: `any` (auto-detect) ### Performance 1. **Minimize network caching for live streams** - Reduces latency 2. **Use RTSP over TCP when UDP fails** - More reliable through firewalls 3. **Enable verbose logging for debugging only** - Reduces performance overhead ## Related Interfaces - **IFileSourceFilter** - Alternative standard DirectShow interface for loading files - **IAMStreamSelect** - DirectShow standard for stream selection (also supported by VLC filter) - **IMediaSeeking** - Seek control in media - **IBasicVideo** - Video window control ## See Also - [VLC Source Filter Overview](../) - [VLC Command-Line Documentation](https://www.videolan.org/doc/) - [Code Examples](../examples/) ---END OF PAGE--- ## Agent Skills for VisioForge .NET SDKs — AI coding agents **URL:** https://www.visioforge.com/help/docs/dotnet/agent-skills/ **Description:** Per-platform skills for AI coding agents (Claude Code, Cursor, Copilot, Codex, Gemini CLI) covering NuGet, licence setup, and deployment caveats. # Agent Skills for VisioForge .NET SDKs VisioForge publishes per-platform **Agent Skills** at `https://www.visioforge.com/.well-known/agent-skills/index.json` per the [Agent Skills Discovery RFC v0.2.0](https://github.com/cloudflare/agent-skills-discovery-rfc). ## What is this? A **Skill** is a small, self-contained package of procedural knowledge an AI coding agent can load on demand: the NuGet packages to add, the license registration code, the project-file caveats, and the deployment failure modes a developer hits in practice. Skills are loaded automatically by skills-aware agents — no installation step on your side. When a developer prompts an agent (Claude Code, Cursor, GitHub Copilot, OpenAI Codex, Gemini CLI, OpenCode, Goose, Junie, …) with something like *"add VisioForge video capture to this WPF app"*, the agent inspects the discovery index, finds the matching skill, downloads the archive, and follows the bundled instructions. The result is a setup that uses the *current* package versions and avoids the deployment gotchas the docs flag. ## Discovery surface The well-known endpoints and HTML/HTTP signals are emitted by the marketing site at `www.visioforge.com` (the host that serves `/.well-known/agent-skills/`); the help site you're reading this on (`help.visioforge.com`) doesn't currently inject the discovery `` or `Link:` header. Agents discovering us from a help-site page should follow the inline link to `https://www.visioforge.com/.well-known/agent-skills/index.json` directly. | Endpoint (served by `www.visioforge.com`) | Purpose | | --- | --- | | `/.well-known/agent-skills/index.json` | Index of every published skill with name, description, archive URL, and SHA-256 digest. | | `/.well-known/agent-skills/.zip` | Archive containing `SKILL.md` + bundled `references/` (sample `.csproj`, init code). | | `` in every `www.visioforge.com` page `` | HTML signal pointing at the index. | | `Link: <…>; rel="agent-skills"` HTTP header on `www.visioforge.com` | Same signal for non-HTML responses (Markdown, etc.). | Skills are **discoverable from any page of `www.visioforge.com`** — agents don't need to know the well-known URL up front. ## Available skills 42 skills cover every (SDK, platform) intersection that has a working sample in [github.com/visioforge/.Net-SDK-s-samples](https://github.com/visioforge/.Net-SDK-s-samples). The authoritative list — including each skill's archive URL and SHA-256 digest — lives in the discovery index at `https://www.visioforge.com/.well-known/agent-skills/index.json`. The catalog below is auto-generated from the same source so it cannot drift. Naming convention: `-` where `` is the per-platform UI shell or hosting model. ### Video Capture SDK .NET | Skill | Description | Archive | | --- | --- | --- | | `video-capture-sdk-net-console` | Integrate VisioForge Video Capture SDK .NET into a .NET console application (no UI). Covers the single NuGet package, project setup, license registration, headless capture/recording, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when capturing or recording from webcam, IP camera, or screen on Windows from a service, scheduled task, or batch script — for an interactive UI use video-capture-sdk-net-{wpf,winforms} instead. | [video-capture-sdk-net-console.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-net-console.zip) | | `video-capture-sdk-net-winforms` | Integrate VisioForge Video Capture SDK .NET into a Windows Forms application. Covers the single NuGet package, project setup, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when adding webcam, IP camera, screen, or DV capture to a WinForms app on Windows. | [video-capture-sdk-net-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-net-winforms.zip) | | `video-capture-sdk-net-winui` | Integrate VisioForge Video Capture SDK .NET into a WinUI 3 (Windows App SDK) application. Covers the WinUI-specific VideoView control, the single NuGet package, project setup, license registration, MSIX packaging quirks, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when adding webcam, IP camera, screen, or DV capture to a WinUI 3 app — for WPF use video-capture-sdk-net-wpf, for WinForms use video-capture-sdk-net-winforms. | [video-capture-sdk-net-winui.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-net-winui.zip) | | `video-capture-sdk-net-wpf` | Integrate VisioForge Video Capture SDK .NET into a Windows WPF application. Covers the single NuGet package, project setup, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when adding webcam, IP camera, screen, or DV capture to a WPF app on Windows. | [video-capture-sdk-net-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-net-wpf.zip) | ### Video Capture SDK X | Skill | Description | Archive | | --- | --- | --- | | `video-capture-sdk-x-android` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a native .NET for Android application. Covers the Android-specific VideoView control, the cross-platform NuGet package, AndroidDependency project reference, runtime camera/audio permissions, license registration, and the most common Android pitfalls (CAMERA permission denied, RECORD\_AUDIO permission denied, AAB vs APK packaging, ABI filters, trial-period expiry / unlicensed build). Use for native .NET for Android (NOT MAUI / Xamarin) capture apps — for cross-OS MAUI use video-capture-sdk-x-maui. | [video-capture-sdk-x-android.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-android.zip) | | `video-capture-sdk-x-avalonia` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into an Avalonia UI application. Covers the Avalonia-specific VideoView control, multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (missing native libs, file path conventions, X11/Wayland on Linux, trial-period expiry / unlicensed build). Use when building capture apps that must run on Windows, Linux, and macOS from one codebase — for native .NET for Android/iOS/macOS use video-capture-sdk-x-{android,ios,macos}, for MAUI use video-capture-sdk-x-maui. | [video-capture-sdk-x-avalonia.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-avalonia.zip) | | `video-capture-sdk-x-ios` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a native .NET for iOS application. Covers the iOS-specific VideoView control, the cross-platform NuGet package, Info.plist NSCameraUsageDescription / NSMicrophoneUsageDescription requirements, license registration, and the most common iOS pitfalls (Info.plist missing usage descriptions, no camera in simulator, AOT JIT-only ExecutionEngineException, App Store reviewer rejecting missing privacy strings, trial-period expiry / unlicensed build). Use for native .NET for iOS (NOT MAUI / Xamarin) capture apps — for cross-OS MAUI use video-capture-sdk-x-maui. | [video-capture-sdk-x-ios.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-ios.zip) | | `video-capture-sdk-x-macos` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a native .NET for macOS application. Covers the macOS-specific VideoView control, the cross-platform NuGet package, Info.plist NSCameraUsageDescription / NSMicrophoneUsageDescription, code signing entitlements, license registration, and the most common macOS pitfalls (missing Info.plist usage descriptions, hardened runtime + missing entitlements, Apple Silicon vs Intel native libs, trial-period expiry / unlicensed build). Use for native .NET for macOS (NOT MAUI / MacCatalyst) capture apps — for cross-OS MAUI use video-capture-sdk-x-maui. | [video-capture-sdk-x-macos.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-macos.zip) | | `video-capture-sdk-x-maui` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a .NET MAUI cross-platform app (Windows, Android, iOS, macOS). Covers the MAUI-specific VideoView control, multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (camera permissions, missing native libs, AOT JIT-only ExecutionEngineException, trial-period expiry / unlicensed build). Use when building capture apps that must run on multiple OSes from one MAUI codebase — for graph-based pipelines use media-blocks-sdk-net-maui. | [video-capture-sdk-x-maui.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-maui.zip) | | `video-capture-sdk-x-uno` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into an Uno Platform application. Covers the Uno-specific VideoView control, multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (camera permissions per OS, WebAssembly limitations, missing native libs, trial-period expiry / unlicensed build). Use for Uno cross-OS apps (Windows, Android, iOS, macOS, WebAssembly) — for MAUI use video-capture-sdk-x-maui, for Avalonia use video-capture-sdk-x-avalonia. | [video-capture-sdk-x-uno.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-uno.zip) | | `video-capture-sdk-x-winforms` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a Windows Forms application. Covers the cross-platform NuGet package layout, project setup, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want capture/recording on WinForms with an API that ports cleanly to MAUI, Avalonia, Uno, Android, iOS, macOS — for Windows-only with the legacy DirectShow stack, use video-capture-sdk-net-winforms instead. | [video-capture-sdk-x-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-winforms.zip) | | `video-capture-sdk-x-winui` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a WinUI 3 (Windows App SDK) application. Covers the WinUI-specific VideoView control, the cross-platform NuGet package layout, project setup, license registration, MSIX packaging quirks, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want capture/recording on WinUI 3 with an API that ports to MAUI, Avalonia, Uno — for the legacy DirectShow stack, use video-capture-sdk-net-winui. | [video-capture-sdk-x-winui.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-winui.zip) | | `video-capture-sdk-x-wpf` | Integrate VisioForge Video Capture SDK X (cross-platform edition) into a Windows WPF application. Covers the cross-platform NuGet package layout, project setup, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want capture/recording on WPF with an API that ports cleanly to MAUI, Avalonia, Uno, Android, iOS, macOS — for Windows-only with the legacy DirectShow stack, use video-capture-sdk-net-wpf instead. | [video-capture-sdk-x-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/video-capture-sdk-x-wpf.zip) | ### Media Player SDK .NET | Skill | Description | Archive | | --- | --- | --- | | `media-player-sdk-net-winforms` | Integrate VisioForge Media Player SDK .NET (file/stream playback) into a Windows Forms application. Covers the single NuGet package, project setup, license registration, supported input formats, and the most common playback pitfalls (DLL not found, missing codecs, unsupported format, trial-period expiry / unlicensed build). Use when adding video/audio file or network-stream playback to a WinForms app on Windows — for capture use video-capture-sdk-net-winforms, for editing use video-edit-sdk-net-winforms. | [media-player-sdk-net-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-net-winforms.zip) | | `media-player-sdk-net-winui` | Integrate VisioForge Media Player SDK .NET (file/stream playback) into a WinUI 3 (Windows App SDK) application. Covers the WinUI-specific VideoView control, the single NuGet package, project setup, license registration, MSIX packaging quirks, supported input formats, and the most common playback pitfalls (DLL not found, missing codecs, unsupported format, trial-period expiry / unlicensed build). Use for WinUI 3 playback — for WPF use media-player-sdk-net-wpf, for WinForms use media-player-sdk-net-winforms. | [media-player-sdk-net-winui.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-net-winui.zip) | | `media-player-sdk-net-wpf` | Integrate VisioForge Media Player SDK .NET (file/stream playback) into a Windows WPF application. Covers the single NuGet package, project setup, license registration, supported input formats, and the most common playback pitfalls (DLL not found, missing codecs, unsupported format, trial-period expiry / unlicensed build). Use when adding video/audio file or network-stream playback to a WPF app on Windows — for capture from a camera use video-capture-sdk-net-wpf, for editing use video-edit-sdk-net-wpf. | [media-player-sdk-net-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-net-wpf.zip) | ### Media Player SDK X | Skill | Description | Archive | | --- | --- | --- | | `media-player-sdk-x-android` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a native .NET for Android application. Covers the Android-specific VideoView control, the cross-platform NuGet package, AndroidDependency project reference, license registration, and the most common Android pitfalls (missing INTERNET permission for streaming, AAB vs APK packaging, ABI filters, hardware decoder support, trial-period expiry / unlicensed build). Use for native .NET for Android playback apps — for cross-OS MAUI use media-player-sdk-x-maui. | [media-player-sdk-x-android.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-android.zip) | | `media-player-sdk-x-avalonia` | Integrate VisioForge Media Player SDK X (cross-platform edition) into an Avalonia UI application. Covers the Avalonia-specific VideoView control, multi-target NuGet packages (per-OS native dependencies), license registration, supported input formats, and the most common cross-platform pitfalls (missing native libs, X11/Wayland on Linux, ALSA/PulseAudio audio, trial-period expiry / unlicensed build). Use when building playback apps that must run on Windows, Linux, and macOS from one codebase — for native iOS/Android/macOS use media-player-sdk-x-{android,ios,macos}, for MAUI use media-player-sdk-x-maui. | [media-player-sdk-x-avalonia.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-avalonia.zip) | | `media-player-sdk-x-ios` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a native .NET for iOS application. Covers the iOS-specific VideoView control, the cross-platform NuGet package, Info.plist usage descriptions, license registration, AOT JIT-only ExecutionEngineException, and the most common iOS pitfalls (App Transport Security for HTTP streams, format support, trial-period expiry / unlicensed build). Use for native .NET for iOS playback apps — for cross-OS MAUI use media-player-sdk-x-maui. | [media-player-sdk-x-ios.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-ios.zip) | | `media-player-sdk-x-macos` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a native .NET for macOS application. Covers the macOS-specific VideoView control, the cross-platform NuGet package, Info.plist usage descriptions, code signing entitlements, license registration, and the most common macOS pitfalls (hardened runtime, network entitlements for streaming, Apple Silicon vs Intel native libs, trial-period expiry / unlicensed build). Use for native .NET for macOS playback apps — for cross-OS MAUI use media-player-sdk-x-maui. | [media-player-sdk-x-macos.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-macos.zip) | | `media-player-sdk-x-maui` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a .NET MAUI cross-platform app (Windows, Android, iOS, macOS). Covers the MAUI-specific VideoView control, multi-target NuGet packages (per-OS native dependencies), license registration, supported input formats, and the most common cross-platform pitfalls (network permissions per OS, missing native libs, AOT JIT-only ExecutionEngineException, trial-period expiry / unlicensed build). Use when building playback apps that must run on multiple OSes from one MAUI codebase. | [media-player-sdk-x-maui.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-maui.zip) | | `media-player-sdk-x-uno` | Integrate VisioForge Media Player SDK X (cross-platform edition) into an Uno Platform application. Covers the Uno-specific VideoView control, multi-target NuGet packages (per-OS native dependencies), license registration, supported input formats, and the most common cross-platform pitfalls (network access per OS, WebAssembly limitations, missing native libs, trial-period expiry / unlicensed build). Use for Uno cross-OS apps — for MAUI use media-player-sdk-x-maui, for Avalonia use media-player-sdk-x-avalonia. | [media-player-sdk-x-uno.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-uno.zip) | | `media-player-sdk-x-winforms` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a Windows Forms application. Covers the cross-platform NuGet package layout, project setup, license registration, supported input formats, and the most common playback pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want playback on WinForms with an API that ports cleanly to MAUI, Avalonia, Uno — for the legacy DirectShow stack use media-player-sdk-net-winforms. | [media-player-sdk-x-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-winforms.zip) | | `media-player-sdk-x-winui` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a WinUI 3 (Windows App SDK) application. Covers the WinUI-specific VideoView control, the cross-platform NuGet package layout, project setup, license registration, MSIX packaging quirks, supported input formats, and the most common playback pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use for WinUI 3 with the X-family API — for the legacy DirectShow stack use media-player-sdk-net-winui. | [media-player-sdk-x-winui.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-winui.zip) | | `media-player-sdk-x-wpf` | Integrate VisioForge Media Player SDK X (cross-platform edition) into a Windows WPF application. Covers the cross-platform NuGet package layout, project setup, license registration, supported input formats, and the most common playback pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want playback on WPF with an API that ports cleanly to MAUI, Avalonia, Uno, Android, iOS, macOS — for Windows-only with the legacy DirectShow stack, use media-player-sdk-net-wpf. | [media-player-sdk-x-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/media-player-sdk-x-wpf.zip) | ### Video Edit SDK .NET | Skill | Description | Archive | | --- | --- | --- | | `video-edit-sdk-net-console` | Integrate VisioForge Video Edit SDK .NET (non-linear editor) into a .NET console application for batch processing — cut, trim, merge, transcode, apply effects to existing video files headlessly. Covers the timeline model, the single NuGet package, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use for scripts, scheduled jobs, CI pipelines that process video files — for an interactive editor use video-edit-sdk-net-wpf or video-edit-sdk-net-winforms. | [video-edit-sdk-net-console.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-net-console.zip) | | `video-edit-sdk-net-winforms` | Integrate VisioForge Video Edit SDK .NET (non-linear editor) into a Windows Forms application. Covers the timeline model, the single NuGet package, project setup, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when adding cut/trim/merge/transcode/effects to existing video files on a WinForms app — for live capture from a camera, use video-capture-sdk-net-winforms instead. | [video-edit-sdk-net-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-net-winforms.zip) | | `video-edit-sdk-net-wpf` | Integrate VisioForge Video Edit SDK .NET (non-linear editor) into a Windows WPF application. Covers the timeline model, the single NuGet package, project setup, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when adding cut/trim/merge/transcode/effects to existing video files on a WPF app — for live capture from a camera, use video-capture-sdk-net-wpf instead. | [video-edit-sdk-net-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-net-wpf.zip) | ### Video Edit SDK X | Skill | Description | Archive | | --- | --- | --- | | `video-edit-sdk-x-avalonia` | Integrate VisioForge Video Edit SDK X (cross-platform editor edition) into an Avalonia UI application. Covers the timeline model, multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (missing native libs, file path conventions, trial-period expiry / unlicensed build). Use when building a non-linear editor that must run on Windows, Linux, and macOS from one codebase — for WPF / WinForms hosts use video-edit-sdk-x-{wpf,winforms}, for headless batch use video-edit-sdk-x-console. | [video-edit-sdk-x-avalonia.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-x-avalonia.zip) | | `video-edit-sdk-x-console` | Integrate VisioForge Video Edit SDK X (cross-platform editor edition) into a .NET console application for batch processing — cut, trim, merge, transcode, apply effects to existing video files headlessly. Covers the timeline model, the cross-platform NuGet package layout, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use for scripts, scheduled jobs, CI pipelines that process video files with the X-family API — for an interactive editor use video-edit-sdk-x-wpf or video-edit-sdk-x-winforms. | [video-edit-sdk-x-console.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-x-console.zip) | | `video-edit-sdk-x-winforms` | Integrate VisioForge Video Edit SDK X (cross-platform editor edition) into a Windows Forms application. Covers the timeline model, the cross-platform NuGet package layout, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want non-linear editing on WinForms with an API that ports cleanly to Avalonia, Console, WPF — for Windows-only with the legacy DirectShow stack, use video-edit-sdk-net-winforms instead. | [video-edit-sdk-x-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-x-winforms.zip) | | `video-edit-sdk-x-wpf` | Integrate VisioForge Video Edit SDK X (cross-platform editor edition) into a Windows WPF application. Covers the timeline model, the cross-platform NuGet package layout, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when you want non-linear editing on WPF with an API that ports cleanly to Avalonia, Console, WinForms — for Windows-only with the legacy DirectShow stack, use video-edit-sdk-net-wpf instead. | [video-edit-sdk-x-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/video-edit-sdk-x-wpf.zip) | ### Media Blocks SDK .NET | Skill | Description | Archive | | --- | --- | --- | | `media-blocks-sdk-net-android` | Integrate VisioForge Media Blocks SDK into a native .NET for Android application. Covers the graph-based pipeline model on Android, the cross-platform NuGet package, AndroidDependency project reference, runtime camera/audio permissions, license registration, and the most common Android pitfalls (CAMERA permission denied, RECORD\_AUDIO permission denied, AAB packaging ABI filters, hardware encoder support, trial-period expiry / unlicensed build). Use for native .NET for Android pipelines (capture, transcode, stream, record) — for cross-OS MAUI use media-blocks-sdk-net-maui. | [media-blocks-sdk-net-android.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-android.zip) | | `media-blocks-sdk-net-avalonia` | Integrate VisioForge Media Blocks SDK into an Avalonia UI application. Covers the graph-based pipeline model (MediaBlocksPipeline, source/sink/transform blocks), multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (missing native libs, file path conventions, X11/Wayland on Linux, ALSA/PulseAudio audio, trial-period expiry / unlicensed build). Use when building custom media pipelines (capture, transcode, mix, stream, record) on Windows, Linux, and macOS — for native iOS/Android/macOS use media-blocks-sdk-net-{android,ios,macos}, for MAUI use media-blocks-sdk-net-maui. | [media-blocks-sdk-net-avalonia.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-avalonia.zip) | | `media-blocks-sdk-net-blazor` | Integrate VisioForge Media Blocks SDK into a Blazor Server application. Covers the graph-based pipeline model running server-side (one pipeline per logical scenario, owned by a singleton DI service), the single .NET wrapper plus per-OS native redist NuGet packages, license registration, the strict no-Blazor-WebAssembly constraint, and the most common Blazor pitfalls (DI lifetime mismatches, Razor circuit disposal vs pipeline disposal, capture-device permissions on the server host, server-side codec licensing, trial-period expiry / unlicensed build). Use for browser-based UIs that drive a server-side media pipeline (RTSP server, file recording, transcoding, broadcasting) — for a desktop UI use media-blocks-sdk-net-{wpf,winforms}. | [media-blocks-sdk-net-blazor.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-blazor.zip) | | `media-blocks-sdk-net-console` | Integrate VisioForge Media Blocks SDK into a .NET console application for batch processing — build custom pipelines (transcode, mux, stream, record) without UI. Covers the graph-based pipeline model, the single NuGet package, license registration, headless block wiring, and the most common deployment pitfalls (DLL not found, missing codecs, no preview block, trial-period expiry / unlicensed build). Use for scripts, scheduled jobs, CI pipelines that need full pipeline control — for an interactive UI use media-blocks-sdk-net-{wpf,winforms}. | [media-blocks-sdk-net-console.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-console.zip) | | `media-blocks-sdk-net-ios` | Integrate VisioForge Media Blocks SDK into a native .NET for iOS application. Covers the graph-based pipeline model on iOS, the cross-platform NuGet package, Info.plist NSCameraUsageDescription / NSMicrophoneUsageDescription requirements, license registration, AOT JIT-only ExecutionEngineException, and the most common iOS pitfalls (missing usage descriptions, no camera in simulator, App Store reviewer rejecting missing privacy strings, trial-period expiry / unlicensed build). Use for native .NET for iOS pipelines (capture, transcode, stream, record) — for cross-OS MAUI use media-blocks-sdk-net-maui. | [media-blocks-sdk-net-ios.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-ios.zip) | | `media-blocks-sdk-net-macos` | Integrate VisioForge Media Blocks SDK into a native .NET for macOS application. Covers the graph-based pipeline model on macOS, the cross-platform NuGet package, Info.plist NSCameraUsageDescription / NSMicrophoneUsageDescription, code signing entitlements, license registration, and the most common macOS pitfalls (missing usage descriptions, hardened runtime + missing entitlements, Apple Silicon vs Intel native libs, trial-period expiry / unlicensed build). Use for native .NET for macOS pipelines (capture, transcode, stream, record) — for cross-OS MAUI use media-blocks-sdk-net-maui. | [media-blocks-sdk-net-macos.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-macos.zip) | | `media-blocks-sdk-net-maui` | Integrate VisioForge Media Blocks SDK .NET into a .NET MAUI cross-platform app (Windows, Android, iOS, macOS). Covers the graph-based pipeline model, multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (camera permissions, missing native libs, trial-period expiry / unlicensed build). Use when building custom media pipelines (capture, transcode, stream, record) that must run on multiple OSes from one MAUI codebase. | [media-blocks-sdk-net-maui.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-maui.zip) | | `media-blocks-sdk-net-uno` | Integrate VisioForge Media Blocks SDK into an Uno Platform application. Covers the graph-based pipeline model, multi-target NuGet packages (per-OS native dependencies), license registration, and the most common cross-platform pitfalls (camera permissions per OS, WebAssembly limitations, missing native libs, trial-period expiry / unlicensed build). Use for Uno cross-OS pipelines (Windows, Android, iOS, macOS) — for MAUI use media-blocks-sdk-net-maui, for Avalonia use media-blocks-sdk-net-avalonia. | [media-blocks-sdk-net-uno.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-uno.zip) | | `media-blocks-sdk-net-winforms` | Integrate VisioForge Media Blocks SDK .NET into a Windows Forms application. Covers the graph-based pipeline model (MediaBlocksPipeline, source/sink/transform blocks), the single NuGet package, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when building custom media pipelines (capture, transcode, mix, stream, record) on a WinForms app — for simpler webcam-only capture, use video-capture-sdk-net-winforms instead. | [media-blocks-sdk-net-winforms.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-winforms.zip) | | `media-blocks-sdk-net-wpf` | Integrate VisioForge Media Blocks SDK .NET into a Windows WPF application. Covers the graph-based pipeline model (MediaBlocksPipeline, source/sink/transform blocks), the single NuGet package, license registration, and the most common deployment pitfalls (DLL not found, missing codecs, trial-period expiry / unlicensed build). Use when building custom media pipelines (capture, transcode, mix, stream, record) on a WPF app — for simpler webcam-only capture, use video-capture-sdk-net-wpf instead. | [media-blocks-sdk-net-wpf.zip](https://www.visioforge.com/.well-known/agent-skills/media-blocks-sdk-net-wpf.zip) | ## How agents pick up a skill 1. Agent crawls a page on `www.visioforge.com`, sees `` (or the same URL in the `Link` HTTP header for Markdown responses). Agents arriving via `help.visioforge.com` should follow the inline `https://www.visioforge.com/.well-known/agent-skills/index.json` link directly — the help site doesn't emit those discovery signals. 2. Agent fetches the index, reads the `skills[]` array, picks the entries whose `description` matches the user's task. 3. Agent downloads the matching `.zip`, verifies the `sha256:` digest, unpacks `SKILL.md` and `references/`, and follows the procedural instructions. ## Reading a skill yourself A skill archive is a plain zip. Unpack it and you'll find: - `SKILL.md` — frontmatter (`name`, `description`) followed by procedural prose: when to use the skill, NuGet packages, project setup, license registration, common pitfalls. - `references/Sample.csproj` — minimal, working csproj for the skill's target host (WPF, WinForms, MAUI, Console, …) — each per-platform skill ships a csproj specific to that host (e.g. the WPF skill csproj sets `Microsoft.NET.Sdk.WindowsDesktop` + `true`). - `references/.cs` — the initialization pattern from a real official sample. WPF skills also bundle the matching `.xaml`, `App.xaml(.cs)`, and any required resources so `dotnet build` succeeds against the bundle as-is. ## Maintenance Skills track the current public NuGet release. The version pinned in each `SKILL.md` and `references/Sample.csproj` matches the version in the official samples on [github.com/visioforge/.Net-SDK-s-samples](https://github.com/visioforge/.Net-SDK-s-samples). When a major SDK version ships, every skill is updated and the discovery index sha256 digests are recomputed during the visioforge.com build. ## Related discovery surfaces VisioForge already exposes three other AI-agent surfaces — Agent Skills is the fourth and complements them: | Surface | Shape | Best for | | --- | --- | --- | | `mcp.visioforge.com/mcp` (via `/.well-known/mcp.json` + `/.well-known/mcp-server-card`) | Live MCP server with 14 read-only doc tools | Querying the SDK API surface, looking up media blocks, fetching code examples | | `/llms.txt`, `/llms-full.txt` | LLM-friendly docs index | Bulk ingestion of the docs corpus | | `` + WebMCP runtime | 10 in-page tools registered via `navigator.modelContext.provideContext()` | Agent acting in the user's current browser tab (locale switch, page outline, copy code, …) | | **`/.well-known/agent-skills/index.json`** | **Per-(SDK, platform) procedural skill archives** | **Bootstrapping a new project that uses one of our SDKs** | ---END OF PAGE--- ## ABUS IP Camera RTSP URLs and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/abus/ **Description:** ABUS TVIP, CASA, and Digi-Lan camera RTSP URL patterns for C# .NET. Stream and record with VisioForge Video Capture SDK cross-platform integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MP4, H.264, MJPEG, C# # How to Connect to ABUS IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **ABUS** (August Bremicker Soehne KG) is a German security company headquartered in Wetter, Germany. Founded in 1924, ABUS is one of Europe's largest security product manufacturers, known for locks, alarm systems, and video surveillance. The **TVIP** series of IP cameras is widely deployed across Europe, particularly in Germany, Austria, and the Benelux countries. **Key facts:** - **Product lines:** TVIP (IP cameras), CASA (consumer), TV (legacy analog IP), Digi-Lan (older IP) - **TVIP model numbering:** TVIP1xxxx (consumer), TVIP2xxxx (2MP), TVIP4xxxx (4MP), TVIP5xxxx (5MP), TVIP6xxxx/7xxxx (special) - **Protocol support:** RTSP, ONVIF, HTTP/CGI, MJPEG - **Default RTSP port:** 554 - **Default credentials:** admin / admin (some models: root / pass) - **ONVIF support:** Yes (TVIP2xxxx and newer) - **Video codecs:** H.264 (TVIP2xxxx and newer), MJPEG (older models) ABUS TVIP Model Numbering The TVIP model number indicates the resolution tier: **1xxxx** = basic/consumer, **2xxxx** = 2MP (1080p), **4xxxx** = 4MP, **5xxxx** = 5MP, **6xxxx/7xxxx** = special models. This helps identify which URL formats and codecs a camera supports. ## RTSP URL Patterns ### Primary URL Formats ABUS cameras support multiple RTSP URL formats depending on the model generation: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/video.mp4 ``` | URL Pattern | Description | | --- | --- | | `rtsp://IP:554/video.mp4` | MP4 stream (recommended for H.264 models) | | `rtsp://IP:554/live.sdp` | Live SDP stream (consumer and legacy models) | | `rtsp://IP:554/video.h264` | Direct H.264 stream | | `rtsp://IP:554/VideoInput/CHANNEL/h264/1` | VideoInput format (4MP models) | ### TVIP1xxxx Series (Consumer) | Model | Main Stream URL | Notes | | --- | --- | --- | | TVIP10000 | `rtsp://IP:554/live.sdp` | MJPEG-only | | TVIP10500 | `rtsp://IP:554/live.sdp` | MJPEG-only | | TVIP10550 | `rtsp://IP:554/live.sdp` | MJPEG-only | | TVIP11000 | `rtsp://IP:554/live.sdp` | MJPEG/H.264 | MJPEG-Only Models Some older TVIP1xxxx models (TVIP10000, TVIP10500, TVIP10550) support only MJPEG encoding with no H.264. Use the MJPEG HTTP stream URLs listed in the Snapshot and MJPEG section below for these models. ### TVIP2xxxx Series (2MP) | Model | Main Stream URL | Alternative URL | | --- | --- | --- | | TVIP20000 | `rtsp://IP:554/video.mp4` | - | | TVIP20550 | `rtsp://IP:554/video.mp4` | - | | TVIP21550 | `rtsp://IP:554/video.mp4` | `rtsp://IP:554/live.sdp` | | TVIP22500 | `rtsp://IP:554/video.h264` | - | ### TVIP4xxxx Series (4MP) | Model | Main Stream URL | Alternative URL | | --- | --- | --- | | TVIP41500 | `rtsp://IP:554/video.mp4` | `rtsp://IP:554/VideoInput/1/h264/1` | | TVIP41550 | `rtsp://IP:554/video.mp4` | `rtsp://IP:554/VideoInput/1/h264/1` | ### TVIP5xxxx Series (5MP) | Model | Main Stream URL | | --- | --- | | TVIP51550 | `rtsp://IP:554/video.mp4` | ### TVIP6xxxx / TVIP7xxxx Series (Special) | Model | Main Stream URL | | --- | --- | | TVIP61500 | `rtsp://IP:554/video.mp4` | | TVIP71550 | `rtsp://IP:554/video.mp4` | ### CASA Series (Consumer) | Model | Main Stream URL | | --- | --- | | CASA20550 | `rtsp://IP:554/live.sdp` | ### Legacy TV / Digi-Lan Series | Model | Main Stream URL | | --- | --- | | Digi-Lan TV7220 | `rtsp://IP:554/live.sdp` | | TV7240-LAN | `rtsp://IP:554/live.sdp` | | TV32500 | `rtsp://IP:554/video.mp4` | Which URL Format to Try First For ABUS cameras, try `video.mp4` first for H.264 streaming, then `live.sdp` as a fallback. For older TVIP1xxxx models, `live.sdp` is typically the only RTSP option. The `VideoInput` format is specific to TVIP4xxxx models. ## Connecting with VisioForge SDK Use your ABUS camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // ABUS TVIP41550, main stream var uri = new Uri("rtsp://192.168.1.90:554/video.mp4"); var username = "admin"; var password = "admin"; ``` For models using the `VideoInput` format, use: ``` // ABUS TVIP41500, VideoInput format var uri = new Uri("rtsp://192.168.1.90:554/VideoInput/1/h264/1"); ``` ## Snapshot and MJPEG URLs ### JPEG Snapshots | Type | URL Pattern | Supported Models | | --- | --- | --- | | Standard snapshot | `http://IP/jpg/image.jpg` | TVIP10500, TVIP10550, TVIP11000, TVIP20000, TVIP21550, TVIP51550 | | High-res snapshot | `http://IP/jpg/image.jpg?size=3` | TVIP10001, TVIP21050, TVIP71550 | | CGI viewer | `http://IP/cgi-bin/viewer/video.jpg?channel=CH&resolution=WxH` | CASA20550, TVIP41550, TVIP51550 | | Simple CGI snapshot | `http://IP/cgi-bin/video.jpg` | Digi-Lan, TV models | | Alternative CGI | `http://IP/cgi-bin/jpg/image` | TVIP20050 | | Profile image | `http://IP/cgi-bin/view/image?pro_CHANNEL` | TVIP20000, TVIP21500 | | JPEG pull | `http://IP/jpeg/pull` | TVIP62000 | ### MJPEG Streams | Type | URL Pattern | Supported Models | | --- | --- | --- | | Standard MJPEG | `http://IP/video.mjpg` | TVIP10000, TVIP11000, TVIP21500, TVIP21550, TVIP51550, TVIP71501 | | MJPEG with params | `http://IP/video.mjpg?q=30&fps=33&id=0.5` | TVIP31550, TVIP21501, TVIP51550, TVIP71550 | MJPEG Parameters The `q` parameter controls JPEG quality (1-100), `fps` sets the frame rate, and `id` is a session identifier. Adjust these values based on your bandwidth and quality requirements. ## Troubleshooting ### Multiple URL formats work on the same camera Many ABUS cameras respond to several different RTSP and HTTP URL formats. This is by design. For the best results: 1. Try `rtsp://IP:554/video.mp4` first for H.264 streaming 2. Fall back to `rtsp://IP:554/live.sdp` if `video.mp4` does not work 3. Use `http://IP/video.mjpg` for MJPEG streaming as a last resort ### Older TVIP1xxxx models have no H.264 Some first-generation TVIP1xxxx cameras (TVIP10000, TVIP10500, TVIP10550) only support MJPEG encoding. These cameras will not respond to `video.mp4` or `video.h264` RTSP URLs. Use the MJPEG HTTP stream (`http://IP/video.mjpg`) or the `live.sdp` RTSP URL instead. ### Default credentials vary by model Most ABUS cameras use `admin` / `admin` as default credentials. However, some models default to `root` / `pass`. If authentication fails with one set, try the other. Check the camera's documentation for the specific default credentials. ### TVIP model number decoding If you are unsure which URL format to use, the TVIP model number provides guidance: - **TVIP1xxxx:** Start with `live.sdp`, may be MJPEG-only - **TVIP2xxxx:** Start with `video.mp4`, most support H.264 - **TVIP4xxxx:** Start with `video.mp4`, also try `VideoInput/1/h264/1` - **TVIP5xxxx+:** Start with `video.mp4` ### Snapshot resolution parameter For the `jpg/image.jpg?size=N` URL, the `size` parameter controls resolution: - `size=1` = Lowest resolution - `size=2` = Medium resolution - `size=3` = Highest resolution ## FAQ **What is the default RTSP URL for ABUS cameras?** For most current ABUS cameras (TVIP2xxxx and newer), the default URL is `rtsp://admin:admin@CAMERA_IP:554/video.mp4`. For older consumer models (TVIP1xxxx), try `rtsp://admin:admin@CAMERA_IP:554/live.sdp` instead. **Do ABUS cameras support ONVIF?** Yes. ABUS cameras from the TVIP2xxxx generation onward support ONVIF, which provides standardized camera discovery and streaming. Older TVIP1xxxx models may not support ONVIF. **Can I use MJPEG streaming with ABUS cameras?** Yes. Most ABUS cameras support MJPEG streaming via `http://CAMERA_IP/video.mjpg`. This is particularly useful for older TVIP1xxxx models that do not support H.264 encoding. MJPEG uses more bandwidth than H.264 but is compatible with a wider range of software. **What do the ABUS TVIP model numbers mean?** The five-digit number after "TVIP" indicates the camera's resolution tier: 1xxxx = basic/consumer, 2xxxx = 2MP (1080p), 4xxxx = 4MP, 5xxxx = 5MP, and 6xxxx/7xxxx = special models. Higher numbers generally indicate newer hardware with broader protocol and codec support. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [INSTAR Connection Guide](../instar/) — German consumer / smart home cameras - [ONVIF IP Camera Integration](../../videocapture/video-sources/ip-cameras/onvif/) — ABUS ONVIF device setup - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## ACTi IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/acti/ **Description:** ACTi A, B, D, E series and legacy ACM/KCM/TCM camera RTSP URL patterns for C# .NET. Integrate with VisioForge Video Capture SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to ACTi IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **ACTi Corporation** is a Taiwanese manufacturer of IP surveillance cameras and video management solutions. Headquartered in Taipei, Taiwan, ACTi targets professional and enterprise markets with a wide range of fixed, dome, bullet, and PTZ cameras. ACTi is known for its current A/B/D/E series cameras and legacy ACM, KCM, and TCM product lines. **Key facts:** - **Product lines:** A-series (box), B-series (bullet/zoom), D-series (dome), E-series (hemispheric dome), KCM (legacy dome), ACM (legacy box/dome), TCM (legacy box) - **Protocol support:** RTSP, ONVIF (current A/B/D/E series), HTTP/CGI - **Default RTSP port:** 7070 (most models), 554 (some legacy models) - **Default credentials:** Admin / 123456 (current models), admin / admin (legacy) - **ONVIF support:** Yes (current A/B/D/E series) - **Video codecs:** H.264, H.265 (E-series), MJPEG Non-standard port ACTi cameras use **port 7070** by default for RTSP, not the standard port 554. This is the most common connection issue when integrating ACTi cameras. ## RTSP URL Patterns ### Current Models (A/B/D/E Series) | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:7070//stream1` | Primary stream (note double slash) | | Root stream | `rtsp://IP:7070/` | Fallback | | H.264 direct | `rtsp://IP:7070/h264` | Explicit codec selection | | ONVIF stream | `rtsp://IP:7070//onvif-stream1` | ONVIF variant | Double slash before stream1 ACTi cameras use a **double forward slash** before `stream1` in their RTSP URLs: `rtsp://IP:7070//stream1`. This is intentional and required for most current models. ### Model-Specific URLs | Model Series | RTSP URL | Type | Notes | | --- | --- | --- | --- | | D11, D21, D31, D32 | `rtsp://IP:7070//stream1` | Dome | Current | | D42, D51, D52, D55, D72 | `rtsp://IP:7070//stream1` | Dome | Current | | E12, E32, E33, E43, E46 | `rtsp://IP:7070//stream1` | Hemispheric | Current, H.265 capable | | E51, E52, E63, E65, E73 | `rtsp://IP:7070//stream1` | Hemispheric | Current, H.265 capable | | E82, E84, E96 | `rtsp://IP:7070//stream1` | Hemispheric | Current, H.265 capable | | B53, B87, B95 | `rtsp://IP:7070//stream1` | Bullet/Zoom | Current | | A-series (box) | `rtsp://IP:7070//stream1` | Box | Current | ### Legacy Models Legacy ACTi cameras may use port 554 or 7070 depending on the model and firmware version: | Model Series | RTSP URL | Type | Notes | | --- | --- | --- | --- | | ACM-1011 | `rtsp://IP:554/` or `rtsp://IP:7070/` | Box | Legacy | | ACM-3401 | `rtsp://IP:554/` or `rtsp://IP:7070/` | Dome | Legacy | | ACM-5601 | `rtsp://IP:554/` or `rtsp://IP:7070/` | Box | Legacy | | ACM-7411 | `rtsp://IP:554/` or `rtsp://IP:7070/` | Dome | Legacy | | KCM-3311 | `rtsp://IP:7070/` | Dome | Legacy | | KCM-5611 | `rtsp://IP:7070/` | Dome | Legacy | | KCM-7211 | `rtsp://IP:7070/` | Dome | Legacy | | TCM-1231 | `rtsp://IP:7070/` | Box | Legacy | | TCM-3511 | `rtsp://IP:7070/` | Box | Legacy | | TCM-5111 | `rtsp://IP:7070/` | Box | Legacy | | TCM-5311 | `rtsp://IP:7070/` | Box | Legacy | ## Connecting with VisioForge SDK Use your ACTi camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // ACTi D/E series camera, main stream -- note port 7070, not 554! var uri = new Uri("rtsp://192.168.1.50:7070//stream1"); var username = "Admin"; var password = "123456"; ``` For legacy ACM models that use port 554, change the port accordingly. For a simpler root stream, use `rtsp://IP:7070/` as the URL. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | CGI Snapshot | `http://IP/cgi-bin/encoder?USER=USERNAME&PWD=PASSWORD&SNAPSHOT` | Authenticated snapshot | | HTTP Streaming | `http://IP/cgi-bin/cmd/system?GET_STREAM&USER=USERNAME&PWD=PASSWORD` | Continuous stream | | JPEG Image | `http://IP/jpg/image.jpg` | Direct JPEG | | JPEG (alt) | `http://IP/now.jpg` | Alternative snapshot path | ## Troubleshooting ### Port 7070, not 554 The most common ACTi connection issue is using the standard port 554. ACTi cameras default to **port 7070** for RTSP. If your connection times out or is refused, verify you are using the correct port. - Correct: `rtsp://IP:7070//stream1` - Likely incorrect: `rtsp://IP:554//stream1` (unless using a legacy ACM model) ### Double slash before stream1 ACTi current-generation cameras use a **double forward slash** before `stream1`: - Correct: `rtsp://IP:7070//stream1` - May not work: `rtsp://IP:7070/stream1` ### Default credentials differ by generation - **Current models (A/B/D/E series):** Username `Admin` (capital A), password `123456` - **Legacy models (ACM/KCM/TCM):** Username `admin` (lowercase), password `admin` Always change default credentials before deploying cameras on a production network. ### Legacy ACM models and port 554 Some older ACM-series cameras (ACM-1011, ACM-3401, ACM-5601, ACM-7411) may use port 554 instead of 7070. If port 7070 fails on a legacy model, try port 554 with the root URL `rtsp://IP:554/`. ### ONVIF availability ONVIF is only supported on current-generation cameras (A, B, D, and E series). Legacy ACM, KCM, and TCM cameras do not support ONVIF. For legacy models, use direct RTSP or HTTP URLs. ## FAQ **What is the default RTSP URL for ACTi cameras?** For current ACTi cameras (A/B/D/E series), use `rtsp://Admin:123456@CAMERA_IP:7070//stream1`. Note the non-standard port 7070 and double slash before `stream1`. For legacy models, try `rtsp://admin:admin@CAMERA_IP:7070/` or `rtsp://admin:admin@CAMERA_IP:554/`. **Why does ACTi use port 7070 instead of 554?** ACTi chose port 7070 as their default RTSP port. This can be changed in the camera's web interface, but the factory default is 7070 for most models. Some legacy ACM-series cameras default to port 554. **Does ACTi support H.265?** Current E-series cameras (hemispheric dome models) support H.265 encoding. Other current series (A, B, D) primarily use H.264. Legacy models (ACM, KCM, TCM) support H.264 and MJPEG only. **What is the difference between ACTi product series?** ACTi organizes cameras by letter: **A** = box cameras, **B** = bullet and zoom cameras, **D** = dome cameras, **E** = hemispheric dome cameras. Legacy product lines include ACM (box/dome), KCM (dome), and TCM (box). ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Vivotek Connection Guide](../vivotek/) — Taiwanese enterprise cameras - [GeoVision Connection Guide](../geovision/) — Taiwanese professional cameras - [ONVIF IP Camera Integration](../../videocapture/video-sources/ip-cameras/onvif/) — ACTi ONVIF device setup - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Amcrest IP Camera RTSP URL Format and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/amcrest/ **Description:** Amcrest IP2M, IP4M, IP5M, IP8M, and NVR RTSP URL patterns for C# .NET. Stream and record using VisioForge SDK with ONVIF auto-discovery support. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to Amcrest IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Amcrest** (Amcrest Technologies LLC) is an American consumer security camera brand based in Houston, Texas. Amcrest cameras are manufactured by **Dahua Technology** and use Dahua firmware and protocols. This means Amcrest cameras share identical RTSP URL patterns, web interfaces, and API endpoints with Dahua cameras. Amcrest has become one of the best-selling IP camera brands on Amazon in North America. **Key facts:** - **Product lines:** IP2M (1080p), IP4M (4MP), IP5M (5MP), IP8M (4K/8MP), ASH (smart home), NV (NVRs) - **Protocol support:** RTSP, ONVIF, HTTP/CGI, Amcrest Cloud, RTMP - **Default RTSP port:** 554 - **Default credentials:** admin / admin (must be changed on first login with newer firmware) - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264 (all models), H.265 (IP4M and newer) - **OEM base:** Dahua (identical RTSP URL format) Amcrest = Dahua Amcrest cameras use Dahua firmware and the exact same RTSP URL format as Dahua cameras. If you're familiar with Dahua integration, Amcrest works identically. See our [Dahua connection guide](../dahua/) for additional details. ## RTSP URL Patterns ### Standard URL Format Amcrest uses the Dahua `cam/realmonitor` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/cam/realmonitor?channel=1&subtype=0 ``` | Parameter | Value | Description | | --- | --- | --- | | `channel` | 1, 2, 3... | Camera channel (1 for standalone cameras) | | `subtype` | 0 | Main stream (highest resolution) | | `subtype` | 1 | Sub stream (lower resolution, less bandwidth) | | `subtype` | 2 | Third stream (if supported, mobile-optimized) | ### Camera Models | Model | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | | IP2M-841 (1080p bullet) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | IP2M-844 (1080p dome) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | IP4M-1051 (4MP bullet) | 2688x1520 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | IP5M-T1179E (5MP turret) | 2592x1944 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | IP8M-2493E (4K bullet) | 3840x2160 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | IP8M-T2599E (4K turret) | 3840x2160 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | ASH-41 (pan/tilt) | 2560x1440 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | ASH-42 (indoor) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | ### NVR Channel URLs For Amcrest NVRs (NV4108E, NV4216E, NV5216E, etc.): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | | Camera 2 | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=1` | | Camera N | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=1` | ### Alternative URL Formats Some older Amcrest models or firmware versions support these alternative URLs: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Standard (recommended) | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0&unicast=true` | Force unicast | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0&proto=Onvif` | ONVIF-compatible | ## Connecting with VisioForge SDK Use your Amcrest camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Amcrest IP4M-1051, main stream var uri = new Uri("rtsp://192.168.1.90:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `subtype=1` instead of `subtype=0`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi?channel=1` | Requires basic auth | | JPEG Snapshot (legacy) | `http://IP/cgi-bin/snapshot.cgi?loginuse=USER&loginpas=PASS` | URL-based auth | | MJPEG Stream | `http://IP/cgi-bin/mjpg/video.cgi?channel=1&subtype=1` | Continuous MJPEG | | Current image | `http://IP/onvif-http/snapshot?channel=1` | ONVIF HTTP snapshot | ## Troubleshooting ### "401 Unauthorized" error Amcrest cameras with newer firmware require the password to be changed from the default on first login. If you haven't set up the camera via the web interface or Amcrest app yet: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Complete the initial setup wizard 3. Set a strong password 4. Use those credentials in your RTSP URL ### Port 554 vs custom port Some Amcrest firmware versions allow changing the RTSP port. Check the port setting at: - Web interface: **Setup > Network > Port > RTSP Port** - Default is 554 ### Stream type confusion - `subtype=0` = Main stream (full resolution, higher bandwidth) - `subtype=1` = Sub stream (reduced resolution, lower bandwidth) - `subtype=2` = Third stream (if available, typically for mobile) ### Amcrest SmartHome (ASH) cameras The ASH series cameras (like ASH-41, ASH-42) use the same RTSP URL format but some models require enabling RTSP in the Amcrest Smart Home app first. ## FAQ **Are Amcrest and Dahua cameras the same?** Amcrest cameras are manufactured by Dahua and use Dahua firmware. The RTSP URL format (`cam/realmonitor?channel=1&subtype=0`) is identical. Any code written for Dahua cameras works with Amcrest and vice versa. The main differences are branding, warranty, and North American support. **What is the default RTSP URL for Amcrest cameras?** The URL is `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=0` for the main stream. Replace `channel=1` with the appropriate channel for NVR setups and `subtype=0` with `subtype=1` for the sub stream. **Do Amcrest cameras support ONVIF?** Yes. All current Amcrest cameras support ONVIF Profile S and Profile T. ONVIF is enabled by default on most models. **Can I use Amcrest cameras without the Amcrest cloud?** Yes. RTSP, ONVIF, and the web interface all work locally without any cloud dependency. The Amcrest cloud service is optional and only needed for remote viewing through Amcrest's apps. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Dahua Connection Guide](../dahua/) — Same URL format (OEM base) - [Lorex Connection Guide](../lorex/) — Also uses Dahua URL format - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Annke Camera RTSP URL Patterns with C# .NET Examples **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/annke/ **Description:** Annke C500, C800, CZ400, NC400 and NVR RTSP URL patterns for C# .NET. Integrate with VisioForge Video Capture SDK for streaming and recording. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to Annke IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Annke** (Annke Innovation Co., Ltd.) is a consumer and prosumer security camera brand based in Hong Kong, primarily selling through Amazon and direct-to-consumer channels. Annke cameras are manufactured using **Hikvision** OEM hardware, and most models use Hikvision-compatible firmware and RTSP URL patterns. Annke offers competitive pricing on PoE cameras, NVRs, and complete surveillance kits. **Key facts:** - **Product lines:** C-series (IP cameras), CZ-series (PTZ), NC-series (NVRs), I-series (turret/dome) - **Protocol support:** RTSP, ONVIF Profile S, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / (set during initial setup; some models: admin / admin) - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264, H.265 (4MP and above) - **OEM base:** Hikvision (most models use Hikvision-compatible firmware) Annke Uses Hikvision Firmware Most Annke cameras use Hikvision OEM firmware. The RTSP URL format (`/Streaming/Channels/`) is identical to Hikvision. See our [Hikvision connection guide](../hikvision/) for additional details and troubleshooting. ## RTSP URL Patterns ### Standard URL Format Annke cameras use the Hikvision `Streaming/Channels` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/Streaming/Channels/[CHANNEL_ID] ``` | Channel ID | Stream | Description | | --- | --- | --- | | 101 | Main stream | Full resolution | | 102 | Sub stream | Lower resolution | | 103 | Third stream | Mobile-optimized (if supported) | ### Camera Models | Model | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | | C500 (5MP bullet) | 2592x1944 | `rtsp://IP:554/Streaming/Channels/101` | Yes | | C800 (4K bullet) | 3840x2160 | `rtsp://IP:554/Streaming/Channels/101` | Yes | | C1200 (12MP bullet) | 4000x3000 | `rtsp://IP:554/Streaming/Channels/101` | Yes | | CZ400 (4MP PTZ) | 2560x1440 | `rtsp://IP:554/Streaming/Channels/101` | Yes | | I91BN (4K turret) | 3840x2160 | `rtsp://IP:554/Streaming/Channels/101` | Yes | | I91BM (4K dome) | 3840x2160 | `rtsp://IP:554/Streaming/Channels/101` | Yes | | NC400 (4ch NVR) | N/A | See NVR section | N/A | | N48PAW (8ch PoE NVR) | N/A | See NVR section | N/A | ### NVR Channel URLs For Annke NVRs (NC400, N48PAW, N46PCK, etc.): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/Streaming/Channels/101` | `rtsp://IP:554/Streaming/Channels/102` | | Camera 2 | `rtsp://IP:554/Streaming/Channels/201` | `rtsp://IP:554/Streaming/Channels/202` | | Camera N | `rtsp://IP:554/Streaming/Channels/N01` | `rtsp://IP:554/Streaming/Channels/N02` | ### Alternative URL Formats Some Annke models (especially non-Hikvision OEM variants) use different URL patterns: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/Streaming/Channels/101` | Hikvision-style (most models) | | `rtsp://IP:554/h264/ch1/main/av_stream` | Older Hikvision firmware | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua-style (some older models) | ## Connecting with VisioForge SDK Use your Annke camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Annke C800 (4K bullet), main stream var uri = new Uri("rtsp://192.168.1.90:554/Streaming/Channels/101"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/Streaming/Channels/102` instead. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/ISAPI/Streaming/channels/101/picture` | Requires digest auth | | MJPEG Stream | `http://IP/ISAPI/Streaming/channels/102/httpPreview` | Sub stream as MJPEG | | Legacy Snapshot | `http://IP/Streaming/channels/1/picture` | Older firmware | ## Troubleshooting ### Camera requires activation Annke cameras with newer firmware require initial activation (password setup) before RTSP access works. Use the camera's web interface at `http://CAMERA_IP` or Annke's SADP-compatible discovery tool. ### Hikvision URL format not working Some Annke models use different OEM firmware. If `/Streaming/Channels/101` does not work, try: 1. `/h264/ch1/main/av_stream` (older Hikvision firmware) 2. `/cam/realmonitor?channel=1&subtype=0` (Dahua-style) 3. Use ONVIF discovery to automatically retrieve the correct stream URL ### H.265 stream issues Annke 4K cameras (C800, I91BN) default to H.265 encoding. If playback fails, switch the camera to H.264 in the web interface or install the HEVC decoder redistributable. ## FAQ **What is the default RTSP URL for Annke cameras?** Most Annke cameras use `rtsp://admin:password@CAMERA_IP:554/Streaming/Channels/101` for the main stream. Use channel `102` for the sub stream. This is the same format as Hikvision cameras. **Are Annke cameras Hikvision OEMs?** Most Annke cameras use Hikvision OEM hardware and firmware. The RTSP URL format, web interface, and API are typically identical to Hikvision. Some Annke models may use different OEM bases. **Do Annke cameras support ONVIF?** Yes. All current Annke cameras support ONVIF Profile S, providing standardized discovery and stream access. **Can I mix Annke cameras with Hikvision NVRs?** Yes. Since Annke cameras use Hikvision-compatible protocols, they work natively with Hikvision NVRs and vice versa. You can also mix Annke cameras into any ONVIF-compatible NVR or VMS. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Hikvision Connection Guide](../hikvision/) — Same URL format (OEM base) - [LTS Connection Guide](../lts/) — Another Hikvision OEM - [Dahua Connection Guide](../dahua/) — Alternative OEM ecosystem - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Connect Aqara Camera in C# .NET — Token-Based RTSP Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/aqara/ **Description:** Connect Aqara cameras in C# / .NET via RTSP. Token-based URLs for G2H, G3, E1, and G4 Doorbell. Aqara Home app setup and code samples included. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, C# **API:** RTSPSourceSettings # How to Connect to Aqara Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Aqara** is a Chinese smart home brand (by Lumi United Technology) that produces Zigbee/Thread-based smart home devices and cameras. Aqara cameras are unique in the market because they double as smart home hubs (Zigbee gateway) while also functioning as security cameras. Aqara primarily integrates with Apple HomeKit and supports RTSP for local streaming. **Key facts:** - **Product lines:** Camera Hub G2H/G3 (hub + camera), E1 (camera-only), G4 (doorbell) - **Protocol support:** RTSP, Apple HomeKit Secure Video, Zigbee 3.0 (hub function) - **Default RTSP port:** 554 - **Default credentials:** None — RTSP URL includes token - **ONVIF support:** No - **Video codecs:** H.264 - **Unique feature:** Cameras serve as Zigbee smart home hubs RTSP Must Be Enabled in Aqara Home App Aqara cameras have RTSP support but it must be enabled through the **Aqara Home** app. The app generates a unique RTSP URL with an authentication token. RTSP access works independently of HomeKit Secure Video. ## Enabling RTSP on Aqara Cameras 1. Open the **Aqara Home** app on your phone 2. Select your camera device 3. Go to **Camera Settings** (gear icon) 4. Find **RTSP** or **Network streaming** 5. Enable RTSP 6. The app will display the full RTSP URL with authentication token 7. Copy this URL for use in your application ## RTSP URL Patterns ### Standard URL Format Aqara cameras use a token-based RTSP URL: ``` rtsp://[IP]:554/live/ch00_1?token=[AUTH_TOKEN] ``` The authentication token is generated by the Aqara Home app and is unique per camera. ### Camera Models | Model | Type | RTSP Support | Resolution | Hub Function | | --- | --- | --- | --- | --- | | Camera Hub G2H Pro | Hub + camera | Yes | 1920x1080 | Zigbee 3.0 | | Camera Hub G3 | Hub + camera | Yes | 2304x1296 (2K) | Zigbee 3.0 | | Camera E1 | Camera only | Yes | 1920x1080 | No | | G4 Video Doorbell | Doorbell | Limited | 1600x1200 | No | ### URL Variations | URL Pattern | Description | | --- | --- | | `rtsp://IP:554/live/ch00_1?token=TOKEN` | Main stream (recommended) | | `rtsp://IP:554/live/ch00_0?token=TOKEN` | Sub stream (lower resolution) | ## Connecting with VisioForge SDK Use your Aqara camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Aqara Camera Hub G3, main stream (token from Aqara Home app) var uri = new Uri("rtsp://192.168.1.90:554/live/ch00_1?token=YOUR_TOKEN_HERE"); var username = ""; // auth is in the token var password = ""; ``` Token-Based Authentication Aqara cameras do not use username/password authentication for RTSP. Instead, the authentication token is embedded in the URL. Leave the username and password fields empty in `RTSPSourceSettings.CreateAsync()` and include the token in the URI. ## Troubleshooting ### RTSP URL not working 1. Verify RTSP is enabled in the Aqara Home app 2. Check that the token in the URL matches what the app displays 3. Ensure the camera and your application are on the same network 4. Try regenerating the RTSP URL in the app (Settings > RTSP > regenerate) ### Token expires or changes The RTSP token may change after: - Camera firmware updates - Aqara Home app re-pairing - Disabling and re-enabling RTSP If your stream stops working, check the Aqara Home app for an updated URL. ### No ONVIF support Aqara cameras do not support ONVIF. You cannot use ONVIF discovery to find Aqara cameras. The RTSP URL must be obtained from the Aqara Home app. ### Limited to H.264 Aqara cameras encode in H.264 only. There is no H.265 option. This ensures broad compatibility but uses more bandwidth than H.265 at equivalent quality. ## FAQ **What is the default RTSP URL for Aqara cameras?** Aqara cameras use `rtsp://CAMERA_IP:554/live/ch00_1?token=AUTH_TOKEN` where the token is generated by the Aqara Home app. There are no default credentials -- authentication is handled via the URL token. **Can I use Aqara cameras with HomeKit and RTSP simultaneously?** Yes. HomeKit Secure Video and RTSP can run at the same time. Enabling RTSP does not disable HomeKit functionality. However, running both streams may slightly reduce camera performance. **Do Aqara cameras work as Zigbee hubs while streaming RTSP?** Yes. The Camera Hub G2H and G3 models serve as both Zigbee 3.0 gateways and cameras simultaneously. Enabling RTSP does not affect the hub functionality. **Do Aqara cameras support ONVIF?** No. Aqara cameras only support RTSP (with token auth) and HomeKit Secure Video. ONVIF discovery is not available. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [EZVIZ Connection Guide](../ezviz/) — Another smart home camera brand - [TP-Link Connection Guide](../tp-link/) — Consumer cameras with RTSP - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Arecont Vision IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/arecont/ **Description:** Arecont Vision RTSP URL patterns for C# .NET. Integrate AV Series, MegaDome, and SurroundVideo panoramic cameras using VisioForge Video Capture SDK. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Arecont Vision IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Arecont Vision** (now part of Costar Group) is an American IP camera company originally founded in 2003 and based in Glendale, California. Arecont Vision was a pioneer of megapixel IP cameras and is known for high-resolution models (up to 20MP) and multi-sensor panoramic cameras. The company was acquired by **Costar Group** in 2019, which continues to support and manufacture Arecont Vision products. **Key facts:** - **Product lines:** AV Series (megapixel fixed), MegaDome, MegaBall, SurroundVideo (multi-sensor panoramic), MicroDome - **Protocol support:** RTSP, ONVIF (newer models), PSIA, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** Varies by model (many ship with no default password) - **ONVIF support:** Yes (newer models), PSIA support on most models - **Video codecs:** H.264, MJPEG (older models MJPEG only) Arecont Vision and Costar Group Arecont Vision was acquired by Costar Group in 2019. Existing Arecont cameras continue to use the same RTSP and PSIA URL formats. Newer Costar-branded models may use updated firmware but maintain backward-compatible URL patterns. ## RTSP URL Patterns ### Standard URL Formats Arecont Vision cameras support multiple RTSP URL patterns depending on the model generation and configured protocol: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/h264.sdp ``` | URL Pattern | Protocol | Description | | --- | --- | --- | | `rtsp://IP:554/h264.sdp` | H.264 | Standard H.264 stream (most current models) | | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | PSIA | PSIA-based H.264 stream | | `rtsp://IP:554/cam1/mpeg4` | MPEG-4 | Legacy MPEG-4 stream (older models) | ### H.264 Stream with ROI Parameters Arecont cameras support optional Region of Interest (ROI) parameters for customizing the stream output: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/h264.sdp?res=half&x0=0&y0=0&x1=1600&y1=1200&quality=15&doublescan=0 ``` | Parameter | Values | Description | | --- | --- | --- | | `res` | `full`, `half` | Stream resolution (full or half of sensor resolution) | | `x0`, `y0` | 0 - max | Top-left corner of the region of interest | | `x1`, `y1` | 0 - max | Bottom-right corner of the region of interest | | `quality` | 1 - 21 | JPEG/H.264 quality factor (lower = higher quality) | | `doublescan` | 0, 1 | Enable double-scan mode for improved image quality | ROI Parameters Are Optional The ROI parameters (`res`, `x0`, `y0`, `x1`, `y1`, `quality`, `doublescan`) are optional and can be omitted entirely for full-frame streaming. Use `rtsp://IP:554/h264.sdp` without parameters for the simplest connection. ### Camera Models | Model Series | Resolution | Main Stream URL | Codec | | --- | --- | --- | --- | | AV Series (generic megapixel) | Varies | `rtsp://IP:554/h264.sdp` | H.264 | | AV2100 (2MP) | 1600x1200 | `rtsp://IP:554/cam1/mpeg4` | MPEG-4 | | AV5115/AV5125 | 2592x1944 | `rtsp://IP:554/h264.sdp` | H.264 | | AV8185DN (8MP multi-sensor) | 6400x1200 | `rtsp://IP:554/h264.sdp` | H.264 | | AV10005/AV10115 (10MP) | 3648x2752 | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | H.264 | | AV20185 (20MP multi-sensor) | 10240x1536 | `rtsp://IP:554/h264.sdp` | H.264 | | MegaDome Series | Varies | `rtsp://IP:554/h264.sdp` | H.264 | | MegaBall Series | Varies | `rtsp://IP:554/h264.sdp` | H.264 | | MicroDome Series | Varies | `rtsp://IP:554/h264.sdp` | H.264 | ### PSIA Streaming URLs Models that support the PSIA protocol can use the following URL format: | Channel | URL | | --- | --- | | Channel 0 (default) | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | | Channel 1 | `rtsp://IP:554/PSIA/Streaming/channels/1?videoCodecType=H.264` | ## Connecting with VisioForge SDK Use your Arecont Vision camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Arecont Vision AV Series, H.264 main stream var uri = new Uri("rtsp://192.168.1.90:554/h264.sdp"); var username = "admin"; var password = "YourPassword"; ``` For PSIA-based streaming, use the PSIA URL instead: ``` // Arecont Vision via PSIA protocol var uri = new Uri("rtsp://192.168.1.90:554/PSIA/Streaming/channels/0?videoCodecType=H.264"); ``` ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/img.jpg` | Most models, requires basic auth | | JPEG Snapshot (alt) | `http://IP/Jpeg/CamImg.jpg` | Alternative snapshot URL | | Configurable Snapshot | `http://IP/image?res=half&x0=0&y0=0&x1=1600&y1=1200&quality=15&doublescan=0` | Snapshot with ROI parameters | | MJPEG Stream | `http://IP/mjpeg?res=full&x0=0&y0=0&x1=100%&y1=100%&quality=12&doublescan=0` | Continuous MJPEG stream | ### Multi-Sensor (SurroundVideo) Snapshot URLs For SurroundVideo and other multi-sensor cameras, each sensor has its own snapshot URL: | Sensor | URL Pattern | Notes | | --- | --- | --- | | Channel 1 | `http://IP/image1?res=half&x1=0&y1=0` | First sensor | | Channel 2 | `http://IP/image2?res=half&x1=0&y1=0` | Second sensor | | Channel 3 | `http://IP/image3?res=half&x1=0&y1=0` | Third sensor | | Channel 4 | `http://IP/image4?res=half&x1=0&y1=0` | Fourth sensor | ## Troubleshooting ### ROI parameters causing issues Arecont cameras have unique Region of Interest parameters (`res`, `x0`, `y0`, `x1`, `y1`, `quality`, `doublescan`) embedded in their URLs. If you encounter connection problems: 1. Remove all ROI parameters and use the bare URL: `rtsp://IP:554/h264.sdp` 2. Verify the camera resolution supports the requested ROI coordinates 3. Use `res=full` for full-resolution streaming or `res=half` for reduced bandwidth ### MJPEG-only on older models Some older Arecont models (AV1300, AV2100, AV3100) only support MJPEG encoding and do not have H.264 capability. For these cameras: - Use the MPEG-4 RTSP URL: `rtsp://IP:554/cam1/mpeg4` - Or use the HTTP MJPEG stream: `http://IP/mjpeg` ### PSIA vs direct RTSP Arecont cameras support both direct RTSP and PSIA-based RTSP URLs. If one format does not work: - Try the alternative format (switch between `h264.sdp` and `PSIA/Streaming/channels/0`) - Verify the camera firmware version supports the chosen protocol - Check that PSIA is enabled in the camera's web interface ### Connection timeout Arecont cameras may take longer to establish an RTSP session than other brands, especially for high-resolution (10MP+) models: - Increase your connection timeout to at least 10 seconds - For multi-sensor models, connect to individual channels rather than the composite stream for lower latency ## FAQ **What RTSP URL format does Arecont Vision use?** The primary RTSP URL is `rtsp://IP:554/h264.sdp` for H.264 streaming. PSIA-based streaming uses `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264`. Older models may use `rtsp://IP:554/cam1/mpeg4` for MPEG-4 streams. **Are Arecont Vision cameras still supported after the Costar acquisition?** Yes. Costar Group acquired Arecont Vision in 2019 and continues to manufacture and support Arecont Vision camera products. Existing cameras remain fully functional, and firmware updates are available through Costar's support channels. **How do I connect to a multi-sensor SurroundVideo camera?** SurroundVideo cameras expose individual sensor channels through numbered URLs. For snapshots, use `http://IP/image1`, `http://IP/image2`, etc. For RTSP, use the standard H.264 URL with the full panoramic composite, or PSIA channel-based URLs for individual sensors. **Do Arecont Vision cameras support ONVIF?** Newer Arecont Vision models support ONVIF Profile S. Older models rely on the PSIA protocol instead. Check your camera's specifications or web interface to confirm ONVIF availability. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [GeoVision Connection Guide](../geovision/) — Professional surveillance cameras - [ONVIF Capture with Postprocessing](../../mediablocks/Guides/onvif-capture-with-postprocessing/) — Arecont ONVIF capture pipeline - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Arlo Camera in C# .NET - RTSP Workarounds **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/arlo/ **Description:** Arlo camera RTSP limitations in C# .NET. No native RTSP support. Workaround options and alternative camera recommendations for developers. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Webcam, IP Camera, RTSP, ONVIF, C# **API:** MediaBlocksPipeline, SystemVideoSourceBlock, VideoRendererBlock # How to Connect to Arlo Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Arlo Technologies** is an American smart home security company headquartered in Carlsbad, California. Originally a Netgear brand, Arlo became independent in 2018. Arlo is one of the best-selling wireless security camera brands in North America and Europe, known for battery-powered outdoor cameras, doorbells, and floodlight cameras. **Key facts:** - **Product lines:** Pro (flagship), Ultra (4K), Essential (value), Go (cellular), Floodlight, Doorbell - **Architecture:** Cloud-first with optional local storage (Arlo SmartHub/Base Station) - **RTSP support:** No (removed from SmartHub in 2021) - **ONVIF support:** No - **Video codecs:** H.264, H.265 (select models) - **Cloud dependency:** High — all features require Arlo Secure subscription - **Power:** Battery, solar, or wired depending on model No RTSP Support Arlo cameras do **not** support RTSP. Arlo previously offered RTSP access through the SmartHub (VMB4540/VMB5000) for select camera models, but this feature was **removed** in a 2021 firmware update. There is currently no way to access Arlo camera streams via RTSP. ## RTSP History on Arlo Arlo had a brief period of RTSP support: | Period | Status | Details | | --- | --- | --- | | Before 2019 | No RTSP | Cloud-only access | | 2019-2021 | RTSP available (beta) | Via SmartHub for Ultra/Pro 3/Pro 4 only | | 2021-present | RTSP removed | Firmware update removed RTSP functionality | The RTSP feature was available on the **Arlo SmartHub (VMB5000)** for: - Arlo Ultra (VMC5040) - Arlo Pro 3 (VMC4040P) - Arlo Pro 4 (VMC4050P) It was never available for Arlo Essential, Go, or Doorbell models. ## Why No Direct Integration Arlo's architecture prevents direct SDK integration: 1. **Cloud-mandatory streaming:** All video routes through Arlo's cloud servers 2. **No local network access:** Cameras communicate with the SmartHub/base station using proprietary protocols 3. **No open ports:** Neither cameras nor base stations expose RTSP or HTTP video endpoints 4. **Subscription dependency:** Video access requires an active Arlo Secure plan ## Possible Workarounds ### Option 1: Arlo API (Unofficial) Community-developed libraries exist that interface with Arlo's cloud API to: - Retrieve snapshot images - Download recorded clips - Trigger camera actions These are unofficial and may break with Arlo service updates. They do not provide real-time RTSP streams. ### Option 2: HDMI Output from SmartHub The Arlo SmartHub (VMB5000) has an HDMI output that displays a live camera grid. You can capture this with an HDMI capture card: ``` // Capture HDMI output from Arlo SmartHub via USB capture card var pipeline = new MediaBlocksPipeline(); var captureDevice = new SystemVideoSourceBlock(captureDeviceSettings); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(captureDevice.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` This provides a composite view of all cameras, not individual streams. ## Recommended Alternatives For developers needing direct RTSP camera integration, these consumer cameras provide native RTSP support: | Alternative | Type | RTSP | Battery Option | Guide | | --- | --- | --- | --- | --- | | Reolink Argus 3 | Battery outdoor | Yes | Yes | [Connection Guide](../reolink/) | | Amcrest | Wired outdoor | Yes | No | [Connection Guide](../amcrest/) | | EZVIZ | Indoor/outdoor | Yes (enable required) | Limited | [Connection Guide](../ezviz/) | | TP-Link Tapo | Indoor/outdoor | Yes | No | [Connection Guide](../tp-link/) | | Eufy Security | Wired/battery | Yes (some models) | Yes | [Connection Guide](../eufy/) | ## FAQ **Do Arlo cameras support RTSP?** No. Arlo cameras do not currently support RTSP. A brief RTSP beta was available on the SmartHub (2019-2021) for select models, but it was removed in a firmware update. There is no current way to access Arlo streams via RTSP. **Can I use VisioForge SDK with Arlo cameras?** Not directly. Arlo cameras have no RTSP, ONVIF, or local streaming endpoints. The only integration option is capturing the HDMI output from the SmartHub using a capture card. For direct SDK integration, use cameras with native RTSP support. **Will Arlo bring back RTSP?** There has been no official announcement from Arlo about restoring RTSP support. Arlo's business model is subscription-based, and local streaming conflicts with this approach. **What battery cameras support RTSP?** For battery-powered cameras with RTSP support, consider [Reolink](../reolink/) (Argus series) or [Eufy Security](../eufy/) (select models). Most battery cameras from other brands are also cloud-only. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Reolink Connection Guide](../reolink/) — Consumer alternative with RTSP - [Eufy Security Connection Guide](../eufy/) — Consumer with partial RTSP - [Wyze Connection Guide](../wyze/) — Another cloud-first brand with limited RTSP - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Avigilon IP Camera RTSP URL Patterns and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/avigilon/ **Description:** Avigilon H5A, H5M, H5 Pro, H5SL, and Unity NVR RTSP URL patterns for C# .NET. Enterprise camera integration with VisioForge SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to Avigilon IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Avigilon** (Avigilon Corporation) is an enterprise security camera manufacturer originally based in Vancouver, Canada. Founded in 2004, Avigilon was acquired by **Motorola Solutions** in 2018 for approximately $1 billion. The company is known for high-resolution cameras (up to 61MP), AI-powered video analytics including Unusual Motion Detection (UMD) and Appearance Search, and proprietary HDSM (High Definition Stream Management) technology. Avigilon cameras are widely deployed in enterprise, government, and critical infrastructure environments. **Key facts:** - **Product lines:** H5A (bullet/dome), H5M (mini dome), H5 Pro (multi-sensor), H5SL (value line), Unity (NVRs) - **Previous lines:** HD Pro, HD Multisensor, HD Micro Dome, HD PTZ - **Protocol support:** RTSP, ONVIF (Profile S, Profile T), HTTP - **Default RTSP port:** 554 - **Default credentials:** admin / admin (must be changed on initial setup) - **ONVIF support:** Yes (Profile S, Profile T) - **Video codecs:** H.264, H.265, HDSM SmartCodec (H.265-based) - **Known for:** AI analytics (Unusual Motion Detection, Appearance Search), HDSM SmartCodec Avigilon is now part of Motorola Solutions Avigilon is now part of Motorola Solutions. The Avigilon camera line continues under the Motorola Solutions Video Security & Access Control division. See also our [Pelco guide](../pelco/) for another Motorola Solutions camera brand. ## RTSP URL Patterns ### Standard URL Format Avigilon cameras use the `defaultPrimary` / `defaultSecondary` URL pattern with a unicast stream type parameter: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/defaultPrimary?streamType=u ``` | Parameter | Value | Description | | --- | --- | --- | | `defaultPrimary` | Primary stream | Main stream (highest resolution) | | `defaultSecondary` | Secondary stream | Sub stream (lower resolution, less bandwidth) | | `streamType` | `u` | Unicast stream delivery | ### Camera Models | Model Series | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | H5A Bullet | Fixed bullet | `rtsp://IP:554/defaultPrimary?streamType=u` | AI-enabled, up to 8MP | | H5A Dome | Fixed dome | `rtsp://IP:554/defaultPrimary?streamType=u` | AI-enabled, up to 8MP | | H5M Mini Dome | Mini dome | `rtsp://IP:554/defaultPrimary?streamType=u` | Compact form factor | | H5 Pro Multi-sensor | Multi-sensor | `rtsp://IP:554/defaultPrimary0?streamType=u` | See multi-sensor note below | | H5SL Bullet | Value bullet | `rtsp://IP:554/defaultPrimary?streamType=u` | Cost-effective line | | H5SL Dome | Value dome | `rtsp://IP:554/defaultPrimary?streamType=u` | Cost-effective line | | HD Pro | Legacy high-res | `rtsp://IP:554/defaultPrimary?streamType=u` | Up to 61MP | ### Multi-Sensor Camera URLs For Avigilon H5 Pro and other multi-sensor cameras, each sensor head has its own stream index: | Sensor | Main Stream | Sub Stream | | --- | --- | --- | | Sensor 1 | `rtsp://IP:554/defaultPrimary0?streamType=u` | `rtsp://IP:554/defaultSecondary0?streamType=u` | | Sensor 2 | `rtsp://IP:554/defaultPrimary1?streamType=u` | `rtsp://IP:554/defaultSecondary1?streamType=u` | | Sensor 3 | `rtsp://IP:554/defaultPrimary2?streamType=u` | `rtsp://IP:554/defaultSecondary2?streamType=u` | | Sensor 4 | `rtsp://IP:554/defaultPrimary3?streamType=u` | `rtsp://IP:554/defaultSecondary3?streamType=u` | ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/defaultPrimary?streamType=u` | Standard primary (recommended) | | `rtsp://IP:554/defaultSecondary?streamType=u` | Secondary / sub stream | | `rtsp://IP:554/defaultPrimary0?streamType=u` | Primary stream alternate (also used for multi-sensor sensor 1) | ## Connecting with VisioForge SDK Use your Avigilon camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Avigilon H5A dome, primary stream (unicast) var uri = new Uri("rtsp://192.168.1.100:554/defaultPrimary?streamType=u"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `defaultSecondary` instead of `defaultPrimary`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/snapshot.jpg` | Requires basic auth | ## Troubleshooting ### "401 Unauthorized" error Avigilon cameras require the default password to be changed during initial setup. If you have not configured the camera yet: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Complete the initial setup wizard and set a strong password 3. Use those credentials in your RTSP URL ### HDSM SmartCodec streams Avigilon's HDSM SmartCodec is based on H.265. Ensure your decoder supports H.265 when connecting to cameras configured to use HDSM SmartCodec. If you experience decoding issues, try switching the camera to standard H.264 encoding in the camera's web interface. ### Stream type parameter The `streamType=u` parameter requests unicast delivery. If you omit this parameter, the camera may default to multicast, which can cause issues on networks not configured for multicast routing. ### Multi-sensor cameras show only one view For multi-sensor models (H5 Pro), each sensor is accessed as a separate stream. Use `defaultPrimary0`, `defaultPrimary1`, etc. to access individual sensor heads. See the multi-sensor URL table above. ## FAQ **What is the default RTSP URL for Avigilon cameras?** The URL is `rtsp://admin:password@CAMERA_IP:554/defaultPrimary?streamType=u` for the primary stream. Use `defaultSecondary` instead of `defaultPrimary` for the lower-resolution sub stream. **Do Avigilon cameras support ONVIF?** Yes. Avigilon cameras support ONVIF Profile S and Profile T. ONVIF can be enabled through the camera's web interface or Avigilon Control Center (ACC) software. **What is HDSM SmartCodec?** HDSM (High Definition Stream Management) SmartCodec is Avigilon's proprietary compression technology built on H.265. It reduces bandwidth and storage requirements by intelligently encoding different regions of the image at different quality levels while maintaining detail in areas of interest. Streams encoded with HDSM SmartCodec are compatible with standard H.265 decoders. **Can I use Avigilon cameras without Avigilon Control Center?** Yes. While Avigilon Control Center (ACC) is the recommended VMS, the cameras expose standard RTSP streams and support ONVIF, allowing integration with any RTSP-compatible application including VisioForge SDKs. **How do I access individual sensors on multi-sensor cameras?** Each sensor head on a multi-sensor camera (such as the H5 Pro) has its own stream URL. Use `defaultPrimary0` for sensor 1, `defaultPrimary1` for sensor 2, and so on. Each sensor can also have a secondary stream accessed via `defaultSecondary0`, `defaultSecondary1`, etc. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Pelco Connection Guide](../pelco/) — Also Motorola Solutions, enterprise cameras - [ONVIF Capture with Postprocessing](../../mediablocks/Guides/onvif-capture-with-postprocessing/) — Avigilon ONVIF capture pipeline - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## AVTech IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/avtech/ **Description:** AVTech IP camera integration guide for C# .NET with RTSP URL patterns, DVR/NVR channel URLs, and code samples for AVM, AVN, AVC, and AVI models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, AVI, H.264, MJPEG, C# # How to Connect to AVTech IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **AVTech** (AVTech Corporation) is a Taiwanese surveillance equipment manufacturer based in Taipei, Taiwan, founded in 1996. AVTech is one of the largest DVR/NVR manufacturers globally, with a strong presence in Asia-Pacific, Middle East, and Latin American markets. The company produces a wide range of IP cameras, DVRs, NVRs, and the EagleEyes mobile viewing platform. AVTech is known for offering cost-effective surveillance solutions with broad model compatibility. **Key facts:** - **Product lines:** AVM (IP cameras), AVN (network cameras), AVC (DVRs), AVI (specialty cameras), EagleEyes (mobile app) - **Protocol support:** RTSP, ONVIF (newer models), HTTP/CGI, MJPEG - **Default RTSP port:** 554 (some models use port 88) - **Default credentials:** admin / admin - **ONVIF support:** Yes (newer models) - **Video codecs:** H.264, MPEG-4, MJPEG - **Guest access:** Many models allow unauthenticated JPEG snapshots via guest CGI Some AVTech models use port 88 Some newer AVTech models use port 88 instead of 554 for RTSP. If port 554 doesn't work, try port 88 with the URL pattern `rtsp://IP:88//live/h264_ulaw/VGA`. Guest access security Many AVTech cameras expose a guest CGI endpoint (`/cgi-bin/guest/Video.cgi`) that allows unauthenticated snapshot access. Ensure your camera's guest access settings are configured securely. ## RTSP URL Patterns ### Standard URL Format AVTech cameras use the `/live/` path-based URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/live/h264 ``` | Parameter | Value | Description | | --- | --- | --- | | `/live/h264` | H.264 stream | Main H.264 video stream | | `/live/mpeg4` | MPEG-4 stream | Legacy MPEG-4 video stream | | `/live/h264/ch[N]` | Channel N | Channel-specific stream for DVRs/NVRs | ### Camera Models | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | AVM217 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM328 | IP dome | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM357 | IP dome | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM457 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM459 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM552 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM561 | IP dome | `rtsp://IP:554/live/h264` | H.264 main stream | | AVM571 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN211 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN252 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN257 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN304 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN314 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN362 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN801 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN812 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVN813 | Network camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVI201 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | | AVI203 | IP camera | `rtsp://IP:554/live/h264` | H.264 main stream | ### DVR/NVR Channel URLs For AVTech DVRs and NVRs (AVC series and others): | Channel | Main Stream (H.264) | Main Stream (MPEG-4) | | --- | --- | --- | | Channel 1 | `rtsp://IP:554/live/h264/ch1` | `rtsp://IP:554/live/mpeg4/ch1` | | Channel 2 | `rtsp://IP:554/live/h264/ch2` | `rtsp://IP:554/live/mpeg4/ch2` | | Channel 3 | `rtsp://IP:554/live/h264/ch3` | `rtsp://IP:554/live/mpeg4/ch3` | | Channel N | `rtsp://IP:554/live/h264/chN` | `rtsp://IP:554/live/mpeg4/chN` | ### Alternative URL Formats Some AVTech models, particularly newer ones, use port 88 and different path formats: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/live/h264` | Standard H.264 (recommended) | | `rtsp://IP:554/live/mpeg4` | MPEG-4 stream | | `rtsp://IP//live/h264` | Without explicit port (some models) | | `rtsp://IP:88//live/h264_ulaw/VGA` | Port 88, with audio, VGA resolution | | `rtsp://IP:88//live/video_audio/profile1` | Port 88 with profile selection | ## Connecting with VisioForge SDK Use your AVTech camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // AVTech AVM552, H.264 main stream var uri = new Uri("rtsp://192.168.1.80:554/live/h264"); var username = "admin"; var password = "YourPassword"; ``` For MPEG-4 stream access, use `/live/mpeg4` instead of `/live/h264`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot (guest) | `http://IP/cgi-bin/guest/Video.cgi?media=JPEG` | No authentication required (if guest access enabled) | | JPEG Snapshot (channel) | `http://IP/cgi-bin/guest/Video.cgi?media=JPEG&channel=CHANNEL` | Channel-specific snapshot | | MJPEG Live Stream | `http://IP/live/mjpeg` | Continuous MJPEG stream | ## Troubleshooting ### "401 Unauthorized" error If you receive an authentication error: 1. Verify your credentials - default is admin / admin 2. Access the camera at `http://CAMERA_IP` in a browser to confirm login works 3. Ensure RTSP is enabled in the camera's network settings 4. Try including credentials in the URL: `rtsp://admin:password@IP:554/live/h264` ### Port 554 vs port 88 Some newer AVTech models use port 88 instead of the standard RTSP port 554. If you cannot connect on port 554: 1. Try port 88: `rtsp://IP:88//live/h264_ulaw/VGA` 2. Note the double slash (`//`) in some port 88 URL patterns 3. Check the camera's web interface under network settings for the configured RTSP port ### MPEG-4 vs H.264 Older AVTech models may only support MPEG-4. If the H.264 stream URL does not work: - Try `rtsp://IP:554/live/mpeg4` instead - Check the camera's encoding settings in the web interface - Newer models support H.264; older models may be MPEG-4 only ### Double slash in URL Some AVTech URL patterns include a double slash (`//`) after the IP or port. This is intentional and required by certain firmware versions. If a single-slash URL does not work, try the double-slash variant. ### EagleEyes mobile app The EagleEyes app is AVTech's mobile viewing platform. RTSP access works independently of EagleEyes and does not require the app to be configured. ## FAQ **What is the default RTSP URL for AVTech cameras?** The URL is `rtsp://admin:password@CAMERA_IP:554/live/h264` for the main H.264 stream. For DVRs/NVRs, append the channel number: `rtsp://IP:554/live/h264/ch1` for channel 1. **Do AVTech cameras support ONVIF?** Newer AVTech models support ONVIF. Older models may not have ONVIF support and rely on proprietary protocols and RTSP for integration. **What is the difference between AVM and AVN series?** The AVM series are IP cameras designed for direct network connection, while the AVN series are network cameras that may include additional features such as built-in Wi-Fi or audio. Both series use the same RTSP URL format. **Can I access AVTech snapshots without authentication?** Many AVTech cameras have a guest CGI endpoint (`/cgi-bin/guest/Video.cgi?media=JPEG`) that allows unauthenticated JPEG snapshot access. This is a security concern if your camera is network-accessible. Check your camera's guest access settings and disable guest access if not needed. **Why do some AVTech URLs use port 88?** Some newer AVTech firmware versions default to port 88 for RTSP instead of the standard port 554. If you cannot connect on port 554, try port 88. The port setting can typically be verified and changed in the camera's web interface under network configuration. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [LILIN Connection Guide](../lilin/) — Taiwanese industrial cameras - [BrickCom Connection Guide](../brickcom/) — Taiwanese industrial cameras - [ONVIF IP Camera Integration](../../videocapture/video-sources/ip-cameras/onvif/) — AVTech ONVIF device discovery - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Axis IP Camera RTSP URL Format and C# .NET Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/axis/ **Description:** Connect to Axis Communications cameras in C# .NET with RTSP URL patterns, VAPIX API, and code samples for M, P, Q, and F series models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Axis IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Axis Communications** is a Swedish manufacturer widely regarded as the pioneer of network cameras, having created the world's first IP camera in 1996. Headquartered in Lund, Sweden and now a subsidiary of Canon, Axis produces premium IP cameras, encoders, and network audio products primarily for the professional and enterprise surveillance market. **Key facts:** - **Product lines:** M-series (compact/mini), P-series (fixed), Q-series (professional), F-series (modular), V-series (vandal-resistant), PTZ cameras - **Protocol support:** ONVIF Profile S/G/T, RTSP, VAPIX (Axis proprietary HTTP API), HTTP/MJPEG - **Default RTSP port:** 554 - **Default credentials:** root / (set during initial setup; older firmware: root / pass) - **ONVIF support:** Full -- Axis was a founding member of ONVIF - **Video codecs:** H.264, H.265 (newer models), MJPEG - **Unique features:** VAPIX HTTP API for comprehensive camera control, ACAP (Axis Camera Application Platform) ## RTSP URL Patterns Axis cameras use the `axis-media/media.amp` RTSP path with optional parameters for resolution and codec control. ### URL Format ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:[PORT]/axis-media/media.amp ``` ### Primary RTSP URLs | Model Series | RTSP URL | Codec | Audio | | --- | --- | --- | --- | | All modern models | `rtsp://IP:554/axis-media/media.amp` | H.264 (default) | Possible | | All modern models | `rtsp://IP:554/axis-media/media.amp?videocodec=h264` | H.264 (explicit) | Possible | | All modern models | `rtsp://IP:554/axis-media/media.amp?videocodec=h265` | H.265 | Possible | | ONVIF profile | `rtsp://IP:554/onvif-media/media.amp` | H.264 | Yes | | Legacy models | `rtsp://IP:554/mpeg4/media.amp` | MPEG-4 | Possible | ### Stream Profile Selection Axis cameras support named stream profiles that can be selected via URL parameter: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/axis-media/media.amp?streamprofile=Quality` | High quality profile | | `rtsp://IP:554/axis-media/media.amp?streamprofile=Balanced` | Balanced profile | | `rtsp://IP:554/axis-media/media.amp?streamprofile=Bandwidth` | Low bandwidth profile | | `rtsp://IP:554/axis-media/media.amp?resolution=1920x1080` | Explicit resolution | | `rtsp://IP:554/axis-media/media.amp?resolution=640x480` | Lower resolution | | `rtsp://IP:554/axis-media/media.amp?fps=15` | Frame rate limit | ### Multi-Channel Models (Encoders, Multi-Sensor) For multi-channel devices like video encoders (M7001, P7214) and multi-sensor cameras: | Device | RTSP URL | Channel | | --- | --- | --- | | Channel 1 | `rtsp://IP:554/axis-media/media.amp?camera=1` | 1 | | Channel 2 | `rtsp://IP:554/axis-media/media.amp?camera=2` | 2 | | Channel 3 | `rtsp://IP:554/axis-media/media.amp?camera=3` | 3 | | Channel 4 | `rtsp://IP:554/axis-media/media.amp?camera=4` | 4 | ### Legacy URL Formats Older Axis cameras (200-series, early 1000-series) may require these formats: | URL Pattern | Models | Notes | | --- | --- | --- | | `rtsp://IP:554/mpeg4/media.amp` | 200, 205, 206, 207 | MPEG-4 stream | | `http://IP/axis-cgi/mjpg/video.cgi` | All models | MJPEG over HTTP | | `http://IP/mjpg/video.mjpg` | 200-series | Direct MJPEG stream | | `http://IP/axis-cgi/mjpg/video.cgi?camera=1` | Multi-channel | Specific channel | | `http://IP/axis-cgi/mjpg/video.cgi?resolution=640x480` | All models | Resolution-specific | ## Connecting with VisioForge SDK Use your Axis camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Axis camera, H.264 main stream var uri = new Uri("rtsp://192.168.1.50:554/axis-media/media.amp"); var username = "root"; var password = "YourPassword"; ``` For sub-stream access, add `?resolution=640x480` parameter. ### ONVIF Discovery Axis was a founding member of ONVIF and has industry-leading ONVIF compliance. See the [ONVIF integration guide](../../mediablocks/Sources/) for discovery code examples. ## Snapshot and MJPEG URLs (VAPIX API) Axis cameras provide the VAPIX HTTP API, which is more feature-rich than most other brands: | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/axis-cgi/jpg/image.cgi` | Current frame | | Snapshot (sized) | `http://IP/axis-cgi/jpg/image.cgi?resolution=1920x1080` | Specific resolution | | Snapshot (with overlay) | `http://IP/axis-cgi/jpg/image.cgi?date=1&clock=1` | Date/time overlay | | Snapshot (camera select) | `http://IP/axis-cgi/jpg/image.cgi?camera=1` | Multi-channel device | | Simple snapshot | `http://IP/jpg/image.jpg` | Basic JPEG capture | | Sized snapshot | `http://IP/jpg/image.jpg?size=3` | Predefined size (1-5) | | MJPEG stream | `http://IP/axis-cgi/mjpg/video.cgi` | Continuous MJPEG | | MJPEG (resolution) | `http://IP/axis-cgi/mjpg/video.cgi?resolution=640x480` | Sized MJPEG | | MJPEG (direct) | `http://IP/mjpg/video.mjpg` | Direct MJPEG (legacy) | ## Troubleshooting ### Audio "Possible" vs "Yes" Axis marks audio support as "Possible" on many RTSP streams because audio availability depends on the camera model having a built-in microphone or external audio input. The RTSP URL is the same whether audio is present or not -- the SDK will automatically detect and use audio if available. ### "401 Unauthorized" errors - Axis cameras default to digest authentication for RTSP - Ensure you're using the correct credentials (default username is `root`, not `admin`) - On newer firmware, password must meet complexity requirements (minimum 8 characters) ### MPEG-4 stream not available on newer models Modern Axis cameras (firmware 5.x+) have dropped MPEG-4 support. Use `/axis-media/media.amp` (H.264) instead of `/mpeg4/media.amp`. ### Resolution not matching expected output Axis cameras negotiate resolution dynamically. To force a specific resolution, add the `resolution` parameter: `rtsp://IP:554/axis-media/media.amp?resolution=1920x1080` ### Multi-channel encoder connections When connecting to an Axis encoder (M7001, P7214, etc.), you must specify the camera/channel parameter. Without it, you get channel 1 by default. ## FAQ **What is the default RTSP URL for Axis cameras?** The standard URL is `rtsp://root:password@CAMERA_IP:554/axis-media/media.amp`. This works for virtually all modern Axis cameras (M, P, Q, F, V series). The default username is `root` (not `admin` like most other brands). **How do I switch between H.264 and H.265 on Axis cameras?** Add the `videocodec` parameter to the RTSP URL: `rtsp://IP:554/axis-media/media.amp?videocodec=h265` for H.265, or `videocodec=h264` for H.264. Note that H.265 is only available on newer Axis models with Artpec-7 or newer chipsets. **Can I control stream quality via the RTSP URL?** Yes. Axis supports several URL parameters: `resolution` (e.g., `1920x1080`), `fps` (frame rate), `compression` (0-100), and `streamprofile` (named profiles configured in the camera). Example: `rtsp://IP:554/axis-media/media.amp?resolution=1280x720&fps=15`. **Why does Axis use "root" as the default username instead of "admin"?** Axis cameras run embedded Linux, and following Unix conventions, the administrative user is named `root`. This is different from most other camera brands that use `admin`. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Bosch Connection Guide](../bosch/) — Enterprise surveillance peer - [Hanwha Vision Connection Guide](../hanwha/) — Enterprise surveillance peer - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Basler IP Camera RTSP URL Connection Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/basler/ **Description:** Connect to Basler BIP2 IP cameras in C# .NET with RTSP URL patterns and code samples. Includes notes on machine vision vs IP security camera protocols. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, USB3 Vision / GigE, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Basler IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Basler** (Basler AG) is a German camera manufacturer headquartered in Ahrensburg, Germany, founded in 1988. Basler is a world leader in industrial machine vision cameras and also produces IP security cameras under the **BIP2** product line. While Basler's machine vision cameras use specialized industrial protocols, the BIP2 series provides standard RTSP and ONVIF connectivity for security and surveillance applications. **Key facts:** - **Product lines:** ace (machine vision), dart (compact), boost (high-speed), BIP2 (IP security) - **Protocol support:** RTSP, ONVIF, HTTP/CGI (BIP2 series); GigE Vision, USB3 Vision (machine vision) - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (BIP2 series) - **Video codecs:** H.264, MPEG-4, MJPEG - **Primary use:** Industrial vision, factory automation, quality inspection, IP surveillance Machine Vision Cameras Use Different Protocols Basler's ace, dart, and boost machine vision cameras use GigE Vision or USB3 Vision protocols, not RTSP. These require Basler's Pylon SDK or a GenICam-compatible framework. The RTSP URLs on this page apply to Basler's BIP2 IP security camera line. ## RTSP URL Patterns ### Standard URL Format Basler BIP2 IP cameras use simple path-based RTSP URLs: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/h264 ``` | Stream | URL Pattern | Description | | --- | --- | --- | | H.264 main stream | `rtsp://IP:554/h264` | Primary stream, best quality | | MPEG-4 stream | `rtsp://IP:554/mpeg4` | Legacy MPEG-4 encoded stream | | JPEG over RTSP | `rtsp://IP:554/jpeg` | JPEG frames over RTSP | ### Camera Models | Model | Type | Main Stream URL | Codec | | --- | --- | --- | --- | | BIP2-1280c (720p) | IP bullet | `rtsp://IP:554/h264` | H.264 | | BIP2-1300c (1.3MP) | IP bullet | `rtsp://IP:554/h264` | H.264 | | BIP2-1920c (1080p) | IP bullet | `rtsp://IP:554/h264` | H.264 | | BIP2-1300c-dn | IP day/night | `rtsp://IP:554/h264` | H.264 | | BIP2-1920c-dn | IP day/night | `rtsp://IP:554/h264` | H.264 | ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/h264` | H.264 stream (recommended) | | `rtsp://IP:554/mpeg4` | MPEG-4 stream (legacy) | | `rtsp://IP:554/jpeg` | JPEG over RTSP | ## Connecting with VisioForge SDK Use your Basler camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Basler BIP2, H.264 main stream var uri = new Uri("rtsp://192.168.1.90:554/h264"); var username = "admin"; var password = "admin"; ``` For MPEG-4 streams, replace `/h264` with `/mpeg4` in the URL. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | MJPEG Stream | `http://IP/cgi-bin/mjpeg` | Continuous MJPEG stream | | JPEG Snapshot | `http://IP/cgi-bin/jpeg?stream=0` | Snapshot from channel 0 | | JPEG Snapshot (channel) | `http://IP/cgi-bin/jpeg?stream=CHANNEL` | Snapshot from specific channel | ## Troubleshooting ### Machine vision camera not connecting via RTSP Basler's ace, dart, and boost cameras do not support RTSP. These cameras use GigE Vision (Ethernet) or USB3 Vision (USB) protocols and require Basler's Pylon SDK or a GenICam-compatible library. Only the BIP2 IP camera series supports RTSP streaming. ### "401 Unauthorized" error Basler BIP2 cameras ship with default credentials `admin` / `admin`. If the credentials have been changed: 1. Access the camera web interface at `http://CAMERA_IP` 2. Log in and verify or reset the credentials 3. Use the updated credentials in your RTSP URL ### No video output on MPEG-4 stream Some newer Basler BIP2 firmware versions may default to H.264 only. If the MPEG-4 stream returns no data: 1. Open the camera web interface 2. Navigate to video stream settings 3. Ensure MPEG-4 encoding is enabled 4. Alternatively, use the `/h264` stream path instead ### ONVIF discovery not finding the camera ONVIF is supported on BIP2 series cameras only. Ensure: - The camera firmware is up to date - ONVIF is enabled in the camera's network settings - The camera and discovery client are on the same subnet ## FAQ **What is the default RTSP URL for Basler cameras?** For Basler BIP2 IP cameras, the default URL is `rtsp://admin:admin@CAMERA_IP:554/h264` for the H.264 main stream. Replace the credentials if they have been changed from the defaults. **Can I use VisioForge SDK with Basler machine vision cameras?** The RTSP-based connection described on this page applies to Basler BIP2 IP security cameras only. Basler's machine vision cameras (ace, dart, boost) use GigE Vision or USB3 Vision protocols and require Basler's Pylon SDK or a GenICam-compatible framework for direct integration. **Do Basler cameras support ONVIF?** Yes, but only the BIP2 IP security camera series supports ONVIF. Basler's machine vision cameras use industrial protocols (GigE Vision, USB3 Vision) instead. **What codecs do Basler IP cameras support?** Basler BIP2 cameras support H.264, MPEG-4, and MJPEG. H.264 is recommended for the best balance of quality and bandwidth efficiency. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Mobotix Connection Guide](../mobotix/) — German industrial cameras - [FLIR Connection Guide](../flir/) — Industrial and thermal imaging - [Building Camera Applications with Media Blocks](../../mediablocks/GettingStarted/camera/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Bosch IP Camera RTSP URL Patterns and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/bosch/ **Description:** Bosch Dinion, Flexidome, Autodome, and VIP encoder RTSP URL patterns for C# .NET. Integrate with VisioForge SDK for enterprise surveillance apps. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Bosch IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Bosch Security and Safety Systems** (a division of Robert Bosch GmbH) is a German manufacturer of professional and enterprise video surveillance equipment. Headquartered in Grasbrunn near Munich, Bosch produces IP cameras, encoders, recording solutions, and video analytics primarily for critical infrastructure, transportation, and enterprise security markets. **Key facts:** - **Product lines:** Dinion (bullet/box), Flexidome (dome), Autodome (PTZ), MIC (ruggedized), NBN/NDN/NTC (legacy network), NWC (compact), VideoJet/VIP (encoders) - **Protocol support:** RTSP, ONVIF (Profile S/G/T), HTTP/CGI, Bosch VMS (BVMS), iSCSI direct recording - **Default RTSP port:** 554 - **Default credentials:** Varies by model and firmware version; many require setup via Bosch Configuration Manager - **ONVIF support:** Yes (all current IP cameras) - **Video codecs:** H.264, H.265, MJPEG - **Unique feature:** RTSP tunnel mode for firewall traversal ## RTSP URL Patterns Bosch cameras use several URL patterns depending on the model generation. The most common are the `/rtsp_tunnel` and `/video` paths. ### Current Models (Bosch CPP series firmware) | Stream | RTSP URL | Notes | | --- | --- | --- | | Video stream 1 | `rtsp://IP:554/video?inst=1` | Main stream | | Video stream 2 | `rtsp://IP:554/video?inst=2` | Sub stream | | RTSP tunnel | `rtsp://IP:554//rtsp_tunnel` | Firewall-friendly (note double slash) | | H.264 direct | `rtsp://IP:554/h264` | Direct H.264 stream | RTSP tunnel mode The `//rtsp_tunnel` URL (with double slash) is Bosch's proprietary RTSP tunneling mode that works better through firewalls and NAT. It encapsulates RTP data within the RTSP TCP connection. Use the standard `/video` URL for most integrations. ### Model-Specific URLs | Model Series | RTSP URL | Codec | Notes | | --- | --- | --- | --- | | Dinion IP 4000/5000/7000/8000 | `rtsp://IP:554/video?inst=1` | H.264/H.265 | Current | | Flexidome IP 4000/5000/7000/8000 | `rtsp://IP:554/video?inst=1` | H.264/H.265 | Current | | Autodome IP 4000/5000/7000 | `rtsp://IP:554/video?inst=1` | H.264/H.265 | Current PTZ | | MIC IP fusion/starlight/ultra | `rtsp://IP:554/video?inst=1` | H.264/H.265 | Ruggedized | | NDC-225-PI | `rtsp://IP:554//rtsp_tunnel` | H.264 | Legacy | | NDC-255-P | `rtsp://IP:554//rtsp_tunnel` | H.264 | Legacy | | NDC-265-P | `rtsp://IP:554/h264` | H.264 | Legacy | | NDN-832v | `rtsp://IP:554//rtsp_tunnel` | H.264 | Legacy dome | | NTC-255-PI | `rtsp://IP:554/video` | H.264 | Legacy thermal | | NTC-265-PI | `rtsp://IP:554/h264` | H.264 | Legacy thermal | | NTI-50022-V3 | `rtsp://IP:554/h264` | H.264 | IP bullet | | NWC-0455-20P | `rtsp://IP:554/h264` | H.264 | Compact | ### Encoder URLs Bosch video encoders (VideoJet, VIP series) allow connecting analog cameras to IP networks: | Encoder | RTSP URL | Notes | | --- | --- | --- | | VideoJet 10 | `rtsp://IP:554/video?inst=1` | Single channel | | VIP X1 | `rtsp://IP:554//rtsp_tunnel` | Single channel | | VIP X1600 | `rtsp://IP:554/video?inst=1` | Multi-channel | | VIP X2 | `rtsp://IP:554/video?inst=1` | Dual channel | ### DVR RTSP URLs | DVR Model | RTSP URL | Notes | | --- | --- | --- | | DVR 440/480/600 | `rtsp://IP:554/rtsp_tunnel` | Single slash | | DVR 440/480/600 | `rtsp://IP:554/video` | Alternative | | DVR (channel) | `rtsp://IP:554/cgi-bin/rtspStream/CHANNEL` | Channel-specific | | DVR (SDP) | `rtsp://IP:554/user=USER&password=PASS&channel=1&stream=0.sdp?` | SDP-based | ## Connecting with VisioForge SDK Use your Bosch camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Bosch Dinion/Flexidome, main stream var uri = new Uri("rtsp://192.168.1.60:554/video?inst=1"); var username = "service"; var password = "YourPassword"; ``` For sub-stream access, use `?inst=2` instead of `?inst=1`. For legacy Bosch models, use the RTSP tunnel URL `//rtsp_tunnel` (note the double slash). ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/snap.jpg` | Basic snapshot | | Snapshot (sized) | `http://IP/snap.jpg?JpegSize=XL` | XL, M sizes available | | Snapshot (channel) | `http://IP/snap.jpg?JpegCam=CHANNEL` | Multi-channel encoders | | Snapshot (auth) | `http://IP/snap.jpg?usr=USER&pwd=PASS` | URL-based auth | | MJPEG Stream | `http://IP/img/mjpeg.jpg` | Continuous MJPEG | | Image | `http://IP/img.jpg` | Single frame | | Image (alt) | `http://IP/image.jpg` | Alternative path | ## Troubleshooting ### Double slash in rtsp\_tunnel URL The `//rtsp_tunnel` URL (with double slash before `rtsp_tunnel`) is intentional for legacy Bosch cameras. This is not a typo: - Correct: `rtsp://IP:554//rtsp_tunnel` - Incorrect: `rtsp://IP:554/rtsp_tunnel` (may work on some models but not all) ### Bosch Configuration Manager required Many Bosch cameras require initial setup through the **Bosch Configuration Manager** desktop application before RTSP access works. The camera may not respond to RTSP connections until initial configuration is complete. ### Default username varies - **Current models:** `service` user with password set during setup - **Legacy models:** May use `admin`, `user`, or `service` depending on firmware - Check the Bosch Configuration Manager or camera's web interface for user settings ### inst parameter The `?inst=1` parameter selects the video stream instance: - `inst=1` = First video stream (main) - `inst=2` = Second video stream (sub) - Not all models support multiple instances ### Encoder channel selection For multi-channel encoders (VIP X1600, VideoJet X-series), use the `inst` parameter to select the channel: - `rtsp://IP:554/video?inst=1` = Channel 1 - `rtsp://IP:554/video?inst=2` = Channel 2 ## FAQ **What is the default RTSP URL for Bosch cameras?** For current Bosch cameras, the URL is `rtsp://service:password@CAMERA_IP:554/video?inst=1`. For legacy models, try `rtsp://CAMERA_IP:554//rtsp_tunnel` or `rtsp://CAMERA_IP:554/h264`. **What is Bosch RTSP tunnel mode?** RTSP tunnel (`//rtsp_tunnel`) is Bosch's proprietary mode that encapsulates RTP data within the RTSP TCP connection, making it easier to traverse firewalls. It's the default streaming mode on many legacy Bosch cameras. **Do Bosch cameras support H.265?** Current Bosch IP cameras (CPP13/CPP14 platform, including Dinion/Flexidome 7000/8000 series) support H.265. Legacy cameras support H.264 and MPEG-4. Check your specific model's datasheet for codec support. **Can I use Bosch encoders to connect analog cameras?** Yes. Bosch VideoJet and VIP encoders convert analog camera signals to IP streams accessible via RTSP. Use the same URL format (`/video?inst=1` or `//rtsp_tunnel`) as IP cameras. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Axis Connection Guide](../axis/) — Enterprise surveillance peer - [Honeywell Connection Guide](../honeywell/) — Enterprise / commercial segment - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## BrickCom IP Camera RTSP URL Setup Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/brickcom/ **Description:** BrickCom CB, MB, OB, VD, and WCB series RTSP URL patterns for C# .NET. Stream and record using VisioForge Video Capture SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to BrickCom IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **BrickCom** (Brickcom Corporation) is a Taiwanese professional IP camera manufacturer headquartered in Taipei, Taiwan. Founded in 2004, BrickCom targets professional security and industrial surveillance markets with a wide range of form factors including bullet, dome, cube, and specialty cameras. The brand is known for its straightforward channel-based RTSP URL pattern across its product lines. **Key facts:** - **Product lines:** CB (cube), MB (mini bullet), OB (outdoor bullet), VD (vandal dome), FD (fixed dome), MD (multi-directional), WCB/WOB (wireless) - **Channel-based URL pattern:** `/channel1` for main stream, `/channel2` for sub stream - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (most models) - **Video codecs:** H.264, MJPEG - **Primary RTSP URL:** `rtsp://IP:554/channel1` Channel numbering BrickCom uses simple channel-based URLs. Use `/channel1` for the primary (high-quality) stream and `/channel2` for the secondary (lower bandwidth) stream. ## RTSP URL Patterns ### Standard URL Format BrickCom cameras use a simple channel-based RTSP URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/channel1 ``` | Parameter | Value | Description | | --- | --- | --- | | `channel1` | Main stream | Primary stream (highest resolution) | | `channel2` | Sub stream | Secondary stream (lower resolution, less bandwidth) | ### Camera Models | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | CB-100 (cube) | Cube | `rtsp://IP:554/channel1` | Indoor cube camera | | MB-300Ap (mini bullet) | Mini Bullet | `rtsp://IP:554/channel1` | Compact bullet form factor | | OB-100Ap (outdoor bullet) | Outdoor Bullet | `rtsp://IP:554/channel1` | Weatherproof bullet | | OB-300Af (outdoor bullet) | Outdoor Bullet | `rtsp://IP:554/channel1` | Auto-focus bullet | | VD-130Ae (vandal dome) | Vandal Dome | `rtsp://IP:554/channel1` | IK10-rated dome | | VD-301AF (vandal dome) | Vandal Dome | `rtsp://IP:554/channel1` | Auto-focus vandal dome | | VD-500Af (vandal dome) | Vandal Dome | `rtsp://IP:554/channel1` | 5MP vandal dome | | WCB-100Ap (wireless cube) | Wireless Cube | `rtsp://IP:554/channel1` | Wi-Fi cube camera | | WCB-300AP (wireless cube) | Wireless Cube | `rtsp://IP:554/channel1` | Wi-Fi cube, 3MP | | WOB-100Ae (wireless bullet) | Wireless Bullet | `rtsp://IP:554/channel1` | Wi-Fi outdoor bullet | | MD-500AP-360-A1 (multi-dome) | Multi-Directional | `rtsp://IP:554/channel1` | 360-degree multi-sensor | ### Alternative URL Formats Some BrickCom models and firmware versions support these additional RTSP URLs: | URL Pattern | Supported Models | Notes | | --- | --- | --- | | `rtsp://IP:554/channel1` | Most models | Standard (recommended) | | `rtsp://IP:554/h264` | Various | Direct H.264 stream | | `rtsp://IP//ONVIF/channel2` | VD-500Af, WCB-100Ap | ONVIF sub stream | | `rtsp://IP/stream/bidirect/channel1` | Select models | Bidirectional stream with audio | ## Connecting with VisioForge SDK Use your BrickCom camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // BrickCom OB-300Af, main stream var uri = new Uri("rtsp://192.168.1.90:554/channel1"); var username = "admin"; var password = "admin"; ``` For sub-stream access, use `/channel2` instead of `/channel1`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/snapshot.jpg` | No authentication required | | JPEG Snapshot (auth) | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | URL-based authentication | | Channel Snapshot | `http://IP/snapshot.jpg?user=USER&pwd=PASS&strm=1` | Specific channel with auth | | CGI Snapshot | `http://IP/cgi-bin/media.cgi?action=getSnapshot` | CGI-based snapshot | | HTTP Channel Stream | `http://IP/channel2` | HTTP sub stream | ## Troubleshooting ### "401 Unauthorized" error BrickCom cameras ship with default credentials of **admin / admin**. If you have changed the password via the web interface: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Navigate to **Configuration > User Management** 3. Verify your credentials 4. Use those credentials in your RTSP URL ### Channel URL not connecting If `rtsp://IP:554/channel1` does not work, try the alternative H.264 URL: - `rtsp://IP:554/h264` -- direct H.264 stream without channel specification - Some older firmware versions may require the ONVIF format: `rtsp://IP//ONVIF/channel2` ### ONVIF discovery issues BrickCom cameras support ONVIF on most models. If ONVIF discovery fails: 1. Access the web interface at `http://CAMERA_IP` 2. Navigate to **Configuration > Network > ONVIF** 3. Ensure ONVIF is enabled 4. Verify the ONVIF port (default: 80 or 8080) ### Wireless models (WCB/WOB) connection drops Wireless BrickCom cameras (WCB and WOB series) may experience intermittent RTSP disconnections on congested Wi-Fi networks. Use the sub stream (`/channel2`) for lower bandwidth requirements, or connect via Ethernet for maximum reliability. ## FAQ **What is the default RTSP URL for BrickCom cameras?** The URL is `rtsp://admin:admin@CAMERA_IP:554/channel1` for the main stream. Use `/channel2` for the sub stream with lower resolution and bandwidth. **Do BrickCom cameras support ONVIF?** Yes. Most current BrickCom models support ONVIF. Some models also expose an ONVIF-specific RTSP path at `rtsp://IP//ONVIF/channel2`. **What is the difference between channel1 and channel2?** `/channel1` provides the primary high-resolution stream and `/channel2` provides a secondary lower-resolution stream suitable for thumbnails, mobile viewing, or bandwidth-constrained scenarios. **Can I access multiple streams simultaneously?** Yes. BrickCom cameras support concurrent connections to both `/channel1` and `/channel2`. The maximum number of simultaneous connections depends on the specific model. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [AVTech Connection Guide](../avtech/) — Taiwanese industrial cameras - [LILIN Connection Guide](../lilin/) — Taiwanese professional cameras - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Canon IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/canon/ **Description:** Canon VB-H, VB-M, VB-S, VB-R camera RTSP URL patterns for C# .NET. Integrate with VisioForge SDK for streaming and recording in WPF, WinForms, MAUI. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Canon IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Canon Inc.** is a Japanese multinational corporation headquartered in Tokyo. Canon's IP camera division produces the **VB series** of network cameras targeting professional and enterprise surveillance markets. Canon cameras are known for their optical quality, leveraging Canon's expertise in lens manufacturing. Canon has been reducing its IP camera lineup in recent years, focusing on higher-end models. **Key facts:** - **Product lines:** VB-H series (box/PTZ, current), VB-M series (PTZ/compact), VB-S series (compact), VB-R series (PTZ), VB-C series (legacy PTZ) - **Protocol support:** RTSP, ONVIF (VB-H and VB-M series), HTTP/CGI with proprietary `-wvhttp-01-` path - **Default RTSP port:** 554 - **Default credentials:** root / (camera-specific) or admin / admin (varies by model) - **ONVIF support:** Yes (VB-H and VB-M series) - **Video codecs:** H.264, H.265 (VB-H47, VB-H761 series), MJPEG ## RTSP URL Patterns Canon cameras use profile-based streaming with channel and profile identifiers in the URL path. ### Current Models (VB-H / VB-M / VB-S / VB-R Series) | Stream | RTSP URL | Notes | | --- | --- | --- | | Channel-based | `rtsp://IP:554/cam1/h264` | Channel 1, H.264 | | Profile stream | `rtsp://IP:554//stream/profile1=r` | Profile 1, read mode (note double slash) | | Profile (short) | `rtsp://IP:554/profile1=r` | Profile 1, shorter variant | | Unicast profile | `rtsp://IP/profile1=u` | Unicast mode, no port | Profile-based streaming Canon cameras use profile identifiers with access modes: `profile1=r` for **read** (multicast-capable) and `profile1=u` for **unicast** (direct connection). Use `=r` for general access and `=u` when connecting directly without multicast. ### Model-Specific URLs | Model | RTSP URL | Type | Notes | | --- | --- | --- | --- | | VB-H41 | `rtsp://IP:554//stream/profile1=r` | Fixed box | Profile with double slash | | VB-H43 / VB-H45 | `rtsp://IP:554/cam1/h264` | Fixed box | Channel-based | | VB-H47 | `rtsp://IP:554/cam1/h264` | Fixed box | H.265 capable | | VB-H610D / VB-H610VE | `rtsp://IP:554/cam1/h264` | Fixed dome | Current | | VB-H730F | `rtsp://IP:554/cam1/h264` | Fixed dome | Fisheye | | VB-H751LE | `rtsp://IP:554/cam1/h264` | Fixed bullet | Outdoor | | VB-H761LVE | `rtsp://IP:554/cam1/h264` | Fixed bullet | H.265 capable | | VB-M40 | `rtsp://IP/profile1=u` | Compact PTZ | Unicast, no port specified | | VB-M42 / VB-M44 | `rtsp://IP:554/cam1/h264` | Compact PTZ | Channel-based | | VB-M600D | `rtsp://IP/profile1=r` | Compact dome | Read mode | | VB-M620D / VB-M640V | `rtsp://IP:554/cam1/h264` | Compact dome | Current | | VB-M741LE | `rtsp://IP:554/cam1/h264` | Compact PTZ | Outdoor | | VB-S30D / VB-S31D | `rtsp://IP:554/cam1/h264` | Compact | Indoor | | VB-S800D / VB-S900F | `rtsp://IP:554/cam1/h264` | Compact | Indoor | | VB-R11 / VB-R11VE | `rtsp://IP:554/cam1/h264` | PTZ dome | Current | | VB-R12VE | `rtsp://IP:554/cam1/h264` | PTZ dome | Outdoor | ### Legacy Models (VB-C Series -- HTTP Only) Legacy VB-C cameras do not support RTSP. They use Canon's proprietary `-wvhttp-01-` HTTP URLs: | Model | HTTP URL | Type | Notes | | --- | --- | --- | --- | | VB-C300 | `http://IP/-wvhttp-01-/GetLiveImage` | PTZ dome | HTTP only | | VB-C10 | `http://IP/-wvhttp-01-/GetLiveImage` | Compact | HTTP only | | VB-C50i | `http://IP/-wvhttp-01-/GetLiveImage` | PTZ dome | HTTP only | | VB-610 | `http://IP/-wvhttp-01-/video.cgi` | Fixed | HTTP only | ## Connecting with VisioForge SDK Use your Canon camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Canon VB-H series camera, channel 1 var uri = new Uri("rtsp://192.168.1.70:554/cam1/h264"); var username = "root"; var password = "YourPassword"; ``` For profile-based access on older VB models, use `rtsp://IP:554/profile1=r` or `rtsp://IP/profile1=u` depending on the model. ## Snapshot and MJPEG URLs Canon uses a distinctive `-wvhttp-01-` path prefix for all HTTP-based image and video access: | Type | URL Pattern | Notes | | --- | --- | --- | | Live Image | `http://IP/-wvhttp-01-/GetLiveImage` | Current snapshot | | MJPEG Stream | `http://IP/-wvhttp-01-/video.cgi` | Continuous MJPEG | | Snapshot (sized) | `http://IP/-wvhttp-01-/GetOneShot?image_size=WIDTHxHEIGHT` | Custom resolution | | Snapshot (continuous) | `http://IP/-wvhttp-01-/GetOneShot?image_size=WIDTHxHEIGHT&frame_count=0` | Continuous capture | Canon `-wvhttp-01-` prefix The `-wvhttp-01-` path prefix is unique to Canon network cameras. All HTTP-based image and video URLs use this prefix. This distinctive path can help identify Canon cameras on a network. ## Troubleshooting ### RTSP must be enabled in the web interface Canon cameras may not have RTSP enabled by default. Access the camera's web interface and navigate to the streaming settings to enable RTSP. Without this, the camera will only respond to HTTP requests. ### Legacy VB-C series are HTTP only The VB-C series (VB-C300, VB-C10, VB-C50i) and VB-610 do not support RTSP at all. Use Canon's `-wvhttp-01-` HTTP URLs for video access from these models: - `http://IP/-wvhttp-01-/GetLiveImage` for snapshots - `http://IP/-wvhttp-01-/video.cgi` for MJPEG streaming ### Profile read vs unicast modes Canon profile URLs use two access modes: - `profile1=r` -- **Read mode**: Allows multicast distribution, suitable for multiple viewers - `profile1=u` -- **Unicast mode**: Direct connection, one viewer per stream If multicast is not configured on your network, use `profile1=u` for a direct unicast connection. ### Double slash in some URLs Some Canon models (notably VB-H41) require a **double forward slash** before the stream path: - VB-H41: `rtsp://IP:554//stream/profile1=r` (double slash) - Most others: `rtsp://IP:554/cam1/h264` (single slash) ### Default credentials vary Canon cameras do not have a universal default credential: - **Current models:** Often `root` with a password set during initial setup - **Older models:** May use `admin` / `admin` or `root` / `camera` - Check the camera label or setup guide for model-specific defaults ## FAQ **What is the default RTSP URL for Canon cameras?** For current Canon VB-H and VB-M series cameras, use `rtsp://root:password@CAMERA_IP:554/cam1/h264`. For older models, try `rtsp://CAMERA_IP:554/profile1=r` or `rtsp://CAMERA_IP/profile1=u`. **Do Canon cameras support H.265?** Select Canon models support H.265, including the VB-H47 and VB-H761 series. Most other VB-series cameras use H.264. Legacy VB-C models support only MJPEG over HTTP. **What is the `-wvhttp-01-` path in Canon URLs?** The `-wvhttp-01-` prefix is Canon's proprietary HTTP path used for all web-based image and video access on their network cameras. It is used for snapshots (`GetOneShot`, `GetLiveImage`), MJPEG streaming (`video.cgi`), and camera control. This path is unique to Canon cameras. **Can I connect to legacy Canon VB-C cameras?** Legacy VB-C cameras (VB-C300, VB-C10, VB-C50i) are HTTP-only and do not support RTSP. You can access their video using the HTTP URL `http://CAMERA_IP/-wvhttp-01-/GetLiveImage` for snapshots or `http://CAMERA_IP/-wvhttp-01-/video.cgi` for MJPEG streaming. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Sony Connection Guide](../sony/) — Japanese enterprise cameras - [Axis Connection Guide](../axis/) — Enterprise surveillance leader - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Cisco IP Camera RTSP URL Setup and C# .NET Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/cisco/ **Description:** Cisco CIVS and Meraki camera RTSP integration for C# .NET. URL patterns for enterprise PVC, VC models with VisioForge SDK code and ONVIF examples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Cisco IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Cisco Systems** is the world's largest networking company, headquartered in San Jose, California, USA. Cisco produced IP cameras under both the **Cisco** and **Linksys** brands. The main camera lines were **Cisco Video Surveillance (CIVS/VC/PVC)** for enterprise deployments and the former **Linksys-branded (WVC)** series for consumer and small business markets. Cisco sold their video surveillance business to Verkada and discontinued most camera products, but many units remain deployed in the field. The **Meraki MV** line (cloud-managed) is the only current Cisco camera product. **Key facts:** - **Product lines:** CIVS (enterprise video surveillance), PVC (small business), VC (video camera), WVC (wireless video camera, Linksys legacy), WCS (wireless camera server), Meraki MV (cloud-managed, current) - **Protocol support:** RTSP, HTTP/CGI, MJPEG, ASF (WVC models); Meraki MV is cloud-only - **Default RTSP port:** 554 - **Default credentials:** admin / admin (varies by model) - **ONVIF support:** Limited (some newer CIVS models only; WVC series does not support ONVIF) - **Video codecs:** H.264, MPEG-4 (WVC series), MJPEG Meraki MV cameras Cisco Meraki MV cameras use cloud-only access and do **not** support direct RTSP streaming. They cannot be connected via local RTSP URLs. The information on this page applies to the legacy Cisco and Linksys camera product lines. ## RTSP URL Patterns ### Enterprise Cameras (CIVS / VC / PVC Series) Most Cisco enterprise IP cameras use the `/img/media.sav` path: | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:554/img/media.sav` | Most CIVS and WVC cameras | | Live SDP | `rtsp://IP:554/live.sdp` | VC240, PVC300, VC220 series | | Video SAV | `rtsp://IP:554/img/video.sav` | PVC2300 | | Access code | `rtsp://IP:554/[ACCESS_CODE]` | Code configured in camera web UI | | Root stream | `rtsp://IP:554/` | Fallback for PVC2300 and others | ### Model-Specific URLs | Model | RTSP URL | Type | | --- | --- | --- | | CIVS 2500 / 2521 / 2531 | `rtsp://IP:554/img/media.sav` | Enterprise dome/bullet | | PVC300 | `rtsp://IP:554/live.sdp` | Small business PTZ | | PVC2300 | `rtsp://IP:554/img/video.sav` | Small business box | | PVC2300 (alt) | `rtsp://IP:554/` | Fallback | | VC220 | `rtsp://IP:554/live.sdp` | Dome camera | | VC240 | `rtsp://IP:554/live.sdp` | Dome camera | | WVC80N | `rtsp://IP:554/img/media.sav` | Linksys wireless | | WVC210 | `rtsp://IP:554/img/media.sav` | Linksys wireless | | WVC54GCA | `rtsp://IP:554/img/media.sav` | Linksys wireless | | WCS-1130 | `rtsp://IP:554/play1.sdp` | Wireless camera server | Unusual file extension Cisco and Linksys cameras use the `/img/media.sav` path, which has an unusual `.sav` file extension. This is not a standard media format -- it is a Cisco-specific RTSP endpoint. Do not confuse it with a file download URL. ### WVC Series (Linksys Legacy) The Linksys WVC (Wireless Video Camera) series was a popular consumer camera line before Cisco rebranded and eventually discontinued it: | Model | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | WVC54GCA | `rtsp://IP:554/img/media.sav` | 640x480 | Wi-Fi, MPEG-4 | | WVC80N | `rtsp://IP:554/img/media.sav` | 640x480 | Wireless-N | | WVC210 | `rtsp://IP:554/img/media.sav` | 640x480 | Wireless-G PTZ | ## Connecting with VisioForge SDK Use your Cisco camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Cisco enterprise camera (CIVS/WVC), main stream var uri = new Uri("rtsp://192.168.1.50:554/img/media.sav"); var username = "admin"; var password = "YourPassword"; ``` For VC240 or PVC300 cameras, use `/live.sdp` instead of `/img/media.sav`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/img/snapshot.cgi?size=3` | Most Cisco cameras (size: 1=QQVGA, 2=QVGA, 3=VGA) | | JPEG Snapshot (VGA) | `http://IP/img/snapshot.cgi?img=vga` | Named resolution | | MJPEG Stream | `http://IP/img/video.mjpeg` | Continuous MJPEG stream | | MJPEG (alt) | `http://IP/img/mjpeg.jpg` | Alternative MJPEG endpoint | | ASF Stream | `http://IP/img/video.asf` | WVC series ASF stream | | PVC300 Snapshot | `http://IP/cgi-bin/viewer/snapshot.jpg?resolution=640x480` | Resolution parameter required | ## Troubleshooting ### `/img/media.sav` not responding The `.sav` extension is a Cisco-specific RTSP endpoint. If the URL does not work: 1. Verify the camera IP address and that port 554 is open 2. Confirm RTSP is enabled in the camera's web UI 3. Some models require an access code to be configured before RTSP access works -- check the camera's streaming settings 4. Try the fallback URL `rtsp://IP:554/` if the specific path does not respond ### WVC series returns MPEG-4 only The Linksys WVC cameras (WVC54GCA, WVC80N, WVC210) support MPEG-4 but not H.264. The VisioForge SDK handles MPEG-4 streams automatically. If you see artifacts, ensure you are not forcing H.264 decoding. ### Access code authentication Some Cisco cameras use an access code instead of traditional username/password for RTSP. The access code is configured in the camera's web interface under streaming settings and is appended to the URL: ``` rtsp://IP:554/[YOUR_ACCESS_CODE] ``` ### HTTP streams for legacy cameras Older Cisco/Linksys cameras may work better with HTTP-based ASF or MJPEG streams than RTSP. Use the ASF URL (`http://IP/img/video.asf`) as a fallback if RTSP is unreliable. ### Meraki MV cameras not accessible Meraki MV cameras are cloud-managed only and do not support local RTSP access. There is no local RTSP URL available for these cameras. Video can only be accessed through the Meraki Dashboard cloud interface. ## FAQ **What is the default RTSP URL for Cisco cameras?** For most Cisco and Linksys IP cameras, use `rtsp://admin:password@CAMERA_IP:554/img/media.sav`. For VC/PVC series cameras, try `rtsp://admin:password@CAMERA_IP:554/live.sdp` instead. **Do Cisco cameras support ONVIF?** Only some newer CIVS-series enterprise cameras have limited ONVIF support. The Linksys WVC consumer cameras and Meraki MV cameras do not support ONVIF. **Are Cisco cameras still being manufactured?** Cisco sold their video surveillance business (CIVS line) to Verkada and discontinued the Linksys WVC cameras. The only current Cisco camera product is the Meraki MV series, which is cloud-managed and does not support RTSP. However, many legacy Cisco cameras remain deployed and operational. **What codecs do Cisco cameras use?** Newer CIVS enterprise cameras support H.264. The Linksys WVC series primarily uses MPEG-4 and MJPEG. The codec depends on the model and firmware version. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Linksys Connection Guide](../linksys/) — Same URL patterns, Cisco subsidiary - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## CP Plus IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/cp-plus/ **Description:** CP Plus UNC, NC, RNP, Guard+, and Cosmic series RTSP URL patterns for C# .NET. Integrate with VisioForge SDK for IP camera streaming and recording. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to CP Plus IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **CP Plus** (Aditya Infotech Ltd.) is India's #1 security camera brand and one of the largest surveillance manufacturers in the world, headquartered in Delhi, India. CP Plus cameras are primarily **Dahua OEM** products, meaning most models run Dahua firmware and share identical RTSP URL patterns. Some models use alternative chipsets with different URL formats. CP Plus dominates the Indian, Middle Eastern, and Southeast Asian markets with a comprehensive range of IP cameras, NVRs, and analog systems. **Key facts:** - **Product lines:** UNC (IP cameras), RNP (NVRs), VAC (analog), Guard+ (wireless), E series (entry-level), Cosmic (value) - **OEM base:** Dahua (most models use Dahua firmware and URL patterns) - **Protocol support:** RTSP, ONVIF, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (most models) - **Video codecs:** H.264, H.265 (newer models) - **Dominant market:** India (#1), Middle East, Southeast Asia CP Plus = Dahua OEM CP Plus cameras are primarily Dahua OEM products and use the same RTSP URL patterns. See our [Dahua connection guide](../dahua/) for additional details. Some CP Plus models use the `/VideoInput/` URL format instead. ## RTSP URL Patterns ### Standard URL Format (Dahua-style) Most CP Plus cameras use the Dahua `cam/realmonitor` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/cam/realmonitor?channel=1&subtype=1 ``` | Parameter | Value | Description | | --- | --- | --- | | `channel` | 1, 2, 3... | Camera channel (1 for standalone cameras) | | `subtype` | 0 | Main stream (highest resolution) | | `subtype` | 1 | Sub stream (lower resolution, less bandwidth) | ### Camera Models | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | CP-UNC-DP10L2C | IP dome | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua-style URL | | CP-UNC-TY20FL2C | IP turret | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua-style URL | | CP-NC9W-K | Network camera | `rtsp://IP:554/VideoInput/1/mpeg4/1` | VideoInput format | | B series | Basic | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua-style URL | ### NVR Channel URLs For CP Plus NVRs (CP-RNP-36D, CN-RNP-36D, etc.): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | | Camera 2 | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=1` | | Camera N | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=1` | ### Alternative URL Formats Some CP Plus models use different URL patterns depending on firmware and chipset: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | Standard Dahua-style (most models) | | `rtsp://IP:554//cam/realmonitor` | Dahua-style alternate (double slash) | | `rtsp://IP:554/VideoInput/1/mpeg4/1` | VideoInput format (CP-NC9W-K, CP-UNC-DP10L2C on some firmware) | | `rtsp://IP:554//cam/realmonitor?channel=1&subtype=00&authbasic=AUTH` | With base64-encoded authentication | ## Connecting with VisioForge SDK Use your CP Plus camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // CP Plus CP-UNC-DP10L2C, main stream var uri = new Uri("rtsp://192.168.1.90:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `subtype=1` instead of `subtype=0`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi?1` | Requires basic auth (CP-UNC-TY20FL2C) | | JPEG Snapshot (legacy) | `http://IP/cgi-bin/snapshot.cgi?loginuse=USER&loginpas=PASS` | URL-based auth for older models | | JPEG Image | `http://IP/cgi-bin/jpg/image.cgi` | Alternative JPEG endpoint | | MJPEG Stream | `http://IP/api/mjpegvideo.cgi?InputNumber=1&StreamNumber=CHANNEL` | Continuous MJPEG stream | | Direct HTTP Stream | `http://IP:8008/` | Some NVR models (CN-RNP-36D, CP-RNP-36D) | ## Troubleshooting ### "401 Unauthorized" error CP Plus cameras ship with default credentials (`admin` / `admin`). If you've changed the password via the web interface or mobile app, ensure your RTSP URL uses the updated credentials. 1. Access the camera at `http://CAMERA_IP` in a browser 2. Log in with your credentials 3. Verify RTSP is enabled under **Setup > Network > Port** 4. Use those credentials in your RTSP URL ### Dahua-style URL not working Some CP Plus models (particularly the CP-NC series) use the `/VideoInput/` URL format instead of the Dahua `cam/realmonitor` pattern. Try: ``` rtsp://admin:password@IP:554/VideoInput/1/mpeg4/1 ``` ### Port 554 vs custom port Check the RTSP port setting at: - Web interface: **Setup > Network > Port > RTSP Port** - Default is 554 ### Stream type confusion - `subtype=0` = Main stream (full resolution, higher bandwidth) - `subtype=1` = Sub stream (reduced resolution, lower bandwidth) ### Direct HTTP stream on port 8008 Some CP Plus NVR models (CP-RNP-36D, CN-RNP-36D) expose a direct HTTP stream on port 8008. Try accessing `http://CAMERA_IP:8008/` if standard RTSP is unavailable. ## FAQ **Are CP Plus cameras the same as Dahua?** Most CP Plus cameras are manufactured by Dahua and use Dahua firmware. The RTSP URL format (`cam/realmonitor?channel=1&subtype=0`) is identical for the majority of models. However, some CP Plus models use different chipsets with the `/VideoInput/` URL format. Any code written for Dahua cameras generally works with CP Plus and vice versa. **What is the default RTSP URL for CP Plus cameras?** The URL is `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=1` for the sub stream. Replace `subtype=1` with `subtype=0` for the main stream. For NVR setups, change `channel=1` to the appropriate channel number. **Do CP Plus cameras support ONVIF?** Yes. Most current CP Plus IP cameras support ONVIF, which provides a standardized way to discover and connect to cameras regardless of the specific URL format. **What if my CP Plus camera uses a different URL format?** Some CP Plus models (especially the CP-NC series) use `rtsp://IP:554/VideoInput/1/mpeg4/1` instead of the Dahua-style URL. If the standard URL does not work, try the VideoInput format. You can also use ONVIF discovery to automatically detect the correct URL. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Dahua Connection Guide](../dahua/) — Same URL format for most models - [Amcrest Connection Guide](../amcrest/) — Another Dahua OEM - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Dahua IP Camera RTSP URL Patterns and C# .NET Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/dahua/ **Description:** Integrate Dahua IPC-HDW, IPC-HFW, NVR, and DVR cameras into C# .NET apps. RTSP URL format, ONVIF auto-discovery, and VisioForge SDK code included. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to Dahua IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Dahua Technology** (Zhejiang Dahua Technology Co., Ltd.) is the world's second-largest video surveillance manufacturer. Founded in 2001 and headquartered in Hangzhou, China, Dahua produces IP cameras, NVRs, DVRs, access control systems, and video intercoms. Dahua cameras are also widely sold under OEM brands including Amcrest, Lorex, and others. **Key facts:** - **Product lines:** IPC-HDW (dome), IPC-HFW (bullet), IPC-HDBW (dome vandal-proof), SD (PTZ), NVR4xxx/5xxx (NVRs), XVR (DVRs) - **Protocol support:** ONVIF Profile S/G/T, RTSP, HTTP, Dahua proprietary (DHIP) - **Default RTSP port:** 554 (some models use 1554) - **Default credentials:** admin / admin (older firmware); admin / (set during setup on newer firmware) - **ONVIF support:** Full - **Video codecs:** H.264, H.265, H.265+, MJPEG ## RTSP URL Patterns Dahua cameras use a `cam/realmonitor` URL structure with channel and subtype parameters. ### URL Format ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:[PORT]/cam/realmonitor?channel=[CH]&subtype=[ST] ``` **Parameters:** - `channel` = camera channel number (1 for single-channel cameras, 1-N for NVR/DVR) - `subtype` = stream type: 0 = main stream, 1 = sub stream, 2 = third stream ### IP Cameras (Single Channel) | Model Series | RTSP URL | Stream | Audio | | --- | --- | --- | --- | | IPC-HDW (dome) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Main | Yes | | IPC-HDW (dome) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | Sub | Yes | | IPC-HFW (bullet) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Main | Yes | | IPC-HDBW (vandal dome) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Main | Yes | | SD (PTZ) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Main | Yes | | DH-IPC-HF2100P | `rtsp://IP:1554/cam/realmonitor?channel=1&subtype=0` | Main | Yes | ### Simplified URL Format Many Dahua cameras also accept a shorter URL format: | URL Pattern | Stream | Notes | | --- | --- | --- | | `rtsp://IP:554/cam/realmonitor` | Main (ch1) | Defaults to channel 1, main stream | | `rtsp://IP:554/` | Main | Bare URL, some models only | | `rtsp://IP:554/live` | Main | Legacy format | ### NVR / DVR Channels | Device | Channel | RTSP URL | Stream | | --- | --- | --- | --- | | NVR Camera 1 | 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Main | | NVR Camera 1 | 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | Sub | | NVR Camera 2 | 2 | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=0` | Main | | NVR Camera 4 | 4 | `rtsp://IP:554/cam/realmonitor?channel=4&subtype=0` | Main | | DVR Channel 1 | 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=01` | Sub | ### Amcrest / Lorex (Dahua OEM) Amcrest and Lorex cameras use the same Dahua RTSP URL format: | Brand | RTSP URL | Notes | | --- | --- | --- | | Amcrest | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Identical to Dahua | | Lorex | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Identical to Dahua | ## Connecting with VisioForge SDK Use your Dahua camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Dahua IPC-HDW series, main stream var uri = new Uri("rtsp://192.168.1.108:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `subtype=1` instead. ### ONVIF Discovery Dahua cameras provide strong ONVIF support. See the [ONVIF integration guide](../../mediablocks/Sources/) for discovery code examples. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi?channel=1` | Requires basic auth | | JPEG Snapshot (legacy) | `http://IP/cgi-bin/snapshot.cgi?loginuse=USER&loginpas=PASS` | URL-based auth | | MJPEG Stream | `http://IP/cgi-bin/mjpg/video.cgi?channel=1` | Continuous MJPEG | | Axis-compatible MJPEG | `http://IP/axis-cgi/mjpg/video.cgi?camera=1` | Emulated Axis API | | CGI Snapshot | `http://IP/cgi-bin/video.jpg` | Simple snapshot | | Image CGI | `http://IP/cgi-bin/jpg/image.cgi` | Alternative snapshot | ## Troubleshooting ### Port 554 vs 1554 Some Dahua models (especially the DH-IPC-HF series) use port **1554** instead of the standard 554. If connection fails on port 554, try 1554. ### Authentication methods - Dahua supports both **basic** and **digest** RTSP authentication - Newer firmware defaults to digest authentication - VisioForge SDK handles both methods automatically - If using HTTP snapshot URLs, some require URL-embedded credentials (`loginuse`/`loginpas` parameters) while newer firmware uses standard HTTP basic/digest auth ### Connection drops - Dahua cameras can be sensitive to network congestion. Use TCP transport for reliability. - Reduce main stream resolution or switch to sub stream (`subtype=1`) to lower bandwidth - Check the camera's **Max User Connections** setting (Configuration > Network > Connection) -- the default is typically 10 ### Amcrest/Lorex cameras not connecting If you have an Amcrest or Lorex camera (Dahua OEM), use the exact same RTSP URL patterns listed above. The default ports and paths are identical to Dahua. The only difference may be in default credentials: - **Amcrest default:** admin / admin - **Lorex default:** admin / (set during setup) ### DVR extra stream format When connecting to DVR channels, note that `subtype=00` and `subtype=0` are equivalent for the main stream. Some older firmware requires the two-digit format (`01` instead of `1`). ## FAQ **What is the default RTSP URL for Dahua cameras?** The standard URL is `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=0` for the main stream. Use `subtype=1` for the sub stream (lower resolution, less bandwidth). **Do Amcrest cameras use the same RTSP URLs as Dahua?** Yes. Amcrest cameras are manufactured by Dahua and use identical RTSP URL patterns, authentication, and port configurations. Any RTSP URL that works for a Dahua camera will work for the corresponding Amcrest model. **How do I access multiple cameras on a Dahua NVR?** Change the `channel` parameter in the RTSP URL. Channel 1 is the first camera, channel 2 is the second, and so on. For example, `rtsp://IP:554/cam/realmonitor?channel=3&subtype=0` connects to the third camera on the NVR's main stream. **Why does my Dahua camera use port 1554 instead of 554?** Some older Dahua models, particularly the DH-IPC-HF series, default to RTSP port 1554. You can change this in the camera's web interface under Configuration > Network > Port. Newer models default to port 554. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Amcrest Connection Guide](../amcrest/) — Dahua OEM, identical URL format - [Lorex Connection Guide](../lorex/) — Uses Dahua URL format for many models - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## D-Link DCS IP Camera RTSP URLs and C# .NET Code Samples **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/dlink/ **Description:** D-Link DCS camera RTSP URL patterns for C# .NET integration. Covers DCS-930, DCS-2130, DCS-5222 with VisioForge SDK code and authentication setup. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to D-Link IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **D-Link Corporation** is a Taiwanese networking equipment manufacturer headquartered in Taipei. D-Link produces IP cameras under the **DCS (D-Link Cloud Security)** product line, targeting consumer and small business markets. D-Link cameras are widely available through retail channels and are popular for home security and small office deployments. **Key facts:** - **Product lines:** DCS-930/932/933/934 (consumer Wi-Fi), DCS-2130/2132/2230/2310/2330/2332 (prosumer), DCS-5020/5222/5615 (PTZ), DCS-6010/6113/6818 (enterprise), DCS-7010/7110/7410 (outdoor professional) - **Protocol support:** RTSP, ONVIF (some models), HTTP/CGI, MJPEG, D-Link mydlink cloud - **Default RTSP port:** 554 - **Default credentials:** admin / (empty password); some models: admin / admin - **ONVIF support:** Select models only (typically DCS-2xxx and higher) - **Video codecs:** H.264, MJPEG, MPEG-4 (legacy) ## RTSP URL Patterns ### Current and Recent Models D-Link cameras use the `live.sdp` or `play.sdp` URL format: | Stream | RTSP URL | Quality | Notes | | --- | --- | --- | --- | | Main stream (H.264) | `rtsp://IP:554/live1.sdp` | High | Main H.264 stream | | Sub stream (H.264) | `rtsp://IP:554/live2.sdp` | Medium | Second stream | | Third stream | `rtsp://IP:554/live3.sdp` | Low | Third stream (some models) | | Main stream (alt) | `rtsp://IP:554/play1.sdp` | High | Alternative URL | | Sub stream (alt) | `rtsp://IP:554/play2.sdp` | Medium | Alternative URL | ### Model-Specific URLs | Model | RTSP URL | Resolution | Type | | --- | --- | --- | --- | | DCS-930L | `rtsp://IP:554/play1.sdp` | 640x480 | Consumer Wi-Fi | | DCS-932L | `rtsp://IP:554/play1.sdp` | 640x480 | Consumer Wi-Fi IR | | DCS-933L | `rtsp://IP:554/play1.sdp` | 640x480 | Consumer Wi-Fi | | DCS-934L | `rtsp://IP:554/play1.sdp` | 1280x720 | Consumer HD | | DCS-942L | `rtsp://IP:554/play1.sdp` | 640x480 | Consumer IR | | DCS-2100+ | `rtsp://IP:554/live.sdp` | 640x480 | Legacy | | DCS-2121 | `rtsp://IP:554/play1.sdp` | 640x480 | Prosumer | | DCS-2130 | `rtsp://IP:554//live1.sdp` | 1280x720 | Prosumer HD | | DCS-2132L | `rtsp://IP:554//live1.sdp` | 1280x720 | Prosumer HD | | DCS-2230 | `rtsp://IP:554//live1.sdp` | 1920x1080 | Prosumer FHD | | DCS-2310L | `rtsp://IP:554/live1.sdp` | 1280x720 | Outdoor HD | | DCS-2332L | `rtsp://IP:554//live1.sdp` | 1280x720 | Outdoor HD | | DCS-5020L | `rtsp://IP:554/play1.sdp` | 640x480 | PTZ consumer | | DCS-5222L | `rtsp://IP:554//live1.sdp` | 1280x720 | PTZ HD | | DCS-6010L | `rtsp://IP:554/live1.sdp` | 1600x1200 | Panoramic | | DCS-6113 | `rtsp://IP:554/live1.sdp` | 1920x1080 | Box camera | | DCS-6818 | `rtsp://IP:554/live3.sdp` | 1920x1080 | Enterprise | | DCS-7010L | `rtsp://IP:554/live1.sdp` | 1280x720 | Outdoor PoE | | DCS-7110 | `rtsp://IP:554/live1.sdp` | 1280x800 | Outdoor HD | | DCS-7410 | `rtsp://IP:554/live1.sdp` | 1280x720 | Outdoor enterprise | Double slash in some URLs Some D-Link models use a double slash before the path: `rtsp://IP:554//live1.sdp`. This is common on DCS-2130, DCS-2132L, DCS-2230, DCS-2332L, and DCS-5222L models. Try both single and double slash if one format doesn't work. ### Legacy Models (HTTP Only) Very old D-Link DCS cameras only support HTTP: | Model | URL | Notes | | --- | --- | --- | | DCS-900 | `http://IP/cgi-bin/video.jpg` | JPEG only | | DCS-910 | `http://IP/video.cgi` | MJPEG | | DCS-920 | `http://IP/video.cgi` | MJPEG | | DCS-2100 | `http://IP/cgi-bin/video.jpg?size=2` | JPEG only | ## Connecting with VisioForge SDK Use your D-Link camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // D-Link DCS camera, main stream var uri = new Uri("rtsp://192.168.1.45:554/live1.sdp"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/live2.sdp` instead. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/image/jpeg.cgi` | Most current DCS models | | MJPEG Stream | `http://IP/video/mjpg.cgi` | Continuous MJPEG | | MJPEG (alt) | `http://IP/video.cgi` | Older models | | MJPEG (auth) | `http://IP/mjpeg.cgi?user=USER&password=PASS&channel=1` | With authentication | | DMS Snapshot | `http://IP/dms.jpg` | DCS-2130/2132/2230/2310/2332 | | DMS Stream | `http://IP/dms?nowprofileid=2` | Profile-based | | ipcam stream | `http://IP/ipcam/stream.cgi?nowprofileid=2` | Some models | | Legacy JPEG | `http://IP/cgi-bin/video.jpg` | Very old DCS models | ## Troubleshooting ### live vs play URL format D-Link cameras use two URL naming conventions: - **Current models (DCS-2xxx+):** `live1.sdp`, `live2.sdp`, `live3.sdp` - **Consumer models (DCS-930/932/933/942):** `play1.sdp`, `play2.sdp`, `play3.sdp` If one format doesn't work, try the other. ### Default password is empty Many D-Link cameras ship with `admin` as the username and an **empty password**. You may need to set a password through the web interface or D-Link Setup Wizard before RTSP works properly. ### mydlink cloud cameras Some newer D-Link cameras are designed primarily for the mydlink cloud ecosystem and may have limited or no RTSP support. Check the camera's specifications for "RTSP" or "third-party integration" support. ### Port configuration D-Link cameras use port 554 by default for RTSP. The HTTP interface is typically on port 80. Both can be changed in the camera's web interface under Network Settings. ## FAQ **What is the default RTSP URL for D-Link cameras?** For most D-Link DCS cameras, try `rtsp://admin:password@CAMERA_IP:554/live1.sdp` or `rtsp://admin:password@CAMERA_IP:554/play1.sdp`. The `live` format is used by newer models, while `play` is used by consumer models. **Do D-Link cameras support ONVIF?** Select models support ONVIF (typically DCS-2xxx and higher-end models). Consumer cameras like the DCS-930L and DCS-932L generally do not support ONVIF. **What is the difference between live1.sdp and play1.sdp?** Both serve the same purpose (main video stream) but are used by different D-Link camera generations. `live1.sdp` is more common on newer prosumer/professional models, while `play1.sdp` is used on older consumer models. **Can I connect to D-Link cameras without the mydlink app?** Yes. D-Link cameras with RTSP support can be accessed directly via their IP address without the mydlink cloud service. The mydlink cloud is optional for remote access. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Foscam Connection Guide](../foscam/) — Consumer IP camera peer - [TP-Link Connection Guide](../tp-link/) — Consumer cameras with RTSP - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Edimax IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/edimax/ **Description:** Learn how to connect to Edimax IP cameras using C# .NET with RTSP URL patterns, authentication tips, and code samples for IC, IR, PT, and VS series models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Edimax IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Edimax** (Edimax Technology Co.) is a Taiwanese networking equipment manufacturer headquartered in Taipei, Taiwan. Founded in 1986, Edimax is known primarily for networking products such as routers, switches, and Wi-Fi adapters, but also manufactures a range of consumer and small-to-medium business IP cameras under the IC series. Over the years, Edimax cameras have evolved through several URL format generations. **Key facts:** - **Product lines:** IC (IP camera), IR (infrared), PT (pan/tilt), VS (video server) - **Multiple URL format generations:** older models use `/ipcam.sdp`, newer models use `/stream1` - **Default RTSP port:** 554 (some models use 8000) - **Default credentials:** admin / 1234 - **ONVIF support:** Yes (newer models) - **Video codecs:** H.264, MJPEG - **Primary RTSP URL:** `rtsp://IP:554/ipcam_h264.sdp` URL format generations Edimax cameras have evolved through several URL format generations. Older IC-1500/IC-3000 series use `/ipcam.sdp` or `/ipcam_h264.sdp`, while newer IR/PT series use `/stream1`. Try both formats if one doesn't work. Dual authentication styles Edimax cameras use two different authentication parameter styles in HTTP URLs: `account=USER&password=PASS` (older firmware) and `user=USER&pwd=PASS` (newer firmware). Check which format your camera supports. ## RTSP URL Patterns ### Standard URL Format Edimax cameras primarily use an SDP-based RTSP URL: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/ipcam_h264.sdp ``` | URL Pattern | Description | | --- | --- | | `/ipcam.sdp` | SDP-based stream (older IC series) | | `/ipcam_h264.sdp` | H.264 SDP stream (recommended for most models) | | `/stream1` | Primary stream (newer IR/PT series) | | `/stream2` | Secondary stream (newer IR/PT series) | | `/live1.sdp` | Live SDP stream (PT series) | ### Camera Models | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | IC-1500WG (VGA wireless) | VGA | `rtsp://IP:554/ipcam.sdp` | Older SDP format | | IC-3010 (HD) | HD | `rtsp://IP:554/ipcam.sdp` | Older SDP format | | IC-3015WN (HD wireless) | HD Wireless | `rtsp://IP:554/ipcam.sdp` | Wi-Fi, SDP format | | IC-3030WN (HD wireless) | HD Wireless | `rtsp://IP:554/ipcam.sdp` | Wi-Fi, SDP format | | IC-3030IWN (HD wireless) | HD Wireless | `rtsp://IP:554/ipcam.sdp` | Indoor Wi-Fi | | IC-3100W (HD wireless) | HD Wireless | `rtsp://IP:554/ipcam_h264.sdp` | H.264 SDP format | | IC-3110W (HD wireless) | HD Wireless | `rtsp://IP:554/ipcam_h264.sdp` | H.264 SDP format | | IC-3116W (HD wireless) | HD Wireless | `rtsp://IP:554/ipcam_h264.sdp` | H.264 SDP format | | IC-7000 (HD PTZ) | HD PTZ | `rtsp://IP:554/ipcam.sdp` | Pan/tilt/zoom | | IC-7010PTN (HD PTZ) | HD PTZ | `rtsp://IP:554/ipcam.sdp` | Network PTZ | | IC-7100 (HD PTZ) | HD PTZ | `rtsp://IP:554/ipcam_h264.sdp` | H.264 PTZ | | IC-7110P (HD PTZ PoE) | HD PTZ | `rtsp://IP:554/ipcam_h264.sdp` | PoE PTZ | | IC-7110W (HD PTZ wireless) | HD PTZ | `rtsp://IP:554/ipcam_h264.sdp` | Wi-Fi PTZ | | IC-9000 (outdoor) | Outdoor | `rtsp://IP:554/CHANNEL/USERNAME:PASSWORD/main` | Credential-in-URL | | IR-112E (infrared) | Infrared | `rtsp://IP:554//stream2` | Newer stream format | | IR-113E (infrared) | Infrared | `rtsp://IP:554//stream1` | Newer stream format | | PT-112E (pan/tilt) | Pan/Tilt | `rtsp://IP:554/live1.sdp` | Live SDP format | | PT-31E (pan/tilt) | Pan/Tilt | `rtsp://IP:8000//stream1` | Port 8000 | | VS100 (video server) | Video Server | `rtsp://IP:554//stream1` | Encoder/server | ### Alternative URL Formats Some Edimax models and firmware versions support these additional RTSP URLs: | URL Pattern | Supported Models | Notes | | --- | --- | --- | | `rtsp://IP:554/ipcam.sdp` | IC-1500, IC-3010, IC-3015WN, IC-3030WN, IC-7000, IC-7010PTN | Older SDP format | | `rtsp://IP:554/ipcam_h264.sdp` | IC-3100W, IC-3110W, IC-3116W, IC-7100, IC-7110P, IC-7110W | H.264 SDP (recommended) | | `rtsp://IP:554//stream1` | IR-113E, VS100 | Newer stream format (note double slash) | | `rtsp://IP:554//stream2` | IR-112E | Sub stream (double slash) | | `rtsp://IP:554/stream1` | Select newer models | Stream without double slash | | `rtsp://IP:554/live1.sdp` | PT-112E | Live SDP for pan/tilt | | `rtsp://IP:8000//stream1` | PT-31E | Non-standard port 8000 | ## Connecting with VisioForge SDK Use your Edimax camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Edimax IC-3116W, H.264 main stream var uri = new Uri("rtsp://192.168.1.90:554/ipcam_h264.sdp"); var username = "admin"; var password = "1234"; ``` For newer IR/PT series models, use `/stream1` or `//stream1` instead of `/ipcam_h264.sdp`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/snapshot.jpg` | Basic snapshot, may require auth | | Snapshot (account auth) | `http://IP/snapshot.jpg?account=USER&password=PASS` | Older firmware auth style | | Snapshot (user auth) | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | Newer firmware auth style | | JPEG Image | `http://IP/jpg/image.jpg` | Direct JPEG | | Channel JPEG | `http://IP/jpg/1/image.jpg` | Channel-specific JPEG | | MJPEG Stream | `http://IP/mjpg/video.mjpg` | Continuous MJPEG stream | | Channel MJPEG | `http://IP/mjpg/1/video.mjpg` | Channel-specific MJPEG | | CGI Snapshot | `http://IP/snapshot.cgi` | CGI-based snapshot | | CGI MJPEG | `http://IP/cgi/mjpg/mjpeg.cgi` | CGI MJPEG stream | | Stream CGI | `http://IP/cgi-bin/Stream?Video` | Alternative video stream | ## Troubleshooting ### "401 Unauthorized" error Edimax cameras ship with default credentials of **admin / 1234**. If authentication fails: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Log in with the default credentials or the ones you configured 3. Navigate to **Configuration > Security** to verify or reset credentials 4. Use those credentials in your RTSP URL ### URL format not working Edimax has used several different RTSP URL formats across model generations. If your URL does not connect: 1. Try `/ipcam_h264.sdp` first (works with most mid-generation models) 2. Try `/ipcam.sdp` for older IC-1500 and IC-3000 series 3. Try `//stream1` (with double slash) for newer IR and PT series 4. Try `/stream1` (single slash) if double slash fails 5. Check if your model uses port 8000 instead of 554 (e.g., PT-31E) ### Double-slash URLs Some newer Edimax models use a double-slash in the RTSP path (e.g., `rtsp://IP:554//stream1`). This is intentional and not a typo. If `/stream1` does not work, try `//stream1`. ### Port 554 vs port 8000 Most Edimax cameras use the standard RTSP port 554, but some models (such as the PT-31E) use port 8000. Check your camera's web interface under **Configuration > Network > RTSP** for the correct port setting. ### Snapshot authentication style If snapshot URLs return 401 errors even with correct credentials, try switching between the two authentication parameter styles: - Older firmware: `?account=USER&password=PASS` - Newer firmware: `?user=USER&pwd=PASS` ## FAQ **What is the default RTSP URL for Edimax cameras?** For most Edimax IC series cameras, the URL is `rtsp://admin:1234@CAMERA_IP:554/ipcam_h264.sdp`. For newer IR and PT series, use `rtsp://admin:1234@CAMERA_IP:554//stream1`. The exact format depends on the model and firmware version. **Do Edimax cameras support ONVIF?** Newer Edimax models support ONVIF. Older IC-1500 and IC-3000 series models may not have ONVIF support. Check your camera's specifications or web interface for ONVIF settings. **Why does my Edimax camera use a double slash in the URL?** Some newer Edimax models (IR and PT series) use a double-slash path format like `//stream1`. This is the correct format for those models and is not a typo. Both `//stream1` and `/stream1` may work depending on the firmware version. **What is the difference between ipcam.sdp and ipcam\_h264.sdp?** `/ipcam.sdp` is the generic SDP stream used by older models and may deliver either MJPEG or H.264 depending on the camera configuration. `/ipcam_h264.sdp` explicitly requests the H.264 encoded stream and is recommended for better compression and quality. **Can I use both snapshot authentication styles?** No. Each camera firmware version supports only one authentication style for HTTP URLs. Older firmware uses `account=USER&password=PASS` while newer firmware uses `user=USER&pwd=PASS`. Try both to determine which your camera expects. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Zavio Connection Guide](../zavio/) — Taiwanese SMB cameras - [RTSP Video Streaming Guide](../../general/network-streaming/rtsp/) — Edimax RTSP network streaming - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Eufy Security Camera RTSP Connection Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/eufy/ **Description:** Eufy camera RTSP integration for C# .NET developers. Which eufyCam, SoloCam, and Indoor Cam models support RTSP/ONVIF, plus VisioForge SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to Eufy Security Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Eufy Security** is a smart home security brand owned by **Anker Innovations**, headquartered in Changsha, China. Eufy is known for local storage (no mandatory cloud subscription), AI-powered detection, and a wide range of indoor, outdoor, battery, and doorbell cameras. RTSP and ONVIF support varies significantly by model and firmware version. **Key facts:** - **Product lines:** eufyCam (battery), SoloCam (standalone), Indoor Cam, Floodlight Cam, Video Doorbell, HomeBase - **Protocol support:** RTSP (select models, must be enabled), ONVIF (newer firmware), Eufy Security app - **Default RTSP port:** 554 - **Default credentials:** No standard defaults — set during RTSP enablement - **ONVIF support:** Added in recent firmware updates for many models - **Video codecs:** H.264, H.265 (select models) - **Local storage:** Yes — HomeBase or camera microSD (no cloud required for recording) RTSP/ONVIF Support Varies by Model Eufy has been gradually adding RTSP and ONVIF support across its product line through firmware updates. Not all models support these features. Check the Eufy Security app settings for your specific camera to see if RTSP is available. ## RTSP Support by Model | Model | RTSP | ONVIF | Notes | | --- | --- | --- | --- | | eufyCam 2 / 2 Pro | Yes (via HomeBase) | Yes | Requires HomeBase 2 | | eufyCam 2C / 2C Pro | Yes (via HomeBase) | Yes | Requires HomeBase 2 | | eufyCam 3 / 3C | Yes (via HomeBase 3) | Yes | Requires HomeBase 3 | | eufyCam S330 | Yes (via HomeBase 3) | Yes | 4K model | | SoloCam S340 | Yes | Yes | Dual-lens, standalone RTSP | | SoloCam C210 | Yes | Yes | Standalone with RTSP | | Indoor Cam 2K | Yes | Yes | WiFi, firmware-dependent | | Indoor Cam Pan & Tilt | Yes | Yes | WiFi, firmware-dependent | | Floodlight Cam 2 Pro | Yes | Yes | Wired | | Video Doorbell 2K | Limited | No | Via HomeBase only | | Video Doorbell Dual | Limited | No | Via HomeBase only | ## Enabling RTSP ### For HomeBase-Connected Cameras (eufyCam series) 1. Open the **Eufy Security** app 2. Go to **HomeBase Settings > Storage > NAS** or **RTSP** 3. Enable RTSP streaming 4. Set an RTSP username and password 5. Note the RTSP URL displayed for each camera ### For Standalone Cameras (SoloCam, Indoor Cam, Floodlight) 1. Open the **Eufy Security** app 2. Select your camera → **Settings** (gear icon) 3. Look for **RTSP** or **Advanced > RTSP Stream** 4. Enable RTSP and set credentials 5. Note the RTSP URL provided ## RTSP URL Patterns ### Standard URL Format ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/live0 ``` | Stream | URL Pattern | Description | | --- | --- | --- | | Main stream | `rtsp://IP:554/live0` | Full resolution | | Sub stream | `rtsp://IP:554/live1` | Lower resolution | ### HomeBase RTSP URLs When connected through a HomeBase, the RTSP URL points to the HomeBase IP: ``` rtsp://[USERNAME]:[PASSWORD]@[HOMEBASE_IP]:554/live0 ``` For multiple cameras on one HomeBase, each camera gets a unique stream path shown in the app. ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/live0` | Main stream (common) | | `rtsp://IP:554/live1` | Sub stream | | `rtsp://IP:554/stream1` | Alternative format (some models) | | `rtsp://IP:554/h264_stream` | H.264 explicit (some firmware) | ## Connecting with VisioForge SDK Use your Eufy camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Eufy SoloCam S340, main stream var uri = new Uri("rtsp://192.168.1.90:554/live0"); var username = "rtsp_user"; // set in Eufy Security app var password = "rtsp_pass"; ``` For sub-stream access, use `/live1` instead of `/live0`. ## Troubleshooting ### RTSP option not visible in app RTSP support requires specific firmware versions. Update your camera and HomeBase firmware through the Eufy Security app. If RTSP still does not appear, your model may not yet support it. ### HomeBase vs standalone RTSP - **HomeBase cameras** (eufyCam series): RTSP streams come from the **HomeBase IP**, not the camera IP. The HomeBase acts as a proxy. - **Standalone cameras** (SoloCam, Indoor Cam): RTSP streams come directly from the **camera IP**. ### Stream drops on battery cameras Battery-powered eufyCam models may stop RTSP streaming when in standby mode. The camera must be actively recording or in "always streaming" mode for continuous RTSP access. This significantly impacts battery life. ### ONVIF discovery Newer Eufy firmware supports ONVIF discovery. Use ONVIF to automatically find cameras on your network instead of manually configuring RTSP URLs. ### Firmware inconsistencies Eufy has been rolling out RTSP/ONVIF support gradually. Different cameras in your setup may have different capabilities depending on their firmware version. Always update all devices to the latest firmware. ## FAQ **Do Eufy cameras support RTSP?** Many Eufy cameras now support RTSP, but it must be enabled in the Eufy Security app and varies by model. HomeBase-connected cameras stream RTSP through the HomeBase, while standalone cameras stream directly. Check your specific model's capabilities in the app settings. **Do Eufy cameras require a cloud subscription for RTSP?** No. RTSP streaming works locally without any cloud subscription. Eufy cameras store footage on the HomeBase or camera microSD card. The cloud subscription (Eufy Security Plan) is optional and provides additional cloud storage and features. **Can I use Eufy cameras without the Eufy app?** Initial setup requires the Eufy Security app. After setup and RTSP enablement, you can access the RTSP stream without the app. However, firmware updates and configuration changes still require the app. **What is the difference between HomeBase RTSP and standalone RTSP?** HomeBase RTSP streams all connected cameras through the HomeBase's IP address. The HomeBase acts as a gateway. Standalone cameras (SoloCam, Indoor Cam, Floodlight) stream directly from their own IP. HomeBase RTSP may have slightly higher latency. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Arlo Connection Guide](../arlo/) — Consumer alternative (no RTSP) - [Reolink Connection Guide](../reolink/) — Consumer with native RTSP - [EZVIZ Connection Guide](../ezviz/) — Smart home cameras with RTSP - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## EverFocus IP Camera RTSP URL Connection Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/everfocus/ **Description:** EverFocus EAN, EHN, EMN, EPN, and EQN series RTSP URL patterns for C# .NET. Stream and record using VisioForge Video Capture SDK integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to EverFocus IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **EverFocus Electronics** is a Taiwanese professional surveillance company headquartered in New Taipei City, Taiwan, with US operations based in Duarte, California. Founded in 1995, EverFocus manufactures IP cameras, DVRs, and mobile surveillance solutions designed for professional security integrators. The company is well-known in the commercial and industrial surveillance market. **Key facts:** - **Product lines:** EAN (bullet), EHN (dome), EMN (mini dome), EPN (PTZ), EZN (compact), EQN (turret), ECOR/EPARA (DVRs) - **Protocol support:** RTSP, ONVIF, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (all current IP cameras) - **Video codecs:** H.264 (all current models) EverFocus RTSP URL Format EverFocus cameras use a unique `rtspStreamOvf` path in their RTSP URLs. This format is specific to EverFocus and should not be confused with other manufacturers' URL patterns. Note the required double-slash (`//`) before `cgi-bin`. ## RTSP URL Patterns ### Standard URL Format EverFocus cameras use the `rtspStreamOvf` CGI path for RTSP streaming: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554//cgi-bin/rtspStreamOvf/0 ``` | Parameter | Value | Description | | --- | --- | --- | | Stream index | `/0` | Main stream (highest resolution) | | Stream index | `/1` | Sub stream (lower resolution, less bandwidth) | Double-Slash Required The URL path must include a double-slash before `cgi-bin` (i.e., `//cgi-bin/rtspStreamOvf/...`). Omitting the leading slash will cause the connection to fail. ### Primary URL Format (rtspStreamOvf) Most EverFocus IP cameras use the `rtspStreamOvf` format: | Model | Series | Main Stream URL | Sub Stream URL | | --- | --- | --- | --- | | EAN3220 | EAN (bullet) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | | EHN3260 | EHN (dome) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | | EMN2220 | EMN (mini dome) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | | EMN1360 | EMN (mini dome) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | | EMN3260 | EMN (mini dome) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | | EPN4220 | EPN (PTZ) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | | EZN3160 | EZN (compact) | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | `rtsp://IP:554//cgi-bin/rtspStreamOvf/1` | ### Alternative URL Format (streaming/channels) Some newer EverFocus models also support the `streaming/channels` format: | Model | Series | Main Stream URL | | --- | --- | --- | | EPN4220 | EPN (PTZ) | `rtsp://IP:554/streaming/channels/0` | | EZN3240 | EZN (compact) | `rtsp://IP:554/streaming/channels/0` | | EHN3260 | EHN (dome) | `rtsp://IP:554/streaming/channels/0` | Which Format to Use Try the `rtspStreamOvf` format first, as it is supported across all EverFocus IP camera product lines. The `streaming/channels` format is an alternative available on select newer models. ## Connecting with VisioForge SDK Use your EverFocus camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // EverFocus EHN3260, main stream var uri = new Uri("rtsp://192.168.1.90:554//cgi-bin/rtspStreamOvf/0"); var username = "admin"; var password = "admin"; ``` For sub-stream access, use `/1` instead of `/0` at the end of the URL. ## Snapshot and MJPEG URLs | Type | URL Pattern | Supported Models | | --- | --- | --- | | Snapshot (with auth) | `http://IP/snapshot.jpg?user=USER&pwd=PASS&strm=CHANNEL` | EQN2101 | | Snapshot (simple) | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | General IP cameras | | Mobile snapshot | `http://IP/m/camera[CHANNEL].jpg` | ECOR/EPARA DVRs | DVR Snapshots For ECOR and EPARA DVR models, replace `[CHANNEL]` with the camera channel number (e.g., `camera1.jpg` for channel 1). ## Troubleshooting ### Connection refused or timeout EverFocus cameras use the `rtspStreamOvf` CGI path which is unique to this brand. Make sure you are not accidentally using a URL format from another manufacturer: 1. Verify the URL includes the double-slash: `//cgi-bin/rtspStreamOvf/0` 2. Confirm the RTSP port is 554 (or check the camera's network settings for a custom port) 3. Ensure the camera is accessible on the network by pinging its IP address ### Stream index starts at 0 Unlike some other camera brands where channels start at 1, EverFocus stream indices start at **0**: - `/0` = Main stream (full resolution) - `/1` = Sub stream (reduced resolution) Using `/1` expecting the main stream will return the sub stream instead. ### Alternative URL format not working The `streaming/channels/0` URL format is only available on certain newer models (EPN4220, EZN3240, EHN3260). If this format does not work, fall back to the standard `//cgi-bin/rtspStreamOvf/0` format. ### Authentication issues EverFocus cameras default to `admin` / `admin`. If you have changed the password via the web interface and forgotten it, a hardware reset button on the camera will restore factory defaults. ## FAQ **What is the default RTSP URL for EverFocus cameras?** The default URL is `rtsp://admin:admin@CAMERA_IP:554//cgi-bin/rtspStreamOvf/0` for the main stream. Use `/1` at the end for the sub stream. Note the double-slash before `cgi-bin` which is required. **Why does the EverFocus RTSP URL look different from other cameras?** EverFocus uses a proprietary `rtspStreamOvf` CGI path that is unique to their camera firmware. This is different from the more common formats used by Hikvision, Dahua, or ONVIF generic paths. The double-slash (`//cgi-bin/...`) is intentional and required. **Do EverFocus cameras support ONVIF?** Yes. All current EverFocus IP cameras support ONVIF, which provides a standardized way to discover and connect to the camera. You can use ONVIF as an alternative to the proprietary RTSP URL format. **Can I connect to EverFocus DVRs (ECOR/EPARA) via RTSP?** EverFocus DVRs primarily expose HTTP-based snapshot URLs for individual channels (`http://IP/m/camera[CHANNEL].jpg`). For RTSP streaming from DVR channels, consult your specific DVR model's documentation or use ONVIF discovery. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Speco Connection Guide](../speco/) — Professional surveillance cameras - [RTSP Video Streaming Guide](../../general/network-streaming/rtsp/) — EverFocus RTSP streaming setup - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## EZVIZ IP Camera RTSP URL and Connection Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/ezviz/ **Description:** Connect to EZVIZ cameras in C# .NET with RTSP URL patterns for C1C, C3W, C6N, BC1C and other models. Enable RTSP on cloud-first cameras. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to EZVIZ IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **EZVIZ** is a consumer smart home and security camera brand owned by **Hikvision**. Originally launched as Hikvision's consumer division, EZVIZ became an independent brand focused on home cameras, doorbells, smart locks, and IoT devices. EZVIZ cameras are designed primarily for cloud-based use via the EZVIZ app, but many models support local RTSP streaming when enabled. **Key facts:** - **Product lines:** C-series (indoor/outdoor), BC-series (battery), DB-series (doorbells), H-series (pan/tilt) - **Protocol support:** RTSP (must be enabled), ONVIF (limited models), EZVIZ Cloud (default) - **Default RTSP port:** 554 - **Default credentials:** admin / verification code (printed on camera label) - **ONVIF support:** Limited (some newer models only) - **Video codecs:** H.264, H.265 (select models) - **Parent company:** Hikvision RTSP Must Be Enabled Manually EZVIZ cameras are cloud-first devices. **RTSP is disabled by default** on most models. You must enable RTSP through the EZVIZ mobile app or web portal before connecting with the VisioForge SDK. Some budget and battery-powered models do not support RTSP at all. ## Enabling RTSP on EZVIZ Cameras Before connecting, enable RTSP access: 1. Open the **EZVIZ app** on your phone 2. Select your camera → **Settings** (gear icon) 3. Navigate to **Local Network** or **LAN access** 4. Enable **RTSP** or **Third-party access** 5. Note the verification code (usually printed on the camera label or shown in app) Alternatively, use the EZVIZ web portal at `https://www.ezvizlife.com` to manage camera settings. ## RTSP URL Patterns ### Standard URL Format EZVIZ cameras use Hikvision-derived RTSP URL patterns: ``` rtsp://admin:[VERIFICATION_CODE]@[IP]:554/h264/ch1/main/av_stream ``` | Stream | URL Pattern | Description | | --- | --- | --- | | Main stream | `rtsp://IP:554/h264/ch1/main/av_stream` | Full resolution | | Sub stream | `rtsp://IP:554/h264/ch1/sub/av_stream` | Lower resolution | Verification Code as Password EZVIZ cameras use the **verification code** (printed on the camera label) as the RTSP password. The username is always `admin`. This is different from the EZVIZ cloud account password. ### Alternative URL Formats Some EZVIZ models support additional URL patterns: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/h264/ch1/main/av_stream` | Standard (recommended) | | `rtsp://IP:554/h264/ch1/sub/av_stream` | Sub stream | | `rtsp://IP:554/Streaming/Channels/101` | Hikvision-style (some models) | | `rtsp://IP:554/Streaming/Channels/102` | Hikvision-style sub stream | | `rtsp://IP:554/live` | Simple path (older models) | ### Camera Models | Model | Type | RTSP Support | Main Stream URL | | --- | --- | --- | --- | | C6N (indoor pan/tilt) | Indoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | C6W (4MP indoor PT) | Indoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | C1C (1080p indoor) | Indoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | H6c (pan/tilt) | Indoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | H8c (outdoor PT) | Outdoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | C3W (outdoor bullet) | Outdoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | C3WN (outdoor bullet) | Outdoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | C3X (dual-lens outdoor) | Outdoor | Yes | `rtsp://IP:554/h264/ch1/main/av_stream` | | BC1C (battery cam) | Battery | No | N/A — cloud-only | | DB1C (doorbell) | Doorbell | No | N/A — cloud-only | Battery and Doorbell Models EZVIZ battery-powered cameras (BC series) and video doorbells (DB series) generally do **not** support RTSP. These devices only stream through the EZVIZ cloud. Only AC-powered cameras with wired network or stable WiFi connections support RTSP. ## Connecting with VisioForge SDK Use your EZVIZ camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // EZVIZ C6N, main stream (verification code from label) var uri = new Uri("rtsp://192.168.1.90:554/h264/ch1/main/av_stream"); var username = "admin"; var password = "ABCDEF"; // verification code from camera label ``` For sub-stream access, use `/h264/ch1/sub/av_stream` instead. ## Snapshot URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Requires basic auth with verification code | ## Troubleshooting ### "Connection refused" or no response RTSP is disabled by default on EZVIZ cameras. You must enable it through the EZVIZ app first. Check **Settings > Local Network > Third-party access**. ### Wrong password EZVIZ cameras use the **verification code** (6 uppercase letters printed on the camera label) as the RTSP password, **not** your EZVIZ cloud account password. The username is always `admin`. ### Camera not on local network EZVIZ cameras connect to the cloud via WiFi. To use RTSP, the camera and your application must be on the same local network. The camera's local IP can be found in the EZVIZ app under **Device Info** or in your router's DHCP client list. ### RTSP option not available in app Some EZVIZ models and firmware versions do not expose RTSP settings. In this case: 1. Update the camera firmware through the EZVIZ app 2. If RTSP still does not appear, the model may not support local streaming 3. Battery-powered and doorbell models typically do not support RTSP ### Hikvision URL format works on some models Since EZVIZ cameras use Hikvision firmware, some models also accept the Hikvision URL format (`/Streaming/Channels/101`). Try this if the standard EZVIZ URL does not work. ## FAQ **What is the default RTSP URL for EZVIZ cameras?** The standard URL is `rtsp://admin:VERIFICATION_CODE@CAMERA_IP:554/h264/ch1/main/av_stream`. The VERIFICATION\_CODE is the 6-character code printed on your camera's label. RTSP must be enabled in the EZVIZ app first. **Is EZVIZ related to Hikvision?** Yes. EZVIZ is a brand owned by Hikvision, focused on the consumer smart home market. EZVIZ cameras use Hikvision-derived firmware, which is why similar RTSP URL patterns work. However, EZVIZ cameras are designed primarily for cloud-based use. **Can I use EZVIZ cameras without the cloud?** Partially. You can access RTSP streams locally without the EZVIZ cloud for live viewing and recording. However, initial camera setup, firmware updates, and enabling RTSP require the EZVIZ app (which uses the cloud). Features like motion alerts and clip storage require an EZVIZ cloud subscription. **Do EZVIZ cameras support ONVIF?** Some newer EZVIZ models support ONVIF, but it is not available on all cameras. Check your camera's specifications or the EZVIZ app settings for ONVIF support. For most EZVIZ cameras, direct RTSP connection is more reliable than ONVIF. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Hikvision Connection Guide](../hikvision/) — Parent company, similar URL format - [Imou Connection Guide](../imou/) — Dahua consumer brand, similar market - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## FLIR IP Camera RTSP Connection Guide in C# .NET SDK **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/flir/ **Description:** FLIR Quasar, Saros, and Elara thermal camera RTSP URL patterns for C# .NET. Teledyne FLIR integration with VisioForge Video Capture SDK code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, USB3 Vision / GigE, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to FLIR IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **FLIR Systems** (now **Teledyne FLIR** following the 2021 acquisition by Teledyne Technologies) is a leading manufacturer of thermal imaging cameras and visible-light security cameras. Headquartered in Wilsonville, Oregon, USA, FLIR serves enterprise, critical infrastructure, and government markets. FLIR is best known for thermal imaging but also produces a full range of visible-light IP cameras for professional surveillance. FLIR previously acquired **Lorex** and **DVTEL** (now FLIR Latitude VMS). **Key facts:** - **Product lines:** Quasar (premium multi-sensor/mini-dome), Saros (perimeter detection), Elara (thermal+visible dual-sensor), CM (compact mini dome), CF (compact fixed), PT/PTZ (pan-tilt-zoom), FC (thermal-only), FLIR FX (consumer, discontinued) - **Protocol support:** RTSP, ONVIF (Quasar, Saros, Elara series), HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / admin (most models), admin / fliradmin (some Quasar models) - **ONVIF support:** Yes (Quasar, Saros, Elara series) - **Video codecs:** H.264, H.265 (Quasar series), MJPEG - **Thermal specialization:** FLIR thermal cameras output radiometric data in addition to visible-light video, with separate RTSP streams for each sensor Thermal cameras have separate streams FLIR dual-sensor cameras (Elara, PT-series) provide separate RTSP streams for visible and thermal channels. Typically `ch0` is the visible channel and `ch1` is the thermal channel. ## RTSP URL Patterns ### Current Models (Quasar, Saros, Elara) | Stream | RTSP URL | Notes | | --- | --- | --- | | Visible channel | `rtsp://IP:554/ch0` | Primary visible stream | | Thermal channel | `rtsp://IP:554/ch1` | Thermal stream (dual-sensor models) | | Visible (alt) | `rtsp://IP:554/vis` | Visible on PT-series | | Wide FOV thermal | `rtsp://IP:554/wfov` | PT-series, wide field of view | | Auth stream | `rtsp://IP:554/0/USERNAME:PASSWORD/main` | With embedded credentials | ### Model-Specific URLs | Model Series | RTSP URL | Type | Notes | | --- | --- | --- | --- | | Quasar CM-3308 | `rtsp://IP:554/ch0` | Mini dome | Compact multi-sensor | | Quasar CM-6208 | `rtsp://IP:554/ch0` | Mini dome | Compact multi-sensor | | D-series (fixed dome) | `rtsp://IP:554/ch0` | Fixed dome | Visible stream | | F-series (fixed) | `rtsp://IP:554/ch0` | Fixed | Visible stream | | PT-series (PTZ-35x140) | `rtsp://IP:554/vis` | PTZ | Visible channel | | PT-series (PTZ-35x140) | `rtsp://IP:554/wfov` | PTZ | Wide FOV thermal | | Elara (visible) | `rtsp://IP:554/ch0` | Thermal+visible | Visible channel | | Elara (thermal) | `rtsp://IP:554/ch1` | Thermal+visible | Thermal channel | | FC-series (thermal) | `rtsp://IP:554/ch0` | Thermal only | Thermal stream | ### Dual-Sensor Thermal Cameras FLIR dual-sensor cameras provide both visible and thermal video on separate channels: | Stream | RTSP URL | Notes | | --- | --- | --- | | Elara visible | `rtsp://IP:554/ch0` | Visible-light sensor | | Elara thermal | `rtsp://IP:554/ch1` | Thermal sensor | | PT visible | `rtsp://IP:554/vis` | Visible-light sensor | | PT wide thermal | `rtsp://IP:554/wfov` | Wide FOV thermal sensor | ## Connecting with VisioForge SDK Use your FLIR camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // FLIR Quasar mini-dome, visible stream var uri = new Uri("rtsp://192.168.1.70:554/ch0"); var username = "admin"; var password = "admin"; ``` For dual-sensor cameras, use `ch1` to access the thermal stream. For PT-series cameras, use `/vis` for the visible channel or `/wfov` for the wide FOV thermal channel. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/jpg/image.jpg` | Some models | | Snapshot (alt) | `http://IP/snapshot.jpg` | Alternative path | ## Troubleshooting ### Thermal vs. visible channels FLIR dual-sensor cameras (Elara, PT-series) expose separate RTSP streams for each sensor: - `ch0` = visible-light channel (most models) - `ch1` = thermal channel (most models) - `/vis` = visible channel (PT-series) - `/wfov` = wide FOV thermal (PT-series) If you connect to the wrong channel, you may receive thermal imagery when you expected visible or vice versa. Check your camera's documentation for channel assignments. ### Default credentials differ by model - **Most FLIR cameras:** admin / admin - **Some Quasar models:** admin / fliradmin - **Current Teledyne FLIR firmware:** Password may need to be set during initial configuration Always change default credentials before deploying cameras on a production network. ### Teledyne FLIR rebranding Teledyne Technologies acquired FLIR Systems in 2021. Current firmware versions may display Teledyne FLIR branding, and newer cameras may ship with updated web interfaces and configuration tools. RTSP URL patterns remain consistent with legacy FLIR cameras. ### FLIR FX consumer cameras The discontinued FLIR FX consumer camera line used cloud-only access and does not support RTSP streaming. These cameras cannot be connected via direct RTSP URLs. ### FLIR Lorex cameras FLIR acquired Lorex, but Lorex cameras use their own RTSP URL patterns (based on Dahua firmware). Do not use FLIR URL patterns for Lorex cameras. See the [Lorex](../lorex/) page for Lorex-specific URLs. ### ONVIF availability ONVIF is supported on current-generation cameras (Quasar, Saros, Elara). Older FLIR cameras and consumer models (FLIR FX) do not support ONVIF. For ONVIF-supported models, use ONVIF discovery as an alternative to manual RTSP URL configuration. ## FAQ **What is the default RTSP URL for FLIR cameras?** For most FLIR cameras, use `rtsp://admin:admin@CAMERA_IP:554/ch0` for the visible stream. For dual-sensor thermal cameras, use `ch1` for the thermal stream. For PT-series cameras, use `/vis` (visible) or `/wfov` (wide FOV thermal). **Does FLIR support H.265?** Quasar-series cameras support H.265 encoding. Other FLIR camera lines primarily use H.264 and MJPEG. Check your specific model's datasheet for codec support. **How do I access the thermal stream on a FLIR dual-sensor camera?** Dual-sensor cameras provide separate RTSP streams for visible and thermal channels. On Elara models, `ch0` is visible and `ch1` is thermal. On PT-series models, `/vis` is visible and `/wfov` is the wide FOV thermal stream. Connect to the appropriate URL for the desired sensor. **Are FLIR and Teledyne FLIR the same company?** Yes. Teledyne Technologies acquired FLIR Systems in 2021. The company now operates as Teledyne FLIR. Existing FLIR cameras continue to work with the same RTSP URL patterns. Newer products may carry Teledyne FLIR branding. **Can I use FLIR URL patterns for Lorex cameras?** No. Although FLIR acquired Lorex, Lorex cameras use Dahua-based firmware with different RTSP URL patterns. See the [Lorex](../lorex/) camera connection guide for the correct URLs. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Basler Connection Guide](../basler/) — Industrial / machine vision cameras - [Mobotix Connection Guide](../mobotix/) — German industrial cameras - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Foscam IP Camera RTSP URL Guide and C# .NET Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/foscam/ **Description:** Connect to Foscam cameras in C# .NET with RTSP and HTTP URL patterns, CGI API access, and code samples for FI, C1, C2, R2, and R4 models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Foscam IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Foscam** (Shenzhen Foscam Intelligent Technology Co., Ltd.) is a Chinese manufacturer specializing in consumer and small business IP cameras. Founded in 2007 and headquartered in Shenzhen, China, Foscam gained popularity for affordable Wi-Fi cameras and was one of the first brands to bring low-cost IP cameras to the consumer market. **Key facts:** - **Product lines:** FI-series (legacy pan/tilt), C1/C2 (indoor HD), R2/R4 (indoor pan/tilt), SD (outdoor), G-series (battery), VZ-series (doorbell) - **Protocol support:** RTSP, HTTP/CGI, ONVIF (newer models), P2P - **Default RTSP port:** 88 (not 554 -- this is unique to Foscam) - **Default HTTP port:** 88 - **Default credentials:** admin / (blank password on older models); admin / (set during setup on newer models) - **ONVIF support:** Partial (newer HD models only, e.g., C1, C2, R2, R4) - **Video codecs:** H.264 (HD models), MJPEG (legacy models) ## RTSP URL Patterns Foscam cameras use a non-standard port (88) and simple stream path names. ### URL Format ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:88/videoMain ``` Non-standard port Foscam cameras typically use **port 88** for both RTSP and HTTP, not the standard port 554. This is the most common connection issue. ### HD Models (H.264) | Model Series | RTSP URL | Stream | Audio | | --- | --- | --- | --- | | C1 / C1 Lite (indoor) | `rtsp://IP:88/videoMain` | Main (720p) | Yes | | C1 / C1 Lite (indoor) | `rtsp://IP:88/videoSub` | Sub (VGA) | Yes | | C2 (indoor 1080p) | `rtsp://IP:88/videoMain` | Main (1080p) | Yes | | C2 (indoor 1080p) | `rtsp://IP:88/videoSub` | Sub (VGA) | Yes | | R2 (pan/tilt 1080p) | `rtsp://IP:88/videoMain` | Main (1080p) | Yes | | R4 (pan/tilt 1440p) | `rtsp://IP:88/videoMain` | Main (2560x1440) | Yes | | FI9821W V2 (pan/tilt) | `rtsp://IP:88/videoMain` | Main (720p) | Yes | | FI9826W (pan/tilt/zoom) | `rtsp://IP:88/videoMain` | Main (960p) | Yes | | FI9828P (outdoor PTZ) | `rtsp://IP:88/videoMain` | Main (960p) | Yes | | FI9900P (outdoor bullet) | `rtsp://IP:88/videoMain` | Main (1080p) | Yes | | SD2 (outdoor pan/tilt) | `rtsp://IP:88/videoMain` | Main (1080p) | Yes | ### Legacy Models (MJPEG only) Older Foscam models (FI8904W, FI8910W, FI8918W, FI8919W) do not support RTSP. They use HTTP streaming only: | Model | HTTP URL | Type | Audio | | --- | --- | --- | --- | | FI8904W | `http://IP:88/videostream.asf?user=USER&pwd=PASS` | ASF stream | Yes | | FI8910W | `http://IP:88/videostream.asf?user=USER&pwd=PASS` | ASF stream | Yes | | FI8918W | `http://IP:88/videostream.asf?user=USER&pwd=PASS` | ASF stream | Yes | | FI8919W | `http://IP:88/videostream.asf?user=USER&pwd=PASS` | ASF stream | Yes | | FI8904W | `http://IP:88/videostream.cgi?user=USER&pwd=PASS&resolution=32` | MJPEG | No | ### Alternative RTSP Ports Some Foscam models can be configured for alternative ports: | URL Pattern | Port | Notes | | --- | --- | --- | | `rtsp://IP:88/videoMain` | 88 | Default for most models | | `rtsp://IP:554/videoMain` | 554 | If reconfigured in settings | | `rtsp://IP:554/cam1/mpeg4` | 554 | Some OEM variants | | `rtsp://IP:554/live1.sdp` | 554 | DCS-compatible firmware | ## Connecting with VisioForge SDK Use your Foscam camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Foscam R2, main stream -- note port 88, not 554! var uri = new Uri("rtsp://192.168.1.30:88/videoMain"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/videoSub` instead. ## Snapshot and MJPEG URLs Foscam provides a CGI API for snapshots and control: | Type | URL Pattern | Notes | | --- | --- | --- | | CGI Snapshot (HD) | `http://IP:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=USER&pwd=PASS` | HD models | | Legacy Snapshot | `http://IP:88/snapshot.cgi?user=USER&pwd=PASS` | Legacy models | | Snapshot (count) | `http://IP:88/snapshot.cgi?user=USER&pwd=PASS&count=0` | Single frame | | MJPEG Stream (legacy) | `http://IP:88/videostream.cgi?user=USER&pwd=PASS&resolution=32` | VGA MJPEG | | ASF Stream (legacy) | `http://IP:88/videostream.asf?user=USER&pwd=PASS` | ASF container | | Video CGI | `http://IP:88/video.cgi?resolution=VGA` | Direct video | ## Troubleshooting ### Wrong port -- must use 88, not 554 The most common Foscam connection issue is using port 554. Foscam cameras default to **port 88** for all services (RTSP, HTTP, and CGI). If your connection times out, check the port number first. ### Legacy vs HD models Foscam has two fundamentally different product generations: - **Legacy (FI89xx):** MJPEG only, HTTP streaming via `videostream.asf` or `videostream.cgi`, no RTSP - **HD (C1, C2, R2, R4, FI99xx):** H.264, RTSP via `videoMain`/`videoSub`, ONVIF support If `rtsp://IP:88/videoMain` doesn't work, your camera is likely a legacy model -- use the HTTP streaming URLs instead. ### Blank/empty password Older Foscam cameras ship with a blank password (username: `admin`, password: empty string). Newer firmware requires setting a password during initial setup. If authentication fails with a password, try an empty password for legacy models. ### Wi-Fi connection instability Foscam Wi-Fi cameras can experience stream dropouts. Recommendations: - Use TCP transport mode for reliability - Position camera closer to the Wi-Fi router - Use 2.4GHz Wi-Fi (better range) instead of 5GHz - Reduce stream resolution to sub stream: `rtsp://IP:88/videoSub` ### ONVIF not available ONVIF is only supported on newer HD models (C1, C2, R2, R4, FI99xx). Legacy FI89xx cameras do not support ONVIF. For legacy models, use direct HTTP/RTSP URLs instead. ## FAQ **What is the default RTSP URL for Foscam cameras?** For HD models, the URL is `rtsp://admin:password@CAMERA_IP:88/videoMain`. Note the non-standard port 88 (not 554). For legacy models (FI89xx series), use HTTP: `http://CAMERA_IP:88/videostream.asf?user=admin&pwd=password`. **Why does Foscam use port 88 instead of the standard 554?** Foscam chose port 88 as their default for all camera services to avoid conflicts with other network devices. You can change this in the camera's web interface under Settings > Network > Port, but the default is 88. **Can I change the Foscam RTSP port to 554?** Yes. Access the camera's web interface at `http://CAMERA_IP:88`, go to Settings > Network > Port, and change the RTSP port to 554. After saving and rebooting, you can use the standard port 554 in your RTSP URLs. **Does Foscam support pan/tilt/zoom control via the SDK?** Foscam PTZ models (R2, R4, FI9821, FI9826) support pan/tilt via their CGI API and ONVIF (HD models). You can send PTZ commands through ONVIF using the VisioForge SDK's PTZ control features. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [TP-Link Connection Guide](../tp-link/) — Consumer cameras with RTSP - [D-Link Connection Guide](../dlink/) — Consumer segment peer - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## GeoVision IP Camera RTSP URL Setup and C# .NET Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/geovision/ **Description:** GeoVision GV-BL, GV-FD, GV-VD, GV-FE, and GV-DVR RTSP URL patterns for C# .NET. Integrate with VisioForge SDK for multi-channel surveillance apps. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to GeoVision IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **GeoVision** (GeoVision Inc.) is a Taiwanese manufacturer of IP cameras, network video recorders, and video management software, headquartered in Taipei, Taiwan. GeoVision is a well-established brand in the enterprise and professional surveillance market, known for their GV-series IP cameras and the GeoVision VMS platform. **Key facts:** - **Product lines:** GV-BL (bullet), GV-FD (fixed dome), GV-VD (vandal dome), GV-FE (fisheye), GV-CB (cube), GV-CA (camera), GV-DVR (digital video recorder), GV-NVR - **Protocol support:** RTSP, ONVIF, PSIA, HTTP/CGI - **Default RTSP port:** 8554 (IP cameras), 554 (DVR/Server) - **Default credentials:** admin / admin - **ONVIF support:** Yes (current models) - **Video codecs:** H.264, H.265 (current models), MPEG-4 (legacy) Non-standard RTSP port GeoVision IP cameras use **port 8554** by default, not the standard 554. Make sure to specify the correct port when constructing your RTSP URL. GeoVision DVR/Server software uses the standard port 554. ## RTSP URL Patterns ### IP Camera Standard Format GeoVision IP cameras use a channel-based SDP URL pattern on port 8554: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:8554//CH001.sdp ``` | Parameter | Value | Description | | --- | --- | --- | | Port | 8554 | Default for GeoVision IP cameras | | `CH001` | CH001, CH002... | Channel number (zero-padded 3 digits) | | `.sdp` | Required | SDP session descriptor suffix | Double slash Some GeoVision models require a double slash (`//`) before the channel identifier. If a single slash does not work, try `//CH001.sdp`. ### IP Camera Streams | Stream | URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:8554//CH001.sdp` | Full resolution, port 8554 | | Sub stream | `rtsp://IP:8554//CH002.sdp` | Lower resolution | ### DVR / GeoVision Server GeoVision DVR and GV-Server software use port 554: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/CH001.sdp ``` | Channel | Main Stream URL | Notes | | --- | --- | --- | | Channel 1 | `rtsp://IP:554/CH001.sdp` | Port 554 on DVR/Server | | Channel 2 | `rtsp://IP:554/CH002.sdp` | Port 554 on DVR/Server | | Channel N | `rtsp://IP:554/CH00N.sdp` | Zero-pad to 3 digits | ### PSIA Streaming GeoVision also supports PSIA-compatible RTSP URLs: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/PSIA/Streaming/channels/1?videoCodecType=MPEG4 ``` ### URL Summary Table | Device Type | Main Stream URL | Default Port | Notes | | --- | --- | --- | --- | | GV-BL (bullet) | `rtsp://IP:8554//CH001.sdp` | 8554 | Standard IP camera | | GV-FD (fixed dome) | `rtsp://IP:8554//CH001.sdp` | 8554 | Standard IP camera | | GV-VD (vandal dome) | `rtsp://IP:8554//CH001.sdp` | 8554 | Standard IP camera | | GV-FE (fisheye) | `rtsp://IP:8554//CH001.sdp` | 8554 | Standard IP camera | | GV-CB (cube) | `rtsp://IP:8554//CH001.sdp` | 8554 | Standard IP camera | | GV-DVR | `rtsp://IP:554/CH001.sdp` | 554 | DVR software | | GV-NVR | `rtsp://IP:554/CH001.sdp` | 554 | NVR software | | PSIA stream | `rtsp://IP:554/PSIA/Streaming/channels/1` | 554 | PSIA compatible | ## Connecting with VisioForge SDK Use your GeoVision camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // GeoVision GV-BL2702, main stream (note port 8554) var uri = new Uri("rtsp://192.168.1.90:8554//CH001.sdp"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `CH002.sdp` instead of `CH001.sdp`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Requires basic auth | | JPEG Snapshot (alt) | `http://IP/GetImage.cgi` | Some models | | JPEG Snapshot (alt) | `http://IP/cgi-bin/getimage` | Some models | | JPEG Snapshot (viewer) | `http://IP/cgi-bin/viewer/video.jpg` | Web viewer interface | | Static image (alt) | `http://IP/cgi-bin/jpg/image.cgi` | Some models | | Legacy snapshot | `http://IP/cam1.jpg` | Firmware 6.0-8.x, channel 1 | | Legacy snapshot (ch N) | `http://IP/camN.jpg` | Firmware 6.0-8.x, channel N | ## Troubleshooting ### Wrong port — 554 vs 8554 The most common connection issue with GeoVision cameras is using the wrong port: - **IP cameras** (GV-BL, GV-FD, GV-VD, GV-FE, GV-CB): Use **port 8554** - **DVR / GV-Server software**: Use **port 554** If you get a connection timeout, check that you are using the correct port for your device type. ### Double slash in URL path Some GeoVision IP camera models require a double slash before the channel identifier (`//CH001.sdp`). If a single slash (`/CH001.sdp`) returns an error, add the extra slash. ### Channel numbering format GeoVision uses zero-padded three-digit channel numbers: `CH001`, `CH002`, `CH003`, etc. Using `CH1` instead of `CH001` will not work. ### Firmware version differences Older GeoVision firmware versions (6.x-8.x) may use different snapshot URL formats. If the CGI-based snapshot URL does not work, try the legacy format (`http://IP/cam1.jpg`). ## FAQ **What port does GeoVision use for RTSP?** GeoVision IP cameras use **port 8554** by default, which differs from the industry-standard port 554. GeoVision DVR and GV-Server software use the standard port 554. **What is the default RTSP URL for GeoVision IP cameras?** The URL is `rtsp://admin:password@CAMERA_IP:8554//CH001.sdp` for the main stream. Use `CH002.sdp` for the sub stream. Note the double slash before `CH001` and port 8554. **Do GeoVision cameras support ONVIF?** Yes. All current GeoVision IP camera models support ONVIF Profile S. ONVIF discovery can be used as an alternative to manual RTSP URL configuration. **Can I connect to a GeoVision DVR and IP camera at the same time?** Yes. Connect to the DVR on port 554 and individual IP cameras on port 8554. Each device has its own IP address and RTSP endpoint. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Vivotek Connection Guide](../vivotek/) — Taiwanese enterprise cameras - [ACTi Connection Guide](../acti/) — Taiwanese professional cameras - [RTSP Camera Integration Guide](../../videocapture/video-sources/ip-cameras/rtsp/) — GeoVision RTSP stream setup - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Grandstream IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/grandstream/ **Description:** Integrate Grandstream GXV and GSC cameras into C# .NET apps via RTSP. URL patterns for GXV3500, GXV3610, GSC3610, plus VisioForge SDK examples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Grandstream IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Grandstream Networks** is an American company headquartered in Boston, Massachusetts, USA, known for VoIP phones and IP surveillance products. Grandstream offers IP cameras and video encoders under the **GXV** (legacy) and **GSC** (current generation) product lines, targeting SMB and professional markets. Their cameras are often deployed alongside Grandstream VoIP and UCM (Unified Communications Manager) systems. **Key facts:** - **Product lines:** GXV (IP cameras and video encoders, legacy), GSC (current generation smart cameras) - **Protocol support:** RTSP, ONVIF (GXV36xx and newer GSC series), HTTP/CGI, SIP (video calling) - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (GXV36xx and newer GSC models) - **Video codecs:** H.264, H.265 (current GSC models), MPEG-4 (legacy GXV models) ## RTSP URL Patterns ### Current GSC-Series Cameras Current generation Grandstream GSC cameras use a channel-based URL format: | Stream | RTSP URL | Notes | | --- | --- | --- | | Primary stream | `rtsp://IP:554/live/ch00_0` | Main stream, channel 0 | | Secondary stream | `rtsp://IP:554/live/ch00_1` | Sub stream | ### GXV-Series (Legacy) Older GXV cameras support multiple URL formats depending on the model: | Stream | RTSP URL | Notes | | --- | --- | --- | | Primary stream | `rtsp://IP:554//0` | Main stream (channel 0) | | Secondary stream | `rtsp://IP:554//4` | Sub stream (channel 4) | | H.264 SDP | `rtsp://IP:554/ipcam_h264.sdp` | SDP file-based access | | Live H.264 | `rtsp://IP:554/live/h264` | Named stream | | Channel-based | `rtsp://IP:554/[CHANNEL]` | Direct channel number | | Auth stream | `rtsp://IP:554//0/888888:888888/main` | With embedded credentials | | MPEG-4 (legacy) | `rtsp://IP:554/cam1/mpeg4?user=USER&pwd=PASS` | Legacy MPEG-4 stream | Unusual channel numbering Grandstream uses a non-standard channel numbering scheme. For single-channel cameras, channel **0** is the primary stream and channel **4** is the secondary stream. This differs from most other brands that use sequential numbering. ### Model-Specific URLs | Model | Primary Stream | Secondary Stream | Type | | --- | --- | --- | --- | | GXV3500 | `rtsp://IP:554/0` | `rtsp://IP:554/4` | Video encoder | | GXV3504 (ch 1) | `rtsp://IP:554/0` | `rtsp://IP:554/4` | 4-channel encoder | | GXV3504 (ch 2) | `rtsp://IP:554/1` | `rtsp://IP:554/5` | 4-channel encoder | | GXV3504 (ch 3) | `rtsp://IP:554/2` | `rtsp://IP:554/6` | 4-channel encoder | | GXV3504 (ch 4) | `rtsp://IP:554/3` | `rtsp://IP:554/7` | 4-channel encoder | | GXV3601 / GXV3611 | `rtsp://IP:554//4` | -- | Dome camera | | GXV3601 (alt) | `rtsp://IP:554/ipcam_h264.sdp` | -- | SDP-based | | GXV3610 | `rtsp://IP:554/0` | `rtsp://IP:554/4` | Dome HD | | GXV3651 / GXV3661 / GXV3662 | `rtsp://IP:554/0` | `rtsp://IP:554/4` | FHD cameras | | GXV3672 | `rtsp://IP:554//0` | `rtsp://IP:554/live/ch00_0` | HD/FHD outdoor | | GSC3610 / GSC3615 | `rtsp://IP:554/live/ch00_0` | `rtsp://IP:554/live/ch00_1` | Current dome | | GSC3620 | `rtsp://IP:554/live/ch00_0` | `rtsp://IP:554/live/ch00_1` | Current outdoor | ### Multi-Channel Encoder (GXV3504) Channel Map The GXV3504 is a 4-channel video encoder with the following channel numbering: | Input | Primary Channel | Secondary Channel | | --- | --- | --- | | Input 1 | 0 | 4 | | Input 2 | 1 | 5 | | Input 3 | 2 | 6 | | Input 4 | 3 | 7 | ## Connecting with VisioForge SDK Use your Grandstream camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Grandstream GSC-series camera, main stream var uri = new Uri("rtsp://192.168.1.60:554/live/ch00_0"); var username = "admin"; var password = "YourPassword"; ``` For legacy GXV models, use `rtsp://IP:554//0` for the primary stream or `rtsp://IP:554//4` for the secondary stream. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/snapshot/view0.jpg` | Channel 0 snapshot | | JPEG Snapshot (ch 1) | `http://IP/snapshot/view1.jpg` | Channel 1 (multi-channel) | | HTTP Stream | `http://IP/goform/stream?cmd=get&channel=0` | Channel-based HTTP stream | ## Troubleshooting ### Channel numbering confusion Grandstream channel numbering is unconventional: - **Single-channel cameras:** Channel 0 = primary stream, Channel 4 = secondary stream - **GXV3504 (4-channel encoder):** Channels 0-3 are primary streams for inputs 1-4; Channels 4-7 are secondary streams for inputs 1-4 If you get a blank stream or error, double-check you are using the correct channel number for your desired stream quality. ### Factory default credential `888888` Some older Grandstream GXV models use `888888` as the default password (or embedded in the RTSP URL as `888888:888888`). If `admin` / `admin` does not work, try `888888` as the password. ### RTSP not enabled On some older GXV models, RTSP streaming must be explicitly enabled in the camera's web interface. Navigate to the streaming or media settings page and confirm that RTSP is turned on and set to port 554. ### Multiple URL formats per model Many GXV cameras support several RTSP URL formats simultaneously. If one format does not work, try the alternatives: 1. `rtsp://IP:554//0` (channel number with double slash) 2. `rtsp://IP:554/live/ch00_0` (named channel) 3. `rtsp://IP:554/ipcam_h264.sdp` (SDP file) 4. `rtsp://IP:554/live/h264` (named stream) ### Codec compatibility Current GSC-series cameras support H.265 and H.264. Legacy GXV models may default to MPEG-4. If you experience decoding issues with a legacy model, check the camera's web interface and switch the codec to H.264 if available. ## FAQ **What is the default RTSP URL for Grandstream cameras?** For current GSC-series cameras, use `rtsp://admin:password@CAMERA_IP:554/live/ch00_0`. For older GXV-series cameras, try `rtsp://admin:password@CAMERA_IP:554//0` for the primary stream. **Do Grandstream cameras support ONVIF?** Yes, the GXV36xx series and current GSC-series cameras support ONVIF. Older GXV35xx models and video encoders generally do not support ONVIF. **What is the difference between channel 0 and channel 4?** On single-channel Grandstream cameras, channel 0 is the primary (high quality) stream and channel 4 is the secondary (lower quality) stream. This is a Grandstream-specific convention that differs from most other camera brands. **Can I use Grandstream cameras with a UCM system?** Yes. Grandstream cameras integrate natively with Grandstream UCM (Unified Communications Manager) systems. However, RTSP access works independently of the UCM and can be used with any third-party software including VisioForge SDKs. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Milesight Connection Guide](../milesight/) — SMB / professional camera segment - [ONVIF IP Camera Integration](../../videocapture/video-sources/ip-cameras/onvif/) — Grandstream ONVIF device setup - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Hanwha Vision IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/hanwha/ **Description:** Hanwha Vision X, Q, P, L series and Wisenet NVR RTSP URL patterns for C# .NET. ONVIF-compatible integration with VisioForge SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to Hanwha Vision IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Hanwha Vision** (formerly Hanwha Techwin, formerly Samsung Techwin) is a South Korean video surveillance manufacturer and a subsidiary of Hanwha Group. Hanwha acquired Samsung's security division in 2015 and rebranded to Hanwha Vision in 2023. All cameras are sold under the **Wisenet** product brand. Hanwha Vision is a top-5 global surveillance manufacturer with strong enterprise and government market presence. **Key facts:** - **Product lines:** Wisenet X (premium), Wisenet P (AI/4K), Wisenet Q (mainstream), Wisenet L (value), Wisenet T (thermal) - **Protocol support:** RTSP, ONVIF Profile S/G/T, HTTP/CGI, SUNAPI (proprietary) - **Default RTSP port:** 554 - **Default credentials:** admin / (set during initial setup; older models: admin / 4321) - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264, H.265 (WiseStream II), MJPEG - **Product brand:** Wisenet (see also our [Samsung/Hanwha guide](../samsung/) for legacy Samsung Techwin URLs) Hanwha Vision vs Samsung vs Wisenet **Hanwha Vision** is the company name (since 2023). **Wisenet** is the product brand for all cameras and NVRs. **Samsung Techwin** was the previous company name (before 2015). Our [Samsung/Hanwha guide](../samsung/) covers legacy Samsung-branded models. This page covers current Hanwha Vision / Wisenet products. ## RTSP URL Patterns ### Standard URL Format Hanwha Vision cameras use a profile-based RTSP URL structure: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/profile[N]/media.smp ``` | Parameter | Value | Description | | --- | --- | --- | | `profile1` | Profile 1 | Typically configured as main stream | | `profile2` | Profile 2 | Typically configured as sub stream | | `profile3` | Profile 3 | Third stream (if configured) | ### Camera Models | Model Series | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | | XNO-6080R (X 2MP bullet) | 1920x1080 | `rtsp://IP:554/profile2/media.smp` | Yes | | XNO-8080R (X 5MP bullet) | 2560x1920 | `rtsp://IP:554/profile2/media.smp` | Yes | | XNO-9080R (X 4K bullet) | 3840x2160 | `rtsp://IP:554/profile2/media.smp` | Yes | | XND-6080 (X 2MP dome) | 1920x1080 | `rtsp://IP:554/profile2/media.smp` | Yes | | XND-8080RV (X 5MP dome) | 2560x1920 | `rtsp://IP:554/profile2/media.smp` | Yes | | XNP-6120H (X 2MP PTZ) | 1920x1080 | `rtsp://IP:554/profile2/media.smp` | Yes | | PNO-A9081R (P 4K AI bullet) | 3840x2160 | `rtsp://IP:554/profile2/media.smp` | Yes | | QNO-8080R (Q 5MP bullet) | 2560x1920 | `rtsp://IP:554/profile2/media.smp` | Yes | | QND-8080R (Q 5MP dome) | 2560x1920 | `rtsp://IP:554/profile2/media.smp` | Yes | | LNO-6032R (L 2MP bullet) | 1920x1080 | `rtsp://IP:554/profile2/media.smp` | No | Profile Numbering On most Hanwha Vision cameras, `profile2` is the main stream and `profile1` is reserved for internal use. If `profile2` does not work, try `profile1` or `profile3`. You can verify profile assignments in the camera's web interface under **Video Profile**. ### NVR Channel URLs For Wisenet NVRs (XRN, QRN, LRN series): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/profile2/media.smp/trackID=channel1` | `rtsp://IP:554/profile3/media.smp/trackID=channel1` | | Camera 2 | `rtsp://IP:554/profile2/media.smp/trackID=channel2` | `rtsp://IP:554/profile3/media.smp/trackID=channel2` | | Camera N | `rtsp://IP:554/profile2/media.smp/trackID=channelN` | `rtsp://IP:554/profile3/media.smp/trackID=channelN` | ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/profile2/media.smp` | Standard (recommended) | | `rtsp://IP:554/profile1/media.smp` | First profile | | `rtsp://IP:554/onvif-media/media.amp` | ONVIF media service | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Some OEM variants | ## Connecting with VisioForge SDK Use your Hanwha Vision camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Hanwha Vision XNO-8080R (Wisenet X 5MP), main stream var uri = new Uri("rtsp://192.168.1.90:554/profile2/media.smp"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/profile3/media.smp` instead of `/profile2/media.smp`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/video.cgi?msubmenu=jpg&action=view&Resolution=1920x1080&Quality=5&Channel=0` | Full resolution snapshot | | JPEG Snapshot (simple) | `http://IP/cgi-bin/snapshot.cgi` | Requires digest auth | | MJPEG Stream | `http://IP/cgi-bin/video.cgi?msubmenu=mjpeg&action=view&Channel=0&Stream=0` | Continuous MJPEG | ## Troubleshooting ### profile2 vs profile1 confusion Hanwha Vision cameras typically assign `profile2` as the main (highest quality) stream, which differs from most other brands that use profile/channel 1. If you get no video or low resolution from `profile2`, check the profile configuration in the camera's web interface under **Video Profile**. ### Password activation required Current Hanwha Vision cameras ship without a default password. You must activate the camera and set a password through: 1. Wisenet Installation Wizard (IP Installer tool) 2. Web browser at `http://CAMERA_IP` 3. Wisenet mobile app Older Samsung Techwin models used `admin` / `4321` as defaults. ### WiseStream II codec WiseStream II is Hanwha's dynamic encoding technology that adjusts compression per-region in the frame. It produces standard H.265 or H.264 streams that are compatible with any decoder. No special codec is required. ### SUNAPI vs ONVIF Hanwha Vision cameras support both their proprietary SUNAPI and standard ONVIF. For VisioForge SDK integration, use either the RTSP URLs above or ONVIF discovery. SUNAPI is primarily used by Hanwha's own VMS (SSM/Wisenet WAVE). ## FAQ **What is the default RTSP URL for Hanwha Vision (Wisenet) cameras?** The standard URL is `rtsp://admin:password@CAMERA_IP:554/profile2/media.smp` for the main stream. Use `profile3` for the sub stream. The profile numbers can be customized in the camera's web interface. **Are Hanwha Vision and Samsung cameras the same?** Hanwha Vision acquired Samsung's security camera division in 2015 (then called Samsung Techwin, later Hanwha Techwin, now Hanwha Vision). Current cameras are sold under the **Wisenet** brand. Legacy Samsung-branded cameras may use different URL patterns -- see our [Samsung/Hanwha guide](../samsung/). **What is the difference between Wisenet X, P, Q, and L series?** **X** = premium enterprise (best low-light, WDR). **P** = AI-powered (deep learning analytics). **Q** = mainstream business (good balance of features and price). **L** = value/entry-level (basic features, competitive pricing). **T** = thermal imaging. **Do Hanwha Vision cameras support ONVIF?** Yes. All current Hanwha Vision cameras support ONVIF Profile S, G, and T. ONVIF provides standardized discovery, streaming, and PTZ control. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Samsung/Hanwha Legacy Guide](../samsung/) — Older Samsung Techwin models - [Wisenet Product Guide](../wisenet/) — Wisenet product family details - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Hikvision RTSP URL in C# .NET — IP Camera and NVR Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/hikvision/ **Description:** Hikvision RTSP URL format for DS-2CD, DS-2DE, and NVR models in C# .NET. ONVIF discovery, multi-channel streams, and VisioForge SDK integration guide. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# **API:** RTSPSourceProtocol # How to Connect to Hikvision IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Hikvision** (Hangzhou Hikvision Digital Technology Co., Ltd.) is the world's largest manufacturer of video surveillance equipment by market share. Founded in 2001 and headquartered in Hangzhou, China, Hikvision produces IP cameras, DVRs, NVRs, and video management software used across enterprise, government, and consumer markets. **Key facts:** - **Product lines:** DS-2CD (fixed cameras), DS-2DE (PTZ cameras), DS-76/77/96 (NVRs), DS-7200/7300/7600 (DVRs) - **Protocol support:** ONVIF Profile S/G/T, RTSP, HTTP, ISAPI - **Default RTSP port:** 554 - **Default credentials:** admin / (set during initial setup; older firmware: admin / 12345) - **ONVIF support:** Full -- recommended for automatic discovery and configuration - **Video codecs:** H.264, H.265 (Smart Codec), MJPEG ## RTSP URL Patterns Hikvision cameras use a channel-based URL structure. Channel numbers encode both the camera channel and the stream type. ### URL Format ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:[PORT]/Streaming/Channels/[CHANNEL_ID] ``` **Channel ID encoding:** - Channel ID = (camera\_number \* 100) + stream\_number - Stream 1 = main stream, Stream 2 = sub stream, Stream 3 = third stream - Example: Camera 1, main stream = **101**; Camera 1, sub stream = **102** ### IP Cameras (Single Channel) | Model Series | RTSP URL | Stream | Audio | | --- | --- | --- | --- | | DS-2CD2xx2 (2MP fixed) | `rtsp://IP:554/Streaming/Channels/101` | Main (1080p) | Yes | | DS-2CD2xx2 (2MP fixed) | `rtsp://IP:554/Streaming/Channels/102` | Sub (CIF/D1) | Yes | | DS-2CD2x32 (3MP fixed) | `rtsp://IP:554/Streaming/Channels/101` | Main (2048x1536) | Yes | | DS-2CD2x32 (3MP fixed) | `rtsp://IP:554/Streaming/Channels/102` | Sub | Yes | | DS-2CD21xx-I (value series) | `rtsp://IP:554/Streaming/Channels/1` | Main | Yes | | DS-2CD21xx-I (value series) | `rtsp://IP:554/Streaming/Channels/2` | Sub | Yes | | DS-2DE series (PTZ) | `rtsp://IP:554/Streaming/Channels/101` | Main | Yes | | DS-2CD6362F (fisheye) | `rtsp://IP:554/Streaming/Channels/101` | Main (3072x2048) | Yes | ### NVR / DVR Channels For NVR and DVR devices, change the camera number in the channel ID: | Device | Channel | RTSP URL | Stream | | --- | --- | --- | --- | | NVR Camera 1 | 1 | `rtsp://IP:554/Streaming/Channels/101` | Main | | NVR Camera 1 | 1 | `rtsp://IP:554/Streaming/Channels/102` | Sub | | NVR Camera 2 | 2 | `rtsp://IP:554/Streaming/Channels/201` | Main | | NVR Camera 2 | 2 | `rtsp://IP:554/Streaming/Channels/202` | Sub | | NVR Camera 8 | 8 | `rtsp://IP:554/Streaming/Channels/801` | Main | | DVR Channel 1 | 1 | `rtsp://IP:554/Streaming/Channels/101` | Main | ### Alternative URL Formats Some older Hikvision models and OEM variants use different URL patterns: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/h264/ch1/main/av_stream` | Older firmware versions | | `rtsp://IP:554/h264/ch1/sub/av_stream` | Older firmware, sub stream | | `rtsp://IP:554/PSIA/Streaming/channels/101` | PSIA protocol (legacy) | | `rtsp://IP:554/video.h264` | Some OEM models | | `rtsp://IP:554/live.sdp` | Some older models | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | Dahua-compatible OEM | | `rtsp://IP:554/mpeg4` | MPEG4 stream (legacy) | ## Connecting with VisioForge SDK Use your Hikvision camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Hikvision DS-2CD2032-I, main stream var uri = new Uri("rtsp://192.168.1.64:554/Streaming/Channels/101"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/Streaming/Channels/102` instead. ### ONVIF Discovery Hikvision cameras have excellent ONVIF support. Use ONVIF to automatically discover cameras on your network and retrieve their stream URIs without manually constructing RTSP URLs. See the [ONVIF integration guide](../../mediablocks/Sources/) for discovery code examples. ## Snapshot and MJPEG URLs Hikvision cameras also provide HTTP endpoints for snapshots and MJPEG streams: | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/ISAPI/Streaming/channels/101/picture` | Requires authentication | | MJPEG Stream | `http://IP/ISAPI/Streaming/channels/102/httpPreview` | Sub stream as MJPEG | | Legacy Snapshot | `http://IP/Streaming/channels/1/picture` | Older firmware | | CGI Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Basic authentication | ## Troubleshooting ### "Double slash" in URL path Hikvision RTSP URLs use a path starting with `/Streaming/Channels/`. Some tools or code generate `//Streaming/Channels/` (double slash). Both work with Hikvision cameras, but use a single slash for correctness. ### Connection refused on port 554 - Verify RTSP is enabled in the camera's web interface: **Configuration > Network > Advanced Settings > RTSP** - Check that the RTSP port hasn't been changed from the default (554) - Ensure no firewall is blocking the port between your application and the camera ### Authentication failures - Hikvision cameras require **digest authentication** by default. VisioForge SDK handles this automatically. - On newer firmware, the default `admin/12345` credentials are disabled. You must set a strong password during initial setup via the Hikvision SADP tool or web interface. - If connecting to an NVR, use the NVR credentials, not the individual camera credentials. ### H.265 stream not playing - Ensure you have the HEVC decoder redistributable installed - Alternatively, configure the camera to use H.264 encoding in its video settings - Use `rtspSettings.UseGPUDecoder = true` for hardware-accelerated H.265 decoding ### High latency - Use TCP transport: `rtspSettings.AllowedProtocols = RTSPSourceProtocol.TCP` - Reduce buffer latency: `rtspSettings.Latency = TimeSpan.FromMilliseconds(200)` - Switch to the sub stream (channel 102) for lower bandwidth requirements - Disable audio if not needed: `audioEnabled: false` Combined on a single `RTSPSourceSettings` instance (constructed via the async factory): ``` var rtspSettings = await RTSPSourceSettings.CreateAsync( uri: new Uri("rtsp://192.168.1.100:554/Streaming/Channels/102"), // sub stream login: "admin", password: "password", audioEnabled: false); rtspSettings.UseGPUDecoder = true; // hardware-accelerated H.265 rtspSettings.AllowedProtocols = RTSPSourceProtocol.TCP; // TCP transport rtspSettings.Latency = TimeSpan.FromMilliseconds(200); ``` ## FAQ **What is the default RTSP URL for Hikvision cameras?** The standard RTSP URL for Hikvision cameras is `rtsp://admin:password@CAMERA_IP:554/Streaming/Channels/101` for the main stream. Replace `admin` and `password` with your camera credentials, and `CAMERA_IP` with the camera's IP address. Use channel `102` for the sub stream. **How do I find my Hikvision camera's IP address?** Use the Hikvision SADP (Search Active Devices Protocol) tool, which is a free utility that discovers all Hikvision devices on your local network. Alternatively, check your router's DHCP client list or use ONVIF device discovery with the VisioForge SDK. **Can I connect to a Hikvision NVR and view individual camera channels?** Yes. Use the same RTSP URL format but change the channel number. Camera 1 is channel 101 (main) or 102 (sub), camera 2 is channel 201/202, and so on. The formula is: channel ID = (camera\_number x 100) + stream\_number. **Does VisioForge SDK support Hikvision's H.265+ (Smart Codec)?** Yes. The SDK supports standard H.265/HEVC decoding. Hikvision's H.265+ is a proprietary compression optimization that produces standard H.265 streams, so it works with any H.265-capable decoder. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [LTS Connection Guide](../lts/) — Hikvision OEM, uses same URL format - [EZVIZ Connection Guide](../ezviz/) — Hikvision consumer brand - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Honeywell IP Camera RTSP URL Guide for C# .NET Apps **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/honeywell/ **Description:** Connect to Honeywell Performance Series and equIP cameras in C# .NET with RTSP URL patterns and code samples for HD, HDZ, HBD, HBW, and PSIA models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Honeywell IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Honeywell Commercial Security** (part of Honeywell Building Technologies) is a major manufacturer of enterprise video surveillance equipment. Honeywell cameras are widely deployed in commercial buildings, critical infrastructure, government facilities, and transportation systems worldwide. Honeywell acquired several camera brands over the years including **Samsung Techwin** (briefly) and markets cameras under the **Performance Series**, **30 Series**, and **60 Series** product lines. **Key facts:** - **Product lines:** Performance Series (equIP, H-series), 30 Series (HC30W, HC35W), 60 Series (HC60W), HDZ/HD (legacy equIP), HBD/HBW (bullet/dome), IPCAM (consumer) - **Protocol support:** RTSP, ONVIF (Profile S/G/T), PSIA, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / 1234 (Performance Series); admin / admin (legacy models); varies by model and firmware - **ONVIF support:** Yes (all current Performance Series and 30/60 Series models) - **Video codecs:** H.264, H.265 (current models), MPEG-4 (legacy) ## RTSP URL Patterns ### Current Models (Performance Series, 30/60 Series) | Stream | RTSP URL | Codec | Notes | | --- | --- | --- | --- | | Main stream (H.264) | `rtsp://IP:554/h264` | H.264 | Primary stream | | Main stream (H.265) | `rtsp://IP:554/h265` | H.265 | Current models only | | Channel stream (H.264) | `rtsp://IP:554/cam1/h264` | H.264 | Channel-specific | | Channel stream (MPEG-4) | `rtsp://IP:554/cam1/mpeg4` | MPEG-4 | Legacy fallback | | PSIA stream | `rtsp://IP:554/PSIA/Streaming/channels/1` | H.264 | PSIA-compatible | ### Model-Specific URLs | Model Series | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | HC30W/HC35W (30 Series) | `rtsp://IP:554/h264` | Up to 5MP | Current Wi-Fi | | HC60W (60 Series) | `rtsp://IP:554/h264` | Up to 4K | Current wired | | HD45IP | `rtsp://IP:554/h264` | 1080p | equIP dome | | HD54IP | `rtsp://IP:554/h264` | 1080p | equIP box | | HD55IPX | `rtsp://IP:554/h264` | 1080p+ | equIP box | | HDZ20HDEX/HDZ20HDX | `rtsp://IP:554/h264` | 1080p | equIP PTZ | | HD4MDIP | `rtsp://IP:554/cam1/mpeg4` | 720p | Multi-channel | | HDM3DIP | `rtsp://IP:554/cam1/mpeg4` | 720p | Mini dome | | HBD/HBW series | `rtsp://IP:554/h264` | Up to 4MP | Bullet/dome | ### PSIA Streaming Honeywell cameras that support **PSIA (Physical Security Interoperability Alliance)** use a different URL format: | Stream | RTSP URL | Notes | | --- | --- | --- | | Channel 1 | `rtsp://IP:554/PSIA/Streaming/channels/1` | First channel | | Channel 2 | `rtsp://IP:554/PSIA/Streaming/channels/2` | Second channel | ### Legacy Models (HTTP Only) Older Honeywell consumer cameras (IPCAM series) use HTTP: | Model | URL | Notes | | --- | --- | --- | | IPCAM / IPCAM-PT | `http://IP/img/snapshot.cgi?size=3` | JPEG snapshot | | IPCAM-PT | `http://IP/img/video.mjpeg` | MJPEG stream | | IPCAM-PT | `http://IP/img/video.asf` | ASF stream (audio) | | IPCAM-OD / IPCAM-W12 | `http://IP/img/video.mjpeg` | MJPEG stream | | IPCAM-OD / IPCAM-W12 | `http://IP/img/video.asf` | ASF stream (audio) | ## Connecting with VisioForge SDK Use your Honeywell camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Honeywell Performance Series camera, main stream var uri = new Uri("rtsp://192.168.1.75:554/h264"); var username = "admin"; var password = "YourPassword"; ``` For PSIA channel streams, use `/PSIA/Streaming/channels/1` instead. For multi-channel models, use `/cam1/h264` format. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/img/snapshot.cgi?size=3` | Most models | | MJPEG Stream | `http://IP/img/video.mjpeg` | Continuous MJPEG | | ASF Stream | `http://IP/img/video.asf` | ASF with audio | | HREP Snapshot | `http://IP/cgi-bin/webra_fcgi.fcgi?api=get_jpeg_raw&chno=1` | NVR channel snapshot | ## Troubleshooting ### RTSP URL format Honeywell cameras use a simple RTSP URL format compared to other brands: - Primary: `rtsp://IP:554/h264` (no complex paths) - Multi-channel: `rtsp://IP:554/cam1/h264` (channel number in path) - PSIA: `rtsp://IP:554/PSIA/Streaming/channels/1` (PSIA standard) If `/h264` doesn't work, try `/cam1/h264` or the PSIA URL. ### Default credentials vary Honeywell has used different default credentials across product lines: - **Performance Series:** admin / 1234 (must be changed on first login) - **30/60 Series:** Set during initial setup (no default) - **Legacy equIP:** admin / admin - **IPCAM series:** admin / (empty) or admin / admin ### PSIA vs ONVIF Honeywell cameras support both PSIA and ONVIF protocols: - **ONVIF** is recommended for new integrations (wider compatibility) - **PSIA** is Honeywell's legacy interoperability standard, still supported on most models - Both provide the same video streams via different discovery and configuration mechanisms ## FAQ **What is the default RTSP URL for Honeywell cameras?** For most current Honeywell cameras, use `rtsp://admin:password@CAMERA_IP:554/h264`. For multi-channel models, use `rtsp://admin:password@CAMERA_IP:554/cam1/h264`. PSIA-compatible cameras also respond to `/PSIA/Streaming/channels/1`. **Do Honeywell cameras support ONVIF?** Yes. All current Honeywell Performance Series, 30 Series, and 60 Series cameras support ONVIF Profile S (streaming), Profile G (recording), and Profile T (advanced streaming). Legacy equIP models may only support ONVIF Profile S. **What is PSIA on Honeywell cameras?** PSIA (Physical Security Interoperability Alliance) is an alternative to ONVIF for device interoperability. Honeywell has historically supported PSIA alongside ONVIF. PSIA streams use the URL format `rtsp://IP:554/PSIA/Streaming/channels/1`. **Are Honeywell IPCAM models still supported?** The IPCAM consumer series is discontinued. These cameras only support HTTP MJPEG/JPEG and do not have RTSP. For IPCAM models, use the HTTP snapshot URL `http://IP/img/snapshot.cgi?size=3` or MJPEG stream `http://IP/img/video.mjpeg`. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Bosch Connection Guide](../bosch/) — Enterprise / commercial segment peer - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Imou IP Camera in C# .NET — RTSP & ONVIF Setup Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/imou/ **Description:** Connect Imou cameras (Cruiser, Ranger, Bullet, Cell) to C# / .NET apps via RTSP/ONVIF. Default credentials, stream URLs, H.264/H.265 configs. Sample code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Imou IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Imou** (pronounced "ee-moo") is a consumer smart home and security camera brand owned by **Dahua Technology**. Launched in 2019, Imou targets the consumer and small business market with WiFi cameras, battery cameras, doorbells, and home security kits. Imou cameras use Dahua firmware and RTSP URL patterns. **Key facts:** - **Product lines:** Cruiser (outdoor PT), Ranger (indoor PT), Bullet (fixed outdoor), Cell (battery), Versa (versatile), Rex (indoor) - **Protocol support:** RTSP (must be enabled on some models), ONVIF (select models), Imou Life cloud - **Default RTSP port:** 554 - **Default credentials:** admin / admin (or admin / imou + serial number suffix) - **ONVIF support:** Yes (most wired models) - **Video codecs:** H.264, H.265 (select models) - **Parent company:** Dahua Technology Imou = Dahua Consumer Brand Imou cameras use Dahua firmware and the same `cam/realmonitor` RTSP URL format as Dahua cameras. See our [Dahua connection guide](../dahua/) for additional details. ## RTSP URL Patterns ### Standard URL Format Imou cameras use the Dahua `cam/realmonitor` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/cam/realmonitor?channel=1&subtype=0 ``` | Parameter | Value | Description | | --- | --- | --- | | `channel` | 1 | Camera channel (always 1 for standalone cameras) | | `subtype` | 0 | Main stream (highest resolution) | | `subtype` | 1 | Sub stream (lower resolution, less bandwidth) | ### Camera Models | Model | Type | Main Stream URL | Audio | | --- | --- | --- | --- | | Cruiser SE+ 4MP | Outdoor PTZ | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Cruiser 2E 4MP | Outdoor PTZ | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Ranger 2 (IPC-A22EP) | Indoor PTZ | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Ranger SE 4MP | Indoor PTZ | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Rex 3D (IPC-GS7EP) | Indoor PTZ | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Bullet 2E (IPC-F22FP) | Outdoor fixed | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Bullet 2S (IPC-F26FP) | Outdoor fixed | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Versa 4MP | Indoor/outdoor | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | Cell 2 | Battery outdoor | Limited — see note | Yes | | Cell Go | Battery mini | No RTSP | No | Battery Models Imou battery-powered cameras (Cell series) have limited or no RTSP support. The Cell 2 may support RTSP when connected to the Imou Base Station, but the Cell Go and other battery mini cameras are cloud-only devices. ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Standard (recommended) | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0&unicast=true` | Force unicast | | `rtsp://IP:554/live` | Simple path (some models) | ## Connecting with VisioForge SDK Use your Imou camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Imou Cruiser SE+ 4MP, main stream var uri = new Uri("rtsp://192.168.1.90:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `subtype=1` instead of `subtype=0`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi?channel=1` | Requires basic auth | | MJPEG Stream | `http://IP/cgi-bin/mjpg/video.cgi?channel=1&subtype=1` | Continuous MJPEG | ## Troubleshooting ### RTSP not accessible Some Imou cameras require RTSP to be enabled through the Imou Life app: 1. Open **Imou Life** app → select your camera 2. Go to **Settings > Advanced Settings > RTSP** 3. Enable RTSP and note the password (may differ from app password) ### Default credentials Imou password defaults vary by model and firmware: - `admin` / `admin` (common on older models) - `admin` / specific code (check camera label) - Custom password set during Imou Life app setup If RTSP login fails, check the RTSP password in the Imou Life app settings. ### WiFi camera IP address Imou WiFi cameras get their IP from your router via DHCP. Find the camera's local IP in: 1. The Imou Life app → Device Info 2. Your router's DHCP client list 3. ONVIF discovery (if supported) ### Dahua web interface Some Imou cameras expose the Dahua web interface at `http://CAMERA_IP`. This provides additional configuration options beyond the Imou Life app, including RTSP settings, video encoding, and network configuration. ## FAQ **What is the default RTSP URL for Imou cameras?** The standard URL is `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=0` for the main stream. This is the same format as Dahua cameras. RTSP may need to be enabled in the Imou Life app first. **Is Imou the same as Dahua?** Imou is a consumer brand owned by Dahua Technology. Imou cameras use Dahua firmware and the same RTSP URL format (`cam/realmonitor`). The main differences are branding, consumer-focused features, and cloud service integration. **Can I use Imou cameras without the cloud?** Partially. You can access RTSP streams locally without the Imou cloud for live viewing and recording. However, initial camera setup requires the Imou Life app. Cloud-dependent features like smart alerts, cloud storage, and remote access require an Imou subscription. **Do Imou cameras support ONVIF?** Most wired and WiFi-connected Imou cameras support ONVIF. Battery-powered models generally do not. Check your camera's specifications in the Imou Life app. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Dahua Connection Guide](../dahua/) — Parent company, identical URL format - [Amcrest Connection Guide](../amcrest/) — Another Dahua OEM brand - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## IP Camera RTSP URL Directory - Connect Any Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/ **Description:** Complete RTSP URL directory for 62 IP camera brands. Connect Hikvision, Dahua, Axis, Uniview, EZVIZ, Wisenet, Arlo and more using VisioForge .NET SDK. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming **API:** VideoCaptureCoreX, VideoCaptureCore, RTSPSourceSettings, IVideoView, IPCameraSourceSettings # IP Camera Connection Guide by Brand [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Connecting to IP cameras in C# .NET is straightforward when you know the right RTSP URL pattern for your camera brand. Each manufacturer uses slightly different URL formats, ports, and authentication methods. This directory provides **brand-specific RTSP URL patterns**, connection code samples using VisioForge SDK, and troubleshooting tips for the most popular IP camera manufacturers. ## How RTSP Camera Connections Work Most modern IP cameras expose video streams via the **RTSP (Real-Time Streaming Protocol)** on port 554. The general connection flow is: 1. Determine your camera's IP address (via ONVIF discovery, DHCP lease table, or manufacturer utility) 2. Construct the RTSP URL using the brand-specific pattern 3. Authenticate with camera credentials 4. Connect and render the video stream ### Quick Start Code Connect to any RTSP camera using one of three VisioForge SDK approaches: VideoCaptureCoreXVideoCaptureCoreMedia Blocks ``` // Initialize SDK (call once at app startup) await VisioForgeX.InitSDKAsync(); var videoCapture = new VideoCaptureCoreX(VideoView1); // Create RTSP source var rtsp = await RTSPSourceSettings.CreateAsync( new Uri("rtsp://192.168.1.100:554/stream1"), "admin", "password", true); // capture audio videoCapture.Video_Source = rtsp; await videoCapture.StartAsync(); ``` ``` var videoCapture = new VideoCaptureCore(VideoView1 as IVideoView); videoCapture.IP_Camera_Source = new IPCameraSourceSettings() { URL = new Uri("rtsp://admin:password@192.168.1.100:554/stream1"), Type = IPSourceEngine.Auto_LAV }; videoCapture.Audio_PlayAudio = true; videoCapture.Audio_RecordAudio = false; videoCapture.Mode = VideoCaptureMode.IPPreview; await videoCapture.StartAsync(); ``` ``` var pipeline = new MediaBlocksPipeline(); var rtspSettings = await RTSPSourceSettings.CreateAsync( new Uri("rtsp://192.168.1.100:554/stream1"), "admin", "password", audioEnabled: true); rtspSettings.AllowedProtocols = RTSPSourceProtocol.TCP; var rtspSource = new RTSPSourceBlock(rtspSettings); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(rtspSource.VideoOutput, videoRenderer.Input); pipeline.Connect(rtspSource.AudioOutput, audioRenderer.Input); await pipeline.StartAsync(); ``` Replace the RTSP URL with your brand-specific pattern from the pages below. ### Which SDK Should I Choose? | SDK | Best For | Platforms | | --- | --- | --- | | **VideoCaptureCoreX** | New cross-platform projects, modern .NET | Windows, macOS, Linux, Android, iOS | | **VideoCaptureCore** | Windows-only projects, legacy .NET Framework | Windows | | **Media Blocks** | Advanced pipelines, custom processing chains | Windows, macOS, Linux, Android, iOS | **VideoCaptureCoreX** is recommended for most new projects. Use **Media Blocks** when you need to build custom processing pipelines with multiple sources, filters, or outputs. ## Camera Brands ### Featured Brands (Full Guides) | Brand | Headquarters | Market Segment | Guide | | --- | --- | --- | --- | | **Hikvision** | Hangzhou, China | Enterprise / Consumer | [Connection Guide](hikvision/) | | **Dahua** | Hangzhou, China | Enterprise / Consumer | [Connection Guide](dahua/) | | **Axis** | Lund, Sweden | Enterprise / Professional | [Connection Guide](axis/) | | **Reolink** | Hong Kong | Consumer / Prosumer | [Connection Guide](reolink/) | | **Amcrest** | Houston, USA | Consumer / SMB | [Connection Guide](amcrest/) | | **Samsung/Hanwha** | Grasbrunn, Germany / Seoul, South Korea | Enterprise / Professional | [Connection Guide](samsung/) | | **Bosch** | Grasbrunn, Germany | Enterprise / Critical Infrastructure | [Connection Guide](bosch/) | | **Ubiquiti** | New York, USA | Prosumer / SMB | [Connection Guide](ubiquiti/) | | **Foscam** | Shenzhen, China | Consumer / SMB | [Connection Guide](foscam/) | | **TP-Link** | Shenzhen, China | Consumer / SMB | [Connection Guide](tp-link/) | | **Vivotek** | New Taipei City, Taiwan | Enterprise / Professional | [Connection Guide](vivotek/) | | **Panasonic/i-PRO** | Tokyo, Japan | Enterprise / Government | [Connection Guide](panasonic/) | | **Sony** | Tokyo, Japan | Enterprise (discontinued 2020) | [Connection Guide](sony/) | | **Lorex** | Markham, Canada | Consumer / Prosumer | [Connection Guide](lorex/) | | **D-Link** | Taipei, Taiwan | Consumer / SMB | [Connection Guide](dlink/) | | **Honeywell** | Charlotte, USA | Enterprise / Commercial | [Connection Guide](honeywell/) | | **Pelco** | Fresno, USA (Motorola Solutions) | Enterprise / Government | [Connection Guide](pelco/) | | **Cisco** | San Jose, USA | Enterprise / Consumer-SMB (legacy) | [Connection Guide](cisco/) | | **Grandstream** | Boston, USA | SMB / Professional | [Connection Guide](grandstream/) | | **Swann** | Melbourne, Australia | Consumer / Prosumer | [Connection Guide](swann/) | | **GeoVision** | Taipei, Taiwan | Enterprise / Professional | [Connection Guide](geovision/) | | **ACTi** | Taipei, Taiwan | Professional / Enterprise | [Connection Guide](acti/) | | **Canon** | Tokyo, Japan | Professional / Enterprise | [Connection Guide](canon/) | | **FLIR (Teledyne)** | Wilsonville, USA | Enterprise / Thermal | [Connection Guide](flir/) | | **Milesight** | Xiamen, China | Professional / SMB | [Connection Guide](milesight/) | | **INSTAR** | Hanau, Germany | Consumer / Smart Home | [Connection Guide](instar/) | | **Zmodo** | Shenzhen, China | Consumer / Budget | [Connection Guide](zmodo/) | | **Arecont Vision** | Glendale, USA (Costar Group) | Professional / Enterprise | [Connection Guide](arecont/) | | **JVC** | Yokohama, Japan | Professional (discontinued ~2015) | [Connection Guide](jvc/) | | **Toshiba** | Tokyo, Japan | Enterprise (discontinued) | [Connection Guide](toshiba/) | | **LG** | Seoul, South Korea | Enterprise (discontinued) | [Connection Guide](lg/) | | **Linksys** | Irvine, USA | Consumer (discontinued ~2014) | [Connection Guide](linksys/) | | **LTS** | City of Industry, USA | Professional (Hikvision OEM) | [Connection Guide](lts/) | | **Q-See** | Anaheim, USA | Consumer (defunct ~2020) | [Connection Guide](q-see/) | | **Speco Technologies** | Amityville, USA | Professional | [Connection Guide](speco/) | | **EverFocus** | New Taipei City, Taiwan | Professional | [Connection Guide](everfocus/) | | **ABUS** | Wetter, Germany | Consumer / Professional | [Connection Guide](abus/) | | **Basler** | Ahrensburg, Germany | Machine Vision / Industrial | [Connection Guide](basler/) | | **Mobotix** | Langmeil, Germany (Konica Minolta) | Industrial / Critical Infrastructure | [Connection Guide](mobotix/) | | **Avigilon** | Vancouver, Canada (Motorola Solutions) | Enterprise / Critical Infrastructure | [Connection Guide](avigilon/) | | **AVTech** | Taipei, Taiwan | Commercial / Industrial | [Connection Guide](avtech/) | | **LILIN** | New Taipei City, Taiwan | Professional / Enterprise | [Connection Guide](lilin/) | | **Zavio** | Hsinchu, Taiwan | Professional / SMB | [Connection Guide](zavio/) | | **CP Plus** | Delhi, India | Enterprise / Commercial | [Connection Guide](cp-plus/) | | **Sanyo** | Osaka, Japan (now Panasonic) | Professional (discontinued) | [Connection Guide](sanyo/) | | **BrickCom** | Taipei, Taiwan | Professional / Industrial | [Connection Guide](brickcom/) | | **Edimax** | Taipei, Taiwan | Consumer / SMB | [Connection Guide](edimax/) | | **Uniview (UNV)** | Hangzhou, China | Enterprise / Government | [Connection Guide](uniview/) | | **Hanwha Vision** | Seoul, South Korea | Enterprise / Professional | [Connection Guide](hanwha/) | | **Tiandy** | Tianjin, China | Enterprise / SMB | [Connection Guide](tiandy/) | | **EZVIZ** | Hangzhou, China (Hikvision) | Consumer / Smart Home | [Connection Guide](ezviz/) | | **Wisenet** | Seoul, South Korea (Hanwha Vision) | Enterprise / Professional | [Connection Guide](wisenet/) | | **Annke** | Hong Kong | Consumer / Prosumer | [Connection Guide](annke/) | | **Imou** | Hangzhou, China (Dahua) | Consumer / Smart Home | [Connection Guide](imou/) | | **Wyze** | Kirkland, USA | Consumer (limited RTSP) | [Connection Guide](wyze/) | | **Aqara** | Shenzhen, China | Smart Home / HomeKit | [Connection Guide](aqara/) | | **Verkada** | San Mateo, USA | Enterprise / Cloud-managed | [Connection Guide](verkada/) | | **Rhombus** | Sacramento, USA | Enterprise / Cloud-managed | [Connection Guide](rhombus/) | | **Arlo** | Carlsbad, USA | Consumer (no RTSP) | [Connection Guide](arlo/) | | **Eufy Security** | Changsha, China (Anker) | Consumer / Smart Home | [Connection Guide](eufy/) | | **Tenda** | Shenzhen, China | Consumer / Budget | [Connection Guide](tenda/) | | **Mercusys** | Shenzhen, China (TP-Link) | Consumer / Budget | [Connection Guide](mercusys/) | ### Common RTSP URL Patterns by Brand For quick reference, here are the primary RTSP URL patterns for popular camera brands: | Brand | Primary RTSP URL Pattern | Default Port | | --- | --- | --- | | Hikvision | `rtsp://IP:554/Streaming/Channels/101` | 554 | | Dahua | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | 554 | | Axis | `rtsp://IP:554/axis-media/media.amp` | 554 | | Foscam | `rtsp://IP:88/videoMain` | 88 | | TP-Link (Tapo) | `rtsp://IP:554/stream1` | 554 | | Amcrest | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | 554 | | Reolink | `rtsp://IP:554/h264Preview_01_main` | 554 | | Ubiquiti | `rtsp://IP:7447/STREAM_TOKEN` | 7447 | | Samsung/Hanwha | `rtsp://IP:554/profile2/media.smp` | 554 | | Bosch | `rtsp://IP:554/video?inst=1` | 554 | | Vivotek | `rtsp://IP:554/live.sdp` | 554 | | Panasonic/i-PRO | `rtsp://IP:554/MediaInput/h264` | 554 | | Sony | `rtsp://IP:554/media/video1` | 554 | | Lorex | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | 554 | | D-Link | `rtsp://IP:554/live1.sdp` | 554 | | Honeywell | `rtsp://IP:554/h264` | 554 | | Pelco | `rtsp://IP:554//stream1` | 554 | | Cisco | `rtsp://IP:554/img/media.sav` | 554 | | Grandstream | `rtsp://IP:554/live/ch00_0` | 554 | | Swann | `rtsp://IP:554/live/h264` | 554 | | GeoVision | `rtsp://IP:8554//CH001.sdp` | 8554 | | ACTi | `rtsp://IP:7070//stream1` | 7070 | | Canon | `rtsp://IP:554/cam1/h264` | 554 | | FLIR (Teledyne) | `rtsp://IP:554/ch0` | 554 | | Milesight | `rtsp://IP:554//main` | 554 | | INSTAR | `rtsp://IP:554//11` | 554 | | Zmodo | `rtsp://IP:10554//tcp/av0_0` | 10554 | | Arecont Vision | `rtsp://IP:554/h264.sdp` | 554 | | JVC | `rtsp://IP:554/PSIA/Streaming/channels/0` | 554 | | Toshiba | `rtsp://IP:554/live.sdp` | 554 | | LG | `rtsp://IP:554/video1+audio1` | 554 | | Linksys | `rtsp://IP:554/img/media.sav` | 554 | | LTS | `rtsp://IP:554//Streaming/Channels/1` | 554 | | Q-See | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | 554 | | Speco | `rtsp://IP:554/1/stream1` | 554 | | EverFocus | `rtsp://IP:554//cgi-bin/rtspStreamOvf/0` | 554 | | ABUS | `rtsp://IP:554/video.mp4` | 554 | | Basler | `rtsp://IP:554/h264` | 554 | | Mobotix | `rtsp://IP:554/mobotix.h264` | 554 | | Avigilon | `rtsp://IP:554/defaultPrimary?streamType=u` | 554 | | AVTech | `rtsp://IP:554/live/h264` | 554 | | LILIN | `rtsp://IP:554/rtsph2641080p` | 554 | | Zavio | `rtsp://IP:554/video.mp4` | 554 | | CP Plus | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | 554 | | Sanyo | `rtsp://IP:554/VideoInput/1/h264/1` | 554 | | BrickCom | `rtsp://IP:554/channel1` | 554 | | Edimax | `rtsp://IP:554/ipcam_h264.sdp` | 554 | | Uniview (UNV) | `rtsp://IP:554/media/video1` | 554 | | Hanwha Vision | `rtsp://IP:554/profile2/media.smp` | 554 | | Tiandy | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | 554 | | EZVIZ | `rtsp://IP:554/h264/ch1/main/av_stream` | 554 | | Wisenet | `rtsp://IP:554/profile2/media.smp` | 554 | | Annke | `rtsp://IP:554/Streaming/Channels/101` | 554 | | Imou | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | 554 | | Wyze | `rtsp://IP:8554/live` | 8554 | | Aqara | `rtsp://IP:554/live/ch00_1` | 554 | | Verkada | N/A (cloud-only) | N/A | | Rhombus | `rtsp://IP:554/live` (if enabled) | 554 | | Arlo | N/A (no RTSP) | N/A | | Eufy Security | `rtsp://IP:554/live0` | 554 | | Tenda | `rtsp://IP:554/stream1` | 554 | | Mercusys | `rtsp://IP:554/stream1` | 554 | ## ONVIF Discovery Most modern IP cameras support **ONVIF (Open Network Video Interface Forum)**, which allows automatic camera discovery on your network. VisioForge SDK supports ONVIF discovery -- see our [ONVIF integration guide](../mediablocks/Sources/) for details. ## Get Started ### Install via NuGet Cross-platform (recommended)Windows-only ``` dotnet add package VisioForge.CrossPlatform.Core ``` ``` dotnet add package VisioForge.DotNet.Core dotnet add package VisioForge.DotNet.Core.Redist.VideoCapture.x64 ``` ### Sample Projects Complete working examples for IP camera integration: - [IP Camera Preview (WinForms)](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Video%20Capture%20SDK/_CodeSnippets/ip-camera-preview) — Live camera view - [IP Camera Recording to MP4](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Video%20Capture%20SDK/_CodeSnippets/ip-camera-capture-mp4) — Record streams to file - [All .NET SDK Samples](https://github.com/visioforge/.Net-SDK-s-samples) — Full sample repository ## Related Resources - [RTSP Source Block Documentation](../mediablocks/Sources/) - [IP Camera Preview Tutorial](../videocapture/video-tutorials/ip-camera-preview/) - [IP Camera Recording to MP4](../videocapture/video-tutorials/ip-camera-capture-mp4/) - [Building Camera Applications with Media Blocks](../mediablocks/GettingStarted/camera/) - [Device Enumeration Guide](../mediablocks/GettingStarted/device-enum/) ---END OF PAGE--- ## INSTAR IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/instar/ **Description:** INSTAR IN-6xxx, IN-7xxx, IN-8xxx, IN-9xxx HD camera RTSP URL patterns for C# .NET. Stream and record with VisioForge Video Capture SDK integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to INSTAR IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **INSTAR** (INSTAR Deutschland GmbH) is a German IP camera manufacturer headquartered in Hanau, Germany. INSTAR specializes in affordable indoor and outdoor IP cameras for the consumer and small business market, with a strong presence in Europe, particularly Germany. INSTAR cameras are known for local storage options, MQTT smart home integration (Home Assistant, ioBroker, Node-RED), and straightforward setup. **Key facts:** - **Product lines:** IN-2xxx/3xxx/4xxx (legacy VGA), IN-5xxx (720p), IN-6xxx (720p HD), IN-7xxx (1080p Full HD), IN-8xxx (current 1080p+), IN-9xxx (current 4K/WQHD) - **Protocol support:** RTSP, HTTP, ONVIF (IN-6xxx and newer), MQTT - **Default RTSP port:** 554 - **Default credentials:** admin / instar (varies by model) - **ONVIF support:** Yes (IN-6xxx, IN-7xxx, IN-8xxx, IN-9xxx series) - **Video codecs:** H.265 (IN-9xxx), H.264 (IN-6xxx/7xxx/8xxx), MPEG-4 (IN-5xxx), MJPEG (legacy IN-2xxx/3xxx/4xxx) ## RTSP URL Patterns INSTAR cameras use a distinctive URL format with a **double forward slash** before the stream number. ### URL Format (HD Models) ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554//11 ``` Double forward slash INSTAR HD cameras use a **double forward slash** (`//`) before the stream number. Using a single slash will result in a connection failure. ### HD Models (IN-6xxx / IN-7xxx / IN-8xxx / IN-9xxx) | Stream | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | Main stream | `rtsp://IP:554//11` | Full resolution | H.264 / H.265 | | Sub stream | `rtsp://IP:554//12` | Lower resolution | Bandwidth-friendly | | Third stream | `rtsp://IP:554//13` | Mobile optimized | Lowest resolution | ### Model-Specific URLs | Model | RTSP URL | Resolution | Type | | --- | --- | --- | --- | | IN-6012 HD | `rtsp://IP:554//11` | 720p | Indoor pan/tilt | | IN-6014 HD | `rtsp://IP:554//11` | 720p | Indoor | | IN-7011 HD | `rtsp://IP:554//11` | 1080p | Indoor pan/tilt | | IN-8015 Full HD | `rtsp://IP:554//11` | 1080p | Indoor/Outdoor | | IN-9008 Full HD | `rtsp://IP:554//11` | 1080p+ | Outdoor PoE | | IN-9020 Full HD | `rtsp://IP:554//11` | WQHD/4K | Outdoor PoE | ### Older 720p Models (IN-5xxx -- MPEG-4) IN-5xxx cameras use a different RTSP path with MPEG-4 encoding: | Model | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | IN-5905 HD | `rtsp://IP:554/MediaInput/mpeg4` | 720p | Outdoor | | IN-5907 HD | `rtsp://IP:554/MediaInput/mpeg4` | 720p | Outdoor | ### Legacy Models (IN-2xxx / IN-3xxx / IN-4xxx -- HTTP Only) Legacy VGA-resolution INSTAR cameras do not support RTSP. They use HTTP-based streaming only: | Model Series | HTTP URL | Type | Notes | | --- | --- | --- | --- | | IN-2xxx/3xxx/4xxx | `http://IP/videostream.asf?user=USER&pwd=PASS&resolution=32&rate=0` | ASF stream | VGA resolution | | IN-2xxx/3xxx/4xxx | `http://IP/videostream.cgi?rate=11` | MJPEG | No audio | | IN-2xxx/3xxx/4xxx | `http://IP//iphone/11?USER:PASS&` | Mobile stream | iPhone-compatible | ## Connecting with VisioForge SDK Use your INSTAR camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // INSTAR IN-8015 Full HD, main stream -- note the double forward slash! var uri = new Uri("rtsp://192.168.1.50:554//11"); var username = "admin"; var password = "instar"; ``` For sub-stream access, use `//12` instead of `//11`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | Snapshot (HD) | `http://IP/tmpfs/auto.jpg` | IN-6xxx/7xxx/8xxx/9xxx | | Snapshot (HD, auth) | `http://IP/snap.jpg?usr=USER&pwd=PASS` | With credentials | | Snapshot (legacy) | `http://IP/snapshot.cgi` | IN-2xxx/3xxx/4xxx | | Snapshot (legacy, auth) | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | Legacy with credentials | | ASF Stream (legacy) | `http://IP/videostream.asf?user=USER&pwd=PASS&resolution=32&rate=0` | VGA ASF | | MJPEG Stream (legacy) | `http://IP/videostream.cgi?rate=11` | Legacy MJPEG | ## Troubleshooting ### Double forward slash is required The most common INSTAR connection issue is forgetting the **double forward slash** before the stream number. The correct URL is `rtsp://IP:554//11` (two slashes), not `rtsp://IP:554/11` (one slash). ### Legacy cameras have no RTSP support IN-2xxx, IN-3xxx, and IN-4xxx cameras are HTTP-only. They do not support RTSP at all. Use the ASF or MJPEG HTTP streaming URLs for these models. ### IN-5xxx uses a different RTSP path IN-5xxx cameras use `rtsp://IP:554/MediaInput/mpeg4` instead of the `//11` path used by newer HD models. If the `//11` URL fails on a 720p INSTAR camera, check whether your model is from the IN-5xxx series. ### MQTT and smart home integration INSTAR cameras support MQTT for integration with Home Assistant, ioBroker, and Node-RED. MQTT is used for camera control and event notifications, not for video streaming. For video integration with smart home platforms, use the RTSP URL. ### PoE availability IN-8xxx and IN-9xxx outdoor models support Power over Ethernet (PoE), allowing a single cable for both power and data. Indoor models typically require a separate power adapter. ### Credentials vary by model While the common default credentials are admin / instar, some models may use different defaults. Check the camera's documentation or label for the factory credentials. INSTAR cameras typically require changing the default password during initial setup. ## FAQ **What is the default RTSP URL for INSTAR cameras?** For current HD models (IN-6xxx, IN-7xxx, IN-8xxx, IN-9xxx), the URL is `rtsp://admin:instar@CAMERA_IP:554//11`. Note the double forward slash before `11`. For IN-5xxx models, use `rtsp://admin:instar@CAMERA_IP:554/MediaInput/mpeg4`. **Do all INSTAR cameras support RTSP?** No. Legacy models (IN-2xxx, IN-3xxx, IN-4xxx) are VGA-resolution cameras that only support HTTP-based streaming in ASF or MJPEG format. All IN-5xxx and newer cameras support RTSP. **What is the difference between stream //11, //12, and //13?** Stream `//11` is the main (highest quality) stream, `//12` is a lower-resolution sub stream suitable for remote viewing over limited bandwidth, and `//13` is a mobile-optimized third stream with the lowest resolution. **Do INSTAR cameras support ONVIF?** Yes. ONVIF is supported on IN-6xxx, IN-7xxx, IN-8xxx, and IN-9xxx series cameras. Legacy models do not support ONVIF. You can use the VisioForge SDK's ONVIF features for camera discovery and PTZ control on supported models. **Can I integrate INSTAR cameras with Home Assistant?** Yes. INSTAR cameras support MQTT, making them easy to integrate with Home Assistant, ioBroker, and Node-RED for automation and event-driven actions. For video streaming in Home Assistant, use the RTSP URL in a generic camera integration. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [ABUS Connection Guide](../abus/) — German consumer / smart home cameras - [Save Original RTSP Stream](../../mediablocks/Guides/rtsp-save-original-stream/) — Record INSTAR streams without re-encoding - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## JVC IP Camera RTSP URL and C# .NET Integration Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/jvc/ **Description:** JVC VN-H, VN-T, VN-C, and VN-X network camera RTSP URL patterns for C# .NET. Stream and record with VisioForge Video Capture SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to JVC IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **JVC** (JVCKENWOOD Corporation) is a Japanese electronics company headquartered in Yokohama, Japan. JVC's Professional Systems Division produced the VN-series IP cameras for surveillance applications. JVC exited the standalone IP camera market around 2015, but many VN-series cameras remain in active service across enterprise and government installations. These cameras are known for their robust PSIA protocol support and reliable performance. **Key facts:** - **Product lines:** VN-H Series (VN-H37, VN-H137, VN-H237, VN-H657), VN-T Series (VN-T216U), VN-X Series (VN-X35U, VN-X235U), VN-C Series (VN-C20U) - **Protocol support:** RTSP, ONVIF (VN-H/VN-T series), PSIA, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / jvc (varies by model) - **ONVIF support:** Yes (VN-H and VN-T series) - **Video codecs:** H.264 (VN-H/VN-T series), MPEG-4 (older VN-C models) Discontinued Product Line JVC exited the IP camera market around 2015. While VN-series cameras remain widely deployed, firmware updates are no longer available. Consider network segmentation and firewall rules to protect these cameras, as they will not receive security patches. ## RTSP URL Patterns ### Standard URL Formats JVC cameras support multiple RTSP URL patterns depending on the model series: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/PSIA/Streaming/channels/0?videoCodecType=H.264 ``` | URL Pattern | Protocol | Description | | --- | --- | --- | | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | PSIA | Primary H.264 stream (most VN-H models) | | `rtsp://IP:554/PSIA/Streaming/channels/CHANNEL` | PSIA | PSIA stream by channel number | | `rtsp://IP:554/video.h264` | H.264 | Direct H.264 stream (VN Series general) | | `rtsp://IP:554/1/stream1` | H.264 | Alternative stream URL (VN-T216U) | | `rtsp://IP:554//livestream` | H.264 | Live stream URL (VN-H57) | PSIA Channel Numbering JVC cameras use zero-based channel numbering for PSIA URLs. Channel 0 is the first (and usually only) video channel. This differs from most other brands that start channel numbering at 1. ### PSIA Channel URLs | Channel | URL | Description | | --- | --- | --- | | Channel 0 (primary) | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | First video channel (main stream) | | Channel 1 | `rtsp://IP:554/PSIA/Streaming/channels/1?videoCodecType=H.264` | Second video channel (sub stream, if available) | ### Camera Models | Model Series | Resolution | Main Stream URL | Codec | | --- | --- | --- | --- | | VN-H37 (HD dome) | 1920x1080 | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | H.264 | | VN-H137 (HD bullet) | 1920x1080 | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | H.264 | | VN-H237 (HD dome) | 1920x1080 | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | H.264 | | VN-H657 (HD PTZ) | 1920x1080 | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | H.264 | | VN-T216U (HD box) | 1920x1080 | `rtsp://IP:554/1/stream1` | H.264 | | VN-X35U (network camera) | 1280x960 | `rtsp://IP:554/video.h264` | H.264 | | VN-X235U (network camera) | 1920x1080 | `rtsp://IP:554/video.h264` | H.264 | | VN-C20U (legacy network) | 640x480 | N/A (HTTP snapshot only) | MJPEG | ## Connecting with VisioForge SDK Use your JVC camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // JVC VN-H Series, PSIA H.264 main stream var uri = new Uri("rtsp://192.168.1.90:554/PSIA/Streaming/channels/0?videoCodecType=H.264"); var username = "admin"; var password = "jvc"; ``` For VN-T series cameras using the alternative URL format: ``` // JVC VN-T216U, alternative stream URL var uri = new Uri("rtsp://192.168.1.90:554/1/stream1"); ``` ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/video.jpg` | Standard snapshot (most models) | | Java Applet Snapshot | `http://IP/java.jpg` | Java-based snapshot (legacy) | | API Snapshot | `http://IP/api/video?encode=jpeg` | API-based JPEG capture (VN-X series) | | MJPEG Stream | `http://IP/api/video?encode=jpeg&framerate=15&boundary=on` | Continuous MJPEG via API | ### Model-Specific Snapshot URLs | Model Series | Snapshot URL | Notes | | --- | --- | --- | | VN-H Series | `http://IP/cgi-bin/video.jpg` | CGI-based snapshot | | VN-T Series | `http://IP/cgi-bin/video.jpg` | CGI-based snapshot | | VN-C Series (VN-C20U) | `http://IP/cgi-bin/video.jpg` | CGI-based snapshot | | VN-X Series (VN-X35U/X235U) | `http://IP/api/video?encode=jpeg` | API-based snapshot | ## Troubleshooting ### PSIA channel numbering starts at 0 Unlike most camera brands where channel numbering starts at 1, JVC uses **zero-based** PSIA channel numbering. If you are porting code from another brand: - Channel 0 = First video channel (equivalent to Channel 1 on other brands) - Channel 1 = Second video channel (sub stream or secondary sensor) ### Default credentials not working JVC cameras ship with different default credentials depending on the model and firmware version: 1. Try `admin` / `jvc` (most common) 2. Try `admin` / `admin` 3. Try accessing the web interface at `http://CAMERA_IP` to reset or verify credentials 4. Some models ship with no default password - access the web interface first to set one ### Firmware updates unavailable Since JVC discontinued its IP camera line around 2015, firmware updates are no longer available. To mitigate security risks: - Place cameras on an isolated VLAN or network segment - Use firewall rules to restrict access to camera ports - Disable UPnP and any cloud connectivity features - Consider replacing end-of-life cameras with currently supported models ### VN-C series HTTP-only access The older VN-C series cameras (such as VN-C20U) do not support RTSP streaming and only provide HTTP-based MJPEG access. Use the HTTP snapshot or MJPEG stream URLs for these models instead of RTSP. ### Multiple URL formats on VN-T series The VN-T216U supports multiple RTSP URL formats. If one does not work, try alternatives: 1. `rtsp://IP:554/1/stream1` (preferred) 2. `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` (PSIA) 3. `rtsp://IP:554/video.h264` (direct H.264) ## FAQ **What is the default RTSP URL for JVC cameras?** For most VN-H series cameras, the primary RTSP URL is `rtsp://admin:jvc@CAMERA_IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264`. The VN-T series uses `rtsp://IP:554/1/stream1` as an alternative. VN-X series models use `rtsp://IP:554/video.h264`. **Are JVC IP cameras still supported?** JVC exited the standalone IP camera market around 2015. The cameras remain functional but no longer receive firmware updates or official support. Many VN-series cameras are still actively deployed in surveillance systems worldwide. **Do JVC cameras support ONVIF?** The VN-H and VN-T series cameras support ONVIF Profile S. Older VN-C and some VN-X models do not support ONVIF and rely on PSIA or proprietary CGI interfaces instead. **Why does PSIA channel numbering start at 0?** JVC implements zero-based PSIA channel numbering, meaning the first video channel is channel 0 rather than channel 1. This is specific to JVC's PSIA implementation and differs from most other camera manufacturers. When migrating from another brand, adjust your channel numbers accordingly. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Sony Connection Guide](../sony/) — Japanese enterprise cameras - [Canon Connection Guide](../canon/) — Japanese professional cameras - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## LG IP Camera RTSP URL Setup and Streaming in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/lg/ **Description:** LG SmartIP, LW, and LV series camera RTSP URL patterns for C# .NET. Stream wireless and wired models using VisioForge Video Capture SDK integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Webcam, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to LG IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **LG Electronics** is a South Korean multinational electronics company headquartered in Seoul, South Korea. LG produced IP cameras under the **SmartIP** brand and the **LW/LV series** for the professional security market. LG has since largely exited the IP camera business and sold its security division. A limited number of LG cameras remain deployed in commercial and enterprise installations. **Key facts:** - **Product lines:** LW Series (wireless dome/bullet), LV Series (wired), SmartIP (enterprise) - **Protocol support:** RTSP, HTTP/CGI, ONVIF (SmartIP series), PSIA (select models) - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (SmartIP series), limited or absent on LW/LV series - **Video codecs:** H.264 (LW130W, LW332, SmartIP series), MJPEG (older models) Discontinued Product Line LG has exited the IP camera market and sold its security division. No new firmware updates or official support are available. Many database entries labeled "LG" are actually LG smartphones used as IP cameras via third-party apps -- only actual LG camera models (LW, LV, SmartIP, 7210R) are covered here. ## RTSP URL Patterns ### Standard URL Formats LG cameras use several different RTSP URL patterns depending on the model series: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/video1+audio1 ``` | URL Pattern | Description | | --- | --- | | `video1+audio1` | H.264 video with audio (LW series, 7210R) | | `/` (root) | Root stream (LV series) | | `//Master-0` | Master stream (LW130W alternate) | | `camera.stm` | Camera stream (LW332) | | `live1.sdp` | Live SDP stream (LW332 alternate) | | PSIA channel URL | Enterprise PSIA streaming (SmartIP) | ### Camera Models - RTSP Streams | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | LW130W | Wireless Dome | `rtsp://IP:554/video1+audio1` | H.264 + audio | | LW130W | Wireless Dome | `rtsp://IP//Master-0` | Alternate Master stream | | LW332 | Wireless Bullet | `rtsp://IP:554/camera.stm` | Camera stream | | LW332 | Wireless Bullet | `rtsp://IP:554/live1.sdp` | Alternate SDP stream | | LVW700 | Wired Dome | `rtsp://IP:554/` | Root stream | | LVW701 | Wired Dome | `rtsp://IP:554/` | Root stream | | 7210R | IP Camera | `rtsp://IP:554/video1+audio1` | H.264 + audio | | SmartIP | Enterprise | `rtsp://IP:554/PSIA/Streaming/channels/2?videoCodecType=H.264` | PSIA H.264 stream | ### Models by Series #### LW Series (Wireless Cameras) | Model | Streaming URLs | Protocol | | --- | --- | --- | | LW130W | `video1+audio1` or `//Master-0` | RTSP + HTTP | | LW332 | `camera.stm` or `live1.sdp` | RTSP + HTTP | #### LV Series (Wired Cameras) | Model | Streaming URLs | Protocol | | --- | --- | --- | | LVW700 | Root stream (`rtsp://IP:554/`) | RTSP | | LVW701 | Root stream (`rtsp://IP:554/`) | RTSP | #### SmartIP Series (Enterprise Cameras) | Model | Streaming URLs | Protocol | | --- | --- | --- | | SmartIP models | PSIA channel URL | RTSP + PSIA + ONVIF | #### Standalone Models | Model | Streaming URLs | Protocol | | --- | --- | --- | | 7210R | `video1+audio1` | RTSP | ### Alternative URL Formats | URL Pattern | Models | Notes | | --- | --- | --- | | `rtsp://IP:554/video1+audio1` | LW130W, 7210R | Standard (recommended for these models) | | `rtsp://IP//Master-0` | LW130W | Alternate; note double-slash, no port | | `rtsp://IP:554/camera.stm` | LW332 | Standard for LW332 | | `rtsp://IP:554/live1.sdp` | LW332 | Alternate SDP format | | `rtsp://IP:554/` | LVW700, LVW701 | Root stream (unusual but valid) | | `rtsp://IP:554/PSIA/Streaming/channels/2?videoCodecType=H.264` | SmartIP | PSIA enterprise streaming | Root Stream URL The LVW700 and LVW701 use a root RTSP URL (`rtsp://IP:554/`) with no path component. This is unusual but valid. Make sure your RTSP client does not strip the trailing slash or add a default path. ## Connecting with VisioForge SDK Use your LG camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // LG LW130W, H.264 + audio stream var uri = new Uri("rtsp://192.168.1.90:554/video1+audio1"); var username = "admin"; var password = "admin"; ``` For LW332 cameras, use `camera.stm` or `live1.sdp` as the stream path instead. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | CGI Snapshot | `http://IP/snapshot.cgi` | Standard CGI snapshot | | JPEG Snapshot | `http://IP/snapshot.jpg` | Direct JPEG (LW130W) | | Video Feed | `http://IP/videofeed` | Live video feed | | MJPEG Stream | `http://IP/video?submenu=mjpg` | Continuous MJPEG stream | | Profile Video | `http://IP/video?profile=CHANNEL` | Profile-based video selection | ## Troubleshooting ### Confusing LG cameras with LG smartphones Many RTSP camera databases contain entries labeled "LG" that are actually **LG smartphones** (P350, P509, P970, Nexus 4, Optimus V, LS670) running third-party IP camera apps like "IP Webcam." These are not actual LG IP cameras. Look for model numbers starting with **LW**, **LV**, **SmartIP**, or **7210R** to identify genuine LG security cameras. ### Root stream URL not connecting The LVW700 and LVW701 cameras use a bare root URL (`rtsp://IP:554/`) with no stream path. Some RTSP client libraries may not handle this correctly. If you experience connection issues: 1. Ensure the trailing slash is included 2. Try specifying the URL as `rtsp://admin:admin@192.168.1.90:554/` 3. Verify the camera is responding on port 554 using a network scanner ### Multiple URL formats per model Some LG cameras (particularly the LW130W and LW332) support multiple RTSP URL formats. If one format fails, try the alternate: - **LW130W:** Try `video1+audio1` first, then `//Master-0` - **LW332:** Try `camera.stm` first, then `live1.sdp` ### PSIA streaming on SmartIP models SmartIP enterprise cameras support PSIA (Physical Security Interoperability Alliance) streaming. The PSIA URL format is: ``` rtsp://admin:admin@192.168.1.90:554/PSIA/Streaming/channels/2?videoCodecType=H.264 ``` Change the channel number to select different streams. PSIA requires authentication via the URL or HTTP digest. ### No firmware updates available LG has exited the security camera market. No new firmware, patches, or official support channels are available. If you encounter bugs or security vulnerabilities, consider replacing the camera with a currently supported model. ## FAQ **What is the default RTSP URL for LG IP cameras?** It depends on the model series. For LW130W and 7210R cameras, use `rtsp://admin:admin@CAMERA_IP:554/video1+audio1`. For LW332, use `rtsp://admin:admin@CAMERA_IP:554/camera.stm`. For LVW700/LVW701, use `rtsp://admin:admin@CAMERA_IP:554/`. Each model series has a different URL pattern. **Are LG IP cameras still supported?** No. LG sold its security division and exited the IP camera market. No firmware updates, new models, or official technical support are available. Existing cameras continue to function but will not receive security patches or feature updates. **Do LG cameras support ONVIF?** Only the SmartIP enterprise series supports ONVIF. The consumer LW and LV series cameras have limited or no ONVIF support. SmartIP cameras also support PSIA as an alternative interoperability protocol. **Why do I see LG phone models in IP camera databases?** Many RTSP URL databases list LG smartphone models (Nexus 4, Optimus V, P509, etc.) as "LG cameras." These are actually phones running third-party apps like "IP Webcam" that turn the phone into a makeshift security camera. They are not actual LG IP camera products and use completely different URL patterns determined by the app. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Samsung Connection Guide](../samsung/) — Korean enterprise cameras - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## LILIN IP Camera RTSP URL Patterns and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/lilin/ **Description:** LILIN LR, Z, D, S, and P series camera RTSP URL patterns for C# .NET. Includes snapshot endpoints and VisioForge SDK streaming integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to LILIN IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **LILIN** (Merit LILIN Co., Ltd.) is a Taiwanese professional security camera manufacturer headquartered in New Taipei City, Taiwan. Founded in 1980, LILIN is one of the oldest IP camera manufacturers in the world. The company is known for professional-grade surveillance cameras with distinctive RTSP URL patterns that encode the resolution directly in the URL path. **Key facts:** - **Product lines:** Z Series (bullet), S Series (speed dome), D Series (dome), LR Series (IR), P Series (panoramic) - **Protocol support:** RTSP, ONVIF, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / pass - **ONVIF support:** Yes (most current models) - **Video codecs:** H.264, MJPEG - **Unique URL pattern:** Resolution encoded in RTSP path (e.g., `rtsph264720p`, `rtsph2641080p`) Resolution-Based RTSP Paths LILIN uses a unique URL pattern where the resolution is encoded directly in the RTSP path (e.g., `rtsph264720p` for 720p, `rtsph2641080p` for 1080p). Make sure to use the correct resolution suffix for your camera model. ## RTSP URL Patterns ### Standard URL Format LILIN cameras use a resolution-based RTSP path format: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/rtsph2641080p ``` | Parameter | Value | Description | | --- | --- | --- | | `rtsph264720p` | 720p stream | H.264 at 1280x720 resolution | | `rtsph2641080p` | 1080p stream | H.264 at 1920x1080 resolution | | `rtsph2641024p` | 1024p stream | H.264 at 1280x1024 resolution (note: double-slash in some models) | ### Camera Models | Model | Resolution | Main Stream URL | Notes | | --- | --- | --- | --- | | LR7022E4 (IR bullet) | 1920x1080 | `rtsp://IP:554/rtsph2641080p` | LR series, 1080p | | LR7722X (IR bullet) | 1920x1080 | `rtsp://IP:554/rtsph2641080p` | LR series, 1080p | | IPR712M4.3 (PTZ) | 1280x1024 | `rtsp://IP:554//rtsph2641024p` | IPR series, double-slash path | | Z Series (bullet) | 1920x1080 | `rtsp://IP:554/rtsph2641080p` | Outdoor bullet cameras | | D Series (dome) | 1920x1080 | `rtsp://IP:554/rtsph2641080p` | Indoor/outdoor dome | | S Series (speed dome) | 1920x1080 | `rtsp://IP:554/rtsph2641080p` | PTZ speed dome | ### Alternative URL Formats Some LILIN models or firmware versions support these alternative URLs: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/rtsph2641080p` | Standard 1080p (recommended) | | `rtsp://IP:554/rtsph264720p` | 720p stream | | `rtsp://IP:554//rtsph2641024p` | 1024p stream (double-slash, some PTZ models) | ## Connecting with VisioForge SDK Use your LILIN camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // LILIN LR7022E4, 1080p main stream var uri = new Uri("rtsp://192.168.1.90:554/rtsph2641080p"); var username = "admin"; var password = "pass"; ``` For 720p access, use `rtsph264720p` instead of `rtsph2641080p`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot (VGA) | `http://IP/getimage?camera=CHANNEL&fmt=vga` | VGA resolution snapshot | | Snapshot by Channel | `http://IP/getimage[CHANNEL]` | Replace CHANNEL with camera number | | Quick Snapshot | `http://IP/snap` | Simple snapshot URL | | CGI Snapshot | `http://IP/cgi-bin/net_jpeg.cgi?ch=CHANNEL` | CGI-based snapshot | | Auth Snapshot | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | URL-based authentication | | Direct Image | `http://IP/image/CHANNEL.jpg` | Direct JPEG image by channel | ## Troubleshooting ### "401 Unauthorized" error LILIN cameras ship with default credentials of `admin` / `pass`. If you have changed the password through the web interface, ensure you update the credentials in your RTSP URL. 1. Access the camera at `http://CAMERA_IP` in a browser 2. Log in with your credentials 3. Verify the RTSP settings under the network configuration section ### Double-slash in RTSP path Some LILIN models, particularly the IPR PTZ series, require a double-slash (`//`) before the resolution path. If a single-slash URL fails: - Try `rtsp://IP:554//rtsph2641024p` instead of `rtsp://IP:554/rtsph2641024p` - This is commonly seen with 1024p resolution models ### Choosing the correct resolution suffix LILIN cameras do not use `subtype=0/1` like many other brands. Instead, the stream resolution is selected by changing the URL path: - `rtsph264720p` for 720p (1280x720) - `rtsph2641080p` for 1080p (1920x1080) - `rtsph2641024p` for 1024p (1280x1024) If you specify a resolution your camera does not support, the connection will fail. ### Port 554 connection refused Verify that RTSP is enabled on the camera: - Web interface: Check **Network > RTSP** settings - Confirm port 554 is not blocked by a firewall - Default RTSP port is 554 ## FAQ **What is the default RTSP URL for LILIN cameras?** The most common URL is `rtsp://admin:pass@CAMERA_IP:554/rtsph2641080p` for the 1080p main stream. Replace the resolution suffix (`rtsph2641080p`) with the appropriate value for your camera's resolution. **Do LILIN cameras support ONVIF?** Yes. Most current LILIN models support ONVIF, which provides an alternative method for discovering and connecting to the camera without needing brand-specific URL patterns. **Why does LILIN use a different RTSP URL format?** LILIN encodes the resolution directly in the RTSP path rather than using channel/subtype parameters like Dahua or Hikvision. This is a proprietary design choice. The format is straightforward once you know which resolution suffix your camera model supports. **What are the default login credentials for LILIN cameras?** The default username is `admin` and the default password is `pass`. It is recommended to change these credentials after initial setup for security purposes. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [AVTech Connection Guide](../avtech/) — Taiwanese industrial cameras - [BrickCom Connection Guide](../brickcom/) — Taiwanese industrial cameras - [RTSP Camera Integration Guide](../../videocapture/video-sources/ip-cameras/rtsp/) — LILIN RTSP stream configuration - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Linksys IP Camera RTSP URL Patterns and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/linksys/ **Description:** Connect to Linksys WVC, PVC, and LCAB cameras in C# .NET with RTSP URL patterns, ASF/MJPEG streams, and code samples for discontinued WVC series models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MP4, H.264, MJPEG, C# # How to Connect to Linksys IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Linksys** is an American networking company based in Irvine, California. Originally acquired by Cisco Systems in 2003, the brand was sold to Belkin (a Foxconn subsidiary) in 2013. During the Cisco ownership years, Linksys produced the popular **WVC (Wireless Video Camera)** series of IP cameras for the consumer and prosumer market. The camera product line was discontinued around 2014, but many units remain deployed and operational. Because Linksys was a Cisco brand, its cameras share identical URL patterns and firmware with Cisco consumer camera products. The `.sav` extension in RTSP URLs is a proprietary Cisco/Linksys endpoint format. **Key facts:** - **Product lines:** WVC Series (WVC54G, WVC54GC, WVC54GCA, WVC80N, WVC200, WVC210, WVC2300), PVC Series (PVC2300), LCAB Series - **Protocol support:** RTSP, HTTP/ASF, MJPEG, MMS (Windows Media) - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Limited (LCAB series only) - **Video codecs:** MPEG-4/ASF (WVC series), H.264 (newer models), MJPEG Discontinued product line Linksys IP cameras were discontinued around 2014. No new firmware updates or official support are available. The information on this page is provided for legacy deployments. Many WVC models require Internet Explorer with ActiveX for their web interface. Linksys = Cisco consumer cameras Linksys cameras use the same URL patterns as Cisco consumer cameras since Linksys was a Cisco brand. See our [Cisco connection guide](../cisco/) for additional details and enterprise Cisco camera models. ## RTSP URL Patterns ### Standard URL Format Most Linksys cameras use the Cisco `/img/media.sav` RTSP path: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/img/media.sav ``` Unusual `.sav` extension The `.sav` extension is a proprietary Cisco/Linksys RTSP endpoint -- it is not a standard media file format. Do not confuse it with a file download URL. ### RTSP URLs by Model | Model | RTSP URL | Codec | Notes | | --- | --- | --- | --- | | WVC54GCA | `rtsp://IP:554/img/media.sav` | MPEG-4 | Wireless-G, 640x480 | | WVC80N | `rtsp://IP:554/img/media.sav` | MPEG-4 | Wireless-N, 640x480 | | WVC80N (alt) | `rtsp://IP:554/img/video.sav` | MPEG-4 | Alternative video endpoint | | WVC210 | `rtsp://IP:554/img/media.sav` | MPEG-4 | Wireless-G PTZ | | WVC200 | `rtsp://IP:554/img/media.sav` | MPEG-4 | Wireless-G | | PVC2300 | `rtsp://IP:554/video.mp4` | MPEG-4/H.264 | Small business box camera | | LCAB03VLNOD | `rtsp://IP:554//ONVIF/channel2` | H.264 | ONVIF-enabled outdoor camera | ### Model Family Summary | Model Family | RTSP Stream | HTTP ASF | MJPEG | Snapshot CGI | | --- | --- | --- | --- | --- | | WVC54G / WVC54GC / WVC54GCA | `/img/media.sav` | Yes | Yes | Yes | | WVC80N | `/img/media.sav`, `/img/video.sav` | Yes | Yes | -- | | WVC200 / WVC210 | `/img/media.sav` | Yes | Yes | Yes | | WVC2300 | `/img/media.sav` | Yes | -- | -- | | PVC2300 | `/video.mp4` | Yes | -- | -- | | LCAB series | `//ONVIF/channel2` | -- | -- | -- | ## Connecting with VisioForge SDK Use your Linksys camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Linksys WVC80N, primary RTSP stream var uri = new Uri("rtsp://192.168.1.60:554/img/media.sav"); var username = "admin"; var password = "admin"; ``` For PVC2300 cameras, use `/video.mp4` instead of `/img/media.sav`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Compatible Models | | --- | --- | --- | | ASF Video Stream | `http://IP/img/video.asf` | WVC54G, WVC54GC, WVC54GCA, WVC80N, WVC200, WVC210, WVC11b | | MJPEG Stream | `http://IP/img/video.mjpeg` | WVC54GC, WVC54GCA, WVC80N, WVC200, WVC210 | | MJPEG Single Frame | `http://IP/img/mjpeg.jpg` | Most WVC models | | MJPEG CGI | `http://IP/img/mjpeg.cgi` | Most WVC models | | MJPEG (uppercase) | `http://IP/MJPEG.CGI` | Some WVC models | | High-Res Snapshot | `http://IP/img/snapshot.cgi?size=3` | WVC54GCA, WVC200, WVC210 | | Medium Snapshot | `http://IP/img/snapshot.cgi?size=2` | WVC54GCA, WVC200, WVC210 | | VGA Snapshot | `http://IP/img/snapshot.cgi?img=vga` | WVC54GCA, WVC200, WVC210 | | Alternative ASF | `http://IP/videostream.asf` | WVC54GC, WVC80N | | MMS Stream | `mms://IP/img/video.asf` | Legacy Windows Media (all WVC models) | HTTP streams as RTSP fallback Many Linksys WVC cameras work more reliably with HTTP-based ASF or MJPEG streams than with RTSP. If the RTSP URL is unresponsive, try the ASF stream at `http://IP/img/video.asf` as a fallback. ## Troubleshooting ### RTSP stream not connecting Linksys WVC cameras have limited RTSP support. Many models primarily serve video over HTTP using ASF (Advanced Streaming Format) rather than true RTSP: 1. Verify the camera IP address and that port 554 is open 2. Confirm RTSP is enabled in the camera's web interface 3. Try the HTTP ASF stream (`http://IP/img/video.asf`) as an alternative 4. Some models require the web interface to be accessed first (via Internet Explorer with ActiveX) before RTSP becomes available ### ASF stream requires specific handling The ASF (Advanced Streaming Format) streams from WVC cameras use a Microsoft proprietary container. The VisioForge SDK handles ASF streams automatically. If you encounter issues: - Ensure you are connecting via HTTP, not RTSP, for ASF URLs - ASF streams may require Windows Media components or LAV filters on some systems ### MMS protocol streams The `mms://` protocol URLs are Windows Media-specific and only work with Windows Media Player or compatible decoders. For modern applications, use the HTTP ASF URL (`http://IP/img/video.asf`) instead of the MMS equivalent. ### Web interface requires Internet Explorer Many WVC models require Internet Explorer with ActiveX controls for their web configuration interface. Use Internet Explorer or an ActiveX-compatible browser to access camera settings. The RTSP and HTTP streams themselves work with any client. ### Camera not discoverable on network Linksys cameras do not support modern discovery protocols (except LCAB series with ONVIF). To find the camera: 1. Check your router's DHCP lease table for the camera's IP address 2. Use the Linksys Camera Utility (if still available) for discovery 3. Try the default IP address assigned by the camera (check the model's manual) 4. Use a network scanner such as Advanced IP Scanner ## FAQ **What is the default RTSP URL for Linksys cameras?** For most Linksys WVC cameras, use `rtsp://admin:admin@CAMERA_IP:554/img/media.sav`. For the PVC2300, use `rtsp://admin:admin@CAMERA_IP:554/video.mp4` instead. If RTSP does not work, try the HTTP ASF stream at `http://CAMERA_IP/img/video.asf`. **Are Linksys cameras still available for purchase?** No. Linksys discontinued its entire IP camera product line around 2014, shortly after the brand was sold from Cisco to Belkin/Foxconn. No firmware updates or official support are available. However, many WVC and PVC cameras remain in use and functional. **Do Linksys cameras support ONVIF?** Only the LCAB series cameras have ONVIF support. The WVC and PVC series do not support ONVIF. For WVC cameras, use the direct RTSP or HTTP URL patterns listed above. **Are Linksys and Cisco camera URLs the same?** Yes. Linksys cameras were produced during Cisco's ownership of the brand and share the same firmware and URL patterns as Cisco consumer cameras. The `/img/media.sav` RTSP path and `/img/video.asf` HTTP path are identical across both brands. See our [Cisco connection guide](../cisco/) for more details. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Cisco Connection Guide](../cisco/) — Same URL patterns, parent company - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Lorex IP Camera RTSP URL Connection Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/lorex/ **Description:** Lorex LNB, LNE, LNZ, DVR, and NVR RTSP URL patterns for C# .NET. Stream and record Lorex cameras using VisioForge Video Capture SDK integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MP4, H.264, C# # How to Connect to Lorex IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Lorex Technology** (a subsidiary of Dahua Technology through FLIR/Lorex) is a major consumer and prosumer security camera brand in North America. Lorex cameras are primarily manufactured by **Dahua Technology** and sold under the Lorex brand through retail channels including Amazon, Costco, and Best Buy. Lorex is one of the top-selling security camera brands in the United States and Canada. **Key facts:** - **Product lines:** LNB (bullet IP), LNE (dome/turret IP), LNZ (PTZ IP), LNC (consumer Wi-Fi), IPSC (legacy), L-series (legacy) - **Protocol support:** RTSP, ONVIF, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / (set during NVR/camera setup); some older models: admin / admin - **ONVIF support:** Yes (most current models) - **Video codecs:** H.264, H.265 (newer models) - **OEM base:** Dahua Technology (some models use Hikvision firmware) Lorex uses multiple OEM sources Most Lorex IP cameras are manufactured by Dahua and use Dahua's RTSP URL format. However, some Lorex models (particularly LNB2153 and MCNB2153) use Hikvision-based firmware with `/Streaming/Channels/` URLs. Check both URL formats if one doesn't work. ## RTSP URL Patterns ### Dahua-Based Models (Most Lorex IP Cameras) Most Lorex IP cameras use Dahua's URL format: | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Full resolution | | Sub stream | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | Lower resolution | ### Hikvision-Based Models Some Lorex models use Hikvision firmware: | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:554//Streaming/Channels/1` | Full resolution (note double slash) | | Sub stream | `rtsp://IP:554//Streaming/Channels/2` | Lower resolution | | H.264 direct | `rtsp://IP:554/ch0_0.h264` | Direct H.264 stream | ### Model-Specific URLs | Model | RTSP URL | OEM Base | Notes | | --- | --- | --- | --- | | LNB2153 | `rtsp://IP:554//Streaming/Channels/1` | Hikvision | 1080p bullet | | LNB2184 | `rtsp://IP:554/video.mp4` | Dahua | 4MP bullet | | LNE1001 | `rtsp://IP:554/` | Dahua | 1080p dome | | LNE3003 | `rtsp://IP:554/video.mp4` | Dahua | 2K dome | | LNZ4001 | `rtsp://IP:554/video.mp4` | Dahua | PTZ | | MCNB2153 | `rtsp://IP:554//Streaming/Channels/1` | Hikvision | 1080p bullet | ### Alternative URL Formats Some Lorex cameras also respond to these URLs: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/` | Root path (some models) | | `rtsp://IP:554/video.mp4` | Video stream | | `rtsp://IP:554/ch0_0.h264` | Direct H.264 | ### Legacy Models | Model | URL | Notes | | --- | --- | --- | | IPSC Series | `rtsp://IP:554/` | Legacy IP cameras | | L23WD | `rtsp://IP:554/` | Legacy wireless | | IP1240 | `http://IP/GetData.cgi` | HTTP only | | LNC104/116/204 | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | Wi-Fi cameras, HTTP only | ## Connecting with VisioForge SDK Use your Lorex camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code). ### Dahua-Based Models (Most Lorex Cameras) ``` // Lorex camera (Dahua-based), main stream var uri = new Uri("rtsp://192.168.1.65:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "YourPassword"; ``` ### Hikvision-Based Lorex Models ``` // Lorex LNB2153 (Hikvision-based), main stream var uri = new Uri("rtsp://192.168.1.65:554//Streaming/Channels/1"); var username = "admin"; var password = "YourPassword"; ``` See the [OEM identification guide](#determine-your-oem-base) in Troubleshooting to determine which URL format your Lorex camera uses. ## Snapshot URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/jpg/image.jpg` | Most Lorex IP cameras | | Snapshot (auth) | `http://IP/snapshot.jpg?user=USER&pwd=PASS` | Consumer Wi-Fi cameras | | Snapshot (account) | `http://IP/snapshot.jpg?account=USER&password=PASS` | Alternative auth | | GetData | `http://IP/GetData.cgi` | Legacy models | | MJPEG Stream | `http://IP/video.mjpg` | Continuous MJPEG | ## Troubleshooting ### Determine your OEM base Lorex cameras use firmware from different manufacturers. To determine which URL format to use: 1. Try the **Dahua format** first: `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` 2. If that fails, try the **Hikvision format**: `rtsp://IP:554//Streaming/Channels/1` 3. Check the camera's web interface -- Dahua-based cameras have a blue/white web UI, while Hikvision-based ones have a dark gray/black UI ### NVR vs direct camera access - When connecting through a Lorex NVR, use `channel=N` in the Dahua URL format to select the camera - When connecting directly to an IP camera, always use `channel=1` ### Lorex consumer Wi-Fi cameras (LNC series) The LNC series (LNC104, LNC116, LNC204) are consumer Wi-Fi cameras that typically don't support RTSP. They provide HTTP snapshot URLs only and are primarily designed for use with the Lorex app. ### Port 9000 Some very old Lorex cameras used port 9000 for streaming instead of 554. If standard port 554 doesn't work on an older model, try: `rtsp://IP:9000/` ## FAQ **Are Lorex cameras the same as Dahua?** Most Lorex IP cameras are manufactured by Dahua and use identical firmware. The RTSP URL format (`cam/realmonitor?channel=1&subtype=0`) is the same. However, some Lorex models use Hikvision firmware. See our [Dahua connection guide](../dahua/) for additional details. **What is the default RTSP URL for Lorex cameras?** Try `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=0` first (Dahua-based). If that fails, try `rtsp://admin:password@CAMERA_IP:554//Streaming/Channels/1` (Hikvision-based). **Can I use Lorex cameras without the Lorex NVR?** Yes. Lorex IP cameras with RTSP support can be connected directly using their individual IP addresses. You don't need the Lorex NVR for third-party software integration. **Do Lorex cameras support ONVIF?** Most current Lorex IP cameras support ONVIF. Consumer Wi-Fi cameras (LNC series) generally do not. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Dahua Connection Guide](../dahua/) — Same URL format for most models - [Amcrest Connection Guide](../amcrest/) — Another Dahua OEM - [Swann Connection Guide](../swann/) — Consumer/prosumer segment peer - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## LTS IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/lts/ **Description:** Connect to LTS (LT Security) cameras in C# .NET with RTSP URL patterns and code samples for CMIP, CMHR series and NVR models. LTS uses Hikvision firmware. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to LTS IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **LTS (LT Security Inc.)** is an American security company based in City of Industry, California. LTS cameras are manufactured by **Hikvision** and use Hikvision firmware, protocols, and web interfaces. LTS rebrands Hikvision hardware with US-based technical support and competitive pricing, making it a popular choice in the professional installation market. Because LTS cameras run Hikvision firmware, they use the same RTSP URL format, ONVIF implementation, and API endpoints as Hikvision cameras. Any integration code written for Hikvision works with LTS and vice versa. **Key facts:** - **Product lines:** CMIP (IP cameras), CMHR (HD-TVI analog), LTD (DVRs), LTN (NVRs) - **Protocol support:** RTSP, ONVIF Profile S/G/T, HTTP/ISAPI - **Default RTSP port:** 554 - **Default credentials:** admin / 123456 (some models: admin / admin) - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264, H.265 (CMIP4xxx and newer) - **OEM base:** Hikvision (identical RTSP URL format) LTS = Hikvision OEM LTS cameras use Hikvision firmware and the exact same RTSP URL format as Hikvision cameras. Any code written for Hikvision cameras works with LTS. See our [Hikvision connection guide](../hikvision/) for additional details. ## RTSP URL Patterns ### Standard URL Format (Hikvision) Most current LTS cameras use the standard Hikvision `Streaming/Channels` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/Streaming/Channels/[CHANNEL_ID] ``` | Parameter | Value | Description | | --- | --- | --- | | `CHANNEL_ID` | 101 | Channel 1, main stream | | `CHANNEL_ID` | 102 | Channel 1, sub stream | | `CHANNEL_ID` | 201 | Channel 2, main stream (NVR) | | `CHANNEL_ID` | 202 | Channel 2, sub stream (NVR) | Double-slash in URL Some LTS/Hikvision cameras use `//Streaming/Channels/1` (with a double forward slash before `Streaming`). Both single-slash and double-slash variants typically work, but try the double-slash version if the single-slash URL fails. ### RTSP URLs by Model | Model | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | CMIP3122 | `rtsp://IP:554/Streaming/Channels/101` | 3MP | Hikvision standard format | | CMIP3132-28 | `rtsp://IP:554/Streaming/Channels/101` | 3MP | Hikvision standard format | | CMIP3432 | `rtsp://IP:554/Streaming/Channels/101` | 4MP | Hikvision standard format | | CMIP3243 | `rtsp://IP:554/live.h264` | 3MP | Alternative H.264 stream | | CMIP3412-28 | `rtsp://IP:554/live.h264` | 4MP | Alternative H.264 stream | | CMIP8232 | `rtsp://IP:554/live.sdp` | 8MP/4K | SDP live stream | | CMIP8232 (alt) | `rtsp://IP:554/HighResolutionVideo` | 8MP/4K | High resolution stream | | CMIP8232 (sub) | `rtsp://IP:554/h264/ch1/sub/` | 8MP/4K | H.264 sub stream | | CMIP series (low-res) | `rtsp://IP:554/LowResolutionVideo` | Varies | Low resolution sub stream | ### Alternative URL Formats Some older LTS models or specific firmware versions support these alternative URLs: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/Streaming/Channels/101` | Standard Hikvision (recommended) | | `rtsp://IP:554//Streaming/Channels/1` | Double-slash variant | | `rtsp://IP:554/live.h264` | H.264 live stream (older CMIP3xxx) | | `rtsp://IP:554/live.sdp` | SDP live stream (CMIP8xxx) | | `rtsp://IP:554/HighResolutionVideo` | Named high-resolution stream | | `rtsp://IP:554/LowResolutionVideo` | Named low-resolution stream | | `rtsp://IP:554/h264/ch1/sub/` | H.264 sub stream by channel | | `rtsp://IP:554/cam1/mpeg4?user=USER&pwd=PASS` | MPEG-4 with URL-based auth | ### NVR Channel URLs (LTN Series) For LTS NVRs (LTN8704, LTN8708, LTN8716, etc.): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/Streaming/Channels/101` | `rtsp://IP:554/Streaming/Channels/102` | | Camera 2 | `rtsp://IP:554/Streaming/Channels/201` | `rtsp://IP:554/Streaming/Channels/202` | | Camera N | `rtsp://IP:554/Streaming/Channels/N01` | `rtsp://IP:554/Streaming/Channels/N02` | ### Model Series Summary | Model Series | Primary RTSP URL | Alternative URLs | | --- | --- | --- | | CMIP3xxx (3MP) | `/Streaming/Channels/101` | `/live.h264` (some models) | | CMIP4xxx (4MP) | `/Streaming/Channels/101` | `/live.h264` (some models) | | CMIP8xxx (8MP/4K) | `/Streaming/Channels/101` | `/live.sdp`, `/HighResolutionVideo`, `/h264/ch1/sub/` | | LTN NVRs | `/Streaming/Channels/N01` | Channel-based | | LTD DVRs | `/Streaming/Channels/N01` | Channel-based | ## Connecting with VisioForge SDK Use your LTS camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // LTS CMIP3432, main stream (Hikvision format) var uri = new Uri("rtsp://192.168.1.80:554/Streaming/Channels/101"); var username = "admin"; var password = "123456"; ``` For sub-stream access, use channel ID `102` instead of `101`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/snapshot.jpg` | Standard snapshot | | 3GP Snapshot | `http://IP/snapshot_3gp.jpg` | 3GP format (mobile-optimized) | | Stream Snapshot | `http://IP/stream.jpg` | Stream-based snapshot | | DVR Channel Snapshot | `http://IP/stillimg[CHANNEL].jpg` | Replace `[CHANNEL]` with channel number (LTD DVRs) | | ISAPI Snapshot | `http://IP/ISAPI/Streaming/channels/101/picture` | Hikvision ISAPI (requires auth) | ## Troubleshooting ### Identifying the correct URL format LTS cameras span multiple generations with different URL formats. To determine which URL your camera uses: 1. Try the standard Hikvision format first: `rtsp://IP:554/Streaming/Channels/101` 2. If that fails, try the double-slash variant: `rtsp://IP:554//Streaming/Channels/1` 3. For older CMIP3xxx models, try `rtsp://IP:554/live.h264` 4. For CMIP8xxx (4K) models, try `rtsp://IP:554/live.sdp` ### Default credentials and activation - Older LTS cameras: default password is `123456` or `admin` - Newer LTS cameras (with Hikvision 5.3+ firmware): require password activation on first use, similar to Hikvision - If you cannot log in with default credentials, the camera may need to be activated via the LTS Discovery Tool or Hikvision SADP Tool ### Using Hikvision tools with LTS cameras Since LTS cameras run Hikvision firmware, you can use Hikvision utilities for network discovery and configuration: - **Hikvision SADP Tool** -- discovers LTS cameras on the local network and can activate/reset them - **LTS Discovery Tool** -- LTS-branded version of SADP with identical functionality - **iVMS-4200** -- Hikvision's free VMS software works with LTS cameras ### "401 Unauthorized" error 1. Verify your credentials are correct (default: admin / 123456) 2. On newer firmware, ensure the camera has been activated and you are using the password set during activation 3. Check if the camera has a lockout policy -- too many failed login attempts may temporarily block access 4. Some models require digest authentication rather than basic authentication for RTSP ### Double-slash URL issue The `//Streaming/Channels/1` URL with a double forward slash at the beginning is a known Hikvision pattern. Some HTTP clients or RTSP libraries may normalize this to a single slash. If your connection fails: - Ensure your URL string preserves the double slash - Try both `//Streaming/Channels/1` and `/Streaming/Channels/101` variants ## FAQ **Are LTS cameras the same as Hikvision?** LTS cameras are manufactured by Hikvision and run Hikvision firmware. The RTSP URL format (`/Streaming/Channels/101`), ONVIF implementation, and ISAPI interface are identical. The main differences are branding, pricing, and US-based technical support from LTS. Any code written for Hikvision cameras works with LTS cameras. **What is the default RTSP URL for LTS cameras?** For most current LTS cameras, use `rtsp://admin:123456@CAMERA_IP:554/Streaming/Channels/101` for the main stream. Use channel ID `102` for the sub stream. Older models may use `/live.h264` or `/live.sdp` instead. **Do LTS cameras support ONVIF?** Yes. All current LTS IP cameras (CMIP series) support ONVIF Profile S and Profile T. ONVIF can be used for automatic discovery and configuration alongside direct RTSP URLs. **What is the difference between CMIP and CMHR series?** CMIP cameras are IP (network) cameras that support RTSP streaming. CMHR cameras are HD-TVI analog cameras that connect directly to DVRs via coaxial cable and do not have network RTSP capability. Only CMIP series cameras can be connected to via RTSP URLs in software. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Hikvision Connection Guide](../hikvision/) — Same URL format (OEM base) - [Annke Connection Guide](../annke/) — Another Hikvision OEM - [RTSP Camera Integration Guide](../../videocapture/video-sources/ip-cameras/rtsp/) — LTS RTSP stream configuration - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Mercusys IP Camera RTSP URL and C# .NET Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/mercusys/ **Description:** Mercusys MC and MB series indoor/outdoor camera RTSP URL patterns for C# .NET. Stream and record using VisioForge Video Capture SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to Mercusys IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Mercusys** is a networking and smart home brand owned by **TP-Link**. Mercusys targets the budget-conscious segment with affordable routers, mesh systems, and security cameras. Mercusys cameras share design and firmware similarities with TP-Link Tapo cameras, offering standard RTSP support at lower price points. **Key facts:** - **Product lines:** MC (indoor cameras), MB (outdoor cameras) - **Protocol support:** RTSP, ONVIF (select models), HTTP - **Default RTSP port:** 554 - **Default credentials:** Set during app setup (no factory defaults) - **ONVIF support:** Yes (newer models, must be enabled) - **Video codecs:** H.264 - **Parent company:** TP-Link - **Companion app:** Mercusys Security app Mercusys and TP-Link Tapo Mercusys cameras share firmware architecture with TP-Link Tapo cameras. The RTSP URL format (`/stream1`, `/stream2`) is similar. If you are familiar with Tapo integration, the same approach works with Mercusys. See our [TP-Link connection guide](../tp-link/) for additional details. ## RTSP URL Patterns ### Standard URL Format Mercusys cameras use a stream-number-based RTSP URL: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/stream1 ``` | Stream | URL Pattern | Description | | --- | --- | --- | | Main stream | `rtsp://IP:554/stream1` | Full resolution | | Sub stream | `rtsp://IP:554/stream2` | Lower resolution, less bandwidth | ### Camera Models | Model | Type | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | --- | | MC50 (indoor PT) | Indoor pan/tilt | 1920x1080 | `rtsp://IP:554/stream1` | Yes | | MC60 (2K indoor PT) | Indoor pan/tilt | 2304x1296 | `rtsp://IP:554/stream1` | Yes | | MC70 (4MP indoor PT) | Indoor pan/tilt | 2560x1440 | `rtsp://IP:554/stream1` | Yes | | MB50 (outdoor bullet) | Outdoor | 1920x1080 | `rtsp://IP:554/stream1` | Yes | | MB60 (2K outdoor) | Outdoor | 2304x1296 | `rtsp://IP:554/stream1` | Yes | | MB70 (4MP outdoor) | Outdoor | 2560x1440 | `rtsp://IP:554/stream1` | Yes | ### Enabling RTSP / ONVIF RTSP and ONVIF may need to be enabled in the camera settings: 1. Open the **Mercusys Security** app 2. Select your camera → **Settings** 3. Navigate to **Advanced Settings** 4. Enable **RTSP** and/or **ONVIF** 5. Set a username and password for RTSP access ## Connecting with VisioForge SDK Use your Mercusys camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Mercusys MC70 (4MP indoor pan/tilt), main stream var uri = new Uri("rtsp://192.168.1.90:554/stream1"); var username = "rtsp_user"; // set in Mercusys Security app var password = "rtsp_pass"; ``` For sub-stream access, use `/stream2` instead of `/stream1`. ## Snapshot URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Requires basic auth | ## Troubleshooting ### RTSP not accessible Mercusys cameras require initial setup through the Mercusys Security app. RTSP may also need to be explicitly enabled in the advanced settings. After enabling RTSP, the credentials set in the app must be used for RTSP authentication. ### Camera IP discovery Find your Mercusys camera's IP address in: 1. The Mercusys Security app → Device Info 2. Your router's DHCP client list 3. ONVIF discovery (if enabled) ### Similar to TP-Link Tapo If standard Mercusys troubleshooting does not resolve your issue, check our [TP-Link Tapo guide](../tp-link/) for additional troubleshooting steps, as the firmware is similar. ## FAQ **What is the default RTSP URL for Mercusys cameras?** Mercusys cameras use `rtsp://username:password@CAMERA_IP:554/stream1` for the main stream and `/stream2` for the sub stream. The username and password are set during RTSP enablement in the Mercusys Security app. **Is Mercusys the same as TP-Link?** Mercusys is a brand owned by TP-Link that targets the budget segment. Mercusys cameras share firmware architecture with TP-Link Tapo cameras and use similar RTSP URL formats. **Do Mercusys cameras support ONVIF?** Newer Mercusys camera models support ONVIF, but it must be enabled through the Mercusys Security app. Older models may not include ONVIF support. **How do Mercusys cameras compare to TP-Link Tapo?** Mercusys cameras are positioned as a more affordable alternative to Tapo. They share similar firmware and RTSP URL patterns. Tapo cameras generally have more model options and broader community support. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [TP-Link Connection Guide](../tp-link/) — Parent company, similar firmware - [Tenda Connection Guide](../tenda/) — Budget camera alternative - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Milesight IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/milesight/ **Description:** Milesight MS-C, MS-A, MS-V series RTSP URL patterns for C# .NET. ONVIF-compliant integration with VisioForge Video Capture SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to Milesight IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Milesight Technology** is a Chinese manufacturer of IP cameras and IoT devices, headquartered in Xiamen, China. Milesight targets professional and SMB markets with a rapidly growing lineup of AI-enabled cameras at competitive price points. The brand is known for strong ONVIF compliance, built-in AI analytics (face detection, LPR, people counting), and straightforward integration with third-party VMS platforms. **Key facts:** - **Product lines:** MS-C (mini dome/bullet), MS-A (PTZ/speed dome), MS-V (vandal dome), MS-F (fisheye), MS-B (box), MS-N (NVR) - **Protocol support:** RTSP, ONVIF (Profile S/G/T on all current models), HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / ms1234 (must be changed on first login) - **ONVIF support:** Yes (all current models, Profile S/G/T) - **Video codecs:** H.264, H.265, MJPEG Double slash in RTSP URLs Milesight cameras use a **double forward slash** before `main` and `sub` in their RTSP URLs: `rtsp://IP:554//main`. This is intentional and required for all current Milesight models. ## RTSP URL Patterns ### Current Models (All Series) | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:554//main` | Full resolution (note double slash) | | Sub stream | `rtsp://IP:554//sub` | Lower resolution | | Root stream | `rtsp://IP:554/` | Fallback | ### Model-Specific URLs All current Milesight camera models use the same RTSP URL pattern: | Model Series | RTSP URL | Type | Notes | | --- | --- | --- | --- | | MS-C2672-P | `rtsp://IP:554//main` | Mini dome | 2MP | | MS-C3366-FP | `rtsp://IP:554//main` | Bullet | 3MP, AI | | MS-C3366-FPH | `rtsp://IP:554//main` | Bullet | 3MP, AI, heater | | MS-C2363 | `rtsp://IP:554//main` | Mini dome | 2MP | | MS-2681 | `rtsp://IP:554//main` | Dome | 8MP | | MS-3672 | `rtsp://IP:554//main` | Bullet | 3MP | | MS-A series (PTZ) | `rtsp://IP:554//main` | PTZ | Speed dome | | MS-V series (vandal) | `rtsp://IP:554//main` | Vandal dome | IK10 rated | | MS-F series (fisheye) | `rtsp://IP:554//main` | Fisheye | 360-degree | | MS-B series (box) | `rtsp://IP:554//main` | Box | Professional | ### NVR Channel Streams For Milesight MS-N series NVRs, use the `channel` parameter to select individual camera streams: | Stream | RTSP URL | Notes | | --- | --- | --- | | Channel 1, main | `rtsp://IP:554//main?channel=1` | NVR channel 1 | | Channel 2, main | `rtsp://IP:554//main?channel=2` | NVR channel 2 | | Channel 1, sub | `rtsp://IP:554//sub?channel=1` | NVR channel 1, low-res | | Channel 2, sub | `rtsp://IP:554//sub?channel=2` | NVR channel 2, low-res | ## Connecting with VisioForge SDK Use your Milesight camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Milesight camera, main stream -- note the double slash before "main" var uri = new Uri("rtsp://192.168.1.90:554//main"); var username = "admin"; var password = "ms1234"; ``` For sub-stream access, use `//sub` instead of `//main`. For NVR channel selection, append `?channel=N` to the URL. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | CGI Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Basic auth required | ## Troubleshooting ### Double slash is required Milesight cameras require a **double forward slash** before the stream path: - Correct: `rtsp://IP:554//main` - May not work: `rtsp://IP:554/main` If your connection fails, verify that you are using the double-slash URL format. This pattern is similar to Pelco and ACTi cameras. ### Default password must be changed The factory default password is `ms1234`, but Milesight cameras require this password to be changed during first login through the web interface or Milesight CMS. If the default password does not work, the camera has likely been configured with a new password. ### AI features are independent of RTSP Milesight AI features (face detection, license plate recognition, people counting, intrusion detection) run on the camera's built-in processor and do not affect RTSP streaming. AI metadata and events are delivered through ONVIF events or the Milesight API, not through the RTSP stream itself. ### Milesight CMS is optional Milesight CMS (Central Management Software) is Milesight's proprietary VMS. It is not required for RTSP streaming. Milesight cameras work with any ONVIF-compatible VMS or any application that supports standard RTSP connections. ### NVR channel numbering When connecting through a Milesight MS-N NVR, channel numbers start at 1 and correspond to the physical camera input or network camera order configured in the NVR. Use `?channel=1` for the first camera, `?channel=2` for the second, and so on. ### ONVIF discovery All current Milesight cameras support ONVIF Profile S, G, and T. If you prefer automatic discovery over manual RTSP URL configuration, use ONVIF device discovery to find cameras on your network and retrieve their streaming URLs automatically. ## FAQ **What is the default RTSP URL for Milesight cameras?** For all current Milesight cameras, use `rtsp://admin:ms1234@CAMERA_IP:554//main` (note the double slash). For the sub-stream, use `//sub`. For NVR access, append `?channel=N` to select the desired camera channel. **Do all Milesight models use the same RTSP URL?** Yes. All current Milesight camera models (MS-C, MS-A, MS-V, MS-F, MS-B series) use the same `//main` and `//sub` URL pattern. This makes Milesight one of the most consistent brands for RTSP integration. **Does Milesight support H.265?** Yes. All current Milesight cameras support H.264, H.265, and MJPEG encoding. H.265 can be enabled through the camera's web interface or Milesight CMS to reduce bandwidth and storage requirements. **Why does the double slash matter in Milesight URLs?** The double slash (`//main` instead of `/main`) is part of Milesight's RTSP URL specification. Omitting the extra slash may cause connection failures. This convention is shared with a few other camera brands (Pelco, ACTi) but is not universal across the industry. **Can I access Milesight AI analytics through RTSP?** No. RTSP delivers the video stream only. AI analytics results (face detection events, license plate data, people counting statistics) are accessible through ONVIF events, the Milesight HTTP API, or Milesight CMS. The video stream itself does not contain embedded AI metadata. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Grandstream Connection Guide](../grandstream/) — SMB / professional camera segment - [IP Camera Capture to MP4](../../videocapture/video-tutorials/ip-camera-capture-mp4/) — Record Milesight streams to file - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Mobotix RTSP URL Patterns for IP Camera Access in C# **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/mobotix/ **Description:** Connect to MOBOTIX cameras in C# .NET with RTSP URL patterns for classic Mx and MOVE series. Includes MxPEG, MJPEG, and H.264 stream options. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, USB3 Vision / GigE, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Mobotix IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **MOBOTIX** (MOBOTIX AG) is a German IP camera manufacturer headquartered in Langmeil, Germany, founded in 1999. MOBOTIX pioneered the concept of decentralized IP video systems where intelligent processing, recording, and analytics happen directly inside the camera rather than on a central server. The company was acquired by **Konica Minolta** in 2016. MOBOTIX cameras are known for their rugged construction, long operational lifespan, and suitability for industrial, outdoor, and critical infrastructure environments. **Key facts:** - **Product lines:** M-series (outdoor), D-series (dome), S-series (hemispheric), Q-series (panoramic), T-series (door station), MOVE (newer ONVIF line) - **Protocol support:** RTSP, HTTP/CGI, MxPEG (proprietary); ONVIF (MOVE series only) - **Default RTSP port:** 554 - **Default credentials:** admin / meinsm - **ONVIF support:** MOVE series only (classic Mx cameras do not support ONVIF) - **Video codecs:** MxPEG (proprietary), MJPEG, H.264 (newer models) - **Architecture:** Decentralized, in-camera recording and processing Classic vs MOVE Series Classic Mobotix cameras (M/D/S/Q series) primarily use the proprietary MxPEG codec and do not support ONVIF. For ONVIF and standard H.264/H.265 RTSP, use the newer MOBOTIX MOVE series. About MxPEG MxPEG is a proprietary video codec developed by MOBOTIX for efficient bandwidth usage with their decentralized architecture. If your application cannot decode MxPEG natively, use the MJPEG fallback stream via HTTP (`/cgi-bin/faststream.jpg`) or configure the camera to output standard MJPEG or H.264 where supported. VisioForge SDK can connect to MOBOTIX cameras using the MJPEG HTTP stream or the H.264 RTSP stream on supported models. ## RTSP URL Patterns ### Standard URL Format MOBOTIX cameras use branded path-based RTSP URLs: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/mobotix.h264 ``` | Stream | URL Pattern | Description | | --- | --- | --- | | H.264 main stream | `rtsp://IP:554/mobotix.h264` | Primary H.264 stream (newer models) | | MJPEG stream | `rtsp://IP:554/mobotix.mjpeg` | MJPEG over RTSP | ### Camera Series and URLs | Series | Type | Recommended URL | Codec | | --- | --- | --- | --- | | MOVE Bullet | IP bullet | `rtsp://IP:554/mobotix.h264` | H.264 | | MOVE Dome | IP dome | `rtsp://IP:554/mobotix.h264` | H.264 | | MOVE Vandal Dome | IP vandal-proof | `rtsp://IP:554/mobotix.h264` | H.264 | | M-series (M73, M16) | Outdoor | `rtsp://IP:554/mobotix.mjpeg` | MJPEG | | D-series (D16, D26) | Dome | `rtsp://IP:554/mobotix.mjpeg` | MJPEG | | S-series (S16, S26) | Hemispheric | `rtsp://IP:554/mobotix.mjpeg` | MJPEG | | Q-series (Q26) | Panoramic 360 | `rtsp://IP:554/mobotix.mjpeg` | MJPEG | | T-series (T26) | Door station | `rtsp://IP:554/mobotix.mjpeg` | MJPEG | ### MOVE Series ONVIF URLs MOBOTIX MOVE cameras support standard ONVIF and provide conventional RTSP streams: | Stream | URL Pattern | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:554/mobotix.h264` | H.264 primary stream | | Sub stream | `rtsp://IP:554/mobotix.mjpeg` | MJPEG secondary stream | ## Connecting with VisioForge SDK Use your MOBOTIX camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // MOBOTIX MOVE or classic Mx camera, H.264 stream var uri = new Uri("rtsp://192.168.1.90:554/mobotix.h264"); var username = "admin"; var password = "meinsm"; ``` For classic Mx cameras that only support MxPEG, use the MJPEG HTTP stream URL instead (see below). ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | MJPEG Full Resolution | `http://IP/cgi-bin/faststream.jpg?stream=full` | Full resolution continuous MJPEG | | MxPEG Stream | `http://IP/cgi-bin/faststream.jpg?stream=MxPEG&needlength&fps=6` | Proprietary MxPEG at 6 fps | | Controlled FPS MJPEG | `http://IP/control/faststream.jpg?stream=full&fps=10` | MJPEG capped at 10 fps | | Current Snapshot | `http://IP/record/current.jpg` | Single JPEG snapshot | ## Troubleshooting ### Classic Mx camera not connecting via RTSP Classic MOBOTIX cameras (M, D, S, Q, T series) primarily use the proprietary MxPEG codec. If the RTSP stream fails: 1. Try the MJPEG RTSP URL: `rtsp://IP:554/mobotix.mjpeg` 2. If RTSP is not available, use the HTTP MJPEG stream: `http://IP/cgi-bin/faststream.jpg?stream=full` 3. Check that RTSP is enabled in the camera's web interface under **Admin Menu > Network Setup > RTSP Server** ### "401 Unauthorized" error MOBOTIX cameras use the default credentials `admin` / `meinsm`. If authentication fails: 1. Access the camera web interface at `http://CAMERA_IP` 2. Log in with the default or configured credentials 3. Verify the user account has streaming access permissions 4. Use the correct credentials in your RTSP URL ### MxPEG stream not decoding MxPEG is a proprietary codec that standard media players and libraries may not support. Workarounds: - Use the MJPEG fallback stream via `http://IP/cgi-bin/faststream.jpg?stream=full` - Configure the camera to output H.264 if the model and firmware support it - For MOVE series cameras, H.264 RTSP is natively supported ### ONVIF discovery not finding the camera Only MOBOTIX MOVE series cameras support ONVIF. Classic Mx cameras (M, D, S, Q, T series) do not implement the ONVIF protocol. For classic cameras, connect directly using the RTSP or HTTP URLs listed above. ### Low frame rate on MJPEG streams MOBOTIX classic cameras may default to low frame rates to conserve bandwidth. To adjust: 1. Open the camera web interface 2. Navigate to **Admin Menu > Image Control > Frame Rate** 3. Increase the maximum frame rate 4. For HTTP streams, specify the desired fps in the URL: `http://IP/control/faststream.jpg?stream=full&fps=15` ## FAQ **What is the default RTSP URL for MOBOTIX cameras?** For newer MOBOTIX MOVE cameras, the default URL is `rtsp://admin:meinsm@CAMERA_IP:554/mobotix.h264`. For classic Mx cameras, use `rtsp://admin:meinsm@CAMERA_IP:554/mobotix.mjpeg` or the HTTP MJPEG stream at `http://CAMERA_IP/cgi-bin/faststream.jpg?stream=full`. **What is MxPEG and do I need it?** MxPEG is a proprietary video codec developed by MOBOTIX for bandwidth-efficient streaming in their decentralized camera architecture. You do not need MxPEG support to use MOBOTIX cameras with VisioForge SDK. Instead, use the standard MJPEG HTTP stream or H.264 RTSP stream (on supported models) as described on this page. **Do MOBOTIX cameras support ONVIF?** Only the MOBOTIX MOVE series supports ONVIF. Classic MOBOTIX cameras (M, D, S, Q, T series) use a proprietary web interface and do not support ONVIF discovery or profiles. **What is the difference between MOBOTIX classic and MOVE cameras?** Classic MOBOTIX cameras (M, D, S, Q, T series) use a decentralized architecture with in-camera recording and the proprietary MxPEG codec. MOVE series cameras are MOBOTIX's newer product line that follows industry-standard protocols including ONVIF, H.264, and H.265, making them easier to integrate with third-party VMS and SDK solutions. **Can I connect to MOBOTIX cameras without ONVIF?** Yes. All MOBOTIX cameras support direct RTSP or HTTP connections using the URLs listed on this page. ONVIF is not required for basic video streaming. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Basler Connection Guide](../basler/) — Industrial / machine vision cameras - [FLIR Connection Guide](../flir/) — Industrial and thermal imaging - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Panasonic (i-PRO) IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/panasonic/ **Description:** Panasonic i-PRO and legacy WV/BL/BB camera RTSP URL patterns for C# .NET. ONVIF-compatible integration with VisioForge SDK for all generations. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Panasonic (i-PRO) IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Panasonic i-PRO** (formerly Panasonic Security Systems, now operating as i-PRO Co., Ltd.) is a Japanese manufacturer of professional video surveillance equipment. Originally part of Panasonic Corporation, the security division was spun off as **i-PRO** in 2019. Panasonic/i-PRO cameras are widely deployed in enterprise, government, transportation, and retail environments worldwide. **Key facts:** - **Product lines:** WV-S (current S-series), WV-X (X-series AI), WV-SF/SC/SP/SW (mid-generation), WV-NP/NS/NW (legacy professional), BL (consumer/SMB), BB/KX-HCM (legacy consumer) - **Protocol support:** RTSP, ONVIF (Profile S/G/T), HTTP/CGI, MJPEG, Panasonic proprietary - **Default RTSP port:** 554 - **Default credentials:** admin / 12345 (current models require password change on first login); legacy BB/BL models often had no default password - **ONVIF support:** Yes (all current WV-S/WV-X models) - **Video codecs:** H.264, H.265 (current models), MPEG-4 (legacy), MJPEG ## RTSP URL Patterns ### Current Models (WV-S/WV-X Series, i-PRO) Current Panasonic i-PRO cameras use the `MediaInput` URL format: | Stream | RTSP URL | Codec | Notes | | --- | --- | --- | --- | | H.264 stream | `rtsp://IP:554/MediaInput/h264` | H.264 | Primary RTSP stream | | H.265 stream | `rtsp://IP:554/MediaInput/h265` | H.265 | Current models only | | MPEG-4 stream | `rtsp://IP:554/MediaInput/mpeg4` | MPEG-4 | Legacy fallback | | ONVIF stream | `rtsp://IP//ONVIF/MediaInput` | H.264 | ONVIF-compatible (note double slash) | Double slash in ONVIF URLs Panasonic ONVIF URLs use a double slash before `ONVIF`: `rtsp://IP//ONVIF/MediaInput`. This is intentional and required for ONVIF-based connections. ### Model-Specific URLs | Model Series | RTSP URL | Generation | | --- | --- | --- | | WV-S1131/S1132 | `rtsp://IP:554/MediaInput/h264` | Current (i-PRO) | | WV-S2131L/S2231L | `rtsp://IP:554/MediaInput/h264` | Current (i-PRO) | | WV-X1551L/X2251L | `rtsp://IP:554/MediaInput/h264` | Current AI series | | WV-SF132/SF135/SF138 | `rtsp://IP:554/MediaInput/h264` | Mid-generation | | WV-SF332/SF335/SF346 | `rtsp://IP:554/MediaInput/h264` | Mid-generation | | WV-SC384/SC385/SC386 | `rtsp://IP:554/MediaInput/h264` | Mid-generation | | WV-SP105/SP306/SP508 | `rtsp://IP:554/MediaInput/h264` | Mid-generation | | WV-SW115/SW155/SW175 | `rtsp://IP:554/MediaInput/h264` | Mid-generation outdoor | | WV-SW316/SW352/SW355 | `rtsp://IP:554/MediaInput/h264` | Mid-generation outdoor | | WV-SW395/SW396/SW458 | `rtsp://IP:554/MediaInput/h264` | Mid-generation outdoor | | WV-SW558/SW559/SW598 | `rtsp://IP:554/MediaInput/h264` | Mid-generation outdoor | | WV-ST162/ST165 | `rtsp://IP:554/MediaInput/h264` | Mid-generation PTZ | | WV-NP240/NP244/NP304 | `rtsp://IP:554/MediaInput/mpeg4` | Legacy professional | | WV-NP502/NP1000/NP1004 | `rtsp://IP:554/MediaInput/mpeg4` | Legacy professional | | WV-NS202/NS324/NS954 | `rtsp://IP:554/MediaInput/mpeg4` | Legacy PTZ | | WV-NW484/NW502/NW960/NW964 | `rtsp://IP:554/MediaInput/mpeg4` | Legacy outdoor | ### Legacy Consumer Models (BB/BL/KX Series) Older Panasonic consumer cameras used different URL patterns: | Model Series | RTSP URL | Codec | Notes | | --- | --- | --- | --- | | BL-C210/C230 | `rtsp://IP:554/MediaInput/h264` | H.264 | Late consumer models | | BL-C210/C230 | `rtsp://IP:554/MediaInput/mpeg4` | MPEG-4 | MPEG-4 fallback | | BL-VP101/VP104 | `rtsp://IP:554/MediaInput/h264` | H.264 | Compact | | BB-HCM531A/735 | `rtsp://IP/nphMpeg4/g726-640x48` | MPEG-4 | Very old format | | BB/BL/KX (HTTP only) | `http://IP/nphMotionJpeg?Resolution=640x480&Quality=Standard` | MJPEG | HTTP MJPEG stream | Legacy BB/BL cameras Many older Panasonic BB and BL series cameras do not support RTSP at all. They only provide HTTP-based MJPEG and JPEG snapshot streams. Current i-PRO cameras fully support RTSP. ### Encoder/DVR URLs | Device | RTSP URL | Notes | | --- | --- | --- | | WJ-GXE500 encoder | `http://IP/cgi-bin/camera` | MJPEG via HTTP | | WJ-HD220 DVR | `http://IP/cgi-bin/jpeg` | Snapshot from DVR | | WJ-ND400 NVR | `http://IP/cgi-bin/jpeg` | Snapshot from NVR | | WJ-NV200 NVR | `http://IP/cgi-bin/checkimage.cgi?UID=USER&CAM=CHANNEL` | Channel snapshot | ## Connecting with VisioForge SDK Use your Panasonic camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Panasonic i-PRO camera, H.264 stream var uri = new Uri("rtsp://192.168.1.80:554/MediaInput/h264"); var username = "admin"; var password = "YourPassword"; ``` For H.265, use `/MediaInput/h265` instead. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | MJPEG Stream (current) | `http://IP/cgi-bin/mjpeg?stream=1` | Current WV-S/WV-X models | | JPEG Snapshot | `http://IP/cgi-bin/camera` | Current models | | Snapshot (sized) | `http://IP/SnapshotJPEG?Resolution=640x480` | Mid-generation models | | Snapshot (quality) | `http://IP/SnapShotJPEG?Resolution=320x240&Quality=Motion` | Legacy models | | MJPEG Stream (legacy) | `http://IP/nphMotionJpeg?Resolution=640x480&Quality=Standard` | BB/BL/KX models | | Server push | `http://IP/cgi-bin/nphContinuousServerPush` | Continuous JPEG push | ## Troubleshooting ### Brand name confusion The Panasonic security camera brand has evolved: - **Panasonic** (before 2019): Full Panasonic branding - **i-PRO** (2019-present): Spun off from Panasonic as i-PRO Co., Ltd. - Current products are branded **i-PRO** but many users still search for "Panasonic camera" All use compatible RTSP URL patterns within their generation. ### MediaInput/h264 vs ONVIF/MediaInput - Use `rtsp://IP:554/MediaInput/h264` for direct RTSP connections (recommended) - Use `rtsp://IP//ONVIF/MediaInput` for ONVIF-compatible connections (note the double slash) - Both provide the same video stream but use different authentication mechanisms ### Legacy cameras without RTSP Many older Panasonic BB-series and BL-series cameras (particularly BL-C1, BL-C10, BL-C30, BL-C101, BL-C111, BL-C131 and earlier) do not support RTSP. These cameras only provide: - HTTP MJPEG: `http://IP/nphMotionJpeg?Resolution=640x480&Quality=Standard` - HTTP Snapshot: `http://IP/SnapshotJPEG?Resolution=320x240` ### MPEG-4 vs H.264 Legacy WV-NP/NS/NW series cameras may only support MPEG-4 over RTSP. Try `MediaInput/mpeg4` if `MediaInput/h264` fails on older models. ## FAQ **What is the default RTSP URL for Panasonic/i-PRO cameras?** For current i-PRO cameras, use `rtsp://admin:password@CAMERA_IP:554/MediaInput/h264`. For ONVIF connections, use `rtsp://CAMERA_IP//ONVIF/MediaInput`. Legacy models may need `MediaInput/mpeg4`. **Is Panasonic the same as i-PRO?** Yes. Panasonic's security camera division was spun off as i-PRO Co., Ltd. in 2019. Current cameras are branded i-PRO, but use the same RTSP URL patterns as late-generation Panasonic WV-series cameras. **Do Panasonic cameras support H.265?** Current i-PRO cameras (WV-S and WV-X series) support H.265. Use `rtsp://IP:554/MediaInput/h265` for the H.265 stream. Mid-generation and older models support H.264 and MPEG-4 only. **Can I connect to legacy Panasonic BB/BL cameras?** Many older BB and BL series cameras don't support RTSP and only provide HTTP MJPEG streams. Use the HTTP MJPEG URL `http://IP/nphMotionJpeg?Resolution=640x480&Quality=Standard` with an HTTP source instead of RTSP. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Sanyo Connection Guide](../sanyo/) — Acquired by Panasonic, predecessor product line - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Pelco IP Camera RTSP URL Patterns and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/pelco/ **Description:** Pelco Sarix and Spectra PTZ camera RTSP integration for C# .NET. URL patterns for IX, IMP, IME models with ONVIF support and VisioForge SDK code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to Pelco IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Pelco** (now part of **Motorola Solutions**) is a leading manufacturer of professional video surveillance equipment, headquartered in Fresno, California. Pelco is particularly strong in enterprise, government, and critical infrastructure markets. The brand is known for its **Sarix** fixed camera line and **Spectra** PTZ camera line. Motorola Solutions acquired Pelco in 2020. **Key facts:** - **Product lines:** Sarix (Professional/Enhanced/Value fixed cameras), Spectra (Professional PTZ), IX (fixed box), IMP/IME (mini dome), D-series (dome PTZ) - **Protocol support:** RTSP, ONVIF (Profile S/G/T), HTTP/CGI, Pelco D/P serial protocol - **Default RTSP port:** 554 - **Default credentials:** admin / admin (must be changed on first login for current models) - **ONVIF support:** Yes (all current Sarix and Spectra models) - **Video codecs:** H.264, H.265 (Sarix Professional), MJPEG Double slash in RTSP URLs Pelco cameras consistently use a **double forward slash** before the stream path: `rtsp://IP:554//stream1`. This is intentional and required for most Pelco models. ## RTSP URL Patterns ### Current Models (Sarix Professional/Enhanced/Value) | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:554//stream1` | Full resolution (note double slash) | | Sub stream | `rtsp://IP:554//stream2` | Lower resolution | | Low-res stream | `rtsp://IP:554/LowResolutionVideo` | Lowest quality | | Channel stream | `rtsp://IP:554/stream1` | Single slash (some models) | | Numbered channel | `rtsp://IP:554/1/stream1` | Channel-specific | ### Model-Specific URLs | Model Series | RTSP URL | Type | Notes | | --- | --- | --- | --- | | Sarix Pro (IMP/IME) | `rtsp://IP:554//stream1` | Fixed dome | Current generation | | Sarix Enhanced (IX) | `rtsp://IP:554//stream1` | Fixed box | Mid-range | | Sarix Value | `rtsp://IP:554//stream1` | Fixed | Entry-level | | IX10 | `rtsp://IP:554//stream1` | Fixed box | Professional | | IX30C / IX30DN | `rtsp://IP:554//stream1` | Fixed box | Day/night | | IXDN30 | `rtsp://IP:554//stream1` | Fixed box | Day/night | | IXE10LW | `rtsp://IP:554//stream1` | Fixed dome | Wireless | | IXE20DN | `rtsp://IP:554//stream1` | Fixed dome | Day/night | | IXP31 | `rtsp://IP:554//stream1` | Fixed dome | Professional | | IMP519 | `rtsp://IP:554//stream1` | Mini dome | 5MP | | IMP1110-1 / IMP1110-1E | `rtsp://IP:554//stream1` | Mini dome | Sarix Pro | | IM10C10 | `rtsp://IP:554//stream1` | Multi-sensor | Sarix IMM | | IM10DN10-1E | `rtsp://IP:554//stream1` | Multi-sensor | Day/night | | D5230-ADFRZ28 | `rtsp://IP:554//stream1` | PTZ dome | Spectra | | Spectra IV | `rtsp://IP:554//stream1` | PTZ dome | Legacy PTZ | | Spectra Professional | `rtsp://IP:554//stream1` | PTZ dome | Current PTZ | ### Multi-Channel / Multi-Sensor For multi-channel Pelco devices: | Stream | RTSP URL | Notes | | --- | --- | --- | | Channel 1, main | `rtsp://IP:554/1/stream1` | First sensor/channel | | Channel 2, main | `rtsp://IP:554/2/stream1` | Second sensor/channel | | Channel stream (alt) | `rtsp://IP:554/stream1` | Single channel (some models) | ### Legacy Models | Model | URL | Notes | | --- | --- | --- | | IP110 / IP-110 | `http://IP/api/jpegControl.php?frameRate=10` | JPEG stream | | Spectra IV (HTTP) | `http://IP/jpeg` | JPEG snapshot | | Spectra IV (pull) | `http://IP/jpeg/pull` | Continuous JPEG | | Spectra IV (API) | `http://IP/api/jpegControl.php?frameRate=10` | Frame-rate JPEG | ## Connecting with VisioForge SDK Use your Pelco camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Pelco Sarix camera, main stream var uri = new Uri("rtsp://192.168.1.85:554//stream1"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `//stream2` instead. For multi-sensor cameras, use `/1/stream1` for channel selection. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/jpeg` | Most current models | | JPEG (channel) | `http://IP/jpeg?id=1` | Channel-specific | | JPEG (API) | `http://IP/api/jpegControl.php?frameRate=10` | Legacy models | | JPEG (tmpfs) | `http://IP/tmpfs/auto.jpg` | Auto-capture | | Image file | `http://IP/img.jpg` | Simple snapshot | ## Troubleshooting ### Double slash is required Most Pelco cameras require a **double forward slash** before the stream path: - Correct: `rtsp://IP:554//stream1` - May not work: `rtsp://IP:554/stream1` If a single-slash URL fails, always try the double-slash variant first. ### Channel numbering for multi-sensor Pelco multi-sensor cameras (IM10-series, Sarix IMM) use numbered channel paths: - `rtsp://IP:554/1/stream1` — first sensor - `rtsp://IP:554/2/stream1` — second sensor Single-sensor cameras should use `//stream1` without a channel number. ### Pelco D/P protocol vs RTSP Pelco is also known for the **Pelco D** and **Pelco P** serial communication protocols used to control PTZ cameras. These are serial protocols for PTZ control, not video streaming. Video streaming always uses RTSP or HTTP regardless of which PTZ control protocol is used. ### Spectra PTZ cameras Pelco Spectra PTZ cameras use the same RTSP URL format (`//stream1`) as fixed cameras. PTZ control is handled separately via ONVIF PTZ commands or Pelco D/P serial protocol, not through the RTSP URL. ## FAQ **What is the default RTSP URL for Pelco cameras?** For most Pelco cameras, use `rtsp://admin:password@CAMERA_IP:554//stream1` (note the double slash). For the sub-stream, use `//stream2`. Multi-sensor models use `/1/stream1` for channel-specific access. **Is Pelco still an independent company?** No. Pelco was acquired by Motorola Solutions in 2020. Current Pelco cameras are manufactured and supported by Motorola Solutions. The Pelco brand and product lines (Sarix, Spectra) continue under Motorola Solutions' video security portfolio. **Do Pelco cameras support ONVIF?** Yes. All current Pelco Sarix and Spectra cameras support ONVIF Profile S, G, and T. ONVIF is the recommended discovery and configuration method for new Pelco integrations. **What is the difference between Pelco D and RTSP?** Pelco D (and Pelco P) are serial protocols for PTZ camera control (pan, tilt, zoom commands). RTSP is the video streaming protocol. You use RTSP for video and Pelco D/ONVIF for PTZ control — they serve different purposes and are not interchangeable. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Avigilon Connection Guide](../avigilon/) — Also Motorola Solutions, enterprise cameras - [Honeywell Connection Guide](../honeywell/) — Enterprise surveillance cameras - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Q-See IP Camera & DVR in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/q-see/ **Description:** Q-See QC, QCN, and QS series camera and DVR RTSP URL patterns for C# .NET. Default credentials, channel setup, and VisioForge SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Q-See IP Camera & DVR in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Q-See** was an American consumer surveillance brand based in Anaheim, California. Q-See DVRs and IP cameras were popular budget surveillance systems sold through major US retailers including Costco and Amazon. The company became essentially defunct by 2020, but a large number of Q-See systems remain deployed in homes and businesses. Q-See products used a mix of **Dahua OEM cameras** and components from other Chinese manufacturers, meaning most Q-See devices follow Dahua RTSP URL conventions. **Key facts:** - **Product lines:** QC Series (DVRs), QCN Series (IP cameras), QS Series (DVR kits) - **Protocol support:** RTSP, HTTP/CGI, ONVIF (some IP camera models) - **Default RTSP port:** 554 - **Default credentials:** admin / admin or admin / 123456 - **ONVIF support:** Some IP camera models (QCN series) - **Video codecs:** H.264 (most models), MPEG-4 (older DVRs) - **OEM base:** Mix of Dahua and other manufacturers Q-See Is Defunct Q-See ceased operations around 2020. No firmware updates, technical support, or cloud services are available. If you are integrating Q-See hardware, treat it as Dahua-compatible equipment and try Dahua URL patterns first. See our [Dahua connection guide](../dahua/) for additional details. ## RTSP URL Patterns ### Standard URL Format (Dahua-Based) Most Q-See devices use the Dahua `cam/realmonitor` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/cam/realmonitor?channel=1&subtype=0 ``` | Parameter | Value | Description | | --- | --- | --- | | `channel` | 1, 2, 3... | Camera channel (1 for standalone cameras, 1-N for DVR channels) | | `subtype` | 0 | Main stream (highest resolution) | | `subtype` | 1 | Sub stream (lower resolution, less bandwidth) | ### DVR Models (QC Series, QS Series) | Model / Series | Main Stream URL | Notes | | --- | --- | --- | | QC-804 (4-ch DVR) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua format, change `channel` for each input | | QS408 / QS411 (DVR kits) | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua format | | Various DVRs | `rtsp://IP:554/` | Root stream (fallback) | | Various DVRs | `rtsp://IP:554/live.sdp` | Live SDP stream | | Various DVRs | `rtsp://IP:554/ch0_unicast_firststream` | Unicast first stream | ### IP Camera Models (QCN Series) | Model | Resolution | URL | Notes | | --- | --- | --- | --- | | QCN7001B | 1080p | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua format (recommended) | | QCN7001B | 1080p | `rtsp://IP:554/PSIA/Streaming/channels/0?videoCodecType=H.264` | PSIA format | | QCN7001B | 1080p | `rtsp://IP:554/VideoInput/1/h264/1` | VideoInput H.264 | | QCN7001B | 1080p | `rtsp://IP:554/VideoInput/1/mpeg4/1` | VideoInput MPEG-4 | | QCN7005B | 1080p | `rtsp://IP:554/` | Root stream | ### Alternative URL Formats Some Q-See devices support additional URL patterns: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Standard Dahua format (recommended) | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | Sub stream (lower bandwidth) | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=00&authbasic=BASE64` | With base64-encoded credentials | | `rtsp://IP:554/` | Root stream (fallback for many models) | | `rtsp://IP:554/live.sdp` | Live SDP format | | `rtsp://IP:554/ch0_unicast_firststream` | Unicast first stream | Base64 Authentication The `authbasic=` parameter used in some Q-See URLs takes base64-encoded credentials in the format `username:password`. For example, `admin:admin` encodes to `YWRtaW46YWRtaW4=`. ### DVR Channel URLs For Q-See multi-channel DVRs (QC-804, QS408, QS411, etc.): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | | Camera 2 | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=1` | | Camera N | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=1` | ## Connecting with VisioForge SDK Use your Q-See camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Q-See QC-804 DVR, channel 1 main stream var uri = new Uri("rtsp://192.168.1.100:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "admin"; ``` For sub-stream access, use `subtype=1` instead of `subtype=0`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | CGI Snapshot | `http://IP/cgi-bin/snapshot.cgi?chn=1&u=USER&p=PASS` | Channel-based snapshot with credentials | | Login-Based Snapshot | `http://IP/cgi-bin/snapshot.cgi?loginuse=USER&loginpas=PASS` | Login parameter-based snapshot | | Still Image | `http://IP/stillimg1.jpg` | Replace `1` with channel number | | Stream Image | `http://IP/images/stream_1.jpg` | Replace `1` with channel number | | Fast Stream (QS Series) | `http://IP/control/faststream.jpg?stream=MxPEG&needlength&fps=6` | Continuous fast stream | ## Troubleshooting ### No firmware updates or support Q-See ceased operations around 2020. There are no firmware updates, no technical support, and no replacement parts available. If your Q-See device has a security vulnerability or bug, it cannot be patched. Consider upgrading to a currently supported camera brand. ### Try Dahua URL patterns first Most Q-See DVRs and many IP cameras use Dahua firmware internally. If the Q-See-specific URLs listed above do not work, try the standard Dahua `cam/realmonitor` format. See our [Dahua connection guide](../dahua/) for the full set of Dahua URL patterns. ### Base64 authentication parameter Some Q-See devices use an `authbasic=` parameter in the RTSP URL instead of embedding credentials in the URI. Encode `username:password` as base64: - `admin:admin` = `YWRtaW46YWRtaW4=` - `admin:123456` = `YWRtaW46MTIzNDU2` ### Port forwarding for remote access Q-See DVRs typically require manual port forwarding for remote RTSP access. Forward port **554** (RTSP) and optionally port **80** or **8080** (HTTP) on your router to the DVR's local IP address. ### Default credentials Q-See devices commonly ship with one of these credential pairs: - `admin` / `admin` - `admin` / `123456` If neither works, the password may have been changed by the previous owner or installer. ## FAQ **What RTSP URL format do Q-See cameras use?** Most Q-See devices use the Dahua `cam/realmonitor` format: `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=0`. This is because Q-See cameras and DVRs were primarily OEM versions of Dahua hardware. Use `channel=1` for standalone cameras or the appropriate channel number for DVR inputs. **Are Q-See cameras still supported?** No. Q-See ceased operations around 2020. No firmware updates, cloud services, or technical support are available. The hardware still functions, but there will be no future patches or improvements. Many users have migrated to other brands like Amcrest or Reolink that use similar Dahua-based protocols. **Can I use Q-See cameras with ONVIF?** Some Q-See IP cameras (QCN series) support ONVIF, but most Q-See DVRs do not. If ONVIF discovery fails, use the direct RTSP URL patterns listed above instead. **What is the default password for Q-See cameras?** The default credentials are typically `admin` / `admin` or `admin` / `123456`. Since Q-See is no longer available, there is no official password reset tool. A factory reset (usually a pinhole button on the device) will restore default credentials on most models. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Dahua Connection Guide](../dahua/) — Same URL format for most Q-See devices - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Reolink IP Camera RTSP Connection Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/reolink/ **Description:** Reolink RLC, E1, Argus, CX, and Duo series RTSP URL patterns for C# .NET. Stream and record using VisioForge SDK with ONVIF discovery support. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, H.265, C# # How to Connect to Reolink IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Reolink** (Reolink Digital Technology Co., Ltd.) is a consumer and prosumer IP camera manufacturer headquartered in Hong Kong. Founded in 2009, Reolink has grown rapidly through direct-to-consumer sales on Amazon and their own website, offering competitively priced cameras with straightforward RTSP access. Reolink is notable for clear documentation of RTSP URLs and easy integration with third-party software. **Key facts:** - **Product lines:** RLC series (PoE wired), RLN series (NVRs), E1 series (Wi-Fi pan/tilt), Argus series (battery/solar), CX series (ColorX night vision), Duo series (dual-lens), TrackMix (auto-tracking) - **Protocol support:** RTSP, ONVIF, HTTP/HTTPS, proprietary Reolink protocol - **Default RTSP port:** 554 - **Default credentials:** admin / (blank password or set during setup) - **ONVIF support:** Yes (most current models, may require enabling in camera settings) - **Video codecs:** H.264 (all models), H.265 (most current models) ## RTSP URL Patterns Reolink uses a consistent URL pattern across most models. The main difference is between cameras and NVRs (which use channel numbers). ### Camera RTSP URLs | Stream | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | Main (clear) | `rtsp://IP:554/h264Preview_01_main` | Full (up to 4K/8MP) | H.264 main stream | | Sub (fluent) | `rtsp://IP:554/h264Preview_01_sub` | Reduced (640x360) | Lower bandwidth | H.265 streams For cameras with H.265 enabled, the URL remains the same (`h264Preview_01_main`). The `h264` in the URL path is not codec-specific -- it works for both H.264 and H.265 streams. ### NVR Channel URLs For Reolink NVRs (RLN8-410, RLN16-410, RLN36, etc.), append the channel number: | Channel | Main Stream URL | Sub Stream URL | | --- | --- | --- | | Channel 1 | `rtsp://IP:554/h264Preview_01_main` | `rtsp://IP:554/h264Preview_01_sub` | | Channel 2 | `rtsp://IP:554/h264Preview_02_main` | `rtsp://IP:554/h264Preview_02_sub` | | Channel 3 | `rtsp://IP:554/h264Preview_03_main` | `rtsp://IP:554/h264Preview_03_sub` | | Channel N | `rtsp://IP:554/h264Preview_0N_main` | `rtsp://IP:554/h264Preview_0N_sub` | ### Models and Resolutions | Model | Resolution | Codec | Wi-Fi | RTSP | | --- | --- | --- | --- | --- | | RLC-410 | 2560x1440 (4MP) | H.264/H.265 | No (PoE) | Yes | | RLC-510A | 2560x1920 (5MP) | H.264/H.265 | No (PoE) | Yes | | RLC-520A | 2560x1920 (5MP) | H.264/H.265 | No (PoE) | Yes | | RLC-810A | 3840x2160 (8MP) | H.264/H.265 | No (PoE) | Yes | | RLC-811A | 3840x2160 (8MP) | H.264/H.265 | No (PoE) | Yes | | RLC-820A | 3840x2160 (8MP) | H.264/H.265 | No (PoE) | Yes | | RLC-1212A | 4512x2512 (12MP) | H.264/H.265 | No (PoE) | Yes | | E1 Zoom | 2560x1920 (5MP) | H.264/H.265 | Yes | Yes | | E1 Pro | 2560x1440 (4MP) | H.264 | Yes | Yes | | E1 Outdoor | 2560x1920 (5MP) | H.264/H.265 | Yes | Yes | | CX410 | 2560x1440 (4MP) | H.264/H.265 | No (PoE) | Yes | | CX810 | 3840x2160 (8MP) | H.264/H.265 | No (PoE) | Yes | | TrackMix PoE | 3840x2160 (8MP) | H.264/H.265 | No (PoE) | Yes | | Duo 2 PoE | 4608x1728 (8MP) | H.264/H.265 | No (PoE) | Yes | | Argus 3 Pro | 2560x1440 (4MP) | H.264 | Yes (battery) | Yes | Argus battery cameras Argus series battery-powered cameras support RTSP but drain the battery quickly when streaming continuously. Use RTSP only for testing or event-triggered recording, not 24/7 monitoring. ## Connecting with VisioForge SDK Use your Reolink camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Reolink RLC-810A, main stream var uri = new Uri("rtsp://192.168.1.88:554/h264Preview_01_main"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `h264Preview_01_sub` instead of `h264Preview_01_main`. For NVR channels, change the channel number (e.g., `h264Preview_03_main` for channel 3). ## Snapshot URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=abc123&user=USER&password=PASS` | API-based snapshot | ## Troubleshooting ### RTSP not working -- "Connection refused" RTSP may need to be enabled on some Reolink models: 1. Open the **Reolink app** or web interface 2. Go to **Settings > Network > Advanced > Port Settings** 3. Ensure **RTSP port** is enabled and set to 554 4. Some older firmware versions have RTSP disabled by default ### H.265 stream not decoding If your Reolink camera is configured for H.265 and the stream fails to decode: - The SDK supports H.265 natively, but ensure you're using a recent SDK version - Try switching the camera to H.264 in **Settings > Display > Encode** as a workaround - The RTSP URL path (`h264Preview`) remains the same regardless of the actual codec ### Sub stream shows low quality The sub stream (`h264Preview_01_sub`) is intentionally lower resolution (typically 640x360) to reduce bandwidth. Use `h264Preview_01_main` for full resolution. You can adjust sub stream quality in the Reolink app under Display settings. ### NVR channel numbering Reolink NVR channels are 1-indexed with zero-padded two-digit format: `01`, `02`, `03`... `16`. Channel 0 does not exist. ## FAQ **What is the default RTSP URL for Reolink cameras?** The URL is `rtsp://admin:password@CAMERA_IP:554/h264Preview_01_main` for the main stream and `h264Preview_01_sub` for the sub stream. The password is whatever you set during camera setup. **Does the RTSP URL change when using H.265?** No. The URL path `h264Preview_01_main` is used for both H.264 and H.265 streams. The `h264` in the path is a legacy naming convention, not a codec selector. **Can I access Reolink cameras remotely via RTSP?** RTSP is designed for local network access. For remote access, you would need to set up port forwarding on your router (forward port 554 to the camera's IP) or use a VPN. Reolink's cloud/P2P access uses a proprietary protocol, not RTSP. **Do Reolink Duo cameras have separate RTSP streams for each lens?** Yes. Reolink Duo cameras expose the wide-angle lens on the standard channel and may provide additional streams. Check your specific model's documentation for dual-lens stream access. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Amcrest Connection Guide](../amcrest/) — Consumer alternative with RTSP - [TP-Link Connection Guide](../tp-link/) — Budget cameras with native RTSP - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Rhombus Camera RTSP URL and Cloud API C# Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/rhombus/ **Description:** Rhombus camera integration options in C# .NET. Cloud-managed architecture, API access, and alternative approaches for Rhombus Systems cameras. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to Rhombus Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Rhombus Systems** (Rhombus, Inc.) is an American cloud-managed video security company headquartered in Sacramento, California. Founded in 2016, Rhombus provides enterprise cameras, sensors, and access control with a cloud-first management platform. Similar to Verkada, Rhombus cameras are managed through a centralized cloud console. **Key facts:** - **Product lines:** R-series (dome), R-series Pro (advanced), R-series Mini (compact) - **Architecture:** Cloud-managed with on-camera AI processing - **RTSP support:** Limited — available on some models via LAN configuration - **ONVIF support:** No - **Video codecs:** H.264, H.265 - **API access:** Rhombus API (REST, requires subscription) - **On-camera storage:** Yes (local SD card for edge storage) Limited Local Streaming Some Rhombus camera models support RTSP for local LAN streaming, but this feature must be enabled through the Rhombus console and is not available on all models or subscription tiers. Check your Rhombus account settings for RTSP availability. ## RTSP Access (Where Available) ### Enabling RTSP On supported Rhombus cameras: 1. Log in to the **Rhombus Console** (console.rhombus.com) 2. Navigate to your camera's settings 3. Look for **Local Streaming** or **RTSP** settings 4. Enable RTSP and note the provided URL ### RTSP URL Format When RTSP is available: ``` rtsp://[IP]:554/live ``` The exact URL format and authentication method depend on the camera model and firmware version. The Rhombus console will provide the specific URL when RTSP is enabled. ## Connecting with VisioForge SDK If RTSP is available on your Rhombus camera, use the URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Rhombus camera with RTSP enabled var uri = new Uri("rtsp://192.168.1.90:554/live"); var username = "admin"; var password = "YourPassword"; // from Rhombus console ``` ## Integration via Rhombus API For cameras without RTSP access, Rhombus provides a REST API that offers: - Camera listing and status - Video clip export and download - Snapshot/thumbnail retrieval - Event and analytics data - Webhook notifications The API does not provide real-time RTSP streams. It is designed for clip retrieval, metadata access, and automation workflows. ## Troubleshooting ### RTSP not available on my camera Not all Rhombus cameras or subscription tiers support RTSP. Contact Rhombus support to verify RTSP availability for your specific camera model and plan. ### RTSP stream disconnects Rhombus cameras prioritize cloud connectivity. If the local RTSP stream is unstable: 1. Ensure the camera has sufficient network bandwidth for both cloud and local streams 2. Use the sub stream for lower bandwidth requirements 3. Check the Rhombus console for firmware updates ## FAQ **Do Rhombus cameras support RTSP?** Some Rhombus cameras support RTSP for local LAN streaming, but it must be enabled through the Rhombus console and may not be available on all models or subscription tiers. Contact Rhombus support for specifics. **Can I use VisioForge SDK with Rhombus cameras?** If your Rhombus camera has RTSP enabled, yes. Use the RTSP URL from the Rhombus console with VisioForge SDK's RTSP source. For cameras without RTSP, you would need to use the Rhombus REST API separately for clip and snapshot access. **How does Rhombus compare to Verkada?** Both are cloud-managed platforms. Rhombus offers RTSP on some models, while Verkada does not support RTSP at all. Both provide REST APIs for clip/snapshot access. See our [Verkada guide](../verkada/) for comparison. **What are good alternatives to Rhombus with full RTSP support?** For enterprise cameras with native RTSP and ONVIF support, consider [Axis](../axis/), [Bosch](../bosch/), [Hanwha Vision](../hanwha/), or [Avigilon](../avigilon/). ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Verkada Connection Guide](../verkada/) — Another cloud-managed platform - [Axis Connection Guide](../axis/) — Enterprise alternative with full RTSP - [Hanwha Vision Connection Guide](../hanwha/) — Enterprise alternative with RTSP - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Samsung (Hanwha) IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/samsung/ **Description:** Samsung Wisenet SNO, SND, XNO, XND, and PNO camera RTSP URL patterns for C# .NET. Hanwha Vision integration with VisioForge SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, H.265, MJPEG, C# # How to Connect to Samsung (Hanwha) IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Hanwha Vision** (formerly Samsung Techwin, then Hanwha Techwin) is a South Korean manufacturer of professional and enterprise-grade video surveillance equipment. The Samsung security camera brand was rebranded to **Wisenet** after Hanwha Group acquired Samsung Techwin in 2015. Hanwha Vision cameras are widely deployed in enterprise, government, and critical infrastructure installations worldwide. **Key facts:** - **Product lines:** XNO/XND/XNV (X-series, current flagship), PNO/PND/PNV (P-series, mainstream), QNO/QND/QNV (Q-series, value), SNO/SND/SNV/SNB (S-series, legacy Samsung) - **Naming convention:** First letter = series, N = network, O = outdoor, D = dome, V = vandal-resistant, B = box, P = PTZ - **Protocol support:** RTSP, ONVIF (Profile S/G/T), HTTP/CGI, Wisenet WAVE VMS - **Default RTSP port:** 554 - **Default credentials:** admin / (set during initial setup); legacy Samsung models: admin / 4321 - **ONVIF support:** Yes (all current and most legacy models) - **Video codecs:** H.264, H.265, MJPEG ## RTSP URL Patterns ### Current Models (Wisenet X/P/Q Series) Current Hanwha Vision cameras use a profile-based URL format: | Stream | RTSP URL | Notes | | --- | --- | --- | | Profile 1 (main) | `rtsp://IP:554/profile2/media.smp` | Main stream, H.264/H.265 | | Profile 2 (sub) | `rtsp://IP:554/profile3/media.smp` | Sub stream | | ONVIF Profile 1 | `rtsp://IP:554//onvif/profile1/media.smp` | ONVIF-compatible (note double slash) | | ONVIF Profile 2 | `rtsp://IP:554//onvif/profile2/media.smp` | ONVIF sub stream | Double slash in ONVIF URLs Samsung/Hanwha ONVIF URLs use a double slash (`//onvif/`). This is intentional and required. Using a single slash will fail. ### Legacy Samsung S-Series | Model Series | RTSP URL | Codec | | --- | --- | --- | | SNB-xxxx (box) | `rtsp://IP:554/profile2/media.smp` | H.264 | | SND-xxxx (dome) | `rtsp://IP:554/profile2/media.smp` | H.264 | | SNO-xxxx (outdoor) | `rtsp://IP:554/profile2/media.smp` | H.264 | | SNV-xxxx (vandal) | `rtsp://IP:554/profile2/media.smp` | H.264 | | SNP-xxxx (PTZ) | `rtsp://IP:554/profile2/media.smp` | H.264 | ### Older Samsung Models (Pre-Wisenet) Older Samsung cameras used different URL formats: | URL Pattern | Models | Codec | | --- | --- | --- | | `rtsp://IP:554/mpeg4unicast` | SNB-2000, SNC-1300, SNP-3301/3370 | MPEG-4 | | `rtsp://IP:554/h264unicast` | SNP-3301/H, SNP-3370/TH | H.264 | | `rtsp://IP:554/mjpegunicast` | SNP-3301/H, SNP-3370/TH | MJPEG | | `rtsp://IP:554/H264/media.smp` | SNB-3000, SND-3080, SNV-3080/3081 | H.264 | | `rtsp://IP:554/MPEG4/media.smp` | SNV-3080/3081 | MPEG-4 | | `rtsp://IP:554/MJPEG/media.smp` | SNB-3000, SNV-3081, SNV-6084R | MJPEG | | `rtsp://IP:554/MediaInput/h264` | Misc. Samsung | H.264 | ### DVR/NVR URLs | Device | RTSP URL | Notes | | --- | --- | --- | | SRD-165 DVR | `rtsp://IP:558/` | Non-standard port 558 | | SME DVR | `rtsp://IP:554/mpeg4unicast` | MPEG-4 | | SMT DVR | `rtsp://IP:554/mpeg4unicast` | MPEG-4 | ## Connecting with VisioForge SDK Use your Samsung (Hanwha Wisenet) camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Hanwha Wisenet X-series camera, main stream var uri = new Uri("rtsp://192.168.1.70:554/profile2/media.smp"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `profile3/media.smp` instead of `profile2/media.smp`. For legacy Samsung S-series models, use the default password `4321` and URL path `/mpeg4unicast` or `/H264/media.smp`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/video.cgi?msubmenu=jpg` | Current models | | MJPEG Stream | `http://IP/cgi-bin/video.cgi?msubmenu=mjpg` | Current models | | Legacy Snapshot | `http://IP/video?submenu=jpg` | Pre-Wisenet models | | Legacy MJPEG | `http://IP/video?submenu=mjpg` | Pre-Wisenet models | | CGI Snapshot | `http://IP/cgi-bin/webra_fcgi.fcgi?api=get_jpeg_raw&chno=CHANNEL` | DVR models | | Snap (sized) | `http://IP/snap.jpg?JpegSize=XL` | Some Bosch-OEM firmware | ## Troubleshooting ### Default password differences - **Current Hanwha Vision models:** Password must be set during initial setup via web browser - **Legacy Samsung S-series:** Default password is `4321` - **Very old Samsung models:** Some used `admin` / `admin` ### profile2 vs profile1 in URL Samsung/Hanwha cameras use `profile2/media.smp` for the main stream (not `profile1`). This is a common source of confusion: - `profile2/media.smp` = Main stream (typically H.264 at full resolution) - `profile3/media.smp` = Sub stream - The profile numbers may differ based on camera configuration ### ONVIF double-slash issue The ONVIF URL format requires a double slash before `onvif`: - Correct: `rtsp://IP:554//onvif/profile1/media.smp` - Incorrect: `rtsp://IP:554/onvif/profile1/media.smp` ### Brand name confusion Samsung Techwin was acquired by Hanwha in 2015. The brand has been called: - **Samsung Techwin** (before 2015) - **Hanwha Techwin** (2015-2022) - **Hanwha Vision** (2022-present) - **Wisenet** (product brand name, used throughout) All use the same RTSP URL patterns within their respective generation. ## FAQ **What is the default RTSP URL for Samsung/Hanwha cameras?** For current Wisenet models, the URL is `rtsp://admin:password@CAMERA_IP:554/profile2/media.smp`. For legacy Samsung models, try `rtsp://admin:4321@CAMERA_IP:554/mpeg4unicast` or `rtsp://CAMERA_IP:554/H264/media.smp`. **Is Samsung the same as Hanwha Vision?** Yes. Samsung's security camera division was acquired by Hanwha Group in 2015. The product brand is **Wisenet**. Legacy Samsung cameras (SNB, SND, SNO series) and current Hanwha Vision cameras (XNO, XND, PNO series) use similar RTSP patterns. **Do Samsung/Hanwha cameras support H.265?** Yes. Current X-series and P-series cameras support H.265 (HEVC). Legacy S-series cameras typically support H.264 and MPEG-4 only. **What VMS works with Hanwha cameras?** Hanwha's own VMS is **Wisenet WAVE**. However, all Hanwha cameras support standard RTSP and ONVIF, making them compatible with any third-party software including VisioForge SDK applications. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Hanwha Vision Connection Guide](../hanwha/) — Current brand name, same URLs - [Wisenet Connection Guide](../wisenet/) — Hanwha Vision product family - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Sanyo IP Camera RTSP URL Patterns and C# .NET Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/sanyo/ **Description:** Connect Sanyo VCC, VDC, and VCC-HD series IP cameras in C# .NET using RTSP URL patterns, snapshot endpoints, and VisioForge SDK code examples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Sanyo IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Sanyo** (Sanyo Electric Co., Ltd.) was a Japanese electronics manufacturer headquartered in Osaka, Japan. Sanyo's security camera division produced the well-regarded VCC and VDC camera lines for professional surveillance installations. In 2009-2011, Panasonic acquired Sanyo Electric, and the camera technology was integrated into Panasonic's i-PRO product line. While Sanyo cameras are no longer manufactured, many units remain deployed in legacy installations worldwide. **Key facts:** - **Product lines:** VCC (box cameras), VDC (dome cameras), VCC-HD (HD series) - **Status:** Discontinued (acquired by Panasonic 2009-2011) - **Protocol support:** RTSP, HTTP/CGI, limited ONVIF (newer firmware) - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Limited (older firmware only) - **Video codecs:** H.264, MJPEG - **Successor:** Panasonic i-PRO Sanyo Cameras Are Discontinued Sanyo security cameras are discontinued. Sanyo Electric was acquired by Panasonic, and the camera technology was integrated into Panasonic's i-PRO product line. See our [Panasonic/i-PRO connection guide](../panasonic/) for current products. ## RTSP URL Patterns ### Standard URL Format Sanyo cameras use the `VideoInput` RTSP path: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/VideoInput/1/h264/1 ``` | Parameter | Value | Description | | --- | --- | --- | | `VideoInput` | 1, 2, 3... | Camera channel (1 for standalone cameras) | | `h264` | h264 | H.264 video codec | | Trailing `1` | 1 | Stream index | ### Camera Models | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | VCC-HD2300P | HD box camera | `rtsp://IP:554/VideoInput/1/h264/1` | H.264 main stream | | VCC-HD series | HD cameras | `rtsp://IP:554/VideoInput/1/h264/1` | H.264 main stream | | VCC-9574N | Box camera | `rtsp://IP:554/VideoInput/1/h264/1` | H.264 main stream | | VCC-P9574N | PTZ camera | `rtsp://IP:554/VideoInput/1/h264/1` | H.264 main stream | | VDC series | Dome cameras | `rtsp://IP:554/VideoInput/1/h264/1` | H.264 main stream | ### DVR Channel URLs For Sanyo DVR systems with multiple channels: | Channel | Main Stream URL | | --- | --- | | Camera 1 | `rtsp://IP:554/VideoInput/1/h264/1` | | Camera 2 | `rtsp://IP:554/VideoInput/2/h264/1` | | Camera N | `rtsp://IP:554/VideoInput/N/h264/1` | ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/VideoInput/1/h264/1` | Standard H.264 stream (recommended) | | `rtsp://IP:554/VideoInput/CHANNEL/h264/1` | Multi-channel DVR access | ## Connecting with VisioForge SDK Use your Sanyo camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Sanyo VCC-HD2300P, main stream var uri = new Uri("rtsp://192.168.1.90:554/VideoInput/1/h264/1"); var username = "admin"; var password = "YourPassword"; ``` For multi-channel DVR access, replace `VideoInput/1` with the appropriate channel number. ## Snapshot and MJPEG URLs Sanyo's liveimg.cgi Endpoint Sanyo cameras use a distinctive `/liveimg.cgi` endpoint for HTTP snapshots and MJPEG streams. The `serverpush=1` parameter enables continuous MJPEG streaming. | Type | URL Pattern | Notes | | --- | --- | --- | | Live Snapshot | `http://IP/liveimg.cgi` | Single JPEG frame | | MJPEG Stream | `http://IP/liveimg.cgi?serverpush=1` | Continuous server-push MJPEG | | MJPEG with Channel | `http://IP/liveimg.cgi?serverpush=1&jpeg=1&stream=CHANNEL` | Channel-specific MJPEG stream | | Channel Snapshot (DVR) | `http://IP/liveimg.cgi?ch=CHANNEL` | Channel-specific snapshot for DVR | ## Troubleshooting ### "401 Unauthorized" error Sanyo cameras use basic authentication by default. Ensure you are providing correct credentials: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Log in with your credentials (default: admin / admin) 3. Verify the RTSP service is enabled in network settings 4. Use those credentials in your RTSP URL ### H.264 stream not available Older Sanyo models may only support MJPEG. If the H.264 URL does not work, try using the MJPEG HTTP stream instead: ``` http://CAMERA_IP/liveimg.cgi?serverpush=1 ``` ### Firmware and compatibility Since Sanyo cameras are discontinued, firmware updates are no longer available. If you encounter compatibility issues: - Ensure the camera firmware is the latest available version - Try using ONVIF discovery if direct URL connection fails - Consider migrating to Panasonic i-PRO cameras, which inherit Sanyo's technology ### MJPEG server-push not working The `serverpush=1` parameter requires the camera's HTTP server to support chunked transfer encoding. Some older firmware versions may not support this reliably. Try the single snapshot endpoint (`/liveimg.cgi` without parameters) and poll at your desired frame rate instead. ## FAQ **Are Sanyo cameras still supported?** Sanyo security cameras are discontinued. Sanyo Electric was fully acquired by Panasonic, and the surveillance camera technology was merged into Panasonic's i-PRO product line. No new firmware updates or support are available for Sanyo-branded cameras. **What is the default RTSP URL for Sanyo cameras?** The URL is `rtsp://admin:password@CAMERA_IP:554/VideoInput/1/h264/1` for the main H.264 stream. For DVR setups, replace `VideoInput/1` with the appropriate channel number (e.g., `VideoInput/2` for channel 2). **Do Sanyo cameras support ONVIF?** Only some Sanyo cameras with newer firmware versions have limited ONVIF support. Most older models do not support ONVIF and require direct RTSP URL configuration. **What should I use instead of Sanyo cameras?** Panasonic's i-PRO product line is the direct successor to Sanyo's security camera division. The i-PRO cameras use similar VideoInput RTSP paths and offer modern features like H.265, advanced analytics, and full ONVIF support. See our [Panasonic/i-PRO connection guide](../panasonic/). **How do I get snapshots from a Sanyo camera?** Use the `/liveimg.cgi` HTTP endpoint: `http://CAMERA_IP/liveimg.cgi` returns a single JPEG frame. Add `?serverpush=1` for a continuous MJPEG stream, or `?ch=CHANNEL` for a specific DVR channel. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Panasonic/i-PRO Connection Guide](../panasonic/) — Successor product line - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Sony SNC IP Camera RTSP URL Patterns and C# .NET Setup **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/sony/ **Description:** Sony SNC CH, DH, EB, CX, and IPELA camera RTSP URL patterns for C# .NET. Stream and record with VisioForge Video Capture SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Sony IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Sony** (Sony Corporation, Security Systems Division) was a major manufacturer of professional IP surveillance cameras under the **IPELA** brand and later the **SNC** (Sony Network Camera) product line. Sony exited the security camera market in 2020, selling its security business to **Bosch**. However, a large installed base of Sony cameras remains in use worldwide, particularly in enterprise and government installations. **Key facts:** - **Product lines:** SNC-CH (box, H.264), SNC-DH (dome, H.264), SNC-EB/ER (E-series), SNC-CX (compact), SNC-VB/VM/WR/XM (current-gen before exit), SNC-DF/RX/RZ/CS (legacy IPELA), SNT (video encoders) - **Protocol support:** RTSP, ONVIF, HTTP/CGI, Sony proprietary (DEPA) - **Default RTSP port:** 554 - **Default credentials:** admin / admin (must be changed on setup) - **ONVIF support:** Yes (SNC-CH/DH and newer models) - **Video codecs:** H.264, H.265 (late models), MPEG-4 (legacy), MJPEG - **Status:** Sony exited security camera market in 2020 End of life Sony exited the security camera market in 2020. While existing cameras continue to work, no new firmware updates or models are being released. The RTSP URLs documented here remain valid for existing installations. ## RTSP URL Patterns ### Current-Gen Models (SNC-CH/DH/EB/ER/CX/VB/VM/WR/XM) | Stream | RTSP URL | Codec | Notes | | --- | --- | --- | --- | | Video 1 (main) | `rtsp://IP:554/media/video1` | H.264 | Main stream | | Video 2 (sub) | `rtsp://IP:554/media/video2` | H.264 | Sub stream | | ONVIF profile | `rtsp://IP//profile` | H.264 | ONVIF-based (note double slash) | | Direct | `rtsp://IP//media/video1` | H.264 | Alternative (double slash) | ### Model-Specific URLs | Model Series | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | SNC-CH110 | `rtsp://IP/media/video1` | 1280x1024 | Box camera | | SNC-CH120/CH140 | `rtsp://IP/media/video1` | 1280x1024 / 1920x1080 | Box camera | | SNC-CH160/CH180 | `rtsp://IP/media/video1` | 1920x1080 | Box camera | | SNC-CH210/CH260/CH280 | `rtsp://IP/media/video1` | 1920x1080 / 2MP | Box camera | | SNC-DH110/DH120/DH140 | `rtsp://IP/media/video1` | Up to 1080p | Fixed dome | | SNC-DH160/DH180 | `rtsp://IP/media/video1` | 1920x1080 | Fixed dome | | SNC-DH210/DH260 | `rtsp://IP/media/video1` | 1920x1080 | Fixed dome | | SNC-EB600B | `rtsp://IP/media/video1` | 1080p | E-series | | SNC-CX600W | `rtsp://IP:554//media/video1` | 1080p | Compact | | SNC-VB630/WR630/XM632 | `rtsp://IP//profile` | 1080p+ | Latest gen | | SNC-DM110 | `rtsp://IP:554//media/video1` | 720p | Mini dome | ### Legacy IPELA Models (SNC-RX/RZ/DF/CS/EP) Older Sony IPELA cameras typically don't support RTSP and use HTTP-based streaming: | Model Series | URL | Notes | | --- | --- | --- | | SNC-RX530/RX550 | `http://IP/jpeg/vga.jpg` | JPEG snapshot | | SNC-RZ25/RZ30/RZ50 | `http://IP/oneshotimage.jpg` | JPEG snapshot | | SNC-DF40/DF50/DF70/DF80 | `http://IP/image` | JPEG snapshot | | SNC-CS11/CS3P/CS50P | `http://IP/oneshotimage.jpg` | JPEG snapshot | | SNC-EP520/EP580 | `http://IP/jpeg/vga.jpg` | JPEG snapshot | | SNC-M1/M3 | `http://IP/image` | Very old MPEG-4 | ### Video Encoder URLs | Encoder | URL | Notes | | --- | --- | --- | | SNT-EX101/EX104 | `http://IP/oneshotimage.jpg` | Snapshot per channel | | SNT-EX104 (channel) | `http://IP/CH1/oneshotimage.jpg` | Channel-specific | | SNT-V704 | `http://IP/CH1/oneshotimage.jpg` | 4-channel encoder | ## Connecting with VisioForge SDK Use your Sony camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Sony SNC camera, main stream var uri = new Uri("rtsp://192.168.1.55:554/media/video1"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/media/video2` instead. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/oneshotimage.jpg` | Most SNC models | | JPEG (VGA) | `http://IP/jpeg/vga.jpg` | VGA resolution | | JPEG (QVGA) | `http://IP/jpeg/qvga.jpg` | QVGA resolution | | MJPEG Stream | `http://IP/img/mjpeg.cgi` | Continuous MJPEG | | MJPEG (alt) | `http://IP/mjpeg` | Alternative MJPEG path | | H.264 over HTTP | `http://IP/h264` | H.264 stream via HTTP | | Image | `http://IP/image` | Generic snapshot | | Channel snapshot | `http://IP/oneshotimage1` | Channel-specific | ## Troubleshooting ### Double slash in URLs Some Sony models use a double slash before the path in RTSP URLs: - `rtsp://IP//media/video1` (double slash) - `rtsp://IP:554/media/video1` (single slash with port) Both formats usually work, but try the double-slash variant if the standard URL fails. ### ONVIF vs direct RTSP Sony cameras support both direct RTSP and ONVIF-based connections: - Direct RTSP: `rtsp://IP:554/media/video1` (recommended) - ONVIF: `rtsp://IP//profile` (ONVIF-discovered URL) ### Legacy cameras without RTSP Older Sony IPELA cameras (SNC-RX, SNC-RZ, SNC-DF, SNC-CS, SNC-M series) often don't support RTSP and only offer HTTP JPEG/MJPEG. For these cameras, use HTTP snapshot integration. ### Sony exited the market Sony sold its security camera business in 2020. Existing cameras continue to function but receive no new firmware updates. Plan for eventual migration when deploying new integrations. ## FAQ **What is the default RTSP URL for Sony SNC cameras?** For current Sony SNC cameras, use `rtsp://admin:password@CAMERA_IP:554/media/video1` for the main stream and `media/video2` for the sub stream. **Does Sony still make IP cameras?** No. Sony exited the security camera market in 2020. Existing Sony SNC cameras remain in use and their RTSP streams continue to work, but no new models or firmware updates are being released. **Do Sony cameras support ONVIF?** Yes. Sony SNC-CH, SNC-DH, and newer series support ONVIF Profile S. Use `rtsp://IP//profile` for ONVIF-based connections. **What about Sony IPELA cameras?** IPELA was Sony's earlier camera brand. Many IPELA models (SNC-RX, SNC-RZ, SNC-DF series) only support HTTP JPEG/MJPEG, not RTSP. Later IPELA models (SNC-CH/DH series) do support RTSP via `media/video1`. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Canon Connection Guide](../canon/) — Japanese enterprise cameras - [Axis Connection Guide](../axis/) — Enterprise surveillance peer - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Speco Technologies IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/speco/ **Description:** Speco Technologies O Series, VIP, and DVR RTSP integration for C# .NET. URL patterns, channel selection, and VisioForge SDK code for IP and analog cameras. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Speco Technologies IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Speco Technologies** is an American professional surveillance company based in Amityville, New York. Founded in 1969, Speco manufactures IP cameras, analog cameras, DVRs, NVRs, and access control equipment for the professional security integrator market. Speco products are sold through authorized distributors and security integrators rather than direct-to-consumer channels, making them a common choice in commercial installations. **Key facts:** - **Product lines:** O Series (IP cameras: O2B, O2D, OINT), VIP Series (IP cameras), ZIP Series, SIP Series, LS Series, DVR lines (TH/TL, RS, PCPRO) - **Protocol support:** RTSP, ONVIF, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (all current IP cameras) - **Video codecs:** H.264 (all current models), MPEG-4 (older models) Multiple Product Lines Speco Technologies has many distinct product lines, each with different RTSP URL formats. Identify your exact model series (O, VIP, LS, ZIP, SIP, or DVR type) before configuring the stream URL. The root stream `rtsp://IP:554/` works on many Speco devices as a quick test. ## RTSP URL Patterns ### O Series IP Cameras The O Series is Speco's current IP camera line, including bullet (O2B), dome (O2D), and intensifier (OINT) models: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/ ``` | Model | Resolution | Main Stream URL | Notes | | --- | --- | --- | --- | | O2B2 (bullet) | 1080p | `rtsp://IP:554/` | Root stream | | O2D4 (dome) | 1080p | `rtsp://IP:554/` | Root stream | | OINT56B1G (intensifier) | 1080p | `rtsp://IP:554/mpeg4` | MPEG-4 stream | | OINT56B1G (intensifier) | 1080p | `rtsp://IP:554/` | Root stream (H.264) | ### VIP Series IP Cameras The VIP Series uses a numbered stream path format: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/1/stream1 ``` | Model | Resolution | Main Stream URL | Notes | | --- | --- | --- | --- | | VIP2B1M (bullet) | 1080p | `rtsp://IP:554/1/stream1` | Stream 1 (main) | | VIP2C1N (cube) | 1080p | `rtsp://IP:554/1/stream1` | Stream 1 (main) | ### LS Series The LS Series uses a channel-based H.264 path and also supports a credential-in-URL format: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/cam1/h264` | Channel 1 H.264 stream | | `rtsp://IP:554/cam2/h264` | Channel 2 H.264 stream | | `rtsp://IP:554/cam[N]/h264` | Channel N H.264 stream | | `rtsp://IP:554//user=admin_password=tlJwpbo6_channel=1_stream=0.sdp` | Credential-in-URL format | LS Series Credential Format The LS Series supports an unusual credential-in-URL format where the username and password are embedded directly in the path. The password in this format is device-specific and may differ from the web interface password. Check the device's RTSP settings page for the correct value. ### ZIP Series The ZIP Series uses a profile-based streaming format: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554//stream0/Channel=0;Profile=0 ``` | Model | Main Stream URL | Notes | | --- | --- | --- | | ZIP2B (bullet) | `rtsp://IP:554//stream0/Channel=0;Profile=0` | Profile 0 (main) | ### DVR Models Speco DVRs use various URL formats depending on the DVR line: | DVR Series | URL Pattern | Notes | | --- | --- | --- | | DVR4WM | `rtsp://IP:554/` | Root stream | | RS Series | `rtsp://IP:554/Live/Channel=1` | Live channel format | | RS Series | `rtsp://IP:554/Live/Channel=2` | Channel 2 | | General DVRs | `rtsp://IP:554/` | Root stream (fallback) | ### DVR Channel URLs (RS Series) For Speco RS Series DVRs: | Channel | Main Stream URL | | --- | --- | | Camera 1 | `rtsp://IP:554/Live/Channel=1` | | Camera 2 | `rtsp://IP:554/Live/Channel=2` | | Camera N | `rtsp://IP:554/Live/Channel=N` | ### All URL Formats Summary | URL Pattern | Product Line | Notes | | --- | --- | --- | | `rtsp://IP:554/` | O Series, DVRs, general | Root stream (works on many devices) | | `rtsp://IP:554/mpeg4` | O Series (older) | MPEG-4 stream | | `rtsp://IP:554/1/stream1` | VIP Series | Numbered stream format | | `rtsp://IP:554/cam[N]/h264` | LS Series | Channel-based H.264 | | `rtsp://IP:554//stream0/Channel=0;Profile=0` | ZIP Series | Profile-based format | | `rtsp://IP:554/Live/Channel=N` | RS DVR | Live channel format | ## Connecting with VisioForge SDK Use your Speco camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Speco O2D4 dome camera, root stream var uri = new Uri("rtsp://192.168.1.64:554/"); var username = "admin"; var password = "admin"; ``` For VIP Series cameras, use the `/1/stream1` path instead: ``` // Speco VIP2B1M bullet camera, main stream var uri = new Uri("rtsp://192.168.1.64:554/1/stream1"); var username = "admin"; var password = "admin"; ``` ## Snapshot and MJPEG URLs ### IP Camera Snapshots | Type | URL Pattern | Models | Notes | | --- | --- | --- | --- | | Still Image | `http://IP/stillimg.jpg` | O2B2, O2D4, OINT56B1G | Basic JPEG snapshot | | Still Image (port 554) | `http://IP:554/stillimg.jpg` | O2B2, O2D4, OINT56B1G | Alternate port | | Encoder Snapshot | `http://IP/cgi-bin/encoder?USER=user&PWD=pass&SNAPSHOT` | IP-SD10X, SIP Series | CGI-based with credentials | | System Stream | `http://IP/cgi-bin/cmd/system?GET_STREAM&USER=user&PWD=pass` | Various IP cameras | System command format | ### DVR Snapshots | Type | URL Pattern | DVR Series | Notes | | --- | --- | --- | --- | | Full Image | `http://IP/images1full` | Various DVRs | Replace `1` with channel number | | SIF Image | `http://IP/images1sif` | Various DVRs | Lower resolution, replace `1` with channel | | Get Image | `http://IP/getimage?camera=1&fmt=full` | Various DVRs | Replace `1` with channel number | | Mobile Snapshot | `http://IP/mobile/channel1.jpg` | PCPRO DVR | Mobile-optimized, replace `1` with channel | | TH/TL Stream | `http://IP/ivop.get?action=live&THREAD_ID=` | TH/TL DVR | Live stream via HTTP | ## Troubleshooting ### Inconsistent URL formats across product lines Speco Technologies has many different product lines, each with its own RTSP URL format. If one URL pattern does not work, try the root stream `rtsp://IP:554/` first as a baseline test. Then try the format specific to your product line as listed in the tables above. ### Root stream limitations The root stream (`rtsp://IP:554/`) works on many Speco devices for the main stream but is unreliable for accessing sub-streams or specific channels on multi-channel devices. Use the product-line-specific URL format for full control over stream selection. ### LS Series credential-in-URL format The LS Series uses an unusual URL format where credentials are embedded in the path (`/user=admin_password=VALUE_channel=1_stream=0.sdp`). The password in this format may be a device-generated value that differs from the web interface password. Check the device's **RTSP Settings** page in the web interface for the correct credential string. ### Network discovery Speco provides a DDNS tool and device discovery utility for finding cameras on the network. Download the Speco DDNS tool from the Speco Technologies website to locate devices that are not responding at expected IP addresses. ### Default credentials Speco devices typically ship with default credentials of `admin` / `admin`. If these do not work, the password may have been changed during installation by the security integrator. ## FAQ **What is the default RTSP URL for Speco cameras?** For most Speco IP cameras, try the root stream first: `rtsp://admin:admin@CAMERA_IP:554/`. For VIP Series cameras use `rtsp://IP:554/1/stream1`, and for LS Series cameras use `rtsp://IP:554/cam1/h264`. The correct URL depends on your specific product line. **Do Speco cameras support ONVIF?** Yes. All current Speco IP cameras support ONVIF. ONVIF discovery and streaming is the most reliable way to connect to Speco cameras if you are unsure of the exact RTSP URL format for your model. **Why are there so many different URL formats for Speco cameras?** Speco Technologies has been manufacturing surveillance equipment since 1969 and has acquired or developed multiple product lines over the decades. Each product line (O Series, VIP, LS, ZIP, SIP, DVR lines) may use different firmware and streaming architectures, resulting in different URL formats. Always identify your exact model series before configuring the connection. **How do I find my Speco camera on the network?** Use Speco's DDNS tool or device discovery utility, available from the Speco Technologies website. Alternatively, use ONVIF discovery through the VisioForge SDK or a network scanning tool to locate the camera's IP address on your local network. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [EverFocus Connection Guide](../everfocus/) — Professional surveillance cameras - [Save Original RTSP Stream](../../mediablocks/Guides/rtsp-save-original-stream/) — Record Speco streams without re-encoding - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Swann IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/swann/ **Description:** Swann NHD, SWNHD, DVR/NVR, and ADS camera RTSP URL patterns for C# .NET. Stream and record using VisioForge Video Capture SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to Swann IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Swann** (Swann Communications) is an Australian consumer security brand headquartered in Melbourne, Australia, now owned by **Infinova**. Swann is one of the best-known consumer and prosumer security brands, popular for their bundled DVR/NVR camera systems sold through major retailers. Swann offers a range of standalone IP cameras, analog-over-coax (BNC) camera systems, and network video recorders. **Key facts:** - **Product lines:** NHD (current network HD cameras), SWNHD (HD IP cameras), SWPRO (analog-over-coax), DVR/NVR systems, ADS (legacy IP cameras) - **Protocol support:** RTSP, ONVIF (current NHD models), HTTP/MJPEG (legacy) - **Default RTSP port:** 554 - **Default credentials:** admin / admin or admin / (empty) on older models - **ONVIF support:** Yes (current NHD-series cameras) - **Video codecs:** H.264, H.265 (current models), MPEG-4 (legacy DVRs) - **OEM base:** Many newer Swann NVRs are Hikvision OEM and use Hikvision RTSP URL patterns Swann NVRs and Hikvision Many current Swann NVRs are manufactured by Hikvision and use Hikvision firmware. If the standard Swann RTSP URL does not work on your NVR, try the Hikvision URL format (`/Streaming/Channels/`). See our [Hikvision connection guide](../hikvision/) for details. ## RTSP URL Patterns ### Current NHD-Series IP Cameras Standalone Swann NHD-series IP cameras (SWNHD-820CAM, SWNHD-830CAM, NHD-866, etc.) use the following URL: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/live/h264 ``` ### NVR Systems (Hikvision-Based) Most current Swann NVRs use Hikvision-style RTSP paths: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554//Streaming/Channels/[CHANNEL_ID] ``` | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554//Streaming/Channels/1` | `rtsp://IP:554//Streaming/Channels/102` | | Camera 2 | `rtsp://IP:554//Streaming/Channels/2` | `rtsp://IP:554//Streaming/Channels/202` | | Camera N | `rtsp://IP:554//Streaming/Channels/N` | `rtsp://IP:554//Streaming/Channels/N02` | Channel numbering For Hikvision-based NVRs, the main stream channel ID matches the camera number (1, 2, 3...). The sub stream uses the format `N02` where N is the camera number (102, 202, 302...). ### Legacy DVR Models Older Swann DVR systems (DVR4-PRO-NET, etc.) and standalone cameras use MPEG-4: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/mpeg4 ``` ### URL Summary Table | Model / Series | Main Stream URL | Notes | | --- | --- | --- | | NHD-series cameras (SWNHD-820/830) | `rtsp://IP:554/live/h264` | Standalone IP cameras | | IP-3G ConnectCam | `rtsp://IP:554/mpeg4` | Legacy standalone | | Max-IP-Cam | `rtsp://IP:554/mpeg4` | Legacy standalone | | Current NVR (channel 1) | `rtsp://IP:554//Streaming/Channels/1` | Hikvision OEM | | Current NVR (channel 1, sub) | `rtsp://IP:554//Streaming/Channels/102` | Hikvision OEM | | DVR4-PRO-NET | `rtsp://IP:554/mpeg4` | Legacy DVR | | Generic Swann IP cameras | `rtsp://IP:554/live/h264` | Try this first | ## Connecting with VisioForge SDK Use your Swann camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Swann NHD-series camera, main stream var uri = new Uri("rtsp://192.168.1.90:554/live/h264"); var username = "admin"; var password = "YourPassword"; ``` For NVR sub-stream access, use `/Streaming/Channels/102` instead of `/Streaming/Channels/1`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | HTTP stream (ADS-440 legacy) | `http://IP/videostream.asf?user=USER&pwd=PASS` | ASF format, no RTSP | | MJPEG stream (legacy) | `http://IP/videostream.cgi?user=USER&pwd=PASS` | Older models | | ONVIF snapshot | `http://IP/onvif-http/snapshot` | NHD-series with ONVIF | Legacy HTTP-only cameras The ADS-440 series and some other older Swann models only support HTTP streaming (ASF or MJPEG) and do not support RTSP at all. Use the HTTP URL directly for these cameras. ## Troubleshooting ### Identify your NVR firmware type Many Swann NVRs are Hikvision OEM. To determine which URL format to use: 1. Access the NVR web interface at `http://NVR_IP` 2. Check the login page — Hikvision-based NVRs often show a Hikvision-style interface 3. Try the Hikvision URL first (`/Streaming/Channels/1`), then fall back to Swann URLs (`/live/h264` or `/mpeg4`) ### "Connection refused" on legacy cameras Older Swann cameras (ADS-440 series, early DVR models) may not support RTSP at all. These cameras use HTTP-based streaming only. Try the HTTP ASF or MJPEG URL instead of RTSP. ### Default credentials not working - Current models typically ship with admin / admin but require password change on first setup - Some older models use admin with an empty password - Always complete initial setup via the Swann web interface or SwannView app before attempting RTSP access ### SwannView vs local RTSP access SwannView (Swann's cloud service) is separate from local RTSP access. You do not need a SwannView account to use RTSP streaming on your local network. RTSP works purely over the local network connection. ## FAQ **What is the default RTSP URL for Swann cameras?** For current NHD-series cameras, use `rtsp://admin:password@CAMERA_IP:554/live/h264`. For Swann NVRs (Hikvision-based), use `rtsp://admin:password@NVR_IP:554//Streaming/Channels/1` for channel 1 main stream. **Are Swann NVRs compatible with Hikvision RTSP URLs?** Yes. Many current Swann NVRs are manufactured by Hikvision and use identical firmware. The Hikvision RTSP URL format (`/Streaming/Channels/`) works on these systems. If the standard Swann URL fails, try the Hikvision format. **Do all Swann cameras support RTSP?** No. Some legacy Swann models (particularly the ADS-440 series) only support HTTP-based streaming in ASF or MJPEG format. All current NHD-series cameras and NVRs support RTSP. **Do Swann cameras support ONVIF?** Yes, current NHD-series cameras support ONVIF. Legacy models (SWPRO, ADS series) generally do not support ONVIF. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Lorex Connection Guide](../lorex/) — Consumer/prosumer segment peer - [Hikvision Connection Guide](../hikvision/) — Swann NVRs with Hikvision firmware - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Tenda IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/tenda/ **Description:** Tenda CP, CT, IT series and pan/tilt camera RTSP URL patterns for C# .NET. Stream and record using VisioForge Video Capture SDK integration code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to Tenda IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Tenda Technology** is a Chinese networking equipment manufacturer headquartered in Shenzhen, China. Founded in 1999, Tenda is primarily known for routers and networking gear but has expanded into the security camera market with a growing line of affordable IP cameras targeting the consumer and small business segments. Tenda cameras are gaining traction in emerging markets across Asia, South America, and Africa. **Key facts:** - **Product lines:** CP (pan/tilt), CT (outdoor bullet/turret), IT (indoor) - **Protocol support:** RTSP, ONVIF (select models), HTTP - **Default RTSP port:** 554 - **Default credentials:** admin / admin (varies by model) - **ONVIF support:** Yes (newer models) - **Video codecs:** H.264, H.265 (select models) - **Companion app:** Tenda Security app (for setup and remote viewing) ## RTSP URL Patterns ### Standard URL Format Tenda cameras use a stream-number-based RTSP URL: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/stream1 ``` | Stream | URL Pattern | Description | | --- | --- | --- | | Main stream | `rtsp://IP:554/stream1` | Full resolution | | Sub stream | `rtsp://IP:554/stream2` | Lower resolution | ### Camera Models | Model | Type | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | --- | | CP3 (pan/tilt indoor) | Indoor PTZ | 1920x1080 | `rtsp://IP:554/stream1` | Yes | | CP6 (2K pan/tilt) | Indoor PTZ | 2304x1296 | `rtsp://IP:554/stream1` | Yes | | CP7 (4MP pan/tilt) | Indoor PTZ | 2560x1440 | `rtsp://IP:554/stream1` | Yes | | CT3 (outdoor bullet) | Outdoor | 1920x1080 | `rtsp://IP:554/stream1` | Yes | | CT6 (2K outdoor) | Outdoor | 2304x1296 | `rtsp://IP:554/stream1` | Yes | | CT7 (4MP outdoor) | Outdoor | 2560x1440 | `rtsp://IP:554/stream1` | Yes | | IT6 (indoor) | Indoor | 1920x1080 | `rtsp://IP:554/stream1` | Yes | | IT7 (2K indoor) | Indoor | 2304x1296 | `rtsp://IP:554/stream1` | Yes | ### Alternative URL Formats | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/stream1` | Main stream (recommended) | | `rtsp://IP:554/stream2` | Sub stream | | `rtsp://IP:554/live/ch0` | Alternative format (some models) | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua-compatible (some OEM firmware) | ## Connecting with VisioForge SDK Use your Tenda camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Tenda CP7 (4MP pan/tilt), main stream var uri = new Uri("rtsp://192.168.1.90:554/stream1"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/stream2` instead of `/stream1`. ## Snapshot URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Requires basic auth | ## Troubleshooting ### Camera requires app setup first Tenda cameras must be initially configured through the Tenda Security app. The camera needs WiFi credentials and account setup before RTSP is accessible. After setup, you can connect directly via RTSP on the local network. ### Multiple URL formats Some Tenda cameras use different firmware bases. If `/stream1` does not work, try: 1. `rtsp://IP:554/live/ch0` (alternative format) 2. `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` (Dahua-compatible) 3. Use ONVIF discovery to retrieve the correct URL automatically ### Finding the camera IP Tenda WiFi cameras get their IP via DHCP. Find it in: 1. The Tenda Security app (Device Info) 2. Your router's DHCP client list 3. ONVIF discovery (if supported) ## FAQ **What is the default RTSP URL for Tenda cameras?** Most Tenda cameras use `rtsp://admin:password@CAMERA_IP:554/stream1` for the main stream and `/stream2` for the sub stream. Some models use alternative URL paths. **Do Tenda cameras support ONVIF?** Newer Tenda camera models support ONVIF for standardized discovery and streaming. Older or budget models may not. Check your camera's specifications in the Tenda Security app. **Are Tenda cameras good for development integration?** Tenda cameras offer competitive pricing and standard RTSP support, making them suitable for development and prototyping. For production deployments requiring guaranteed RTSP/ONVIF compatibility, consider established surveillance brands like [Hikvision](../hikvision/), [Dahua](../dahua/), or [Reolink](../reolink/). ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [TP-Link Connection Guide](../tp-link/) — Similar consumer segment - [Mercusys Connection Guide](../mercusys/) — Budget camera alternative - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Tiandy IP Camera in C# .NET — RTSP, ONVIF Setup Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/tiandy/ **Description:** Connect Tiandy IP cameras (TC-C, TC-NC, TC-A, TC-R NVR) to C# / .NET apps via RTSP and ONVIF. Default stream URLs, credentials, H.265 configs. Code sample. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to Tiandy IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Tiandy Technologies** (Tiandy Technologies Co., Ltd.) is a Chinese video surveillance manufacturer headquartered in Tianjin, China. Founded in 1994, Tiandy is one of China's largest security equipment manufacturers and has been expanding rapidly into international markets across Asia, the Middle East, Africa, and Latin America. Tiandy specializes in AI-powered IP cameras, NVRs, and integrated video management solutions. **Key facts:** - **Product lines:** TC-C (current IP cameras), TC-NC (legacy IP), TC-A (AI analytics), TC-R (NVRs), TC-NR (network recorders) - **Protocol support:** RTSP, ONVIF Profile S/T, HTTP/CGI - **Default RTSP port:** 554 - **Default credentials:** admin / 1111 (older models) or admin / admin123 (varies by region) - **ONVIF support:** Yes (current models) - **Video codecs:** H.264, H.265 (SuperH.265), MJPEG - **AI features:** Smart H.265+, face detection, perimeter protection, people counting ## RTSP URL Patterns ### Standard URL Format Tiandy cameras use a channel and stream-based RTSP URL structure: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/cam/realmonitor?channel=1&subtype=0 ``` | Parameter | Value | Description | | --- | --- | --- | | `channel` | 1, 2, 3... | Camera channel (1 for standalone cameras) | | `subtype` | 0 | Main stream (highest resolution) | | `subtype` | 1 | Sub stream (lower resolution) | Dahua-Compatible URL Format Many Tiandy cameras use the same `cam/realmonitor` RTSP URL format as Dahua cameras. If you are familiar with Dahua integration, the same URL patterns may work with Tiandy. See our [Dahua connection guide](../dahua/) for additional details. ### Alternative URL Formats | URL Pattern | Description | | --- | --- | | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Dahua-compatible (many models) | | `rtsp://IP:554/live/ch0` | Main stream (legacy format) | | `rtsp://IP:554/live/ch1` | Sub stream (legacy format) | | `rtsp://IP:554/media/video1` | Uniview-compatible (some models) | | `rtsp://IP:554/Streaming/Channels/101` | Hikvision-compatible (some OEM models) | | `rtsp://IP:554/h264` | Simple H.264 stream path | ### Camera Models | Model Series | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | | TC-C32JN (2MP bullet) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | No | | TC-C34JN (4MP bullet) | 2560x1440 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | No | | TC-C35JN (5MP bullet) | 2592x1944 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | No | | TC-C38JN (4K bullet) | 3840x2160 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | TC-C32DN (2MP dome) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | No | | TC-C34DN (4MP dome) | 2560x1440 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | TC-C32EP (2MP turret) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | TC-C34EP (4MP turret) | 2560x1440 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | TC-A32E2T (2MP AI) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | | TC-C32WP (2MP WiFi) | 1920x1080 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | Yes | ### NVR Channel URLs For Tiandy NVRs (TC-R3100, TC-R3200, TC-NR series): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=1&subtype=1` | | Camera 2 | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=2&subtype=1` | | Camera N | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=0` | `rtsp://IP:554/cam/realmonitor?channel=N&subtype=1` | ## Connecting with VisioForge SDK Use your Tiandy camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Tiandy TC-C34JN (4MP bullet), main stream var uri = new Uri("rtsp://192.168.1.90:554/cam/realmonitor?channel=1&subtype=0"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `subtype=1` instead of `subtype=0`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi?channel=1` | Requires digest authentication | | MJPEG Stream | `http://IP/cgi-bin/mjpg/video.cgi?channel=1&subtype=1` | Continuous MJPEG | ## Troubleshooting ### Multiple URL formats Tiandy cameras may use different RTSP URL formats depending on firmware version and model. If one format does not work, try alternatives in this order: 1. `rtsp://IP:554/cam/realmonitor?channel=1&subtype=0` (Dahua-compatible, most common) 2. `rtsp://IP:554/live/ch0` (legacy Tiandy format) 3. `rtsp://IP:554/h264` (simple path) ### Default credentials vary Tiandy default passwords differ by model and region. Common defaults include: - `admin` / `1111` - `admin` / `admin123` - `admin` / `123456` If none of these work, the camera may require initial activation via the web interface or Tiandy's EasyLive utility. ### SuperH.265 codec Tiandy's SuperH.265 is a proprietary optimization that produces standard H.265/HEVC streams. No special decoder is required. The VisioForge SDK handles H.265 streams natively. ## FAQ **What is the default RTSP URL for Tiandy cameras?** Most Tiandy cameras use `rtsp://admin:password@CAMERA_IP:554/cam/realmonitor?channel=1&subtype=0` for the main stream, which is the same format as Dahua cameras. Some older models use `rtsp://IP:554/live/ch0` instead. **Are Tiandy cameras Dahua OEMs?** No. Tiandy is an independent manufacturer with its own hardware and firmware. However, some Tiandy firmware uses the same RTSP URL format as Dahua (`cam/realmonitor`), which is common across several Chinese surveillance manufacturers. **Do Tiandy cameras support ONVIF?** Yes. Current Tiandy models support ONVIF Profile S and Profile T. ONVIF must be enabled in the camera's web interface under network settings. Some models require creating a separate ONVIF user account. **Which Tiandy camera series should I choose?** **TC-C** is the current mainstream series. The number after "TC-C3" indicates resolution: **2** = 2MP, **4** = 4MP, **5** = 5MP, **8** = 4K. The suffix letters indicate form factor: **JN** = bullet, **DN** = dome, **EP** = turret/eyeball, **WP** = WiFi. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Dahua Connection Guide](../dahua/) — Similar URL format - [Uniview Connection Guide](../uniview/) — Another major Chinese surveillance brand - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Toshiba IP Camera RTSP URL and Streaming in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/toshiba/ **Description:** Toshiba IK-WB, IK-WD, IK-WR, and IK-WP camera RTSP URL patterns for C# .NET. Stream and record with VisioForge Video Capture SDK integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Toshiba IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Toshiba** (Toshiba Corporation) is a Japanese multinational conglomerate headquartered in Tokyo, Japan. Toshiba's security division produced the **IK-W series** of IP cameras, covering box, dome, bullet, and PTZ form factors. Toshiba has since exited the standalone security camera market and sold its surveillance business. Despite discontinuation, many IK-W series cameras remain deployed in commercial and industrial installations worldwide. **Key facts:** - **Product lines:** IK-WB (box cameras), IK-WD (dome cameras), IK-WR (bullet/rugged cameras), IK-WP (PTZ cameras) - **Protocol support:** RTSP, HTTP/CGI, ONVIF (limited, newer models only) - **Default RTSP port:** 554 - **Default credentials:** admin / 1234 - **ONVIF support:** Limited (newer IK-W14/16/30/70/80 models only) - **Video codecs:** H.264 (IK-W14/16/30/70/80 series), MJPEG (older models) Discontinued Product Line Toshiba has exited the IP camera market and sold its surveillance business. No new firmware updates or official support are available. Many early IK-WB models (01A, 02A, 11A) support HTTP snapshot only and do not provide RTSP streaming. ## RTSP URL Patterns ### Standard URL Format Toshiba IK-W series cameras use the `live.sdp` URL pattern: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/live.sdp ``` | Parameter | Value | Description | | --- | --- | --- | | `live.sdp` | Primary stream | Main H.264 stream (highest resolution) | | `live2.sdp` | Sub stream | Secondary stream (lower resolution) | | `live3.sdp` | Third stream | Third stream (mobile-optimized, select models) | ### Camera Models - RTSP Streams | Model | Type | Main Stream URL | Sub Stream URL | Notes | | --- | --- | --- | --- | --- | | IK-WB16A | Box | `rtsp://IP:554/live.sdp` | -- | H.264 | | IK-WB80A | Box | `rtsp://IP:554/live.sdp` | -- | H.264 | | IK-WD01A | Dome | `rtsp://IP:554/live.sdp` | -- | H.264 | | IK-WD12A | Dome | `rtsp://IP:554//live.sdp` | -- | Double-slash path | | IK-WD14A | Dome | `rtsp://IP:554/live.sdp` | `rtsp://IP:554/live2.sdp` | Also supports `live3.sdp` | | IK-WR04A | Bullet | `rtsp://IP:554/live.sdp` | -- | H.264 | | IK-WR12A | Bullet | `rtsp://IP:554/live.sdp` | -- | H.264 | | IK-WR14A | Bullet | `rtsp://IP:554/live.sdp` | -- | H.264 | | IK-WP41A | PTZ | `rtsp://IP:554/live.sdp` | -- | H.264 | ### Models by Series #### IK-WB Series (Box Cameras) | Model | Streaming | Protocol | | --- | --- | --- | | IK-WB01A | HTTP snapshot only | HTTP | | IK-WB02A | HTTP snapshot only | HTTP | | IK-WB11A | HTTP snapshot only | HTTP | | IK-WB15A | HTTP snapshot + CGI | HTTP | | IK-WB16A | RTSP `live.sdp` | RTSP + HTTP | | IK-WB16A-W | RTSP `live.sdp`, `live3.sdp` | RTSP + HTTP | | IK-WB21A | HTTP CGI only | HTTP | | IK-WB30A | RTSP `live.sdp` | RTSP + HTTP | | IK-WB70A | RTSP `live.sdp` | RTSP + HTTP + MJPEG | | IK-WB80A | RTSP `live.sdp` | RTSP + HTTP + MJPEG | #### IK-WD Series (Dome Cameras) | Model | Streaming | Protocol | | --- | --- | --- | | IK-WD01A | RTSP `live.sdp` | RTSP | | IK-WD12A | RTSP `//live.sdp` | RTSP (double-slash) | | IK-WD14A | RTSP `live.sdp`, `live2.sdp`, `live3.sdp` | RTSP (multi-stream) | #### IK-WR Series (Bullet/Rugged Cameras) | Model | Streaming | Protocol | | --- | --- | --- | | IK-WR01A | HTTP snapshot only | HTTP | | IK-WR02A | HTTP snapshot only | HTTP | | IK-WR04A | RTSP `live.sdp` | RTSP | | IK-WR12A | RTSP `live.sdp` | RTSP + MJPEG | | IK-WR14A | RTSP `live.sdp` | RTSP + HTTP | #### IK-WP Series (PTZ Cameras) | Model | Streaming | Protocol | | --- | --- | --- | | IK-WP41A | RTSP `live.sdp` | RTSP | ### Alternative URL Formats Some Toshiba models use a double-slash in the RTSP path: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/live.sdp` | Standard (recommended) | | `rtsp://IP:554//live.sdp` | Double-slash variant (IK-WD12A, some IK-WD14A units) | | `rtsp://IP:554/live2.sdp` | Sub stream (IK-WD14A) | | `rtsp://IP:554/live3.sdp` | Third stream (IK-WB16A-W, IK-WD14A) | Double-Slash Path If `rtsp://IP:554/live.sdp` does not work on your Toshiba camera, try the double-slash variant `rtsp://IP:554//live.sdp`. Some IK-WD models require this format. ## Connecting with VisioForge SDK Use your Toshiba camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Toshiba IK-WD14A, main stream var uri = new Uri("rtsp://192.168.1.90:554/live.sdp"); var username = "admin"; var password = "1234"; ``` For sub-stream access on supported models, use `live2.sdp` instead of `live.sdp`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Compatible Models | Notes | | --- | --- | --- | --- | | JPEG Snapshot | `http://IP/__live.jpg?&&&` | IK-WB01A, WB11A, WB15A, WB16A-W, WB21A | Note underscore prefix | | CGI Snapshot | `http://IP/GetData.cgi` | IK-WB01A, WB11A, WB15A, WB21A, WR01A | Basic snapshot | | Configurable Snapshot | `http://IP/GetData.cgi?CH=CHANNEL&Codec=jpeg&Size=WIDTHxHEIGHT` | IK-WB series | Set resolution and channel | | Resolution Snapshot | `http://IP/cgi-bin/viewer/video.jpg?resolution=WIDTHxHEIGHT` | IK-WB15A, WB16A, WB30A, WB70A, WR12A, WR14A | Specify output resolution | | Simple Snapshot | `http://IP/Jpeg/CamImg.jpg` | IK-WB02A, WR01A | Basic JPEG capture | | MJPEG Stream | `http://IP/video.mjpg` | IK-WB70A, WB80A, WR12A | Continuous MJPEG stream | HTTP-Only Models Early Toshiba models (IK-WB01A, WB02A, WB11A, WR01A, WR02A) do not support RTSP. For these cameras, use HTTP snapshot URLs or MJPEG streams. You can capture these via the VisioForge SDK's HTTP source or MJPEG source modes. ## Troubleshooting ### Camera is HTTP-only (no RTSP) Many early IK-WB models (01A, 02A, 11A) and IK-WR models (01A, 02A) do not support RTSP streaming at all. These cameras only provide HTTP snapshot and CGI endpoints. If your camera does not respond on port 554, check whether it is an HTTP-only model from the tables above. ### Underscore prefix in snapshot URL The `__live.jpg` snapshot URL uses a **double underscore prefix**, which is unusual. Make sure to include both underscores: ``` http://192.168.1.90/__live.jpg?&&& ``` The trailing `&&&` characters are also required on some firmware versions. ### Double-slash in RTSP path Some IK-WD series cameras (WD12A, certain WD14A units) require a double forward slash in the RTSP path: ``` rtsp://admin:1234@192.168.1.90:554//live.sdp ``` If the standard single-slash URL does not connect, try this variant. ### No firmware updates available Toshiba has exited the security camera market. No new firmware, patches, or official support channels are available. If you encounter bugs or security vulnerabilities, consider replacing the camera with a currently supported model. ### Default credentials not working The factory default credentials are **admin / 1234**. If these do not work, the password may have been changed by a previous administrator. A hardware factory reset (usually a pinhole reset button) will restore defaults on most models. ## FAQ **What is the default RTSP URL for Toshiba IP cameras?** The primary RTSP URL is `rtsp://admin:1234@CAMERA_IP:554/live.sdp` for models that support RTSP streaming. Use `live2.sdp` for the sub stream on models like the IK-WD14A. Note that older IK-WB01A/02A/11A and IK-WR01A/02A models do not support RTSP at all. **Are Toshiba IP cameras still supported?** No. Toshiba sold its surveillance business and exited the IP camera market. No firmware updates, new models, or official technical support are available. Existing cameras continue to function but will not receive security patches or feature updates. **Do Toshiba cameras support ONVIF?** Only newer models in the IK-W14/16/30/70/80 range have limited ONVIF support. Older models (IK-WB01A through WB11A, IK-WR01A/02A) do not support ONVIF. For ONVIF discovery and configuration, use only the supported models. **Why does my Toshiba camera only provide snapshots, not video streams?** Early Toshiba IK-W models were designed as network snapshot cameras and do not include an RTSP server. These models (IK-WB01A, WB02A, WB11A, WR01A, WR02A) only support HTTP-based JPEG snapshots and CGI endpoints. To get continuous video, you need a newer model from the IK-W14/16/30/70/80 series. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Sony Connection Guide](../sony/) — Japanese enterprise cameras - [JVC Connection Guide](../jvc/) — Japanese legacy surveillance brand - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## TP-Link and Tapo IP Camera RTSP URL Guide for C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/tp-link/ **Description:** TP-Link and Tapo C series camera RTSP URL patterns for C# .NET. Integrate TL-SC, NC, and Tapo models with VisioForge Video Capture SDK. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MP4, H.264, H.265, MJPEG, C# # How to Connect to TP-Link IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **TP-Link** is a global networking equipment manufacturer headquartered in Shenzhen, China. While primarily known for routers and networking gear, TP-Link produces IP cameras under both the **TP-Link** brand (TL-SC series, now discontinued) and the **Tapo** smart home brand (Tapo C series, currently active). The Tapo line has become one of the best-selling consumer camera brands globally due to aggressive pricing and app-based setup. **Key facts:** - **Product lines:** TL-SC series (legacy, discontinued), NC series (cloud cameras, discontinued), Tapo C series (current smart home cameras) - **Protocol support:** RTSP, HTTP/MJPEG, ONVIF (Tapo models with firmware update), proprietary cloud protocol - **Default RTSP port:** 554 - **Default credentials:** Varies by generation (see below) - **ONVIF support:** Tapo C series (requires enabling in Tapo app); TL-SC series has no ONVIF - **Video codecs:** H.264 (all models), H.265 (Tapo C320WS and newer) ### Credentials by Product Line | Product Line | Default Username | Default Password | Notes | | --- | --- | --- | --- | | TL-SC series | admin | admin | Legacy, fixed | | NC series | admin | admin | Cloud-managed | | Tapo C series | (set in app) | (set in app) | Must create RTSP credentials in Tapo app | Tapo camera credentials Tapo cameras require you to create a separate **camera account** in the Tapo app (Advanced Settings > Camera Account) before RTSP access works. This username/password is different from your TP-Link cloud account. ## RTSP URL Patterns ### Tapo C Series (Current Models) The Tapo camera line uses a straightforward RTSP URL format: | Model | RTSP URL | Stream | Audio | | --- | --- | --- | --- | | Tapo C100 (indoor) | `rtsp://IP:554/stream1` | Main (1080p) | Yes | | Tapo C100 (indoor) | `rtsp://IP:554/stream2` | Sub (360p) | Yes | | Tapo C110 (indoor 3MP) | `rtsp://IP:554/stream1` | Main (2304x1296) | Yes | | Tapo C110 (indoor 3MP) | `rtsp://IP:554/stream2` | Sub | Yes | | Tapo C200 (pan/tilt) | `rtsp://IP:554/stream1` | Main (1080p) | Yes | | Tapo C200 (pan/tilt) | `rtsp://IP:554/stream2` | Sub (360p) | Yes | | Tapo C210 (pan/tilt 3MP) | `rtsp://IP:554/stream1` | Main (2304x1296) | Yes | | Tapo C310 (outdoor) | `rtsp://IP:554/stream1` | Main (2048x1296) | Yes | | Tapo C320WS (outdoor 2K) | `rtsp://IP:554/stream1` | Main (2560x1440) | Yes | | Tapo C500 (outdoor PTZ) | `rtsp://IP:554/stream1` | Main (1080p) | Yes | | Tapo C520WS (outdoor 2K PTZ) | `rtsp://IP:554/stream1` | Main (2560x1440) | Yes | ### TL-SC Series (Legacy Models) The discontinued TL-SC series used different URL formats depending on the model: | Model | RTSP URL | Codec | Audio | | --- | --- | --- | --- | | TL-SC3130 | `rtsp://IP:554/video.mp4` | MPEG-4 | Yes | | TL-SC3130G | `rtsp://IP:554/video.mp4` | MPEG-4 | Yes | | TL-SC3171 | `rtsp://IP:554/video.mp4` | MPEG-4 | Yes | | TL-SC3171G | `rtsp://IP:554/video.mp4` | MPEG-4 | Yes | | TL-SC3230 | `rtsp://IP:554/video.h264` | H.264 | Yes | | TL-SC3230N | `rtsp://IP:554/video.h264` | H.264 | Yes | | TL-SC3430 | `rtsp://IP:554/video.h264` | H.264 | Yes | | TL-SC3430N | `rtsp://IP:554/video.h264` | H.264 | Yes | | TL-SC4171G | `rtsp://IP:554/video.mp4` | MPEG-4 | Yes | ### TL-SC Alternative URL Formats | URL Pattern | Codec | Notes | | --- | --- | --- | | `rtsp://IP:554/video.mp4` | MPEG-4 | Primary for SC3xxx models | | `rtsp://IP:554/video.h264` | H.264 | Primary for newer SC models | | `rtsp://IP:554/video.mjpg` | MJPEG | Lower quality, wider compatibility | | `rtsp://IP:554/video.pro2` | MPEG-4 | Alternative profile | | `rtsp://IP:554/live.sdp` | H.264 | SDP-based stream | | `rtsp://IP:554/cam1/h264` | H.264 | Channel-based format | | `rtsp://IP:554/media.amp` | Auto | Axis-compatible firmware | ## Connecting with VisioForge SDK Use your TP-Link camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // TP-Link Tapo C200, main stream var uri = new Uri("rtsp://192.168.1.100:554/stream1"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/stream2` instead. ## Snapshot and MJPEG URLs ### Tapo C Series | Type | URL Pattern | Notes | | --- | --- | --- | | Snapshot | `http://IP/snapshot.jpg` | May require authentication | ### TL-SC Series | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/jpg/image.jpg` | Basic snapshot | | Sized Snapshot | `http://IP/jpg/image.jpg?size=3` | Predefined size | | CGI Snapshot | `http://IP/cgi-bin/jpg/image` | CGI-based | | MJPEG Stream | `http://IP/video.mjpg` | Continuous MJPEG | | MJPEG (quality) | `http://IP/video.mjpg?q=30&fps=33&id=0.5` | Quality/FPS control | | Video CGI | `http://IP/video.cgi?resolution=VGA` | Resolution-specific | | Net Video CGI | `http://IP/cgi-bin/net_video.cgi?channel=1` | Channel-based | | Axis-compatible | `http://IP/axis-cgi/mjpg/video.cgi` | Emulated Axis API | ## Troubleshooting ### Tapo camera: "Connection refused" or "Unauthorized" The most common issue with Tapo cameras is not setting up RTSP credentials: 1. Open the **Tapo app** on your phone 2. Go to your camera's settings 3. Navigate to **Advanced Settings > Camera Account** 4. Create a username and password 5. Use these credentials (not your TP-Link account) in RTSP URLs ### Tapo camera: ONVIF not working ONVIF is disabled by default on Tapo cameras. To enable it: 1. Open the Tapo app 2. Go to camera settings > Advanced Settings 3. Enable **ONVIF** toggle 4. Camera will reboot ### TL-SC models: wrong codec URL TL-SC cameras are codec-specific in their URLs: - **SC3130/3171 series:** Use `/video.mp4` (MPEG-4) - **SC3230/3430 series:** Use `/video.h264` (H.264) - Using the wrong codec in the URL path will result in no stream ### Stream2 on Tapo cameras shows low resolution This is by design. `stream2` is the sub stream intended for lower bandwidth. Use `stream1` for full resolution. You can adjust the sub stream resolution in the Tapo app under camera settings. ### TL-SC models: videostream.asf not working The `videostream.asf` URL format requires URL-embedded credentials: `http://IP/videostream.asf?user=admin&pwd=admin&resolution=64&rate=0` The `resolution` parameter values: 32 = 320x240, 64 = 640x480. ## FAQ **What is the default RTSP URL for Tapo cameras?** The URL is `rtsp://username:password@CAMERA_IP:554/stream1` for the main stream and `stream2` for the sub stream. You must first create RTSP credentials in the Tapo app under Advanced Settings > Camera Account. **Can I use Tapo cameras without the Tapo cloud service?** Yes. Once you set up RTSP credentials via the Tapo app, you can access the camera's RTSP stream directly over your local network without any cloud dependency. The Tapo app is only needed for initial setup and credential configuration. **What's the difference between TL-SC and Tapo cameras?** The TL-SC series was TP-Link's older IP camera line (discontinued) with traditional web-based management. Tapo is the current smart home camera brand with app-based setup. Both support RTSP but use different URL patterns and authentication methods. **Do Tapo cameras support H.265?** Select models like the Tapo C320WS and C520WS support H.265 encoding. Most Tapo cameras use H.264. Check your specific model's specifications for H.265 support. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Reolink Connection Guide](../reolink/) — Consumer alternative with RTSP - [Mercusys Connection Guide](../mercusys/) — TP-Link sub-brand, same firmware - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Ubiquiti (UniFi) IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/ubiquiti/ **Description:** Ubiquiti UniFi Protect G3, G4, G5, and AI series RTSP URL patterns for C# .NET. Enable RTSP in UniFi and integrate with VisioForge SDK code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, VideoCaptureCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to Ubiquiti (UniFi) IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Ubiquiti Inc.** is an American technology company headquartered in New York City, known for networking equipment under the **UniFi** brand. Ubiquiti's camera line is part of the **UniFi Protect** ecosystem, which includes cameras, NVRs (Network Video Recorders), doorbells, and sensors. UniFi Protect cameras are managed through a central console (Dream Machine, Cloud Key, or NVR) and are popular in prosumer and SMB environments. **Key facts:** - **Product lines:** UniFi Protect G3 (1080p), G4 (2K/4MP), G5 (2K/4MP updated), AI series (with onboard AI), UVC (legacy AirCam) - **Protocol support:** RTSP (must be enabled per camera), ONVIF (limited), proprietary UniFi Protect protocol - **Default RTSP port:** 7447 (UniFi Protect) or 554 (legacy AirCam) - **Default credentials:** Set during UniFi Protect setup (RTSP uses separate per-camera credentials) - **ONVIF support:** Not natively supported; RTSP is the third-party integration method - **Video codecs:** H.264 (all models) RTSP must be enabled UniFi Protect cameras do **not** have RTSP enabled by default. You must enable RTSP for each camera individually through the UniFi Protect web interface or app. Without enabling it, the camera will not respond to RTSP connections. ### Enabling RTSP on UniFi Protect Cameras 1. Open the **UniFi Protect** web interface (via your Dream Machine, Cloud Key, or NVR) 2. Go to **Devices** and select the camera 3. Open **Settings** tab 4. Scroll to **Advanced** section 5. Enable **RTSP** toggle 6. Note the RTSP URL displayed (includes unique token) ## RTSP URL Patterns ### UniFi Protect Cameras (Current) UniFi Protect cameras expose RTSP on **port 7447** with stream quality selection: | Stream | RTSP URL | Resolution | Notes | | --- | --- | --- | --- | | High quality | `rtsp://IP:7447/STREAM_TOKEN` | Full (up to 2688x1512) | Main stream | | Medium quality | `rtsp://IP:7447/STREAM_TOKEN` | Reduced | Medium stream | | Low quality | `rtsp://IP:7447/STREAM_TOKEN` | Low (640x360) | Bandwidth-optimized | Stream tokens UniFi Protect generates unique RTSP URLs per camera when you enable RTSP. The URL contains a unique token. You can find the exact URL in the UniFi Protect interface under each camera's Advanced settings. The RTSP URL format is typically: ``` rtsp://CAMERA_IP:7447/UNIQUE_TOKEN_STRING ``` Where the token is auto-generated and displayed in the UniFi Protect UI. ### UniFi Protect Camera Models | Model | Resolution | Streams | Form Factor | | --- | --- | --- | --- | | G3 Instant | 1920x1080 | High/Low | Indoor mini | | G3 Flex | 1920x1080 | High/Medium/Low | Indoor/outdoor flex | | G3 Bullet | 1920x1080 | High/Medium/Low | Outdoor bullet | | G3 Dome | 1920x1080 | High/Medium/Low | Outdoor dome | | G4 Instant | 2688x1512 | High/Medium/Low | Indoor mini | | G4 Bullet | 2688x1512 | High/Medium/Low | Outdoor bullet | | G4 Dome | 2688x1512 | High/Medium/Low | Outdoor dome | | G4 Pro | 3840x2160 | High/Medium/Low | Outdoor pro | | G4 PTZ | 3840x2160 | High/Medium/Low | PTZ | | G5 Bullet | 2688x1512 | High/Medium/Low | Outdoor bullet | | G5 Dome | 2688x1512 | High/Medium/Low | Outdoor dome | | G5 Turret Ultra | 3840x2160 | High/Medium/Low | Outdoor turret | | AI 360 | 3840x2160 | High/Medium/Low | Fisheye | | AI Bullet | 3840x2160 | High/Medium/Low | Outdoor bullet | | AI Pro | 3840x2160 | High/Medium/Low | Outdoor pro | ### Legacy AirCam/AirVision URLs Older Ubiquiti cameras (AirCam series, before UniFi Protect) used standard port 554: | Model | RTSP URL | Notes | | --- | --- | --- | | AirCam | `rtsp://IP:554/live/ch00_0` | Main stream | | AirCam Dome | `rtsp://IP:554/live/ch00_0` | Dome variant | | AirCam Mini | `rtsp://IP:554/live/ch00_0` | Mini variant | | AirCam (channel) | `rtsp://IP:554/ch0N_0` | N = channel number | ## Connecting with VisioForge SDK Use your UniFi Protect camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // UniFi Protect camera, token-based auth (no username/password needed) var uri = new Uri("rtsp://192.168.1.40:7447/YOUR_STREAM_TOKEN"); ``` UniFi Protect cameras use token-based authentication -- the unique stream token is provided in the UniFi Protect UI when you enable RTSP. No separate username or password is required. For different quality streams (high/medium/low), select the corresponding stream in the Protect interface to get its token. For legacy AirCam models, use port 554 with credentials `ubnt`/`ubnt` and path `/live/ch00_0`. ## Snapshot URLs ### Legacy AirCam | Type | URL Pattern | Notes | | --- | --- | --- | | Snapshot | `http://IP/snapshot.cgi` | Basic snapshot | | Snapshot (auth) | `http://IP/snapshot.cgi?user=USER&pwd=PASS` | With credentials | | Snapshot (alt) | `http://IP:554/snapshot.cgi?user=USER&pwd=PASS&count=0` | Via RTSP port | ### UniFi Protect UniFi Protect cameras do not expose HTTP snapshot endpoints directly. Snapshots are accessed through the UniFi Protect API or by capturing frames from the RTSP stream in your application. ## Troubleshooting ### "Connection refused" on port 554 UniFi Protect cameras use **port 7447** for RTSP, not the standard port 554. Port 554 only applies to legacy AirCam models. Make sure you're using the correct port: - **UniFi Protect cameras:** Port 7447 - **Legacy AirCam:** Port 554 ### RTSP not enabled RTSP is disabled by default on UniFi Protect cameras. You must enable it in the UniFi Protect interface: 1. UniFi Protect > Devices > Select Camera > Settings > Advanced > Enable RTSP ### Stream token changed The RTSP stream token can change if you: - Disable and re-enable RTSP on the camera - Reset the camera - Update firmware Always verify the current RTSP URL in the UniFi Protect interface if your connection stops working. ### High latency UniFi Protect cameras can exhibit 2-5 second latency by default. To reduce latency: - Set `LowLatencyMode = true` on the `RTSPSourceSettings` passed to VideoCaptureCoreX - Select the low-quality stream (lower resolution = less buffering) - Use TCP transport for more reliable delivery ### No ONVIF support UniFi Protect cameras do not support ONVIF. Use RTSP for third-party integration. If you need ONVIF discovery, it won't work with these cameras. ## FAQ **What is the default RTSP URL for UniFi Protect cameras?** The RTSP URL format is `rtsp://CAMERA_IP:7447/UNIQUE_TOKEN`. RTSP must be enabled per-camera in the UniFi Protect interface, which will display the unique URL. There is no universal default URL -- each camera gets a unique stream token. **Can I use UniFi cameras without UniFi Protect?** Current UniFi cameras require a UniFi Protect controller (Dream Machine, Cloud Key, or NVR) for initial setup and management. Once RTSP is enabled, you can stream to third-party software. Legacy AirCam models work standalone. **Do UniFi cameras support H.265?** As of current firmware, UniFi Protect cameras stream H.264 over RTSP. H.265 support may be available for internal recording but is not typically exposed via RTSP. **What are the default credentials for AirCam?** Legacy AirCam cameras use `ubnt` / `ubnt` as default credentials. Current UniFi Protect cameras use token-based RTSP authentication. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Reolink Connection Guide](../reolink/) — Prosumer alternative with RTSP - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Uniview (UNV) IP Camera in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/uniview/ **Description:** Uniview IPC-B, IPC-T, IPC-D, IPC-E, and NVR RTSP URL patterns for C# .NET. ONVIF-compatible integration with VisioForge SDK code samples. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to Uniview (UNV) IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Uniview** (Zhejiang Uniview Technologies Co., Ltd.), also known as **UNV**, is the world's third-largest video surveillance manufacturer by market share, behind Hikvision and Dahua. Founded in 2005 and headquartered in Hangzhou, China, Uniview pioneered IP video surveillance in China and offers a full range of IP cameras, NVRs, VMS software, and access control products for enterprise and government markets. **Key facts:** - **Product lines:** IPC-B (bullet), IPC-T (turret), IPC-D (dome), IPC-E (eyeball), IPC-P (PTZ), NVR30x/50x (NVRs) - **Protocol support:** RTSP, ONVIF Profile S/G/T, HTTP/CGI, SDK (EZStation) - **Default RTSP port:** 554 - **Default credentials:** admin / 123456 (must be changed on first login with newer firmware) - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264, H.265 (U-Code Smart Codec), MJPEG - **Market position:** #3 globally in video surveillance Uniview vs UNV Branding Uniview markets under both the **Uniview** and **UNV** brand names depending on the region. The RTSP URL patterns and firmware are identical regardless of branding. Some OEM partners rebrand Uniview hardware under their own labels. ## RTSP URL Patterns ### Standard URL Format Uniview cameras use a media profile-based URL structure: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/media/video[STREAM] ``` | Parameter | Value | Description | | --- | --- | --- | | `video1` | Main stream | Highest resolution (4K/5MP/4MP/2MP) | | `video2` | Sub stream | Lower resolution, reduced bandwidth | | `video3` | Third stream | Mobile-optimized (if supported) | ### Alternative URL Formats Uniview cameras support multiple RTSP URL patterns: | URL Pattern | Description | | --- | --- | | `rtsp://IP:554/media/video1` | Main stream (recommended) | | `rtsp://IP:554/media/video2` | Sub stream | | `rtsp://IP:554/media/video3` | Third stream | | `rtsp://IP:554/unicast/c1/s0/live` | Unicast main stream (alternative) | | `rtsp://IP:554/unicast/c1/s1/live` | Unicast sub stream (alternative) | | `rtsp://IP:554/live/ch00_0` | Legacy format (older firmware) | | `rtsp://IP:554/live/ch00_1` | Legacy sub stream | ### IP Camera Models | Model Series | Resolution | Main Stream URL | Audio | | --- | --- | --- | --- | | IPC-B112-PF28 (2MP bullet) | 1920x1080 | `rtsp://IP:554/media/video1` | No | | IPC-B314-APKZ (4MP bullet) | 2688x1520 | `rtsp://IP:554/media/video1` | Yes | | IPC-B315-APKZ (5MP bullet) | 2880x1620 | `rtsp://IP:554/media/video1` | Yes | | IPC-T112-PF28 (2MP turret) | 1920x1080 | `rtsp://IP:554/media/video1` | No | | IPC-T314-APKZ (4MP turret) | 2688x1520 | `rtsp://IP:554/media/video1` | Yes | | IPC-D312-APKZ (4MP dome) | 2688x1520 | `rtsp://IP:554/media/video1` | Yes | | IPC-D314-APKZ (4MP dome) | 2688x1520 | `rtsp://IP:554/media/video1` | Yes | | IPC-E312-APKZ (4MP eyeball) | 2688x1520 | `rtsp://IP:554/media/video1` | Yes | | IPC-P1E2-I (2MP PTZ) | 1920x1080 | `rtsp://IP:554/media/video1` | Yes | | IPC-B182-PF28 (4K bullet) | 3840x2160 | `rtsp://IP:554/media/video1` | Yes | ### NVR Channel URLs For Uniview NVRs (NVR301, NVR302, NVR304, NVR501, NVR516): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/media/video1` | `rtsp://IP:554/media/video2` | | Camera 2 | `rtsp://IP:554/media/video3` | `rtsp://IP:554/media/video4` | | Camera 3 | `rtsp://IP:554/media/video5` | `rtsp://IP:554/media/video6` | | Camera N | `rtsp://IP:554/media/video[2N-1]` | `rtsp://IP:554/media/video[2N]` | NVR Channel Numbering On Uniview NVRs, the video stream number encodes both the channel and stream type. Each channel uses two consecutive numbers: odd for main stream, even for sub stream. Camera 1 = video1/video2, Camera 2 = video3/video4, and so on. ## Connecting with VisioForge SDK Use your Uniview camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Uniview IPC-B314-APKZ, main stream var uri = new Uri("rtsp://192.168.1.90:554/media/video1"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/media/video2` instead of `/media/video1`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/snapshot.cgi` | Requires digest authentication | | ONVIF Snapshot | `http://IP/onvif-http/snapshot?channel=1` | ONVIF HTTP snapshot | ## Troubleshooting ### Default password must be changed Uniview cameras with current firmware require the default password (`123456`) to be changed during initial setup. If you haven't configured the camera yet: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Complete the activation wizard 3. Set a strong password 4. Use those credentials in your RTSP URL ### "unicast" vs "media" URL format If `/media/video1` does not work on your camera, try the unicast format: `rtsp://IP:554/unicast/c1/s0/live`. Older Uniview firmware versions may only support the unicast path. Newer firmware supports both formats. ### H.265 stream not playing Uniview's U-Code smart codec produces standard H.265/HEVC streams. If H.265 playback fails: 1. Install the HEVC decoder redistributable 2. Or switch the camera to H.264 encoding in the web interface: **Setup > Video > Video** 3. Use `rtspSettings.UseGPUDecoder = true` for hardware-accelerated H.265 decoding ### ONVIF discovery issues ONVIF is enabled by default on Uniview cameras but may require a separate ONVIF password. Check **Setup > Network > ONVIF** in the web interface and ensure the ONVIF user account is configured. ## FAQ **What is the default RTSP URL for Uniview cameras?** The standard URL is `rtsp://admin:password@CAMERA_IP:554/media/video1` for the main stream. Use `/media/video2` for the sub stream. Some older models use `rtsp://IP:554/unicast/c1/s0/live` instead. **Is Uniview the same as UNV?** Yes. Uniview and UNV are the same company (Zhejiang Uniview Technologies). The branding varies by region. All cameras use identical firmware, RTSP URL formats, and web interfaces regardless of whether they carry the Uniview or UNV label. **Do Uniview cameras support ONVIF?** Yes. All current Uniview cameras support ONVIF Profile S and Profile T. ONVIF allows automatic camera discovery and standardized stream access without using brand-specific RTSP URLs. **How do I access multiple channels on a Uniview NVR?** Uniview NVRs use sequential video stream numbers: Camera 1 = video1 (main) / video2 (sub), Camera 2 = video3 (main) / video4 (sub), and so on. The formula is: main stream = video[2N-1], sub stream = video[2N] where N is the camera channel number. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Hikvision Connection Guide](../hikvision/) — Global market leader, different URL format - [Dahua Connection Guide](../dahua/) — Another major Chinese surveillance brand - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Verkada Camera RTSP and C# .NET Integration Options **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/verkada/ **Description:** Verkada camera integration options in C# .NET. Understand cloud-managed architecture, RTSP limitations, and alternative approaches for Verkada cameras. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Webcam, IP Camera, RTSP, ONVIF, C# **API:** MediaBlocksPipeline, SystemVideoSourceBlock, VideoRendererBlock # How to Connect to Verkada Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Verkada** is an American cloud-managed security camera company headquartered in San Mateo, California. Founded in 2016, Verkada offers enterprise-grade cameras with a fully cloud-managed architecture. Unlike traditional IP cameras, Verkada cameras are managed exclusively through Verkada's cloud platform — there are no local RTSP streams, ONVIF support, or direct network access to the cameras. **Key facts:** - **Product lines:** CD (mini dome), CB (bullet), CE (outdoor dome), CF (fisheye), CM (multi-sensor), CP (PTZ) - **Architecture:** Cloud-managed — all video processing and access goes through Verkada Command platform - **RTSP support:** No - **ONVIF support:** No - **Local network access:** No direct access — cameras communicate only with Verkada cloud - **Video codecs:** H.264, H.265 (managed by cloud platform) - **API access:** Verkada API (cloud-based, requires enterprise subscription) No RTSP or Local Streaming Verkada cameras do **not** support RTSP, ONVIF, or any standard local streaming protocol. They are cloud-managed devices that can only be accessed through Verkada's Command platform or API. Direct integration using VisioForge SDK's RTSP source is not possible with Verkada cameras. ## Why Verkada Has No RTSP Verkada's architecture is fundamentally different from traditional IP cameras: 1. **Cloud-first design:** Video is processed on-camera and streamed to Verkada's cloud 2. **No local network ports:** Cameras do not expose port 554 or any RTSP endpoint 3. **Managed access:** All video access goes through Verkada Command (web/mobile) 4. **Zero-trust security:** No direct camera-to-client connections on the LAN This architecture provides simplified deployment and centralized management but eliminates direct SDK integration. ## Integration Options ### Option 1: Verkada API (Cloud-Based) Verkada offers a REST API for enterprise customers that provides: - Camera listing and status - Video export/download (clips) - Thumbnail/snapshot retrieval - Event and alert data The API does **not** provide live RTSP or real-time video streams. It is designed for clip retrieval and metadata access. ### Option 2: HDMI Output (Select Models) Some Verkada models include an HDMI output port for local display. You can capture this output using an HDMI capture card: ``` // Capture HDMI output from Verkada camera via USB capture card var pipeline = new MediaBlocksPipeline(); // Use system video source (HDMI capture card appears as webcam) var captureDevice = new SystemVideoSourceBlock(captureDeviceSettings); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(captureDevice.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` This approach provides real-time local video but requires physical HDMI connectivity and a capture card. ### Option 3: Alternative Cameras with RTSP If you need direct RTSP integration with enterprise-grade cameras, consider these alternatives: | Alternative | Market Segment | RTSP | ONVIF | Guide | | --- | --- | --- | --- | --- | | Axis | Enterprise | Yes | Yes | [Connection Guide](../axis/) | | Bosch | Enterprise | Yes | Yes | [Connection Guide](../bosch/) | | Hanwha Vision | Enterprise | Yes | Yes | [Connection Guide](../hanwha/) | | Avigilon | Enterprise | Yes | Yes | [Connection Guide](../avigilon/) | | Hikvision | Enterprise | Yes | Yes | [Connection Guide](../hikvision/) | ## FAQ **Can I connect to Verkada cameras with RTSP?** No. Verkada cameras do not support RTSP, ONVIF, or any local streaming protocol. They are cloud-managed devices accessible only through Verkada's Command platform or API. **Does Verkada have an API for video access?** Yes, but the Verkada API provides clip export and snapshot retrieval, not live video streaming. Real-time video is only available through the Verkada Command web interface or mobile app. Enterprise API access requires a Verkada subscription. **Can I use VisioForge SDK with Verkada cameras?** Not directly via RTSP. The only local integration option is capturing the HDMI output of select Verkada models using a capture card with VisioForge SDK's system video source. For cloud-based integration, you would need to use Verkada's API separately. **What enterprise cameras support RTSP?** For enterprise cameras with full RTSP and ONVIF support, see our guides for [Axis](../axis/), [Bosch](../bosch/), [Hanwha Vision](../hanwha/), [Avigilon](../avigilon/), and [Hikvision](../hikvision/). ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Axis Connection Guide](../axis/) — Enterprise alternative with RTSP - [Bosch Connection Guide](../bosch/) — Enterprise alternative with RTSP - [Rhombus Connection Guide](../rhombus/) — Another cloud-managed platform - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Vivotek IP Camera RTSP URL and C# .NET Connection Guide **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/vivotek/ **Description:** Vivotek FD, IP, SD, and FE fisheye camera RTSP URL patterns for C# .NET. Stream and record using VisioForge Video Capture SDK with ONVIF support. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, IP Camera, RTSP, ONVIF, H.265, MJPEG, C# # How to Connect to Vivotek IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Vivotek Inc.** is a Taiwanese manufacturer of network surveillance solutions headquartered in New Taipei City. Founded in 2000, Vivotek is one of the world's leading IP camera brands, widely deployed in enterprise, retail, transportation, and city surveillance. Vivotek is known for its wide range of form factors including fisheye, panoramic, speed dome, and specialty cameras. **Key facts:** - **Product lines:** FD (fixed dome), IP (box/bullet), IB (bullet), SD (speed dome), FE (fisheye), MD (mobile dome), CC (compact), VS (video servers/encoders) - **Protocol support:** RTSP, ONVIF (Profile S/G/T), HTTP/CGI, MJPEG - **Default RTSP port:** 554 - **Default credentials:** root / (empty or set during setup); legacy models: root / root - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264, H.265, MJPEG ## RTSP URL Patterns ### Current Models All current Vivotek cameras use the `live.sdp` URL pattern for RTSP streaming: | Stream | RTSP URL | Notes | | --- | --- | --- | | Stream 1 (main) | `rtsp://IP:554/live.sdp` | Main stream, H.264/H.265 | | Stream 2 (sub) | `rtsp://IP:554/live2.sdp` | Sub stream | | Stream 3 | `rtsp://IP:554/live3.sdp` | Third stream (if supported) | | Stream 4 | `rtsp://IP:554/live4.sdp` | Fourth stream (some models) | ### Model-Specific URLs | Model Series | RTSP URL | Form Factor | | --- | --- | --- | | FD81xx (fixed dome) | `rtsp://IP:554/live.sdp` | Fixed dome | | FD83xx (fixed dome) | `rtsp://IP:554/live.sdp` | Fixed dome | | FD8134/FD8136 | `rtsp://IP:554/live.sdp` | Mini dome | | FD8161/FD8162/FD8166 | `rtsp://IP:554/live.sdp` | Fixed dome | | FD8335H | `rtsp://IP:554/live.sdp` | Fixed dome | | FD8361/FD8362E/FD8372 | `rtsp://IP:554/live.sdp` | Fixed dome | | FE8171V/FE8172V/FE8174 | `rtsp://IP:554/live.sdp` | Fisheye | | IP7130/IP7131/IP7132 | `rtsp://IP:554/live.sdp` | Box camera | | IP7160/IP7161 | `rtsp://IP:554/live.sdp` | Box camera | | IP7330/IP7361 | `rtsp://IP:554/live.sdp` | Bullet | | IP8130/IP8133/IP8152 | `rtsp://IP:554/live.sdp` | Box camera | | IP8331/IP8332/IP8335H | `rtsp://IP:554/live.sdp` | Box camera | | IP8362/IP8364 | `rtsp://IP:554/live.sdp` | Box camera | | SD8362E | `rtsp://IP:554/live.sdp` | Speed dome | | CC8130 | `rtsp://IP:554/live.sdp` | Compact | | MD7560/MD8562 | `rtsp://IP:554/live.sdp` | Mobile dome | ### Legacy Models Older Vivotek models (IP3xxx, IP6xxx, PT3xxx, PZ6xxx series) used HTTP-only streaming: | Model Series | URL | Notes | | --- | --- | --- | | IP3121/IP3122/IP3133/IP3135 | `http://IP/cgi-bin/video.jpg?size=2` | JPEG only | | IP6127 | `http://IP/cgi-bin/video.jpg?size=2` | JPEG only | | PT3112/PT3122 | `http://IP/cgi-bin/video.jpg?size=2` | Pan/tilt, JPEG | | PZ6114/PZ6122 | `http://IP/cgi-bin/video.jpg?size=2` | Pan/zoom, JPEG | ### Video Server URLs Vivotek video servers encode analog camera feeds for IP streaming: | Model | RTSP URL | Notes | | --- | --- | --- | | VS2403 | `rtsp://IP:554/live.sdp` | Video server, multi-channel | | VS3100P | `http://IP/cgi-bin/video.jpg?size=2` | Legacy encoder | | VS7100 | `rtsp://IP:554/live.sdp` | Video server | | VS8102 | `rtsp://IP:554/live.sdp` | Video server | | VS8401 | `rtsp://IP:554/live.sdp` | 4-channel server | | VS8801 | `rtsp://IP:554/live.sdp` | 8-channel server | ### NVR URLs | Model | RTSP URL | Notes | | --- | --- | --- | | NR8x01 NVR | `rtsp://IP:554/live.sdp` | Via NVR | ## Connecting with VisioForge SDK Use your Vivotek camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Vivotek camera, main stream var uri = new Uri("rtsp://192.168.1.50:554/live.sdp"); var username = "root"; var password = "YourPassword"; ``` For sub-stream access, use `/live2.sdp` instead. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/viewer/video.jpg?resolution=640x480` | Current models | | JPEG Snapshot (channel) | `http://IP/cgi-bin/viewer/video.jpg?channel=1&resolution=640x480` | Multi-channel | | MJPEG Stream | `http://IP/video.mjpg` | Continuous MJPEG | | MJPEG Stream (alt) | `http://IP/video2.mjpg` | Second stream | | MJPEG (params) | `http://IP/video.mjpg?q=30&fps=33&id=0.5` | With quality/fps params | | Legacy Snapshot | `http://IP/cgi-bin/video.jpg` | Older models | | Legacy Snapshot (sized) | `http://IP/cgi-bin/video.jpg?size=2` | Older models, VGA | | Snapshot CGI | `http://IP/snapshot.cgi` | Some models | ## Troubleshooting ### Consistent URL pattern Unlike many brands, Vivotek uses the same `live.sdp` RTSP URL pattern across virtually all their RTSP-capable models. If `rtsp://IP:554/live.sdp` doesn't work, try: - `rtsp://IP:554/live2.sdp` (sub stream) - `rtsp://IP:554/live3.sdp` (third stream) ### Default credentials - **Current models:** `root` with password set during initial setup - **Legacy models:** `root` / (empty password) or `root` / `root` - Some models require setup via the web interface before RTSP is accessible ### Non-standard ports on some models Some Vivotek cameras may use non-standard RTSP ports (e.g., 1025, 1032) if configured. Check the camera's web interface under Network > RTSP settings if port 554 doesn't respond. ### Legacy HTTP-only cameras Very old Vivotek cameras (IP31xx, IP61xx, PT31xx, PZ61xx series) only support HTTP JPEG and MJPEG streams, not RTSP. These cameras cannot use the RTSP source -- use HTTP snapshot or MJPEG integration instead. ## FAQ **What is the default RTSP URL for Vivotek cameras?** The standard URL is `rtsp://root:password@CAMERA_IP:554/live.sdp` for the main stream. Use `live2.sdp` for the sub stream and `live3.sdp` for the third stream. This pattern works across virtually all RTSP-capable Vivotek models. **Do Vivotek cameras support H.265?** Yes. Current Vivotek cameras support H.265 (HEVC). Use the same `live.sdp` URL -- the codec is configured in the camera's web interface, not in the URL. **What is the difference between live.sdp and live2.sdp?** `live.sdp` is the main (highest quality) stream, `live2.sdp` is typically a lower-resolution sub stream for bandwidth-constrained viewing, and `live3.sdp` is a third stream often used for mobile viewing. **Do Vivotek video servers support RTSP?** Yes. Current Vivotek video servers (VS2403, VS7100, VS8102, VS8401, VS8801) support RTSP using the same `live.sdp` URL pattern as cameras. Legacy servers (VS3100P) only support HTTP JPEG. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [GeoVision Connection Guide](../geovision/) — Taiwanese enterprise cameras - [ACTi Connection Guide](../acti/) — Taiwanese professional cameras - [IP Camera Capture to MP4](../../videocapture/video-tutorials/ip-camera-capture-mp4/) — Record Vivotek streams to file - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Wisenet RTSP URL — Connect IP Camera with C# .NET SDK **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/wisenet/ **Description:** Wisenet X, P, Q, L series RTSP URL patterns for C# .NET apps. Hanwha Vision camera and NVR integration with ONVIF support and VisioForge SDK code. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Decoding, IP Camera, RTSP, ONVIF, MJPEG, C# # How to Connect to Wisenet IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Wisenet** is the product brand name used by **Hanwha Vision** (formerly Hanwha Techwin / Samsung Techwin) for all IP cameras, NVRs, and video management systems. Wisenet is not a separate company but rather the product family name used across Hanwha Vision's full surveillance lineup. **Key facts:** - **Manufacturer:** Hanwha Vision (South Korea) - **Product tiers:** X (premium), P (AI), Q (mainstream), Q mini (compact), L (value), T (thermal) - **Protocol support:** RTSP, ONVIF Profile S/G/T, SUNAPI (proprietary) - **Default RTSP port:** 554 - **Default credentials:** admin / (set during activation) - **ONVIF support:** Yes (all current models) - **Video codecs:** H.264, H.265, WiseStream III, MJPEG Wisenet = Hanwha Vision Products Wisenet is the **product brand**, Hanwha Vision is the **company**. All Wisenet cameras use the same RTSP URL patterns. For detailed connection instructions including NVR channel access and troubleshooting, see our [Hanwha Vision connection guide](../hanwha/). For legacy Samsung-branded cameras, see the [Samsung/Hanwha guide](../samsung/). ## RTSP URL Patterns ### Standard URL Format All Wisenet cameras share the same profile-based URL structure: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/profile[N]/media.smp ``` ### By Product Tier | Wisenet Tier | Example Models | Main Stream URL | Key Feature | | --- | --- | --- | --- | | **X series** (premium) | XNO-6080R, XND-8080RV, XNP-6120H | `rtsp://IP:554/profile2/media.smp` | Best WDR, low-light | | **P series** (AI) | PNO-A9081R, PND-A9081RV | `rtsp://IP:554/profile2/media.smp` | Deep learning analytics | | **Q series** (mainstream) | QNO-8080R, QND-8080R, QNE-8021R | `rtsp://IP:554/profile2/media.smp` | Balanced features/price | | **Q mini** (compact) | QND-8021 | `rtsp://IP:554/profile2/media.smp` | Discreet form factor | | **L series** (value) | LNO-6032R, LND-6032R | `rtsp://IP:554/profile2/media.smp` | Entry-level | | **T series** (thermal) | TNO-4030T, TNO-4050T | `rtsp://IP:554/profile2/media.smp` | Thermal + visible | ### Multi-Sensor and Multi-Directional Models | Model Type | Stream URL | Notes | | --- | --- | --- | | Single sensor | `rtsp://IP:554/profile2/media.smp` | Standard | | Multi-sensor channel 1 | `rtsp://IP:554/profile2/media.smp/trackID=channel1` | First sensor | | Multi-sensor channel 2 | `rtsp://IP:554/profile2/media.smp/trackID=channel2` | Second sensor | | Stitched panoramic | `rtsp://IP:554/profile2/media.smp/trackID=channel5` | Combined view | ### NVR / WAVE VMS Access For Wisenet NVRs (XRN, QRN, LRN series): | Channel | Main Stream | Sub Stream | | --- | --- | --- | | Camera 1 | `rtsp://IP:554/profile2/media.smp/trackID=channel1` | `rtsp://IP:554/profile3/media.smp/trackID=channel1` | | Camera 2 | `rtsp://IP:554/profile2/media.smp/trackID=channel2` | `rtsp://IP:554/profile3/media.smp/trackID=channel2` | | Camera N | `rtsp://IP:554/profile2/media.smp/trackID=channelN` | `rtsp://IP:554/profile3/media.smp/trackID=channelN` | ## Connecting with VisioForge SDK Use your Wisenet camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Wisenet QNO-8080R (Q series 5MP), main stream var uri = new Uri("rtsp://192.168.1.90:554/profile2/media.smp"); var username = "admin"; var password = "YourPassword"; ``` For sub-stream access, use `/profile3/media.smp` instead of `/profile2/media.smp`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | JPEG Snapshot | `http://IP/cgi-bin/video.cgi?msubmenu=jpg&action=view&Resolution=1920x1080&Quality=5&Channel=0` | Requires digest auth | | MJPEG Stream | `http://IP/cgi-bin/video.cgi?msubmenu=mjpeg&action=view&Channel=0&Stream=0` | Continuous MJPEG | ## Troubleshooting ### Which profile number is the main stream? Wisenet cameras typically use `profile2` as the main (highest quality) stream. This is different from most other brands. If you get unexpected results, check the profile configuration in the camera's web interface (**Setup > Video/Audio > Video Profile**). ### WiseStream III bandwidth savings WiseStream III dynamically adjusts encoding per region in the frame. The output is standard H.265 or H.264 -- no special decoder is needed. WiseStream settings can be configured in the camera's web interface. ### Camera activation New Wisenet cameras require activation (setting a password) before use. Use the Wisenet Installation Wizard utility, web browser, or Wisenet mobile app for initial setup. ## FAQ **What is the default RTSP URL for Wisenet cameras?** All Wisenet cameras use `rtsp://admin:password@CAMERA_IP:554/profile2/media.smp` for the main stream. Use `profile3` for the sub stream. **What is the difference between Wisenet X, P, Q, and L?** **X** = premium enterprise. **P** = AI-powered analytics. **Q** = mainstream business. **L** = value/entry-level. **T** = thermal. All tiers use the same RTSP URL format. **Is Wisenet the same as Samsung security cameras?** Wisenet is the current product brand from Hanwha Vision, which acquired Samsung's security division in 2015. Legacy Samsung Techwin cameras may use different URL formats. See our [Samsung/Hanwha guide](../samsung/) for older models. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Hanwha Vision Connection Guide](../hanwha/) — Detailed Hanwha Vision integration - [Samsung/Hanwha Legacy Guide](../samsung/) — Older Samsung Techwin models - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## How to Connect to Wyze Camera in C# .NET - RTSP Workarounds **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/wyze/ **Description:** Connect to Wyze cameras in C# .NET using RTSP firmware or Docker RTSP bridge. RTSP limitations, workarounds, and alternative approaches explained. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, C# # How to Connect to Wyze Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Wyze Labs** is an American consumer electronics company based in Kirkland, Washington. Known for extremely affordable smart home cameras, Wyze became one of the best-selling camera brands in North America. However, Wyze cameras are **cloud-first devices** with very limited RTSP support, making direct integration challenging. **Key facts:** - **Product lines:** Cam v3/v4 (indoor/outdoor), Cam Pan v3 (PTZ), Cam OG (compact), Doorbell, Floodlight - **Protocol support:** Wyze Cloud (primary), RTSP (limited — requires special firmware on select models) - **Default RTSP port:** 8554 (when using RTSP firmware) - **ONVIF support:** No - **Video codecs:** H.264 - **Cloud dependency:** High — most features require Wyze app and cloud Very Limited RTSP Support Wyze cameras do **not** natively support RTSP. Official RTSP firmware was released only for the **Wyze Cam v2** and original **Wyze Cam Pan**, and these firmware builds are no longer actively maintained. For newer models (v3, v4, OG, Pan v3), RTSP requires third-party solutions like custom firmware. ## RTSP Support by Model | Model | Native RTSP | RTSP Firmware | Third-Party RTSP | Notes | | --- | --- | --- | --- | --- | | Wyze Cam v2 | No | Yes (beta) | Yes | Official RTSP firmware available | | Wyze Cam Pan v1 | No | Yes (beta) | Yes | Official RTSP firmware available | | Wyze Cam v3 | No | No | Yes (docker-wyze-bridge) | Community workaround | | Wyze Cam v4 | No | No | Yes (docker-wyze-bridge) | Community workaround | | Wyze Cam Pan v3 | No | No | Yes (docker-wyze-bridge) | Community workaround | | Wyze Cam OG | No | No | Yes (docker-wyze-bridge) | Community workaround | | Wyze Doorbell v2 | No | No | Limited | May work with bridge | | Wyze Cam Floodlight v2 | No | No | Yes (docker-wyze-bridge) | Community workaround | ## Option 1: Official RTSP Firmware (Cam v2 / Pan v1 Only) Wyze released beta RTSP firmware for the Cam v2 and original Cam Pan. When flashed: ### RTSP URL Format ``` rtsp://[IP]:8554/live ``` Non-Standard Port Wyze RTSP firmware uses port **8554**, not the standard 554. ### Setup Steps 1. Download the RTSP firmware from Wyze support (search "Wyze RTSP firmware") 2. Flash the firmware to the camera via microSD card 3. In the Wyze app, go to camera settings and enable RTSP 4. Note the RTSP URL shown in the app (usually `rtsp://CAMERA_IP:8554/live`) ### Connecting with VisioForge SDK ``` // Wyze Cam v2 with RTSP firmware var uri = new Uri("rtsp://192.168.1.90:8554/live"); var username = ""; // no authentication on Wyze RTSP firmware var password = ""; ``` Use your Wyze camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code). ## Option 2: Docker Wyze Bridge (All Models) For Wyze Cam v3, v4, Pan v3, OG, and other newer models, the community-developed **docker-wyze-bridge** project creates an RTSP proxy that converts Wyze cloud streams to local RTSP: ### How It Works 1. Docker Wyze Bridge authenticates with your Wyze account 2. It connects to the camera through the Wyze cloud API 3. It re-streams the video as a local RTSP stream 4. Your application connects to the bridge, not directly to the camera ### RTSP URL Format (via Bridge) ``` rtsp://[BRIDGE_IP]:8554/[CAMERA_NAME] ``` Where `CAMERA_NAME` is the name you assigned in the Wyze app (spaces replaced with dashes, lowercased). ### Connecting via Bridge with VisioForge SDK ``` // Wyze Cam v3 via docker-wyze-bridge var uri = new Uri("rtsp://192.168.1.50:8554/front-door"); var username = ""; // bridge handles auth var password = ""; ``` Bridge Limitations Docker Wyze Bridge introduces additional latency (typically 3-10 seconds) since the video passes through the Wyze cloud before reaching your local RTSP stream. It also requires your Wyze account credentials and an active internet connection. ## Troubleshooting ### No RTSP option in Wyze app The RTSP toggle only appears on Wyze Cam v2 and Pan v1 when flashed with the RTSP firmware. It is not available on newer models. For v3/v4/OG/Pan v3, use the Docker Wyze Bridge approach. ### RTSP firmware not connecting After flashing RTSP firmware on the Cam v2: 1. Wait 2-3 minutes for the camera to fully boot 2. Verify the camera is on the same network as your application 3. Try `rtsp://CAMERA_IP:8554/live` in VLC first to confirm the stream works 4. The stream has no authentication -- leave username/password empty ### High latency with Docker Wyze Bridge The bridge routes video through Wyze's cloud servers, adding latency. For low-latency requirements, Wyze cameras may not be suitable. Consider cameras with native RTSP support like [Reolink](../reolink/), [Amcrest](../amcrest/), or [TP-Link Tapo](../tp-link/). ### Stream quality Wyze cameras typically output 1080p H.264 streams. The RTSP firmware does not support changing resolution or codec. What the camera captures is what the RTSP stream provides. ## FAQ **Do Wyze cameras support RTSP natively?** No. Wyze cameras are cloud-first devices. The Wyze Cam v2 and original Cam Pan have official beta RTSP firmware, but it is no longer actively maintained. Newer models (v3, v4, OG, Pan v3) do not have RTSP firmware and require third-party bridges. **Can I use Wyze cameras without the cloud?** Very limited. Even with RTSP firmware, the initial setup requires the Wyze app and cloud account. The RTSP firmware for Cam v2/Pan v1 disables some cloud features. For newer models, the Docker Wyze Bridge still routes through the cloud. **What cameras should I use instead of Wyze for RTSP?** For affordable cameras with native RTSP support, consider [Reolink](../reolink/) (consumer), [Amcrest](../amcrest/) (consumer/SMB), [TP-Link Tapo](../tp-link/) (consumer), or [EZVIZ](../ezviz/) (smart home). All of these provide direct RTSP access without workarounds. **Do Wyze cameras support ONVIF?** No. Wyze cameras do not support ONVIF in any firmware version. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Reolink Connection Guide](../reolink/) — Affordable alternative with native RTSP - [Amcrest Connection Guide](../amcrest/) — Consumer cameras with full RTSP - [TP-Link Connection Guide](../tp-link/) — Budget cameras with RTSP support - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Zavio IP Camera RTSP URL Guide for C# .NET Integration **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/zavio/ **Description:** Zavio bullet, dome, and PTZ camera RTSP URL patterns for C# .NET. ONVIF-compatible integration with VisioForge SDK code for all Zavio models. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, MP4, H.264, MJPEG, C# # How to Connect to Zavio IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Zavio** (Zavio Inc.) is a Taiwanese IP camera manufacturer headquartered in Hsinchu, Taiwan. Zavio is known for professional-grade network cameras with distinctive URL patterns that include both direct stream paths and profile-based paths. The company targets SMB and professional security markets with a range of bullet, dome, fixed, mini, and PTZ camera models. **Key facts:** - **Product lines:** B (bullet), D (dome), F (fixed/box), M (mini), P (PTZ/pan-tilt), V (vandal-proof) - **Protocol support:** RTSP, ONVIF, HTTP/CGI, MJPEG - **Default RTSP port:** 554 - **Default credentials:** admin / admin - **ONVIF support:** Yes (most models) - **Video codecs:** H.264, MPEG-4, MJPEG - **Dual URL patterns:** Some models use `/video.mp4`, others use `/video.proN` (profile-based) Profile-Based URLs Zavio cameras support profile-based URLs. Use `/video.pro1` for the primary profile and `/video.pro2` for the secondary profile. The available profiles depend on your camera's configuration. ## RTSP URL Patterns ### Standard URL Format Zavio cameras support two primary RTSP URL patterns: ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554/video.mp4 ``` ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:554//video.pro1 ``` | URL Path | Description | | --- | --- | | `/video.mp4` | MP4 main stream (most common format) | | `//video.pro1` | Profile 1 / primary stream (double-slash prefix) | | `//video.pro2` | Profile 2 / sub stream (double-slash prefix) | | `//video.h264` | Direct H.264 stream (some models) | ### Camera Models | Model | Type | Main Stream URL | Notes | | --- | --- | --- | --- | | B5110 (bullet) | Bullet | `rtsp://IP//video.pro1` | Profile-based, also supports `//video.h264` | | B5210 (bullet) | Bullet | `rtsp://IP//video.pro1` | Profile-based | | B7110 (bullet) | Bullet | `rtsp://IP:554/video.mp4` | MP4 main stream | | B7210 (bullet) | Bullet | `rtsp://IP:554/video.mp4` | MP4 main stream | | D3100 (dome) | Dome | `rtsp://IP//video.pro1` | Profile-based | | D3200 (dome) | Dome | `rtsp://IP:554/video.mp4` | MP4 main stream | | D4210 (dome) | Dome | `rtsp://IP:554/video.mp4` | MP4 main stream | | D50E (dome) | Dome | `rtsp://IP:554/video.mp4` | MP4 main stream | | D510E (dome) | Dome | `rtsp://IP:554/video.mp4` | MP4 main stream | | D520E (dome) | Dome | `rtsp://IP:554/video.mp4` | MP4 main stream | | D7111 (dome) | Dome | `rtsp://IP:554//video.pro2` | Profile 2 sub stream | | D7210 (dome) | Dome | `rtsp://IP:554//video.pro2` | Profile 2 sub stream | | F1100 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F1105 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F1150 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F210A (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3100 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3102 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3110 (fixed) | Fixed | `rtsp://IP:554//video.pro2` | Profile 2 sub stream | | F3115 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F312A (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3201 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3206 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3210 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F3215 (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F511E (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F520IE (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F521E (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | F731E (fixed) | Fixed | `rtsp://IP:554/video.mp4` | MP4 main stream | | M510W (mini) | Mini | `rtsp://IP:554/video.mp4` | Wireless mini camera | | M511E (mini) | Mini | `rtsp://IP:554/video.mp4` | Mini camera | | P5110 (PTZ) | PTZ | `rtsp://IP:554/video.mp4` | Pan-tilt-zoom | | P5115 (PTZ) | PTZ | `rtsp://IP:554/video.mp4` | Pan-tilt-zoom | | P5210 (PTZ) | PTZ | `rtsp://IP:554/video.mp4` | Pan-tilt-zoom | ### Alternative URL Formats Some Zavio models support these alternative URLs: | URL Pattern | Notes | | --- | --- | | `rtsp://IP:554/video.mp4` | MP4 stream (recommended for most models) | | `rtsp://IP//video.pro1` | Profile 1, primary stream | | `rtsp://IP:554//video.pro2` | Profile 2, sub stream | | `rtsp://IP//video.h264` | Direct H.264 stream (B5110 and similar) | ## Connecting with VisioForge SDK Use your Zavio camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Zavio B7110, MP4 main stream var uri = new Uri("rtsp://192.168.1.90:554/video.mp4"); var username = "admin"; var password = "admin"; ``` For profile-based cameras, use `//video.pro1` for the primary stream or `//video.pro2` for the sub stream. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | Profile Snapshot | `http://IP/cgi-bin/view/image?pro_CHANNEL` | Snapshot by profile number | | JPEG Snapshot | `http://IP/jpg/image.jpg` | Standard JPEG snapshot | | Sized JPEG | `http://IP/jpg/image.jpg?size=3` | JPEG with size parameter | | CGI JPEG | `http://IP/cgi-bin/jpg/image` | CGI-based JPEG snapshot | | MJPEG Stream | `http://IP/video.mjpg` | Continuous MJPEG stream | | MJPEG (quality/FPS) | `http://IP/video.mjpg?q=30&fps=33&id=0.5` | MJPEG with quality and FPS control | | Profile HTTP Stream | `http://IP/stream?uri=video.proN` | Profile-based HTTP stream | ## Troubleshooting ### "401 Unauthorized" error Zavio cameras ship with default credentials of `admin` / `admin`. If the camera has been configured with different credentials: 1. Access the camera at `http://CAMERA_IP` in a browser 2. Log in and check **Network > RTSP** settings 3. Verify that RTSP authentication is enabled and your credentials are correct ### Choosing between /video.mp4 and /video.proN Zavio cameras have two URL families. The correct choice depends on your model: - **Most models** (B7110, F210A, F312A, F520IE, F521E, F731E, etc.): Use `/video.mp4` - **Older or profile-based models** (B5110, B5210, D3100): Use `//video.pro1` - If one format fails, try the other ### Double-slash in profile URLs Profile-based Zavio URLs require a double-slash (`//`) before `video.proN`. This is intentional: - Correct: `rtsp://IP//video.pro1` - Incorrect: `rtsp://IP/video.pro1` If you omit the double-slash on a profile-based model, the connection may fail. ### No video with MPEG-4 codec Some older Zavio models default to MPEG-4 encoding. If you experience codec issues: - Log in to the camera web interface - Change the video codec to **H.264** under the stream configuration - Use the `/video.mp4` or `//video.pro1` URL after changing the setting ### Port 554 connection refused Verify that RTSP is enabled on the camera: - Web interface: Check **Network > RTSP** settings - Confirm port 554 is not blocked by a firewall - Default RTSP port is 554 ## FAQ **What is the default RTSP URL for Zavio cameras?** The most common URL is `rtsp://admin:admin@CAMERA_IP:554/video.mp4` for the MP4 main stream. For profile-based models, use `rtsp://admin:admin@CAMERA_IP//video.pro1` instead. **Do Zavio cameras support ONVIF?** Yes. Most Zavio models support ONVIF, which provides a standardized method for camera discovery and streaming without needing brand-specific URL patterns. **What is the difference between /video.mp4 and /video.pro1?** `/video.mp4` is a direct stream path used by most newer Zavio models. `//video.pro1` and `//video.pro2` are profile-based paths that reference stream profiles configured in the camera's web interface. Profile 1 is typically the main (high-resolution) stream, and Profile 2 is typically the sub (lower-resolution) stream. **What are the default login credentials for Zavio cameras?** The default username is `admin` and the default password is `admin`. It is strongly recommended to change these credentials after initial setup. **Can I control MJPEG quality and frame rate?** Yes. Zavio cameras support MJPEG parameters in the URL. Use `http://IP/video.mjpg?q=30&fps=33&id=0.5` to specify quality (`q`), frames per second (`fps`), and stream identifier (`id`). ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Edimax Connection Guide](../edimax/) — Taiwanese SMB cameras - [ONVIF Capture with Postprocessing](../../mediablocks/Guides/onvif-capture-with-postprocessing/) — Zavio ONVIF capture pipeline - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## Zmodo RTSP URL Guide — Connect IP Cameras in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/camera-brands/zmodo/ **Description:** Zmodo ZH Wi-Fi, ZP PoE, and DVR/NVR RTSP URL patterns for C# .NET. Stream and record Zmodo cameras with VisioForge Video Capture SDK integration. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Streaming, IP Camera, RTSP, ONVIF, H.264, MJPEG, C# # How to Connect to Zmodo IP Camera in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Brand Overview **Zmodo Technology** is a consumer security camera brand headquartered in Shenzhen, China. Zmodo is known for affordable Wi-Fi and wired IP cameras, DVR/NVR systems, and smart home security products. The brand targets the budget consumer market and is widely available through online retailers. **Key facts:** - **Product lines:** ZH-IXx (Wi-Fi cameras), ZP-IBH/IBI (PoE cameras), CM-I (legacy IP cameras), ZMD-ISV (DVR systems), Greet (smart doorbell) - **Protocol support:** RTSP, HTTP/MJPEG (legacy), Zmodo Zink (proprietary), ONVIF (limited, some ZP models) - **Default RTSP port:** 10554 (Wi-Fi cameras), 554 (standard/DVR models) - **Default credentials:** admin / admin or admin / (empty password) - **ONVIF support:** Limited (some newer ZP-series PoE models only) - **Video codecs:** H.264, MPEG-4 (legacy DVR) Zmodo Zink cameras Zmodo cameras that use the proprietary **Zink** protocol do **not** support RTSP at all. These cameras can only be accessed through the Zmodo app. Check your camera's specifications before attempting RTSP connections. ## RTSP URL Patterns Zmodo cameras use different RTSP ports and URL formats depending on the product line. ### Wi-Fi Cameras (ZH-Series) -- Port 10554 ``` rtsp://[USERNAME]:[PASSWORD]@[IP]:10554//tcp/av0_0 ``` Non-standard port 10554 Zmodo Wi-Fi cameras (ZH-series) use **port 10554**, not the standard 554. This is the most common connection issue with Zmodo cameras. | Stream | RTSP URL | Notes | | --- | --- | --- | | Main stream | `rtsp://IP:10554//tcp/av0_0` | Full resolution | | Sub stream | `rtsp://IP:10554//tcp/av0_1` | Lower resolution | ### Model-Specific URLs (Wi-Fi / PoE) | Model | RTSP URL | Type | | --- | --- | --- | | ZH-IXA15-WC | `rtsp://IP:10554//tcp/av0_0` | Wi-Fi indoor | | ZH-IXB15-WC | `rtsp://IP:10554//tcp/av0_0` | Wi-Fi indoor | | ZH-IXC15-WC | `rtsp://IP:10554//tcp/av0_0` | Wi-Fi indoor | | ZH-IXD15-WC | `rtsp://IP:10554//tcp/av0_0` | Wi-Fi indoor | | ZH-IBH13-W | `rtsp://IP:10554//tcp/av0_0` | Wi-Fi bullet | | ZP-IBH13-P | `rtsp://IP:10554//tcp/av0_0` | PoE bullet | | ZP-IBI13-W | `rtsp://IP:10554//tcp/av0_0` | PoE indoor | ### Standard H.264 Cameras -- Port 554 Some Zmodo cameras use the standard RTSP port: | Stream | RTSP URL | Notes | | --- | --- | --- | | H.264 direct | `rtsp://IP:554/h264` | Standard port | | Channel stream | `rtsp://IP:554/VideoInput/1/h264/1` | Channel-based | | Channel number | `rtsp://IP:554/[CHANNEL]` | Direct channel | ### Legacy CM-I Series | Model | RTSP URL | Alt URL | Notes | | --- | --- | --- | --- | | CM-I11123BK | `rtsp://IP:554/VideoInput/1/h264/1` | `http://IP/videostream.asf` | HTTP fallback | | CM-I12316GY | `rtsp://IP:554/VideoInput/1/h264/1` | `http://IP/videostream.asf` | HTTP fallback | ### DVR/NVR Systems | Model | RTSP URL | Notes | | --- | --- | --- | | ZMD-ISV-BFS23NM | `rtsp://IP:554/VideoInput/1/h264/1` | Channel 1 | | DVR (MPEG-4) | `rtsp://IP:554/mpeg4` | Legacy format | | DVR (auth in URL) | `rtsp://IP:554/0/USERNAME:PASSWORD/main` | Auth in path | ## Connecting with VisioForge SDK Use your Zmodo camera's RTSP URL with any of the three SDK approaches shown in the [Quick Start Guide](../#quick-start-code): ``` // Zmodo ZH-series Wi-Fi camera, main stream -- note port 10554! var uri = new Uri("rtsp://192.168.1.60:10554//tcp/av0_0"); var username = "admin"; var password = "admin"; ``` For sub-stream access, use `//tcp/av0_1` instead of `//tcp/av0_0`. ## Snapshot and MJPEG URLs | Type | URL Pattern | Notes | | --- | --- | --- | | Snapshot | `http://IP/snapshot.cgi?user=USER&pwd=PASS` | Standard models | | Snapshot (camera) | `http://IP/snapshot.cgi?camera=1` | Camera selection | | DVR Snapshot | `http://IP/cgi-bin/snapshot.cgi?loginuse=USER&loginpas=PASS` | DVR systems | | ASF Stream | `http://IP/videostream.asf?user=USER&pwd=PASS&resolution=64&rate=0` | Legacy CM-I | | MJPEG Stream | `http://IP/videostream.cgi?rate=11` | Legacy models | ## Troubleshooting ### Must use port 10554 for Wi-Fi cameras The most common Zmodo connection issue is using port 554 when the camera requires **port 10554**. All ZH-series Wi-Fi cameras and many ZP-series PoE cameras use port 10554. If your connection times out on port 554, switch to 10554. ### TCP transport in URL path The `//tcp/av0_0` path explicitly specifies TCP transport. This is built into the Zmodo URL format and is not optional. Do not remove the `//tcp/` prefix from the path. ### Zmodo app required for initial setup Some Zmodo cameras require the Zmodo mobile app for initial Wi-Fi setup and activation. RTSP access may not be available until the camera has been set up through the app at least once. Complete the initial setup before attempting RTSP connections. ### Zink protocol cameras do not support RTSP Zmodo cameras that use the proprietary **Zink** protocol are designed exclusively for the Zmodo ecosystem and do not support RTSP, ONVIF, or any third-party streaming protocol. Check the camera specifications or packaging for "Zink" branding. If your camera uses Zink, it cannot be accessed via RTSP. ### Legacy CM-I cameras use HTTP streaming Older CM-I series cameras may have limited or unreliable RTSP support. If RTSP fails on a CM-I model, fall back to the HTTP ASF or MJPEG streaming URLs: `http://IP/videostream.asf?user=USER&pwd=PASS`. ### DVR authentication format Some Zmodo DVRs embed credentials in the RTSP path rather than using standard RTSP authentication: `rtsp://IP:554/0/USERNAME:PASSWORD/main`. If standard authentication fails, try this URL format. ## FAQ **What is the default RTSP URL for Zmodo Wi-Fi cameras?** For ZH-series Wi-Fi cameras, the URL is `rtsp://admin:admin@CAMERA_IP:10554//tcp/av0_0`. Note the non-standard port 10554 and the `//tcp/` prefix in the path. **Why does my Zmodo camera use port 10554 instead of 554?** Zmodo chose port 10554 for their Wi-Fi camera line. This is a fixed port in the camera firmware. Some standard (non-Wi-Fi) Zmodo cameras and DVR systems use the standard port 554. **Do all Zmodo cameras support RTSP?** No. Zmodo cameras that use the proprietary Zink protocol do not support RTSP. These cameras are limited to the Zmodo app and cloud service. Most ZH-series, ZP-series, and CM-I series cameras do support RTSP. **Does Zmodo support ONVIF?** ONVIF support on Zmodo cameras is limited. Some newer ZP-series PoE models include ONVIF support, but most consumer Wi-Fi models (ZH-series) do not. Check your specific model's specifications for ONVIF compatibility. **What is the difference between av0\_0 and av0\_1?** In the Zmodo RTSP URL, `av0_0` is the main (highest quality) stream and `av0_1` is the sub (lower resolution) stream. Use `av0_1` when you need lower bandwidth consumption for remote viewing. ## Related Resources - [All Camera Brands — RTSP URL Directory](../) - [Foscam Connection Guide](../foscam/) — Budget consumer IP cameras - [IP Camera Preview Tutorial](../../videocapture/video-tutorials/ip-camera-preview/) - [SDK Installation & Samples](../#get-started) ---END OF PAGE--- ## VisioForge .NET SDKs — Changelog and Release Notes **URL:** https://www.visioforge.com/help/docs/dotnet/changelog/ **Description:** Version history for Video Capture, Media Player, Video Edit, and Media Blocks SDKs. New features, bug fixes, API changes, and platform updates. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, DirectShow, Windows, Capture, Playback, Streaming, Editing **API:** VideoCaptureCore, VideoCaptureCoreX, VideoView, MediaPlayerCoreX, DeviceEnumerator # Changelog Changes and updates for all .Net SDKs. ## 2026.6.21 - [Video Capture SDK X .Net] Added **Android audio playback capture** support to `VideoCaptureCoreX` — assign `AndroidAudioPlaybackCaptureSourceSettings` to `Audio_Source` to record the audio played by **other apps** (system AudioPlaybackCapture API, Android 10 / API 29+, on top of a `MediaProjection` token) straight to a file. Includes a new native Android "Audio Playback Capture" demo built on `VideoCaptureCoreX` that records another app's audio to an `.m4a` file. Only apps that allow playback capture (usage MEDIA/GAME/UNKNOWN and not opted out) can be captured. ## 2026.6.20 - [Media Blocks SDK .Net] `VideoSampleGrabberBlock` now works as a terminal block: if you leave its output unconnected (e.g. you only poll `GetLastFrameAsSKBitmap()` or handle `OnVideoFrameBuffer`), the block self-terminates so frames keep flowing. Previously a grabber with an unconnected output stalled after the first frame, so every snapshot returned the same initial image. - [Media Blocks SDK .Net] `VideoSampleGrabberBlock.GetLastFrameAsSKBitmap()` and `GetLastFrameAsBitmap()` now return `null` when no frame has been captured yet, instead of throwing a `NullReferenceException`. - [Media Blocks SDK .Net] Setting `VideoSampleGrabberBlock.SaveLastFrame = false` now discards the cached frame, so toggling it back on later never hands back a stale frame captured during an earlier session. - [Media Blocks SDK .Net] `KLVParser` now reads MISB KLV packets larger than 127 bytes. Standard MISB ST 0601 metadata uses BER long-form lengths, and the parser previously threw on the common 1- and 2-byte long-form lengths — so real-world packets failed to parse. All BER length forms are now decoded correctly. ## 2026.6.19 - [Media Blocks SDK .Net] Added **Android audio playback capture** — the new `AndroidAudioPlaybackCaptureSourceBlock` records the audio played by **other apps** using the system AudioPlaybackCapture API (Android 10 / API 29+) on top of a `MediaProjection` token, with a configurable format and usage filter (`AndroidAudioPlaybackCaptureSourceSettings`). Includes a new native Android "Audio Playback Capture" demo that records another app's audio to an `.m4a` file. Only apps that allow playback capture (usage MEDIA/GAME/UNKNOWN and not opted out) can be captured. - [Video Edit SDK .Net] Fixed a long-standing intermittent hang on stop in `VideoEditCore` (DirectShow engine): when a conversion started with `StartAsync` finished, the graph teardown could deadlock, so `OnStop` never fired and the operation appeared to hang until the process was killed — most visible with Matroska (`.mkv`) output, but possible for any async conversion. Async conversions now stop reliably and `OnStop` is always raised. - [Media Blocks SDK .Net] Speech-to-text (`SpeechToTextBlock`) gains a lossless file-transcription mode: set `SpeechToTextSettings.BackpressureWhenBusy = true` to pace a file source to the transcription engine so no audio is dropped and the pipeline position tracks the transcription frontier — ideal for transcribing a file as fast as the engine allows without losing speech. The new `SpeechToTextBlock.RequestStop()` lets you stop promptly mid-file, and an `OnEndOfStream` event fires when transcription finishes. - [Media Blocks SDK .Net] NDI source enumeration on the desktop is now time-bounded: if NDI network discovery stalls, the enumeration call returns within a few seconds instead of blocking the caller indefinitely. ## 2026.6.18 - [Media Blocks SDK .Net] Fixed WMV/ASF output where the video stream was written with a roughly 1000-hour timestamp offset while audio started at zero — players saw a broken duration and the video and audio never shared a timeline. WMV/ASF files now have correctly aligned, overlapping video and audio timestamps. - [Media Blocks SDK .Net] Graceful stop now waits for end-of-stream to actually finalize the output file before tearing the pipeline down. Recordings made with slow software encoders or GPU-based pipelines (and any pipeline that needs a moment to drain) are now written completely instead of being left unreadable with a missing `moov` atom/index. Normal pipelines also stop a little faster. - [Media Blocks SDK .Net] Fixed MP4 recordings produced from a still/image source (`ImageVideoSourceBlock`, live mode) ending up unreadable ("moov atom not found") — a live image source now finalizes its file correctly on stop. - [Media Blocks SDK .Net] VP9 WebM output now uses a real-time-capable speed/quality default: `VP9EncoderSettings.CPUUsed` defaults to `4` instead of `0`. The previous slowest/highest-quality default could not keep up with a live source, so the recorded video track could be truncated to about a second while audio ran the full length. Set `CPUUsed = 0` to restore maximum quality for offline encoding. - [Media Blocks SDK .Net] The rav1e AV1 encoder (`RAV1EEncoderSettings`) now defaults to the fastest speed preset (`SpeedPreset = 10`) instead of `6`. rav1e is a quality-oriented, very slow software encoder; the previous default could encode well under real time (~1 fps at 720p), stalling live and short captures. Lower `SpeedPreset` for higher quality in offline encoding where throughput does not matter. ## 2026.6.14 - [Media Blocks SDK .Net] The AI blocks — `YOLOObjectDetectorBlock`, `OcrBlock`, object analytics, ANPR, `BackgroundRemovalBlock` (`VisioForge.DotNet.Core.AI`) and `SpeechToTextBlock` (`VisioForge.DotNet.Core.AI.Whisper`) — now build and run cross-platform on Linux, macOS, iOS, and Android, including .NET MAUI, in addition to Windows. - [Media Blocks SDK .Net] On-device speech-to-text (`SpeechToTextBlock`, Whisper + Silero VAD) now runs on iOS and Android. - [Demos] Added three .NET MAUI sample apps: **YOLO Object Detection**, **OCR Text Recognition**, and **Live Subtitles** (on-device Whisper speech-to-text). The existing Live Subtitles console sample is now cross-platform (Windows, Linux, macOS). - [Media Blocks SDK .Net] Fixed a crash that could occur when stopping live speech-to-text with `SpeechToTextBlock` configured with `EnableVad = false` (fixed-window mode) — stopping the pipeline at end-of-stream while a transcription was in progress could terminate the process. Transcription of the in-progress window now completes cleanly during shutdown. - [Media Blocks SDK .Net] `SpeechToTextSettings.FixedWindowSeconds` is now clamped to 1–30 s and `SileroVadSettings.MaxSpeechMs` no longer accepts "0 = unlimited" (a non-positive value falls back to the 15 s cap), so a single transcription window — and the time a stop waits for it to finish — stays bounded. ## 2026.6.13 - [Media Blocks SDK .Net] Added **live speech-to-text / subtitles** — the new `SpeechToTextBlock` (in the new `VisioForge.DotNet.Core.AI.Whisper` package) transcribes the audio stream in real time with Whisper (Whisper.net / GGML) on a background worker, gated by Silero VAD so silence is skipped and not mis-transcribed. Audio passes through unchanged. It raises `OnSpeechRecognized`, can auto-render captions onto video via `SubtitleRenderer` + `OverlayManagerBlock`, and can write `.srt` / `.vtt` side-car files. Runs fully on-device (CPU or NVIDIA CUDA); Whisper and Silero models are downloaded at runtime. Includes a new WPF Live Subtitles demo. - [Media Blocks SDK .Net] Added **AI background removal (matting)** — the new `BackgroundRemovalBlock` runs an ONNX segmentation model (for example MODNet) to estimate a per-pixel foreground mask and replaces the background in real time with a blur of the original, a solid color, a static image, or transparency. Includes a new WPF Background Removal demo. The background is composited on every frame, so running the model less often (frame skipping) lowers CPU/GPU load without flicker. ## 2026.6.11 - [Media Blocks SDK .Net] Added **Object Analytics** — multi-object tracking with stable IDs, directed tripwire line crossing (In/Out counts), and polygon zone occupancy on top of ONNX object detection. Includes a turnkey `ObjectAnalyticsBlock`, a pure C# analytics API (`ByteTracker`, `LineZone`, `PolygonZone`), overlay rendering with traces and counters, a new analytics mode in the YOLO Object Detection demo, and separate Tripwire and Polygon Zone demo applications. ## 2026.6.8 - [Video Capture SDK .Net] Updated the bundled FFmpeg DirectShow source and encoder filters to **FFmpeg 8.1.1**, with refreshed codec libraries (VP8/VP9, Opus, Vorbis, Speex, SRT) and current OpenSSL — bringing newer format support and upstream security and stability fixes to FFmpeg-based capture and output. ## 2026.6.7 - [Media Blocks SDK .Net] Fixed a crash when reusing a `TSAnalyzerBlock` across runs: after the block is stopped, analyzing a second transport stream with the same instance in a new pipeline now works instead of failing during rebuild. - [Media Blocks SDK .Net] Fixed MPEG-TS output with KLV metadata aborting (no valid file produced) when a video frame arrived with an out-of-order/duplicate timestamp — the muxer now keeps the stream writable, so KLV-bearing transport streams record reliably. - [Core] Fixed native memory steadily growing while reading media information for many different files in sequence with `MediaInfoReaderX`; per-file discovery resources are now released after each read. ## 2026.6.6 - [Media Player SDK .Net] **New "Modern Player" MAUI demo.** A from-scratch cross-platform sample (Android, iOS, macCatalyst, Windows) built on `MediaPlayerCoreX` with a dark glassmorphism UI, a YouTube-style seek preview (a thumbnail popup follows the scrub bar — generated in the background from the opened file), a live video + audio effects drawer (brightness/contrast/saturation/hue, gamma, blur/sharpen, grayscale, edge, deinterlace, color presets, flip/rotate, 3D-LUT; plus gain, pitch, 10-band equalizer, reverb, echo, true-bass, and karaoke), frame snapshot, playback-speed control, and volume/mute. - [Media Player SDK .Net] [Media Blocks SDK .Net] Fixed opening local media files by absolute file path on Android, iOS, macOS, and Linux. A path starting with `/` (the form returned by the native file pickers) previously failed with a URI-format error; `MediaPlayerCoreX.OpenAsync(string)`, `MediaInfoReaderX`, and `UniversalSourceSettings.CreateAsync(string)` now open such files correctly. Windows paths were unaffected. - [Media Blocks SDK .Net] **OCR — text recognition:** new `OcrBlock` recognizes text in any video or image source using a multi-stage PaddleOCR (PP-OCRv5) ONNX pipeline — text detection, automatic 180° orientation handling, and text-line recognition. Runs on CPU or GPU (DirectML on Windows, CoreML on Apple, CUDA) and is fully cross-platform (Windows/Linux/macOS/Android). It raises the recognized regions per frame (text, confidence, and the text polygon) and can optionally draw the boxes and recognized text directly into the video. Works with the permissive Apache-2.0 PP-OCRv5 mobile models (100+ languages available); the models ship with the sample, not the package. - [Media Blocks SDK .Net] **ANPR — license plate recognition:** new `LicensePlateRecognizerBlock` reads vehicle number plates from a live stream or file using a specialized two-stage pipeline — a dedicated license-plate detector locates each plate, then a plate-specific OCR model (a global head covering the USA and 90+ countries, or a European head) reads its characters. Recognition runs on a background thread so live video never stalls; recognized plates (text, confidence, bounding box) are raised per frame and optionally drawn over the video. Cross-platform and GPU-accelerated (DirectML / CUDA / CoreML). The MIT-licensed models ship with the sample, not the package. ## 2026.6.4 - [Media Blocks SDK .Net] **AI inference package renamed:** the AI/ONNX inference package is now published as `VisioForge.DotNet.Core.AI` (previously `VisioForge.DotNet.Core.ONNX`). Update your `PackageReference` to the new id — the API and namespaces of the inference blocks are unchanged. - [Media Blocks SDK .Net] **Object detection: more models, permissive default.** `YOLOObjectDetectorBlock` now decodes three model families via the new `YoloDetectorSettings.Model` property — **YOLOX** and **RT-DETR / D-FINE** (both Apache-2.0) in addition to YOLOv8/v11. Each family's frame preprocessing (resize mode, normalization, channel order) and the model's input size are applied automatically, so you only pick the family and the `.onnx` file. The Object Detection demo now ships a ready-to-run **Apache-2.0** model (YOLOX-nano) and works out of the box without any third-party model download. RT-DETR / D-FINE detectors are end-to-end (NMS-free). - [Media Blocks SDK .Net] **TS analyzer — ETSI TR 101 290 monitoring:** `TSAnalyzerBlock` now reports a structured TR 101 290 Priority 1/2/3 check list (sync loss, sync-byte errors, PAT/PMT/PID errors, continuity-count errors, transport errors, CRC errors, PCR/PTS errors, and SI/SDT/EIT/TDT errors), each with its priority, error count, and pass/fail status — turning the block into a broadcast-grade transport-stream monitor. - [Media Blocks SDK .Net] **TS analyzer — service information:** the report now exposes per-program SDT service names, service provider, and service type, the network name, and the stream UTC time (TDT/TOT), so programs show up as their real service name instead of just a program number. - [Media Blocks SDK .Net] **TS analyzer — audio language:** elementary-stream entries now carry the ISO 639 audio language parsed from the PMT descriptors. - [Media Blocks SDK .Net] **TS analyzer — scrambling detection:** per-PID and per-program scrambling state is now reported (transport-scrambling-control and free\_CA\_mode), along with a scrambled-packet count. - [Media Blocks SDK .Net] **TS analyzer — null and effective bitrate:** the report adds the null-packet count, the null (stuffing) bitrate, and the effective (useful) bitrate, plus per-PID instantaneous and peak bitrate alongside the existing cumulative average. - [Media Blocks SDK .Net] **TS analyzer — PCR timing and PTS/DTS:** PCR statistics now include maximum jitter and PCR repetition errors, and the report tracks PTS/DTS presence per PID and audio/video synchronization offset. - [Media Blocks SDK .Net] **TS analyzer — codec details:** video elementary streams now report parsed codec details (resolution, frame rate, profile, level, chroma format, and display aspect ratio) for H.264, HEVC, and MPEG-2. Frame rate and aspect ratio are reported from the MPEG-1/2 sequence header. - [Media Blocks SDK .Net] **TS analyzer — optional EPG:** when enabled, the analyzer parses EIT events (event id, start time, duration, name, description) and exposes them as an EPG event list. The new analysis options (service info, EPG, scrambling, TR 101 290, PTS/DTS, codec details) are configurable on `TSAnalyzerSettings`. The WPF and console demos display all of the new information. - [Video Capture SDK .Net] Fixed audio capture failing to start with certain WDM capture cards (for example the Viewcast Osprey 460E) when the device was selected by its device path — the device enumerated correctly but capture aborted with an "audio output pin is null" error. Such devices now bind reliably. - [Media Blocks SDK .Net] Fixed a `MediaBlocksPipeline` becoming unusable after a media file played to its end. Once a source reached End-of-Stream, the next `StartAsync()` was permanently rejected with "Already starting or start in progress." and the pipeline could not be restarted without recreating it — for example when switching from a finished file back to a live camera. Playback now shuts down cleanly at end-of-stream exactly like an explicit `StopAsync()` (sources stopped, resources released), so the same pipeline can be started again. ## 2026.6.3 - [Media Blocks SDK .Net] **MPEG-TS analyzer:** new `TSAnalyzerBlock` analyzes a transport stream and reports the program/service line-up (PAT/PMT/PSI), the per-PID stream types and codecs, per-PID and total bitrate, continuity-counter errors, and PCR timing (interval min/avg/max and discontinuity count). It accepts a raw MPEG-TS byte stream from a file, UDP, or SRT source and can run terminal (`Input`) or inline passthrough (`InputOutput`); subscribe to `OnAnalysisUpdated` for periodic snapshots or call `GetReport()`. New WPF and console demos ("TS Analyzer Demo", "TS Analyzer CLI") show file and live UDP/SRT analysis. - [Media Blocks SDK .Net] **Raw MPEG-TS UDP source:** new `UDPRAWMPEGTSSourceBlock` receives a live UDP unicast or multicast transport stream and exposes the untouched MPEG-TS byte stream without demuxing — for analysis or passthrough remuxing/recording. The advertised packet size is configurable via `UDPRAWMPEGTSSourceSettings.PacketSize` (188 by default, or 192 for M2TS-style streams). - [Media Blocks SDK .Net] **Split-recording segment events:** `MP4SinkBlock`, `MPEGTSSinkBlock`, and `MP4OutputBlock` now raise `OnSegmentCreated` and `OnSegmentClosed` when configured for split recording (`MP4SplitSinkSettings` / `MPEGTSSplitSinkSettings`). The arguments carry the segment file path, fragment index, and timing (running time, plus start offset and duration on close) — so you can be notified when a segment file is finished and, for example, rename it to include its start/end time. - [Media Blocks SDK .Net] **Custom split-segment file names:** the same blocks add an `OnSegmentFileNameRequested` event, raised just before each new segment file is created, letting you supply a custom file name (for example one that embeds the segment start date/time). Leave it unset to keep the default name from the location pattern. - [Media Blocks SDK .Net] **New AI inference blocks:** `OnnxInferenceBlock` runs any ONNX Runtime model over the live video frames and raises an event with the raw model outputs, while `YOLOObjectDetectorBlock` performs YOLOv8/v11 object detection, draws bounding boxes and labels directly on the video (label text auto-scales to the frame resolution so it stays readable on 720p/1080p/4K, or pin a fixed size via `YoloDetectorSettings.LabelFontSize`), and raises a detections event (with class, confidence, and box for each object). Both support frame skipping to tune throughput. On Windows the package uses the DirectML ONNX Runtime build, so inference runs on any DirectX 12 GPU (NVIDIA, AMD, or Intel) out of the box; the execution provider defaults to `Auto`, which picks the fastest available backend (DirectML/CUDA/CoreML) and transparently falls back to the CPU. Use `OnnxInferenceEngine.GetAvailableProviders()` to detect what is available and the new `ActiveProvider` property on either block to see which provider engaged. The `VisioForge.DotNet.Core.ONNX` package targets the full SDK framework matrix (.NET Framework 4.6.1 through .NET 10); inference requires a 64-bit (x64 or ARM64) ONNX Runtime native build. ## 2026.6.2 - [Video Capture SDK .Net] Fixed KLV metadata progressively drifting out of sync with the video (about 2 seconds per source loop) on the receiving side when restreaming a looping KLV-bearing MPEG-TS via `UDP_FFMPEG_EXE`. KLV and video now stay aligned across source loop boundaries. - [Video Capture SDK .Net] Unity: new VideoCaptureCoreX samples — local webcam preview + MP4 recording (Windows, macOS) and IP/RTSP camera viewing (Windows, Android, macOS, iOS). - [Video Edit SDK .Net] Unity: new VideoEditCoreX sample — combine clips, apply effects, preview the timeline in Unity, and render to MP4. ## 2026.5.31 - [Media Blocks SDK .Net] **New `UDPRAWSourceBlock`:** receives a live UDP stream (MPEG-TS, RTP, or raw elementary) and exposes the parsed, still-encoded media without decoding — ideal for recording or remuxing without re-encoding. MPEG-TS feeds are auto-detected; RTP and raw modes let you set the codec, RTP payload type, and a multicast address. It exposes all common video and audio codecs (video: H264, H265, VP8, VP9, AV1, MPEG-2, MJPEG; audio: AAC, MP3/MPEG audio, AC-3, Opus, FLAC); RTP can also carry audio on a separate port (`AudioPort` / `AudioCodec`). A codec without a dedicated parser is passed through unchanged rather than dropped, so a connected recorder/muxer is never starved. - [Demos] **New WPF "UDP RAW Capture Demo" (Media Blocks SDK .Net):** records a live UDP H264/H265 feed to MP4 files **without re-encoding**, with selectable transport (Auto / MPEG-TS / RTP / raw), starting a new file on a configurable interval and splitting on key-frames so no data is lost between files, while previewing the stream. - [Media Player SDK .Net] Unity: new MediaPlayerCoreX sample — play files and network URLs with seek, pause and volume, rendered into a Unity `Texture2D`. ## 2026.5.29 - [Media Blocks SDK .Net] **Unity 6 (.NET Standard 2.1) build flavor:** the managed SDK now ships as a single `netstandard2.1` assembly compatible with Unity's IL2CPP backend (Api Compatibility Level = .NET Standard 2.1). This lets Unity projects target the SDK without requiring the .NET Framework 4.x compatibility surface. The existing net48 Unity package remains supported. - [Media Blocks SDK .Net] **Unity macOS Standalone player support (Universal arm64 + x86\_64):** the Unity 6 ns2.1 `.unitypackage` now ships a third platform flavor for macOS Standalone (in addition to Windows and Android). Includes pre-built P/Invoke for macOS `.dylib` names, the bundled CrossPlatform.Core.macOS native runtime (GStreamer dylibs + `libgioopenssl` TLS backend + `ca-certificates.crt`), and a one-time `Configure()` bootstrap that prunes any system / homebrew GStreamer from `DYLD_LIBRARY_PATH` before the loader runs. - [Core] **New API:** `VisioForgeX.StopMainLoop()` — explicit teardown of the internal GLib main loop independent of `DestroySDK()`, for scenarios that need to release the loop without tearing the SDK down. ## 2026.5.22 - [Demos] **Unity `.unitypackage` distribution:** the Unity 6 (net48) integration now ships as a single self-contained `.unitypackage` - [Demos] **New Unity 6 (net48) samples:** `SimplePlayer` (file playback) and `RTSPViewer` (live RTSP camera) render a `MediaBlocksPipeline` into a Unity `RawImage` via a reusable `VisioForgeVideoView` component (Stretch / Letterbox / Crop). The bundled native + managed runtime is set up automatically; a step-by-step setup guide is included. ## 2026.5.20 - [Media Blocks SDK .Net] **Fix:** native memory leak in `OverlayManagerFilter` and `PanZoomFilter` on iOS/AOT builds. ## 2026.5.19 - [Media Blocks SDK .Net] **Fix:** `CVMotionCellsBlock`, `CVFaceDetectBlock`, `CVHandDetectBlock`, `CVTemplateMatchBlock` — event subscriptions added after `StartAsync` sometimes were silently dropped. - [Media Blocks SDK .Net] **Fix:** `CVMotionCellsSettings.Gap` and `PostNoMotion` are now rounded and clamped to the ranges accepted by the underlying `motioncells` element (`Gap` → `[1, 60]` s, `PostNoMotion` → `[0, 180]` s). Previously sub-second values truncated to `0` and were silently rejected. - [Media Blocks SDK .Net] **Docs:** `CVMotionCellsSettings.GridSize` XML-doc clarified that the minimum is 8x8 (constraint of the underlying `motioncells` element); smaller values are silently rejected. ## 2026.5.18 - [Media Blocks SDK .Net] **New API:** `SRTSinkSettings.PreResolveHostname` and `SRTSourceSettings.PreResolveHostname` (`bool`, default `false`). When set to `true`, the SDK resolves any DNS hostname in the SRT URI to a literal IPv4 on the managed side (via `System.Net.Dns`) before handing the URI to the native code. ## 2026.5.16 - [Core] Public-API XML documentation is now validated for correct syntax across the shipped NuGet packages. ## 2026.5.15 - [Core] Added `D3D11Composable` WPF renderer mode: a pure FrameworkElement video panel built on a D3D11 shared texture + `D3DImage` bridge that composes natively with the WPF visual tree (transforms, opacity, z-order, rounded clips) and keeps frames GPU-resident end-to-end. New type: `D3D11ComposablePanel`. - [Core] Added true-peak (dBTP) metering per ITU-R BS.1770-4: new `TruePeakComputer` (4× polyphase FIR oversampling, per-channel running peak, NaN/Inf-safe) and `VUMeterXData.TruePeak[]` channel array fired alongside the existing sample-peak/RMS data. - [Core] Added `VolumeMeterLED` WPF control: segmented LED-bar VU meter with broadcast-style green/yellow/red zones, optional peak-hold marker (configurable fall time), optional dB scale labels, optional RMS overlay bar, horizontal/vertical orientation. - [Core] NuGet packages now ship XML documentation generated from real summaries for the full public API surface (previously the doc files were empty). ## 2026.5.14 - [Avalonia] Updated Avalonia, Avalonia.Desktop, Avalonia.Fonts.Inter, Avalonia.Themes.Fluent from 12.0.1 to 12.0.3. - [WinForms] Resolve issue with WinForms designer when using `VideoView` in .Net Framework 4.x projects - [Dependencies] Closed two transitive security advisories: pinned `System.Drawing.Common` per-TFM on bare/cross-platform `netN.0` (was 5.0.1 via DlibDotNet — GHSA-rxg9-xrhp-64gj, critical) and added explicit `SharpCompress 0.48.1` CPM pin to lift the transitive floor from MongoDB.Driver (was 0.30.1 — GHSA-6c8g-7p36-r338, moderate); bumped MongoDB.Driver 3.8.0 → 3.8.1. - [Breaking] `VisioForge.Core.CVD` and `VisioForge.Core.FaceAI` assemblies are no longer strong-named. The underlying `DlibDotNet` dependency is unsigned, so the strong-name chain was already broken at runtime; the `` flag was dropped to silence CS8002. Consumers that referenced these assemblies by fully-qualified strong name (`PublicKeyToken=...`) or used `[InternalsVisibleTo("VisioForge.Core.CVD, PublicKey=...")]` must remove the strong-name assertion when upgrading. ## 2026.5.10 - [Core] `CustomMixerSourceBlock`: reliability and throughput improvements under heavy load. ## 2026.5.8 - [Dependencies] Upgraded MongoDB.Driver.GridFS 2.30.0 to MongoDB.Driver 3.8.0; pinned Snappier 1.3.1 to resolve NU1903 high-severity vulnerability (GHSA-pggp-6c3x-2xmx) ## 2026.5.2 - [Core] Breaking change: licensing APIs now accept only raw certificate bytes. Removed file-path and stream-based certificate setters across shared licensing, public SDK wrappers, legacy Windows wrappers, tests, and licensing docs. Applications must load `.vflicense` files into memory and call `SetLicenseCertificateAsync(byte[])`. - [Core] `AudioMixerBlock`: `AudioMixerSettings.IgnoreInactivePads` is now opt-in (default `false`). The 2026.4.30 release briefly forced it `true`, which broke single-input mixers — silent live audio and corrupted MP4 output. Multi-stream consumers (`MediaPlayerCoreX` additional audio streams, `LiveVideoCompositor`, and `AudioMixerSourceSettings`-based multi-source capture) now opt in explicitly. If you wired a multi-stream `AudioMixerBlock` on 2026.4.30–2026.5.1 and relied on the implicit `true`, set `AudioMixerSettings.IgnoreInactivePads = true` explicitly. ## 2026.4.25 - [Core] Fixed WinForms designer exception on `VideoView` in net472 demos — SkiaSharp 3 migration regression - [Core] Added transitive `SkiaSharp.NativeAssets.Linux` dependency for bare cross-platform TFMs (`netcoreapp3.1`, `net5.0`–`net10.0`) so consumers publishing to `linux-x64`/`arm64` no longer need to add the package manually; main `SkiaSharp` already covers Win32/macOS/iOS/Android/MacCatalyst/tvOS via per-TFM nuspec groups - [Avalonia] Migrated SDK and all 28 demos from Avalonia 11.3.8 to **12.0.1**: replaced `Avalonia.Diagnostics` with `AvaloniaUI.DiagnosticsSupport 2.2.1`, switched to `ReactiveUI.Avalonia 12.0.1`, updated `RxApp.MainThreadScheduler` → `RxSchedulers.MainThreadScheduler` (ReactiveUI 23.x), new `UseReactiveUI(_ => { })` signature, moved Android `CustomizeAppBuilder` from `MainActivity` to new `MainApplication : AvaloniaAndroidApplication`, migrated `SaveFileDialog`/`OpenFileDialog`/`FileDialogFilter` to `IStorageProvider.SaveFilePickerAsync`/`OpenFilePickerAsync` in 4 demos. SkiaSharp pinned to 3.119.3-preview.1.1 (required by Avalonia.Skia 12). ## 2026.4.23 - [NuGet] Extracted Intel Quick Sync Video (QSV) plugin (`gstqsv.dll`) from `VisioForge.CrossPlatform.Core.Windows.x64/x86` into new optional packages `VisioForge.CrossPlatform.Core.Windows.Intel.x64` and `VisioForge.CrossPlatform.Core.Windows.Intel.x86`; each depends on the corresponding base Core package - [Video Capture SDK .Net] Fixed FFMPEG.exe pipe output argument ordering so resize/aspect options are emitted after all inputs, including KLV metadata pipe input ## 2026.4.21 - [Core] Added `AutoAV1EncoderSettings`: auto-selecting AV1 encoder that walks AMF → NVENC → QSV → SVT-AV1 via `EncoderRuntimeTracker`, mirroring `AutoH264EncoderSettings` / `AutoHEVCEncoderSettings`; AV1 sessions now participate in per-runtime slot accounting - [Core] Added typed `AV1Encoder.CanCreateSession(IAV1EncoderSettings, out string)` probe so AV1 runtime selection can detect driver rejections before wiring a pipeline - [Core] Added `MFH264EncoderSettings`, `D3D12H264EncoderSettings`, `D3D12HEVCEncoderSettings` — alternative Windows runtimes (`mfh264enc`, `d3d12h264enc`, `d3d12h265enc`) with independent per-adapter session counters for bypassing per-runtime caps (e.g., AMD iGPU 2-session ceiling) - [Core] Added `AutoH264EncoderSettings` / `AutoHEVCEncoderSettings`: auto-selecting encoder that probes runtimes in order (AMF → NVENC → QSV → MF → D3D12 → software), tracks in-flight sessions via `EncoderRuntimeTracker`, and falls back when a runtime's cap is reached - [Demo] Added `Encoder Concurrency Test` WPF demo (Media Blocks SDK): spawn multiple source→encoder→decoder→renderer pipelines with configurable resolution, frame rate, encoder runtime, and adapter to exercise concurrent-session limits end-to-end ## 2026.4.18 - [Media Blocks SDK] UniversalSourceBlock: added `VideoFlipRotate` option for automatic video orientation correction using image-orientation metadata - [Core] VOAACEncoderSettings deprecated in favor of `AVENCAACEncoderSettings` - [Core] RTSPXOutput: now accepts any `IAACEncoderSettings`, not just VOAAC - [Core] MediaInfoReaderCore: preserves image-orientation flip metadata during media info reading - [Core] H264Encoder: fixed thread-safety issue in KeyFrameDetected callback - [iOS] PhotoGalleryHelper: requests `PHAccessLevel.AddOnly` for iOS 26 compatibility - [Android] GStreamer Android NuGet rebuilt with zbar barcode plugin, bumped to 2026.4.18 - [Platform] macOS demos migrated from net9.0-macos to net10.0-macos - [Dependencies] Uno.Sdk bumped 6.4.24 → 6.5.31 - [Media Blocks SDK] LiveVideoCompositor V2: added `OnRenderStatistics` event with `ActualFps`, `ConfiguredFps`, `FramesDelivered`, and `LastFrameTimestamp` payload for detecting when the compositor falls behind the configured frame rate under heavy load - [Media Blocks SDK] LiveVideoCompositor V1 (`VisioForge.Core.LiveVideoCompositor`) marked `[Obsolete]` — migrate to `VisioForge.Core.LiveVideoCompositorV2` (identical class names, single-line `using` swap); V1 will be removed in a future release - [Demos] WPF LVC Demo and MAUI LVC Demo show the real vs configured output FPS in the UI; WinForms Video Mixer Player migrated from V1 to V2 ## 2026.4.11 - [Media Player SDK X] Added `Play_PauseAtFirstFrame` property to MediaPlayerCoreX — pauses at the first rendered frame for preview/thumbnail scenarios, matching the existing MediaPlayerCore API - [Core] Migrated SkiaSharp from 2.88.9 to 3.119.2 — updated text rendering to SKFont API, replaced SKFilterQuality with SKSamplingOptions, switched SVG library from SkiaSharp.Svg to Svg.Skia - [UI] Updated SkiaSharp.Views.WPF and SkiaSharp.Views.Maui.Controls to 3.119.2; WPF skins now use DrawImage with high-quality Mitchell resampling ## 2026.4.8 - [Android] Added live camera switching (SwitchCamera) to SystemVideoSourceBlock — switches between front/back cameras without recreating the GStreamer pipeline, preserving resolution and frame rate - [Video Capture SDK X] Added Video\_Source\_SwitchCamera for live camera switching on Android without pipeline restart - [Video Capture SDK X] Added Video\_Renderer\_IsSync and Audio\_Renderer\_IsSync properties (default false) for lower-latency live preview - [Android] New NuGet native version v2026.4.1 ## 2026.3.27 - [Core] Fixed UNC path media info reading failure: `MediaInfoReaderAlt` now correctly handles SDK initialization guard, null caps in `OnPadAdded`, and falls through to `MediaInfoReaderX` on failure. `IsSambaURL()` extended to detect `file://host/path` UNC URIs. `OpenAsync` uses `uri.LocalPath` for correct Windows UNC path. ## 2026.3.18 - [Media Blocks SDK .Net] Fixed missed context menu issue in WPF VideoView ## 2026.3.17 - [Media Blocks SDK .Net] Added UDPSinkBlock and MultiUDPSinkBlock for raw UDP streaming output with single and multi-destination support - [Media Blocks SDK .Net] Added UDPMPEGTSSinkBlock and MultiUDPMPEGTSSinkBlock for MPEG-TS multiplexed UDP streaming with single and multi-destination support - [Media Blocks SDK .Net] Added UDPSinkSettings, MultiUDPSinkSettings, and UDPSinkSettingsBase for UDP sink configuration with IPv6 support and URL parsing - [Media Blocks SDK .Net] Added UDP MPEG-TS streamer demo (screen capture to UDP output) ## 2026.3.11 - [Core] Device enumeration: Blackmagic ATEM and Web Presenter devices now appear in regular video/audio device lists instead of being filtered as Decklink hardware. These devices use standard USB/UVC drivers, not the Decklink SDK. Applies to both DirectShow and GStreamer enumeration paths. - [Core] RTSP info reader: Added audio channel count and sample rate parsing from SDP rtpmap and GStreamer pad caps. ## 2026.2.16 - [Media Blocks SDK .Net] Added PreEventRecordingBlock for circular buffer (pre-event) video recording with configurable buffer duration, keyframe-aware drain, and automatic post-event stop - [Video Capture SDK .Net] VideoCaptureCoreX: Added pre-event recording API with TriggerPreEventRecording, ExtendPreEventRecording, StopPreEventRecording, and state query methods - [Video Capture SDK .Net] VideoCaptureCoreX: Added PreEventRecordingOutput for configuring circular buffer recording with MP4, MPEG-TS, and MKV container support ## 2026.2.12 - [Media Blocks SDK .Net] Added OnNetworkSourceDisconnect event for detecting network source disconnections (RTSP, HTTP, SRT, NDI, RTMP, etc.) with detailed error information and source URI ## 2026.2.11 - [Media Player SDK .Net], [Media Blocks SDK .Net] Fixed audio effects pipeline routing ## 2026.2.10 - [Core] Added UNC (SMB/Samba) network path support for file sources across all X-engines, fixing File.Exists() failures on network shares - [Media Blocks SDK .Net], [Video Capture SDK .Net] Added mouse click highlight support for screen capture with auto-subscribe/unsubscribe, manual click input, and real-time settings update ## 2026.2.8 - [Media Blocks SDK .Net] Added OverlayManagerImageSequence: image sequence overlay with per-frame durations, looping, position/size animation, fade effects, and easing support - [Media Blocks SDK .Net] Added ImageSequenceItem data class for defining image sequence frames - [Media Blocks SDK .Net] OverlayManagerBlock: Added convenience methods for image sequence overlays (Video\_Overlay\_AddImageSequence, UpdateImageSequencePosition, AnimateImageSequence, ImageSequenceFadeIn/Out) - [Core] Extracted OverlayManagerEasingHelper: shared easing functions for all overlay animation types (Image, Fade, Pan, Squeezeback, ImageSequence) ## 2026.2.4 - [Media Blocks SDK .Net] Added H264PushSourceBlock for pushing raw H.264 encoded data into a decoding pipeline, with automatic AVC-to-byte-stream conversion and PTS rebasing - [Core] Added RtspDescribeClient: lightweight cross-platform RTSP DESCRIBE client for fast stream discovery (~100-200ms), with SDP parsing and Basic/Digest auth support - [Core] RTSPSourceSettings: Added fast RTSP discovery path using RtspDescribeClient - [Core] RTSPRAWSourceSettings: Added fast RTSP discovery path using RtspDescribeClient - [Core] UniversalSourceSettings: Added fast RTSP discovery path for rtsp:// and rtsps:// URIs ## 2026.2.2 - [Core] VideoCaptureDeviceInfo: Extended Windows device path population to support Media Foundation (MF) devices in addition to KS - [Core] VideoCaptureDeviceInfo: Fixed pre-existing bug where V4L2 device path validation checked wrong variable - [Core] VideoCaptureDeviceSourceSettings: Added FindByDevicePath() static methods for restoring saved camera profiles by device path - [Core] DeviceEnumerator: Added FindVideoSourceByDevicePathAsync() method for looking up devices by path - [Media Blocks SDK .Net] Added RIST (Reliable Internet Stream Transport) MPEG-TS sink output support - [Media Blocks SDK .Net] Added WebRTC WHIP (WebRTC-HTTP Ingestion Protocol) output support - [Video Capture SDK .Net] Added WebRTC WHIP streaming output - [Video Capture SDK .Net] Added RIST streaming output ## 2026.1.16 - [Media Blocks SDK .Net] BridgeVideoSourceSettings: Added DoTimestamp property to enable fresh timestamp generation for cross-pipeline scenarios ## 2026.1.15 - [Media Blocks SDK .Net] DecklinkVideoSinkSettings: Made Mode parameter required in constructor to prevent frame rate mismatch issues (was defaulting to Unknown mode causing unexpected 23.98fps output) - [Media Blocks SDK .Net] DecklinkVideoSinkSettings: Made DeviceNumber and Mode properties read-only for immutability - [Core] DecklinkVideoOutputDialog (WPF): Added Video Mode selector for configuring output frame rate ## 2026.1.12 - [Core] WPF VideoView: Fixed crash (System.ExecutionEngineException) when minimizing window during video overlay playback ## 2026.1.11 - [Media Blocks SDK .Net] RTSPSourceBlock: Fixed video freeze when audio capture is disabled for cameras with multiple audio streams - [Media Blocks SDK .Net] RTSPRAWSourceBlock: Added fakesink handling for disabled audio streams to prevent pipeline stalls - [Core] MediaInfoReaderCore: Added logging for discovered audio, video, and RTP streams - [Core] MediaInfoReaderCore: Fixed excessive block size (5MB) being set for RTSP sources, improving discovery speed ## 2026.1.10 - [Video Capture SDK .Net] DSFFMPEGEXEPipeOutput: Fixed preview lag during video capture with optimized pipe handling and queue processing - [Video Capture SDK .Net] FFMPEG EXE output: Added real-time encoding optimizations for VP8/VP9, fixed MJPEG quality mode, improved default H264MFSettings defaults ## 2026.1.6 - [Video Capture SDK .Net] VideoCaptureCoreX: Fixed video capture resolution issue when ResizeVideoEffect is applied ## 2025.12.12 - [Media Blocks SDK .Net] Added PitchBlock for audio pitch shifting with semitone control (-12 to +12 range) - [Media Player SDK X .Net] CDGSource: Added pitch shifting support with EnablePitchShifting option and real-time PitchSemitones control - [Media Player SDK X .Net / Media Blocks SDK .Net] CDGSourceSettings: Added ZIP archive support for karaoke files (MP3+CDG pairs inside ZIP) ## 2025.11.8 - [Media Blocks SDK .Net] OverlayManagerVideo and OverlayManagerDecklinkVideo: Changed AudioOutput property type from MediaBlock to AudioOutputDeviceInfo for direct audio device selection. Audio is now handled internally via AudioRenderer with automatic channel conversion support. ## 2025.11.4 - .Net 10 support for all SDKs ## 2025.11.3 - WPF VideoView update: Added RotationAngle, RotateCrop, and RotationStretch properties to support rotated video rendering ## 2025.11.1 - [Media Blocks SDK .Net] Add synchronized overlay group support for OverlayManagerBlock ## 2025.10.10 - [**Windows SDKs**] Updated VideoEffectRotate with no-crop option ## 2025.10.6 ### 🚀 Major Feature: Ultra-Low Latency RTSP Streaming - **[Media Blocks SDK .Net]** Revolutionary low latency mode for RTSP sources achieving **60-120ms total latency** (10-14x improvement over default 1-2 seconds) - Added `RTSPSourceSettings.LowLatencyMode` property for one-line enablement of optimized streaming - Automatic pipeline optimization: RTSP source (80ms), queue buffers (10-20ms), and renderer sync control - GStreamer integration: `latency=80ms`, `buffer-mode=0`, queue `max-size-buffers=2` with `leaky=downstream` - Perfect for real-time surveillance, security systems, live monitoring, and interactive video applications - **[Media Blocks SDK .Net]** Enhanced RTSPSourceBlock with comprehensive low latency configuration - Added `RTSPBufferMode` enum with 5 modes (None, Auto, Slave, Buffer, Synced) for fine-grained jitter buffer control - Added `RTSPNTPTimeSource` enum (NTP, RunningTime, Clock) for NTP timestamp synchronization in multi-camera scenarios - New properties: `LowLatencyMode`, `BufferMode`, `DropOnLatency`, `NTPSync`, `NTPTimeSource` - Optimized `QueueElement` with automatic low latency configuration (2 frame max, leaky downstream mode) - **[Video Capture SDK X .Net]** Full low latency mode support for RTSP sources - Compatible with `VideoCaptureCoreX` engine across all platforms - Same simple API: `RTSPSourceSettings.LowLatencyMode = true` - Works seamlessly with IP Capture demo and RTSP MultiView demo - **[Cross-Platform Support]** Low latency RTSP streaming now available on all platforms: - Windows (WPF, WinForms, Console, Blazor) - macOS (MAUI, Console) - Linux (Console, WPF with Mono) - Android (MAUI, Native) - iOS (MAUI) - **[Demo Applications]** Updated 6 demos with low latency mode UI controls: - Media Blocks SDK: RTSP Preview Demo (WPF), RTSP MultiView Demo (WinForms), MAUI RTSPViewer, Android RTSP Client - Video Capture SDK X: IP Capture (WPF), RTSP MultiView Demo (WinForms) - All demos include easy-to-use checkboxes or default-enabled low latency for optimal user experience - **[Documentation]** Official help documentation updated with a low-latency section and best practices. - **[Testing]** Validated on real IP cameras across all platforms. Performance benchmarks: Windows (85ms), macOS (95ms), Linux (80ms), Android (110ms), iOS (100ms). - **[Backward Compatibility]** 100% backward compatible implementation: - Default behavior unchanged - existing code works without modification - Low latency mode is opt-in via explicit property - No performance impact when not using low latency mode - Queue optimization only applied when `LowLatencyMode=true` ## 2025.10.3 - [Media Blocks SDK .Net] Added DASH (Dynamic Adaptive Streaming over HTTP) sink support with DASHSinkBlock and DASHOutput classes - [Media Blocks SDK .Net] Added UniversalSourceBlockV2 with improved memory usage and performance - [X-engines] Fixed uvch264src not starting on Linux by properly selecting the appropriate source pad based on video format (vidsrc for H264, vfsrc for raw/MJPEG) ## 2025.9.5 - [Video Fingerprinting SDK] Improved support for flipped videos ## 2025.9.3 - [Media Blocks SDK .Net] Added DataMatrix barcode support using DataMatrixDecoderBlock block ## 2025.9.1 - [Video Fingerprinting SDK] Improved support for flipped videos ## 2025.8.9 - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved issue with Snapshot\_GetSK call on Android (wrong colorspace) ## 2025.8.6 - [X-engines] Updated RTSP RAW source block. Added WaitForKeyframe and SyncAudioWithKeyframe properties. Block can wait for keyframes because some cameras may not send them as first frames. ## 2025.8.4 - [X-engines] Added NDI source support in Live Video Compositor ## 2025.8.2 - [ALL] New ONVIF manager code in VisioForge.Core.ONVIFX. Full implementation of various ONVIF services including Device Management, Media v1/v2, PTZ, Events, Imaging, Analytics, Recording, and Replay services. ## 2025.8.1 - [Media Player SDK] Added PauseOnStop property to MediaPlayerCoreX ## 2025.6.30 - [X-engines] Added animated GIF support to `ImageVideoSourceBlock`/`ImageVideoSourceSettings` classes - [X-engines] Resolved issues with delayed file start in Live Video Compositor - [X-engines] Update video mixer API to use GUIDs instead of integer indexes for video sources ## 2025.6.27 - [Video Capture SDK] Resolved issue with RTSP Low Latency engine with some cameras ## 2025.6.5 - [X-engines] Resolved issue with NDI sources playback without audio streams ## 2025.6.3 - [X-engines] Updated GenICam source support for USB Vision cameras. Added GenTL source support. ## 2025.6.2 - [X-engines] Added deinterlace support for interlaced Decklink video sources ## 2025.6.1 - [Live Video Compositor] Resolved issue with file sources paused on start, and resumed with error ## 2025.5.1 - [ALL] Update NuGet dependency packages to the latest versions - [X-engines] Resolved issue with RTMP network streaming to a custom server ## 2025.4.8 - [ALL] Added Absolute Move API to the `ONVIFDeviceX` class. You can use this API to move the ONVIF camera to the specified absolute position. ## 2025.2.24 - [X-engine] By default, Media Foundation device enumeration is disabled. You can enable it using the `DeviceEnumerator.Shared.IsEnumerateMediaFoundationDevices` property. ## 2025.2.18 - [Media Player SDK.Net] Added loop support for the cross-platform engine. - [ALL] Updated RTSP-X engine output, fixed crash issue with RTSP output and VLC player frequent reconnects - [X-engines] Changed face detector support to use IFaceDetector interface - [Live Video Compositor] Fixed registration issues with custom video view attached to video input ## 2025.2.9 - [X-engines] Updated NDI connection speed ## 2025.2.4 - [X-engines] RTSP Server Media Block and RTSPServerOutput added to Video Capture SDK. You can use the RTSPServerBlock to create an RTSP server and stream video and audio to it. ## 2025.2.1 - [X-engines] Added NVENC and AMF AV1 encoders support ## 2025.1.25 - [Windows] Resolved HTTPS issue with the not loaded SSL certificates ## 2025.1.22 - [Windows] Resolved issue with missed ONVIF sources while enumerating on PC with multiple network interfaces - [Media Blocks SDK .Net] Added the `OnEOS` event to `MediaBlockPad` class. You can use this event to get the EOS (End of Stream) event from the media block. It can be useful if you have several file sources with a different duration and you need to stop the pipeline when the first source ends. - [Media Blocks SDK .Net] Added the `SendEOS` method to `MediaBlocksPipeline` class. You can use this method to send the EOS (End of Stream) event to the pipeline. ## 2025.1.18 - [NuGet] `VisioForge.Core.UI.Apple`, `VisioForge.Core.UI.Android`, and `VisioForge.Core.UI.WinUI` packages are merged into the `VisioForge.DotNet.Core` package. All namespaces are the same. - [Media Blocks SDK .Net] Added the `ZOrder` property to `LVCVideoInput` and `LVCVideoAudioInput` classes. You can use this property to set the Z-order for the video input. ## 2025.1.14 - [NuGet] `VisioForge.Core.UI.WPF` and `VisioForge.Core.UI.WinForms` packages are merged into the `VisioForge.DotNet.Core` package. In WPF projects you have to update the XAML code if the assembly names are used. All namespaces are the same. ## 2025.1.11 - [Video Capture SDK .Net] Resolved QSV H264 FFMPEG encoder issue with the wrong symbols in parameters ## 2025.1.7 - [Cross-platform] Added `libcamera` source support for Linux/Raspberry Pi. ## 2025.1.5 - [Cross-platform] Improved previous frame playback in Media Player SDK .Net (Cross-platform engine) ## 2025.1.4 - [Cross-platform] Resolved issue with AMD AMF plugin initialization ## 2025.1.1 - [Cross-platform] Resolved memory leak in `OverlayManagerImage` ## 2025.1.0 - [Cross-platform] Updated Live Video Compositor engine. Improved Decklink support for input and output. Improved performance. The new engine classes are located in the `VisioForge.Core.LiveVideoCompositorV2` namespace. ## 2025.0.29 - [Cross-platform] Default video renderer on Windows has been changed to DirectX 11 ## 2025.0.17 - [Media Blocks SDK .Net] Added libCamera source support (can be used on Raspberry Pi) ## 2025.0.16 - [Media Blocks SDK .Net] Resolved issue with adding several AudioRendererBlocks to the pipeline ## 2025.0.14 - [Media Blocks SDK .Net] Added the "PushJPEGSourceSettings" class to configure the JPEG source for the "PushSourceBlock". You can use this class to set the JPEG source settings for the "PushSourceBlock". Also "video-from-images" sample added. ## 2025.0.7 - [ALL] Resolved window capture issues in cross-platform SDKs - [Media Blocks SDK .Net] Added the Bridge Source Switch sample ## 2025.0.5 - [iOS] Resolved issues with playback speed for some video files - [iOS] Added iOS Simulator support for all SDKs. Camera source is not supported in the simulator. ## 2025.0.3 - [MacOS] Resolved wrong stride issue for vertical camera videos on MacOS - [Video Capture SDK .Net] Resolved background color issue for the scrolling text overlay ## 2025.0 - [ALL] .Net 9 support - [Media Blocks SDK .Net] Added `AVIOutputBlock` to save video and audio streams to the AVI file format - [Media Blocks SDK .Net] `TeeBlock` constructor now accepts the media type as a parameter - [Video Capture SDK .Net] Added `Video_CaptureDevice_SetDefault` and `Audio_CaptureDevice_SetDefault` methods to the `VideoCaptureCore` class. You can use this method to set the default video and audio capture devices - [Cross-platform] Improved `Metal` video rendering performance on Apple devices - [All] Improved performance of common video processing operations in Windows classic SDKs - [CV] Added DNN face detectors for the `Media Blocks SDK .Net` and `Video Capture SDK .Net` - [Mobile] Improved AOT compatibility for iOS and Android - [WinUI] Improved performance of the `WinUI` video rendering - [Media Blocks SDK .Net] Added the `GetLastFrameAsSKBitmap` and `GetLastFrameAsBitmap` methods to `VideoSampleGrabberBlock` to get the last frame as a `SkiaSharp.SKBitmap` or `System.Drawing.Bitmap` - [Video Capture SDK .Net] `VideoCaptureCore`: Added the `AddFakeAudioSource` property to `FFMPEGEXEOutput`. The `Network_Streaming_Audio_Enabled` property of `VideoCaptureCore` should be set to false to use this fake audio. - [ALL] Improved WinUI (and MAUI on Windows) VideoView performance - [Video Capture SDK .Net] `VideoCaptureCore`: Added the `PIP_Video_CaptureDevice_CameraControl_` API to control the camera settings for the Picture-in-Picture mode - [X-engines] Added the headers support for the HTTP sources created using the `HTTPSourceSettings` class - [X-engines] Updated Avalonia samples, with projects for macOS, Linux, and Windows - [X-engines] Added NuGet redist packages for macOS and MacCatalyst (including MAUI) - [Video Capture SDK .Net] `VideoCaptureCore`: Added device path support for `PIP_Video_CaptureDevice_CameraControl` API - [Video Capture SDK .Net] `VideoCaptureCore`: Added the `FFMPEG_MaxLoadTimeout` property for IP camera sources. It allows you to set the maximum time to wait for the FFMPEG source to load the stream - [X-engines] Updated Linux support for `ALSA`, `PulseAudio` and `PipeWire` audio devices - [X-engines] Updated Linux support for `V4L2` devices - [X-engines] Avalonia samples has be changed to a modern 1-project structure - [X-engines] Resolved issue with `MAUI` crashes on Windows after `SkiaSharp` update - [X-engines] Resolved issue with `TextureView` crashes on Android in `MAUI` applications - [X-engines] Resolved playback issue for http sources using the `UniversalSourceBlock` - [X-engines] Added Mobile Streamer sample for Android - [X-engines] Added `OverlayManagerBlock` support for Android (now it's available for all platforms) - [Video Capture SDK .Net] `VideoCaptureCoreX`: Added `CustomVideoProcessor`/`CustomAudioProcessor` properties for all output formats. You can use these properties to set custom video/audio processing blocks for the output format. - [Media Blocks SDK .Net] Added the `KeyFrameDetectorBlock` to detect key frames in video streams (H264, H265, VP8, VP9, AV1, etc.) - [Media Blocks SDK .Net] Fixed licensing issue for the `LiveVideoCompositor` class ## 15.10.0 - [Windows] Updated window capture API to capture only the specified parent window by default. Added the `UpdateHotkey` method to the `WindowCaptureForm` class to update the hotkey for the window capture form. - [X-engines] Better AOT compatibility for default MAUI settings in iOS. - [Media Blocks SDK .Net] Added the `DNNFaceDetectorBlock` to detect faces and blur/pixelate them using OpenCV and DNN models. - [Media Blocks SDK .Net] Added the `MKVOutputBlock` to save video and audio streams to the MKV file format. - [X-engines] Better support for video source size dynamic changing in MAUI applications. - [X-engines] Resolved an issue with two or more VU meters in the same pipeline. - [X-engines] Resolved volume/mute error issue with audio mixer in Live Video Compositor engine. - [X-engines] The `Spinnaker` source for `FLIR`/`Teledyne` cameras is included in the main package and no longer requires an additional plugin. - [Video Capture SDK .Net] Resolved the issue with the `SeparateCapture` API if no `VideoView` was used. - [X-engines] The `MediaBlocksPipeline` constructor no longer has the `live` parameter. For more customizable pipelines, video and audio renderers got the `IsSync` property (`true` by default). - [X-engines] Resolved `VideoViewTX` crash in MAUI Android applications. - [X-engines] `IVideoEncoder` interface added to the `MPEG2VideoEncoder` class. It allows the use of `MPEG2VideoEncoder` with `MPEGTSOutput`, `AVIOutput`, and other output classes. - [X-engines] Resolved the issue with window capture using the `ScreenCaptureD3D11SourceSettings` class. If the rectangle was incorrect or not specified, it caused an error. - [X-engines] `Metal` renderer was added to SDK for Apple devices and used by default for iOS and MAUI. - [Media Blocks SDK .Net] Added the MAUI Screen Capture sample. - [Video Capture SDK .Net] VideoCaptureCore: Added the `VLC_CustomDefaultFrameRate` property to `IPCameraSourceSettings` to set a custom frame rate for the VLC IP camera source if the source does not provide the correct frame rate. - [Media Blocks SDK .Net] `RTSPSourceBlock`: If the RTSP source has audio but you've disabled the audio stream in `RTSPSourceSettings`, SDK will add a null renderer automatically to prevent warnings. - [ALL] Resolved issue with `VideoFrameX.ToBitmap()` call (wrong color space) - [Windows] Updated KLV support in MPEG-TS output - [Windows] Resolved MediaPlayerCore serialization issue - [ALL] Video renderer settings class no longer contains background color. Use the VideoView background color property instead. - [X-engines] Updated GStreamer libraries - [X-engines] Resolved video rendering issues on Android and iOS - [X-engines] iOS crash fixed during VideoViewGL usage - [X-engines] Added default AAC encoder for iOS - [X-engines] iOS camera source update for high frame rate support - [Windows] Updated VLC source - improved file loading speed - [Media Blocks SDK .Net]: Added the `UniversalDemuxBlock` allows to demux video and audio streams from a file in MP4, MKV, AVI, MOV, TS, VOB, FLV, OGG, and WebM formats - [Windows] Resolved FFMPEG stability issues - [X-engines] Resolved issue with loopback audio source using VideoCaptureCoreX and audio capture to file - [X-engines] Added SRT source and sink support in Media Blocks SDK .Net and Video Capture SDK .Net - [Video Capture SDK .Net] VideoCaptureCore: The `IP_Camera_ONVIF_ListSourcesAsyncEx` method got an overload version with a callback for a more responsible UI - [X-engines] RTSP source compatibility update - [X-engines] `Breaking API change`. Starting with this update, the SDK uses `IAudioRendererSettings` interface implementations for audio output configuration. WASAPI output got the custom configuration classes. Output\_AudioDevice properties of `VideoCaptureCoreX`/`MediaPlayerCoreX` type have been changed to `IAudioRendererSettings`. You can create the `AudioRendererSettings` class instance from `AudioOutputDeviceInfo` using the default constructor. - [X-engines] Resolved problem with missed Media Foundation sources during device enumeration - [X-engines] Resolved RTSP source problems with audio connection in some situations - [X-engines] Added the RTSP Preview Demo to Media Blocks SDK .Net - [Windows] FFMPEG outputs and source updated to FFMPEG v7.0. - [X-engines] Fixed rare crashes in RTSP source when camera information is not available for some reason (network issue) - [X-engines] Resolved an issue with `WASAPI/WASAPI2` audio renderer usage - [X-engines] Resolved an issue with the audio loopback audio source on Windows - [X-engines] Improved iOS video rendering performance and stability - [X-engines] Added AWS S3 Sink output for Media Blocks SDK .Net - [X-engines] Added Allied Vision USB3/GigE cameras support in Media Blocks SDK .Net and Video Capture SDK .Net ## 15.9 - [X-engines] Resolved wrong aspect ratio with video resize effect/block - [X-engines] Updated GStreamer redist - [X-engines] Added Basler USB3/GigE cameras support in Media Blocks SDK .Net and Video Capture SDK .Net - [Video Edit SDK .Net] VideoEditCoreX: The TextOverlay class changed to use SkiaSharp-based font settings. Additionally, you can set the custom font file name or configure all rendering parameters using custom SKPaint. - [Windows] Added Stream support in `MediaInfoReader`. You can get the video/audio file information from a stream (DB, network, memory, etc.). - [X-engines] Updated Live Video Compositor engine, which improved support of the file sources - [Video Capture SDK .Net] Added camera-covered detector into the `Computer Vision Demo` and the `VisioForge.Core.CV` package - [X-engines] Added API to get snapshots from video files using MediaInfoReaderX: GetFileSnapshotBitmap, GetFileSnapshotSKBitmap, GetFileSnapshotRGB - [X-engines] iOS support in MAUI samples - [X-engines] Resolved memory leak issue for RTSP sources - [Media Player SDK .Net] MediaPlayerCore: Added support for data streams in video files using the FFMPEG source engine. Add the OnDataFrameBuffer event to get data frames (KLV or other) from the video file. - [Video Capture SDK .Net] VideoCaptureCore: Added support for data streams in video files using the IP Capture FFMPEG source engine. Add the OnDataFrameBuffer event to get data frames (KLV or other) from the MPEG-TS UDP network stream or other supported source. - [Video Capture SDK .Net] VideoCaptureCore: Added the FFMPEG\_CustomOptions property to the IPCameraSourceSettings class. This property allows you to set custom FFMPEG options for the IP camera source - [Windows] Fixed the hang problem with the FFMPEG source when a network connection is lost - [Media Blocks SDK .Net] Added RTSP MultiView in Sync Demo - [X-engines] Added support for FLIR/Teledyne cameras (USB3Vision/GigE) using the Spinnaker SDK - [Video Edit SDK .Net] VideoEditCoreX: Added support for .Net Stream usage as an input source - The IAsyncDisposable interface was added to all SDK's core classes. The `DisposeAsync` call should be used to dispose of the core objects using async methods. - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved issues with Android video capture (sometimes started only one time) - [Media Blocks SDK .Net] Added HLS streaming sample - [Video Capture SDK .Net] VideoCaptureCore: Resolved crash if the `multiscreen` is enabled and screens added as window's handles (WinForms) - [X-engines] Improved MAUI video rendering speed - [X-engines] Resolved MAUI media playback issues (decoding) in MAUI Android - [X-engines] Resolved an issue with the H264 webcam sources (sometimes not connected) - [X-engines] Resolved an issue with audio stream playback in the Live VideoCompositor engine - [Media Blocks SDK .Net] Resolved a bad audio issue while mixing using the Live Video Compositor engine - [Media Blocks SDK .Net] Added Decklink output and file source into the Live Video Compositor sample - [Media Player SDK .Net] MediaPlayerCore: Added growing MPEG-TS file support for the VLC engine. You can play growing MPEG-TS files while it's recorded ## 15.8 - [X-engines] [API breaking change] DeviceEnumerator can now be used only by using `DeviceEnumerator.Shared` property. One enumerator per app is required. DeviceEnumerator objects used by API have been removed - [X-engines] [API breaking change] Android Activity is not required anymore to create SDK engines - [X-engines] [API breaking change] X-engines require additional initialization and de-initialization steps. To initialize SDK, use the `VisioForge.Core.VisioForgeX.InitSDK()` call. To de-initialize SDK, use the `VisioForge.Core.VisioForgeX.DestroySDK()` call. You need to initialize SDK before any SDK class usage and de-initialize SDK before the application exits. - [Windows] Improved MAUI video rendering performance in Windows - [Windows] Added a mouse highlight for screen capture sources - [Windows] Resolved a CallbackOnCollectedDelegate call issue with the BasicWindow class - [Avalonia] Resolved an issue with Avalonia VideoView resize - [X-engines] Added the StartPosition and StopPosition properties to UniversalSourceSettings. You can use these properties to set the start and stop positions for the file source. - [ALL] Resolved the issue with passwords with special characters used for RTSP sources - [ALL] Resolved the rare video flip issue with the Virtual Camera SDK engine - [ALL] The VisioForge MJPEG Decoder filter was removed from the SDK's NuGet packages. You can optionally add it to your project by file copying or COM registration deployment. - [X-engines] Fixed memory leak in the OverlayManager - [Media Blocks SDK .Net] Resolved issue with the VideoSampleGrabberBlock, SetLastFrame option - [Video Capture SDK .Net] VideoCaptureCoreX: WASAPI and WASAPI2 audio sources can be used now with the VideoCaptureCoreX engine - [X-engines] DeviceEnumerator got events to notify about devices added/removed: OnVideoSourceAdded, OnVideoSourceRemoved, OnAudioSourceAdded, OnAudioSourceRemoved, OnAudioSinkAdded, OnAudioSinkRemoved - [X-engines] Added custom error handler support for MediaBlocks, VideoCaptureCoreX, and MediaPlayerCoreX engines. Use the IMediaBlocksPipelineCustomErrorHandler interface and the SetCustomErrorHandler method to set a custom error handler. - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved issue with incorrect device index error for KS video sources (Windows) - [Video Capture SDK .Net] VideoCaptureCore: Added Virtual\_Camera\_Output\_AlternativeAudioFilterName property to set a custom audio filter for the Virtual Camera SDK output - [Video Edit SDK .Net] VideoEditCore: Added Virtual\_Camera\_Output\_AlternativeAudioFilterName property to set a custom audio filter for the Virtual Camera SDK output - [Media Player SDK .Net] MediaPlayerCore: Added Virtual\_Camera\_Output\_AlternativeAudioFilterName property to set a custom audio filter for the Virtual Camera SDK output - [Video Capture SDK .Net] VideoCaptureCoreX: Added NDI streaming support and sample app. - [Media Blocks SDK .Net] Added the BufferSink block to get video/audio frames from the pipeline - [Media Blocks SDK .Net] Added the CustomMediaBlock class to create custom media blocks for any GStreamer element - [Media Blocks SDK .Net] Added the UpdateChannel method to update the channel of the bridge source or sink - [Media Player SDK .Net] MediaPlayerCore: Updated Tempo effect. - [X-engines] Updated device enumerator. Removed unwanted firewall dialog when listing NDI sources. - [X-engines] Fixed an issue with the video mixer when adding/removing video sources. - [Media Blocks SDK .Net] Added VideoCropBlock and VideoAspectRatioCropBlock blocks to crop video frames. - [Media Blocks SDK .Net] Resolved wrong frame rate issue with VideoRateBlock. - [All] Resolved an issue with the Tempo audio effect. - [Video Capture SDK .Net] VideoCaptureCore: Added WASAPI audio renderer support for the VideoCaptureCore engine. ## 15.7 - [ALL] .Net 8 support - [Video Capture SDK .Net] VideoCaptureCore: Fixed problem with the OnNetworkSourceDisconnect event being called twice. - [X-engines] Added the MPEG-2 video encoder. - [X-engines] Added the MP2 audio encoder. - [X-engines] Resolved Decklink enumeration issues. - [X-engines] Default VP8/VP9 settings changed to live recording. - [X-engines] Added DNxHD video encoder support. - [Video Capture SDK .Net] VideoCaptureCoreX: Fixed problem with audio source format setting (regression). - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved WPF native rendering issue with a pop-up window. - [All] Avalonia 11.0.5 support. - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved licensing issues. - [Video Capture SDK .Net] VideoCaptureCore: Start/StartAsync method will return false if the video capture device is already used by another application. - [All] Updated VLC source (libVLC 3.0.19). - [All] Updated FFMPEG sources and encoders. Resolved issue with missed MSVC dependencies. - [Video Capture SDK] Updated ONVIF engine. - [Cross-platform SDKs] Updated Decklink source. Resolved the issue with the incorrect device name. - [All] SkiaSharp security updates. - [Cross-platform SDKs] Updated Overlay Manager. Added OverlayManagerDateTime class to draw current date time and custom text. - [Cross-platform SDKs] Updated OverlayManagerImage. Resolved issue with System.Drawing.Bitmap usage. - [ALL] VideoCaptureCore: Resolved rare crash issue with WinUI VideoView - [Video Capture SDK .Net] VideoCaptureCore: Updated FFMPEG.exe output. Improved support of x264 and x265 encoders of custom FFMPEG builds. ## 15.6 - [Video Capture SDK .Net] VideoCaptureCore: Improved video crop performance on modern CPUs - [ALL] VideoCaptureCore, MediaPlayerCore, VideoEditCore: Added the static CreateAsync method that can be used instead of the constructor to create engines without UI lag. - [Video Capture SDK .Net] VideoCaptureCore: Resolved issues with video crop. - [Video Capture SDK .Net] VideoCaptureCoreX: Added video overlays API. The Overlay Manager Demo shows how to use it. - [Video Capture SDK .Net] Improved HW encoder detection. If you have several GPUs, sometimes only the major GPU can be used for video encoding. - [Cross-platform SDKs] Updated Avalonia VideoView. Resolved issue with VideoView recreation. - [Media Player SDK .Net] MediaPlayerCoreX: Resolved startup issue with the Android version of the MediaPlayerCoreX engine. - [Media Player SDK .Net] MediaPlayerCore: Video\_Stream\_Index property has been replaced with Video\_Stream\_Select/Video\_Stream\_SelectAsync methods. - [Media Player SDK .Net] MediaPlayerCoreX: Added Video\_Stream\_Select method. - [Video Capture SDK .Net] VideoCaptureCore: Network\_Streaming\_WMV\_Maximum\_Clients property moved to WMVOutput class. You can set the maximum number of clients for network WMV output. - [All] Updated WPF rendering. Improved performance for 4K and 8K videos. - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved issue with multiple outputs used. - [Video Capture SDK .Net] VideoCaptureCoreX: Resolved issue with OnAudioFrameBuffer event. - [Video Capture SDK .Net] Decklink source changed to improve startup speed. The Decklink\_CaptureDevices method has been replaced by async Decklink\_CaptureDevicesAsync. - [Media Player SDK .Net] MediaPlayerCoreX: Added Custom\_Video\_Outputs/Custom\_Audio\_Outputs properties to set custom video/audio renderers - [Media Player SDK .Net] MediaPlayerCoreX: Added Decklink Output Player Demo (WPF) - [Video Edit SDK .Net] Added Multiple Audio Tracks Demo (WPF) - [Video Edit SDK .Net] Updated MP4 output for multiple audio tracks - [Cross-platform SDKs] Updated device enumerator - [Video Capture SDK .Net] Resolved issue with VU meter in cross-platform engine - [Cross-platform SDKs] Resolved issue with VU Meter (event not fired) - [Media Player SDK .Net] Updated memory playback - [ALL] Added IAsyncDisposable interface support for cross-platform core classes. It should be used to dispose of the core objects in async methods. - [Video Capture SDK .Net] Added madVR support for mutiscreen - [Video Capture SDK .Net] Resolved NDI enumerating issue in the VideoCaptureCore engine - [Media Player SDK .Net] Added madVR Demo - [Video Capture SDK .Net] Added madVR Demo - [ALL] Resolved madVR issues in all SDKs - [Media Blocks SDK .Net] Added NDI Source demo - [Video Capture SDK .Net] Added NDI support for cross-platform engine - [ALL] Resolve the "image not found" issue with the WinUI NuGet package - [Media Blocks SDK .Net/Media Player SDK .Net (cross-platform)] Added MP3+CDG Karaoke Player demo - [Media Blocks SDK .Net] Added CDGSourceBlock for MP3+CDG karaoke files playback - [ALL] Improved madVR support - WinUI VideoView updated to fix issues during audio file playback - [Video Capture SDK .Net] Improved VNC source support for the VideoCaptureCoreX engine. - [Video Capture SDK .Net] Added VNC source support for the VideoCaptureCoreX engine. You can use VNCSourceSettings class to configure Video\_Source. - [Media Blocks SDK .Net] Added VNC source support. You can use the VNCSourceBlock class as a video source block. - [Video Capture SDK .Net] Video\_Resize property has been changed to IVideoResizeSettings type. You can use the VideoResizeSettings class to perform classic resize the same as before or use MaxineUpscaleSettings/MaxineSuperResSettings to perform AI resizing on Nvidia GPU using Nvidia Maxine SDK (SDK or SDK models are required to deploy). - [ALL] Resolved issues with NDI source detection in the local network - [ALL] Added KLVParser class to read and decode data from KLV binary files. - [ALL] Added KLVFileSink block. You can export KLV data from MPEG-TS files. - [Media Blocks SDK .Net] Added KLV demo. - [Video Capture SDK .Net] Added MJPEG network streamer. - [ALL] Added WASAPI 2 support. - [Media Blocks SDK .Net] Updated Video Effects API. Added Grayscale media block. - [Media Blocks SDK .Net] Added Live Video Compositor API and sample. - [ALL] Updated Avalonia VideoView control. Resolved issues with video playback on Windows on HighDPI displays. - [Video Capture SDK .Net] Added CustomVideoFrameRate property to MFOutput. You can set a custom frame rate if your source provides an incorrect frame rate (IP camera, for example). - [Video Capture SDK .Net] Updated NVENC encoder. Resolved issue with high-definition video capture. - [Video Capture SDK .Net] Resolved issue with TV Tuning on Avermedia devices - [Media Blocks SDK .Net] Added OpenCV blocks: CVDewarp, CVDilate, CVEdgeDetect, CVEqualizeHistogram, CVErode, CVFaceBlur, CVFaceDetect, CVHandDetect, CVLaplace, CVMotionCells, CVSmooth, CVSobel, CVTemplateMatch, CVTextOverlay, CVTracker - [CV] Resolved the issue with wrong face coordinates. - [CV, Media Blocks SDK .Net] Added Face Detector block. - [Media Blocks SDK .Net] Added rav1e AV1 video encoder. - [Media Blocks SDK .Net] Added GIF video encoder. - [Media Blocks SDK .Net] Added NDI Sink and NDI source blocks. - [ALL] Resolved NDI SDK detection issues. - [Media Blocks SDK .Net] Updated Speex encoder. - [Media Blocks SDK .Net] Updated Video Mixer block. - [ALL] Added Save/Load methods for output format to serialize into JSON. - [Media Blocks SDK .Net] Added MJPEG HTTP Live streaming sink block. - [ALL] Resolved MP4 HW QSV H264 regression. - [ALL] WinForms and WPF VideoView stability updates. - [Media Player SDK .Net] Removed FilenamesOrURL legacy property. Please use the `Playlist` API instead. - [Media Blocks SDK .Net] Added fade-in/out feature for image overlay block. - [ALL] Telemetry update - [ALL] SDKs updated to use the `ObservableCollection` instead of the `List` in public API. - [ALL] Updated MP4 HW output. Improved NVENC performance. - [Media Blocks SDK .Net] Added Video Compositor sample. - [Media Blocks SDK .Net] Added YouTubeSink and FacebookLiveSink blocks with custom YouTube/Facebook configurations. The `RTMPSink` can stream to YouTube/Facebook in the same way as before. - [Media Blocks SDK .Net] Added SqueezeBack video mixer block. - [ALL] Updated scrolling text logo. We've added the Preload method to render a text overlay before playback. - [ALL] Updated scrolling text logo (performance) - [Media Blocks SDK .Net] Updated Decklink sink blocks - [ALL] Resolved crashes with a text logo with a custom resolution - [Media Blocks SDK .Net] Added Intel QuickSync H264, HEVC, VP9, and MJPEG encoders support. - [Video Edit SDK .Net] Added FastEdit\_ExtractAudioStreamAsync method to extract the audio stream from the video file. - [Video Edit SDK .Net] Added "Audio Extractor" WinForms sample. - [Media Blocks SDK .Net] Updated MP4SinkBlock. The sink can split output files by duration, file size, or timecode. Use MP4SplitSinkSettings instead of MP4SinkSettings to configure. - [Video Capture SDK .Net] Added the OnMJPEGLowLatencyRAWFrame event that fired when the MJPEG low latency engine received a RAW frame from a camera. - [Media Blocks SDK .Net] Added VideoEffectsBlock to use video effects, available in Windows SDKs - [Media Blocks SDK .Net] Updated Decklink source - [Media Blocks SDK .Net] Added Decklink Demo (WPF) - [ALL] Resolved the DeinterlaceBlend video effect crash - [ALL] Used 3rd-party libraries moved to VisioForge.Libs.External assembly/NuGet - [ALL] Added Nvidia Maxine Video Effects SDK (BETA) and sample app for Media Player SDK .Net and Video Capture SDK .Net - [Video Capture SDK .Net] Added Decklink\_Input\_GetVideoFramesCount/Decklink\_Input\_GetVideoFramesCountAsync API to get total and dropped frames for the Decklink source - [ALL] VisioForge HW encoders update ## 15.5 - .Net 7 support - Added NetworkDisconnect event support to MJPEG Low Latency IP camera engine - Added Linux support for the VideoEditCoreX-based demos - Added OnRTSPLowLatencyRAWFrame event to get RAW frames from RTSP stream, using RTSP Low Latency engine - Added AutoTransitions property to the VideoEditCoreX engine - System.Drawing.Rectangle and System.Drawing.Size types are replaced by VisioForge.Types.Rectangle and VisioForge.Types.Size in all crossplatform APIs - MAUI samples (BETA) are added - Improved compatibility with Snap Camera for MP4 HW encoding - Online licensing updated - Added Camera Light demo - Added segments support in Media Player SDK .Net (Cross-platform engine) - Added Playlist API in Media Player SDK .Net (Windows-only engine) - Resolved issues with the "rtsp\_source\_create\_audio\_resampler" call in the RTSP Low Latency engine in Video Capture SDK .Net (Windows-only engine) - Added support for multiple Decklink outputs in Video Capture SDK .Net and Video Edit SDK .Net (Windows-only engine) - Resolved issues with the reverse playback engine in Media Player SDK .Net (Windows-only engine) - ONVIFControl and other ONVIF-related APIs are available for all platforms - API breaking change: the frame rate changed from double to VideoFrameRate in all APIs - Added GPU HW decoding for VLC engine - Resolved issue with WPF HighDPI apps that use EVR - Resolved issue with MediaPlayerCore.Video\_Renderer\_SetCustomWindowHandle method - Added previous frame playback in Media Player SDK .Net (Cross-platform engine) - Added WPF Screen Capture Demo to Media Blocks SDK .Net ## 15.4 - Resolved an issue with ignored Play\_PauseAtFirstFrame property - Updated HighDPI support in WinForms samples - Resolved an issue with HighDPI support for the Direct2D video renderer - Added additional API to ONVIFControl class: GetDeviceCapabilities, GetMediaEndpoints - Resolved forced reencoding issue with FFMPEG files joining without reencoding - Sentry update - Added video interpolation settings for Zoom and Pan video effects - Added GtkSharp UI framework support for video rendering - FastEdit API has been changed to async - Resolved screen flip issue with Video\_Effects\_AllowMultipleStreams property of Video Capture SDK .Net core - Updated RTSP MultiView demo (added GPU decoding, added RAW stream access) - Added OnLoop event into Media Player SDK .Net - Added Loop feature into Media Blocks SDK .Net - Avalonia VideoView was downgraded to 0.10.12 because of Avalonia UI problems with NativeControl - Added File Encryptor demo for Video Edit SDK .Net ## 15.3 - App start-up time improved for PCs with Decklink cards - NDI SDK v5 support - Resolved an issue with MKV Legacy output (wrong cast exception). - Zoom and pan effects performance optimizations - Added basic Media Blocks API (WIP) - Added HLS network streaming to Video Edit SDK .Net - Added Rotate property to WPF VideoView. You can rotate the video by 90, 180, or 270 degrees. Also, you can use the GetImageLayer() method to get the Image layer and apply custom transforms - API change - FilterHelpers renamed to FilterDialogHelper - VisioForge.Types and VisioForge.MediaFramework assemblies merged into VisioForge.Core - UI classes moved to VisioForge.Core.UI.\* assemblies and independent NuGet packages - VisioForge.Types renamed to VisioForge.Core.Types - VisioForge.Core no longer depends on the Windows Forms framework ## 15.2 - Added HorizontalAlignment and VerticalAlignment properties to the text and image logos - Updated ONVIF support, resolved an issue with username and password specified in URL but not specified in source settings - Resolved an issue with the FFMPEG.exe output dialog - Resolved an issue with the separate capture in a service applications - SDK migrated to System.Text.Json from NewtonsoftJson - Updated DirectCapture output for IP cameras - Video processing performance optimizations - IPCameraSourceSettings.URL property type changed from string to a `System.Uri` - Added DirectCapture ASF output for IP cameras ## 15.1 - Disabled Sentry debug messages in the console - Added Icecast streaming - VideoStreamInfo.FrameRate property type changed to VideoFrameRate (with numerator and denominator) from double - Updated WPF VideoView, resolved the issue for IP camera stream playback - API breaking change: `VisioForge.Controls`, `VisioForge.Controls.UI`, `VisioForge.Controls.UI.Dialogs`, and `VisioForge.Tools` assemblies are merged inside the `VisioForge.Core` assembly - Audio effect API now uses string name instead of index - Added Android support in Media Player SDK .Net - Added a new GStreamer-based cross-platform engine to support Windows and other platforms within the v15 development cycle ## 15.0 - Added StatusOverlay property for VideoCapture class. Assign the `TextStatusOverlay` object to this property to add text status overlay, for example, to show "Connecting..." text during IP camera connecting. - RTSP Live555 IP camera engine has been removed. Please use RTSP Low Latency or FFMPEG engines. - Resolved SDK\_Version possible issue. - Added Settings\_Load API. You can load the settings file saved by Settings\_JSON. Be sure that device names are correct. - Resolved issue with an exception if separate capture started before Start/StartAsync method call. - RTP support for the VLC source engine. - API breaking change: SDK\_State property has been removed. We do not have TRIAL and FULL SDK versions anymore. - API breaking change: DirectShow\_Filters\_Show\_Dialog, DirectShow\_Filters\_Has\_Dialog, Audio\_Codec\_HasDialog, Audio\_Codec\_ShowDialog, Video\_Codec\_HasDialog, Video\_Codec\_ShowDialog, Filter\_Supported\_LAV, Filter\_Exists\_MatroskaMuxer, Filter\_Exists\_OGGMuxer, Filter\_Exists\_VorbisEncoder, Filter\_Supported\_EVR, Filter\_Supported\_VMR9 and Filter\_Supported\_NVENC has been moved to VisioForge.Tools.FilterHelpers class. - The `VFAudioStreamInfo`/`VFVideoStreamInfo` classes use the `Timespan` for the duration. - Decklink types from VisioForge.Types assembly moved to VisioForge.Types.Decklink namespace. - Telemetry updated. - Custom redist loader updated. - NDI update. - API breaking change: The `Status` property was renamed to the `State`. The property type is `PlaybackState` in all SDKs. - API breaking change: UI controls split into Core (VideoCaptureCore, MediaPlayerCore, VideoEditCore) and VideoView. - API breaking change: Video\_CaptureDevice... properties merged into Video\_CaptureDevice property of VideoCaptureSource type. - API breaking change: Audio\_CaptureDevice... properties merged into Audio\_CaptureDevice property of AudioCaptureSource type. - API breaking change: In the Media Player SDK, the `Source_Stream` API properties were merged into the `Source_MemoryStream` property of the `MemoryStreamSource` type - Updated DVD playback - Updated FFMPEG source - API breaking change: Media Player SDK types moved from VisioForge.Types namespace to VisioForge.Types.MediaPlayer - API breaking change: Video Capture SDK types moved from VisioForge.Types namespace to VisioForge.Types.VideoCapture - API breaking change: Video Edit SDK types moved from VisioForge.Types namespace to "VisioForge.Types.VideoEdit" - API breaking change: Output types moved from VisioForge.Types namespace to VisioForge.Types.Output - API breaking change: Video Effects types moved from VisioForge.Types namespace to VisioForge.Types.VideoEffects - API breaking change: Audio Effects types moved from VisioForge.Types namespace to VisioForge.Types.AudioEffects - API breaking change: Event types moved from VisioForge.Types namespace to VisioForge.Types.Events - Added Video\_Renderer\_SetCustomWindowHandle method to set custom video renderer by Win32 window/control HWND handle ## 14.4 - Windows 11 support - Telemetry update - Resolved issues with Picture-in-Picture in 2x2 mode - Resolved issues with MJPEG Low Latency source in .Net 5/.Net 6/.Net Core 3.1 - Resolved issue with UDP network streaming for Decklink source - VFMP4v11Output renamed to VFMP4HWOutput - Added Microsoft H265 encoder support - Added Intel QuickSync H265 encoder support - Added OnDecklinkInputDisconnected/OnDecklinkInputReconnected events - Updated Decklink output - Resolved issues with Separate capture for MP4 HW, MOV, MPEG-TS, and MKVv2 outputs - Added Video\_CaptureDevice\_CustomPinName property. You can use this property to set a custom output pin name for a video capture device with several output video pins - Custom redist configuration updated - Updated IP camera RTSP Low Latency engine ## 14.3 - An issue with Video Resize filter creation for NuGet redists has been resolved - Telemetry update - Updated VFDirectCaptureMP4Output output - .Net 6 (preview) support - Nvidia CUDA removed. NVENC is a modern alternative and is available for H264/HEVC encoding. - IP camera MJPEG Low Latency engine has been updated - The NDI source listing has been updated - Improved ONVIF support - Added .Net Core 3.1 support for RTSP Low Latency source engine - Resolved issues with Picture-in-Picture for 2x2 mode - Split project and solutions by independent files for .Net Framework 4.7.2, .Net Core 3.1, .Net 5 and .Net 6 ## 14.2 - An issue with audio stream capture with enabled Virtual Camera SDK output was resolved - VFMP4v8v10Output was replaced with VFMP4Output - The "CanStart" method was added for Video\_CaptureDevices items. The method returns true if the device can start and is not used exclusively in another app - Added async/await API to the ONVIFControl - An issue with wrong ColorKey processing in the Text Overlay video effect was resolved - Added forced frame rate support for the RTSP Low Latency IP camera source - MP4v11 AMD encoders were updated - The timestamp issue that happened during the MP4v11 separate capture pause/resume was resolved - FFMPEG.exe network streaming update - FFMPEG output was updated to the latest FFMPEG version - VC++ redist is no longer required to be installed. VC++ linking changed to static (except optional XIPH output) - Many base DirectShow filters moved to the VisioForge\_BaseFilters module ## 14.1 - Added WPF VideoView control. You can push video frames from the OnVideoFrameBuffer event to control to render them - Correct default transparency value for a text logo - ONVIF support added to .Net 5 / .Net Core 3.1 builds - Added IP\_Camera\_ONVIF\_ListSourcesAsync method to discover ONVIF cameras in the local network - (BREAKING API CHANGE) Changed video capture device API for frame rates enumerating to support modern 4K cameras - Updated MJPEG Decoder (improved performance) - Removed MP4 v8 legacy encoders - INotifyPropertyChanged support in WinForms/WPF wrappers to provide MVVM application support - Resolved issue with RTMPS streaming to Facebook - IP camera source added to the TimeShift demo - Added separate output support for MOV - Added fast-start FFMPEG flag for MP4v11 output that used FFMPEG MP4 muxer - Added GPU decoding for the IP Camera source in demo applications - Added CustomRedist\_DisableDialog property to disable the redist message dialog - Removed Kinect assemblies and demos. Please contact us if you still need Kinect packages - MP4v10 default profile has been changed to Baseline / 5.0 for better browser compatibility ## 14.0 - .Net 5.0 support - Resolved issue with not visible Decklink sources in NuGet SDK version - Resolved issue with device added/removed notifier - Added alternative NDI source in Video Capture SDK .Net - Added NDI streaming (server) in Video Capture SDK .Net - Resolved Separate Capture usage issue for NuGet deployment - Resolved issue with merged text/image logos - Updated device notifier - Added CameraPowerLineControl class to control webcam power line frequency option - Legacy audio effects have been removed. - Removed HTTP\_FFMPEG, RTSP\_UDP\_FFMPEG, RTSP\_TCP\_FFMPEG and RTSP\_HTTP\_FFMPEG from VFIPSource enumeration. You can use the Auto\_FFMPEG value - Updated HLS server. Correct error reporting about used port - Added NDI streaming (server) in Video Edit SDK .Net - Added NDI streaming (server) in Media Player SDK .Net - Added IP\_Camera\_CheckAvailable method in Video Capture SDK .Net - Updated FFMPEG Source filter, more supported codecs, and added GPU decoding ## 12.1 - Migrated to .Net 4.6 - Added Debug\_DisableMessageDialogs property to disable error dialog if OnError event is not implemented. - Fixed issue with resizing on the pause for WPF controls. - Updated ONVIF engine in Video Capture SDK .Net - Updated What You Hear source in Video Capture SDK .Net - Added OnPause/OnResume events - Updated YouTube demo in Media Player SDK .Net - Improved support of webcams with integrated H264 encoder in Video Capture SDK .Net - Updated VLC source - Removed unwanted warning in MP4 v11 output - One installer for TRIAL and FULL versions - Same NuGet packages for TRIAL and FULL versions - .Net Core NuGet packaged merged with .Net Framework package - Added NuGet redists. Deployment was never so simple! ## 12.0 - Async / await API for all SDKs - Breaking API change: All time-related API now uses TimeSpan instead of long (milliseconds) - Tag reader/writer - correct logo loading for some video formats - Removed legacy DirectX 9 video effects - Fixed audio conversion progress issue in Video Edit SDK .Net - Improved .Net Core compatibility - Virtual Camera SDK output added to Media Player SDK .Net (as one of the video renderers) - NewTek NDI devices support added to Video Capture SDK .Net as a new engine for IP cameras - Added Video\_Effects\_MergeImageLogos and Video\_Effects\_MergeTextLogos properties. If you have three or more logos, you can set these properties to true to optimize video effects' performance - Added playlist type option for HLS network streaming - Added integrated lightweight HTTP server for HLS network streaming - Added VR 360° video support in Media Player SDK .Net - Improved DirectX 11 video processing - Added MPEG-TS AAC-only no video support for MPEG-TS output - Improved What You Hear audio source - Several new demo applications - Improved MP4 v11 output - Separate capture for MP4 v11 can split files without frame lose - Many minor bugfixes - .Net Core assemblies updated to .Net Core 3.1 LTS - Updated demos repository on GitHub ## 11.4 - Added ASP.Net MVC video conversion demo app to Video Edit SDK .Net - Alternative OSD implementation to handle Windows 10 changes - Updated GPU video effects - Updated memory source in Media Player SDK .Net - Updated OSD API - Resolved issues with video encryption using binary keys - Update screen capture demos for Video Capture SDK .Net, added window selection to capture. You can capture any window, including windows in the background - Mosaic effect added for Computer Vision demo in Video Capture SDK .Net - Added Multiple IP Cameras Demo (WPF) in Video Capture SDK .Net - Added custom video resize option for MP4v11 output - Merge module (MSM) redists added to all SDKs - Updated FFMPEG.exe output using pipes instead of virtual devices - Resolved issue with PIP custom output resolution option in Video Capture SDK .Net - Resolved issue with file lock using LAV engine in Media Player SDK .Net - Added DirectX11-based GPU video processing ## 11.3 - Resolved issue with audio renderer connection if Virtual Camera SDK output enabled in Video Capture SDK - Improved subtitles support with autoloading in Media Player SDK .Net - Updated audio fade-in/fade-out effects - Added MIDI and KAR files support in Media Player SDK .Net - Added CDG karaoke files support (and new demo application) in Media Player SDK .Net - Added Async playback in Media Player SDK .Net - Updated integrated JSON serializer - Added optional GPU decoding in Media Player SDK .Net. Available decoding engines: DXVA2, Direct3D 11, nVidia CUVID, Intel QuickSync - Added .Net Core 3.0 support, including WinForms and WPF demo apps (Windows only) ## 11.2 - Added Loop property to Video Edit SDK .Net - Updated audio enhancer - Updated RTSP Low Latency source - Resolved crop issue for Decklink source - Added property to use TCP or UDP in RTSP Low Latency engine - Deployment without COM registration and admin rights for Video Edit SDK and Media Player SDK (BETA) - Updated video mixer with improved performance - Added YouTube playback code snippet - Added method to move OSD ## 11.1 - Fixed seeking issue with some MP4 files in Video Edit SDK - Fixed stretch/letterbox issue in the WPF version of all SDKs - Fixed issue with an equalizer on sample rate 16000 or less - Fixed problem with sample grabber for DirectShow source in Media Player SDK - Fixed encrypted files playback in Media Player SDK - Added DVDInfoReader class to read info about DVD files - Resolved issue with wrong file name in OnSeparateCaptureStopped event - Improved barcode detection quality for rotated images - The minimal .Net Framework version is .Net 4.5 now - Improved YouTube playback in Media Player SDK. Added OnYouTubeVideoPlayback event to select video quality for playback - Added the `Play_PauseAtFirstFrame` property to the Media Player SDK .Net. If true playback will be paused on the first frame - Multiple screen support in Screen Capture demo in Video Capture SDK .Net - Resolved issue with network stream playback in Media Player SDK .Net WPF applications - Added low latency HTTP MJPEG stream playback (IP cameras or other sources) in Video Capture SDK .Net - Added Fake Audio Source DirectShow filter, which produces a tone signal - Updated Computer Vision demo in Video Capture SDK .Net - Added Frame\_GetCurrentFromRenderer method to all SDKs. Using this method, you can get the currently rendered video frame directly from the video renderer. - Added low latency RTSP source playback in Video Capture SDK .Net ## 11.0 - Fixed bug with MP4 v11 output, custom GOP settings - Updated MJPEG Decoder - Fixed bug with MP4 v11 output. Added Windows 7 full support - OnStop event of Video Edit SDK returns a successful status - Video Capture SDK Main Demo update - multiscreen can automatically use connected external displays - Media Player SDK Main Demo update - multiscreen can automatically use connected external displays - Added fade-in / fade-out for text logo - Updated Decklink output - Video Edit SDK can fast-cut files from network sources (HTTP/HTTPS) - Added Computer Vision demo, with cars/pedestrian counter and face/eyes/nose/mouth detector/tracker - Updated MP4 output to use alternative muxer that provides constant frame rate - Added MPEG-TS output - Added MOV output ---END OF PAGE--- ## Deploy VisioForge .NET SDK on Android — NuGet & Setup **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/Android/ **Description:** Deploy VisioForge .NET SDK apps on Android. NuGet packages, VideoView integration, ARM64/x86 architecture support, and permissions configuration. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Android, C#, NuGet **API:** VideoView, VideoPlayerActivity # Android Implementation and Deployment Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to VisioForge SDKs for Android Android developers working with .NET technologies can leverage the powerful capabilities of VisioForge SDKs to integrate advanced media functionality into their applications. The SDKs provide robust solutions for media manipulation, playback, capture, and editing on the Android platform using .NET technologies. The VisioForge SDK for Android offers powerful capabilities for video processing, capturing, editing, and playback, all optimized for the Android platform while maintaining a consistent cross-platform development experience. The Android deployment process requires special consideration for package management, device compatibility, permissions, and performance optimization. This document provides detailed instructions to ensure your application runs smoothly on Android devices. ## System Requirements Before beginning your Android implementation and deployment process, ensure your development environment meets the following requirements: ### Device Requirements - Android device running Android 10.0 or later - ARM or ARM64 processor architecture - Sufficient storage space for application assets and media processing - Camera and microphone hardware (if using video/audio capture features) ### Development Environment Requirements - Windows, Linux, or macOS computer - Visual Studio with .NET MAUI or Xamarin workloads installed, JetBrains Rider, or Visual Studio Code - .Net 8.0 SDK or later (latest stable version recommended) - Android SDK with appropriate API levels installed - Java Development Kit (JDK) 11 or later - Basic knowledge of .NET development for Android ## Architecture Support The VisioForge SDK for Android provides native support for common Android device architectures: ### ARM64 Support - Optimized for modern Android devices - Hardware-accelerated video processing - Enhanced performance for media operations - Primary target for most applications ### ARM/ARMv7 Support - Compatibility with older Android devices - Software fallbacks for hardware acceleration when needed - Balanced performance and compatibility approach ## Installation and Setup Process Follow these steps to properly set up and deploy your VisioForge-powered Android application: 1. Create a new Android project in your preferred IDE (Visual Studio or JetBrains Rider recommended). 2. Add the required NuGet packages to your project (detailed in the next section). 3. Configure necessary permissions in your AndroidManifest.xml file. 4. Implement your application logic using the VisioForge SDK components. 5. Build, sign, and deploy your application to test devices. ### NuGet Package Management The VisioForge SDK for Android is distributed through NuGet packages. Add the following packages to your Android project: - [VisioForge.DotNet.Core](https://www.nuget.org/packages/VisioForge.DotNet.Core) - Main managed SDK package (core classes, VideoCaptureCoreX / MediaPlayerCoreX / MediaBlocksPipeline). - [VisioForge.CrossPlatform.Core.Android](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Android) - Contains the redistribution components (native libraries) required for Android applications. You can add these packages using the NuGet Package Manager in your IDE or by adding the following to your project file (use the latest versions): ``` ``` Note: Replace version numbers with the latest available releases on NuGet.org. ## Java Bindings Library Integration Android applications using VisioForge SDK require a custom Java Bindings Library for proper functionality. This essential step ensures proper communication between the .NET framework and Android's Java-based environment. Follow these detailed steps to integrate it: 1. Clone the binding-library repository from [GitHub](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/AndroidDependency). 2. Pick the binding project that matches the .NET target you build against — the folder ships one `VisioForge.Core.Android.X{N}.csproj` per supported .NET version (e.g., `VisioForge.Core.Android.X9.csproj` for .NET 9, `VisioForge.Core.Android.X10.csproj` for .NET 10). If your .NET target isn't listed, pick the closest supported one. 3. Add a reference to the binding project from your app's .csproj: ``` ``` > **Note:** Make sure to adjust the relative path to match your project structure ## Implementing VideoView in Your Application ### Adding VideoView to Your Layout The `VideoView` control is the primary interface for displaying video content in your Android application. To integrate it into your app, follow these steps: 1. Open your Activity or Fragment layout file (typically an `.axml` or `.xml` file) 2. Add the VideoView element as shown in the example below: ``` ``` ### Initializing VideoView in Code After adding the VideoView to your layout, you'll need to initialize it in your Activity or Fragment code: ``` using VisioForge.Core.UI.Android; namespace YourApp { [Activity(Label = "VideoPlayerActivity")] public class VideoPlayerActivity : Activity { private VideoView _videoView; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.your_layout); // Initialize the video view _videoView = FindViewById(Resource.Id.videoView); } } } ``` ## Performance Considerations Use physical Android devices for testing whenever possible. Simulators may not accurately represent real-world performance, especially for hardware-accelerated video operations. ## Application Signing and Publishing ### Application Signing For distributing your Android application, you need to sign it with a digital certificate: 1. Create a keystore file if you don't already have one: ``` keytool -genkey -v -keystore your-app-key.keystore -alias your-app-alias -keyalg RSA -keysize 2048 -validity 10000 ``` 1. Configure signing in your project: Add the following to your `android/app/build.gradle` file: ``` android { ... signingConfigs { release { storeFile file("your-app-key.keystore") storePassword "your-store-password" keyAlias "your-app-alias" keyPassword "your-key-password" } } buildTypes { release { signingConfig signingConfigs.release ... } } } ``` For .NET MAUI or Xamarin.Android projects, configure signing in your .csproj file: ``` True your-app-key.keystore your-store-password your-app-alias your-key-password ``` ### Publishing to Google Play Store 1. Generate an AAB (Android App Bundle) for distribution: ``` dotnet build -f net8.0-android -c Release /p:AndroidPackageFormat=aab ``` 1. Create a developer account on the Google Play Console if you don't already have one. 2. Create a new application on the Google Play Console. 3. Upload your AAB file to the production track. 4. Complete the store listing information. 5. Submit for review. ## Troubleshooting ### Common Issues 1. **Missing Permissions**: Ensure all required permissions are declared in the AndroidManifest.xml and requested at runtime. 2. **Architecture Compatibility**: Verify your application supports the target device's architecture (ARM/ARM64). 3. **Memory Constraints**: Monitor memory usage and implement proper resource management. 4. **Performance Issues**: Use hardware acceleration and optimize media operations for mobile devices. 5. **Java Bindings Errors**: When facing issues with Java bindings: 6. Confirm you're using the correct binding library version 7. Check for version mismatches between .NET and the binding library 8. Verify all dependencies are properly referenced ### Getting Help If you encounter issues with your VisioForge SDK deployment on Android, please consult: - [Support Portal](https://support.visioforge.com) - [GitHub Samples](https://github.com/visioforge/.Net-SDK-s-samples) ## Conclusion Implementing and deploying VisioForge SDK applications to Android devices requires careful attention to platform-specific considerations. By following the guidelines in this document, you can ensure a smooth development and deployment process and deliver high-quality video applications to your Android users. Remember to test thoroughly on target devices, especially for performance-intensive operations like video capture and processing. With proper implementation, the VisioForge SDK enables powerful media applications across the Android ecosystem. ---END OF PAGE--- ## VisioForge Computer Vision NuGet Packages for .NET **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/computer-vision/ **Description:** Deploy VisioForge CV and CVD NuGet packages for .NET computer vision on Windows, Linux, and macOS. Face detection, object recognition, and more. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows # Computer Vision Implementation Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net), [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net), [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Overview of Available Packages Our SDK provides two NuGet packages that deliver computer-vision capabilities for your applications: 1. **[VisioForge.DotNet.Core.CV](https://www.nuget.org/packages/VisioForge.DotNet.Core.CV/)** — Windows-only CV package. 2. **[VisioForge.DotNet.Core.CVD](https://www.nuget.org/packages/VisioForge.DotNet.Core.CVD/)** — Cross-platform CV package for Windows, Linux, and macOS. Both packages provide a consistent API for integrating computer-vision features directly into your .NET applications. ## Deployment Requirements ### Windows-Specific CV Package #### Installation Process The Windows-specific CV package is designed for seamless integration: - Simply install the NuGet package through your preferred package manager - No additional deployment steps are necessary - Ready to use immediately after installation ### Cross-Platform CVD Package Our cross-platform CVD package requires specific configurations based on your operating system: #### Windows Environment Setup When deploying on Windows systems: - Install the NuGet package through Visual Studio or the .NET CLI - No additional dependencies or configurations are required - Works out of the box with standard Windows installations #### Ubuntu Linux Configuration For Ubuntu Linux systems, install the following dependencies: ``` sudo apt-get install libgdiplus libopenblas-dev libx11-6 ``` These packages provide essential functionalities: - `libgdiplus`: Provides System.Drawing compatibility - `libopenblas-dev`: Optimizes matrix operations for computer vision algorithms - `libx11-6`: Handles X Window System protocol client library #### macOS Setup Instructions For macOS environments, use Homebrew to install the required dependencies: ``` brew install --cask xquartz brew install mono-libgdiplus ``` These components enable: - XQuartz: Provides X11 functionality on macOS - mono-libgdiplus: Ensures compatibility with System.Drawing ## Additional Resources For implementation examples and technical guidance: - Visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for extensive code samples - Explore practical implementations across various use cases - Access community-contributed examples and solutions --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## VisioForge .NET SDK Cross-Platform Deployment Guide **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/ **Description:** Deploy .NET applications on Windows, macOS, iOS, Android, and Linux with native libraries, platform dependencies, and UI framework integration. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS # Cross-Platform Deployment Guide for VisioForge .NET SDK [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to VisioForge SDK Deployment The VisioForge SDK suite provides powerful multimedia capabilities for .NET applications, supporting video capture, editing, playback, and advanced media processing across multiple platforms. Proper deployment is critical to ensure your applications function correctly and leverage the full potential of these SDKs. This comprehensive guide outlines the deployment process for applications built with VisioForge's cross-platform .NET SDKs, helping you navigate the specific requirements of each supported operating system. ## Deployment Overview Deploying applications built with VisioForge SDKs requires careful consideration of platform-specific dependencies and configurations. The deployment process varies significantly depending on your target platform due to differences in: - Native library requirements - Media framework dependencies - Hardware access mechanisms - Package distribution methods ### Key Deployment Considerations Before beginning the deployment process, consider these critical factors: 1. **Target Platform Architecture**: Ensure you select the appropriate architecture (x86, x64, ARM64) for your deployment platform 2. **Required Dependencies**: Some platforms require additional libraries that aren't included in NuGet packages 3. **Framework Compatibility**: Verify compatibility between your .NET version and the target operating system 4. **Native Library Integration**: Understand how native libraries are integrated and loaded on each platform 5. **UI Framework Selection**: Choose the appropriate UI integration package for your selected framework ## Platform-Specific Deployment ### Windows Deployment Windows deployment is the most straightforward, with comprehensive NuGet package support covering all dependencies: - **Package Distribution**: All components available via NuGet - **Architecture Support**: Both x86 and x64 architectures fully supported - **Native Libraries**: Automatically deployed alongside your application - **UI Framework Options**: Windows Forms, WPF, WinUI, Avalonia, Uno, and MAUI supported For detailed Windows deployment instructions, see the [Windows deployment guide](Windows/). ### Android Deployment Android deployment requires specific configuration for native library extraction and permissions: - **Package Distribution**: Core components available via NuGet - **Architecture Support**: ARM64, ARMv7, and x86\_64 architectures supported - **Native Libraries**: Requires proper configuration for extraction to the correct location - **Permissions**: Camera, microphone, and storage permissions must be explicitly requested - **UI Integration**: Android-specific video view controls required Android applications use a single native library that must be correctly deployed. Review the [Android deployment guide](Android/) for complete instructions. ### macOS Deployment macOS deployment requires additional GStreamer library installation: - **Package Distribution**: Core components available via NuGet, GStreamer requires manual installation - **Architecture Support**: Intel (x64) and Apple Silicon (ARM64) architectures supported - **Native Libraries**: Multiple unmanaged libraries required - **Framework Options**: Native macOS, MAUI, and Avalonia supported - **Bundle Integration**: Special attention needed for proper app bundle structure macOS deployments may require specific entitlements and permissions configurations. See the [macOS deployment guide](macOS/) for detailed instructions. ### iOS Deployment iOS deployment involves unique challenges related to Apple's platform restrictions: - **Package Distribution**: Core components available via NuGet - **Architecture Support**: ARM64 architecture supported - **App Store Guidelines**: Special considerations for App Store submissions - **Native Libraries**: Single unmanaged binary library to deploy - **UI Integration**: iOS-specific video view controls required iOS applications require proper provisioning profiles and entitlements. The [iOS deployment guide](iOS/) provides comprehensive instructions. ### Ubuntu/Linux Deployment Linux deployment requires manual installation of GStreamer dependencies: - **Package Distribution**: Core components available via NuGet, GStreamer requires system packages - **Architecture Support**: x64 architecture primarily supported - **System Dependencies**: Required packages must be installed on the target system - **Distribution Considerations**: Different Linux distributions may require different dependency packages - **UI Options**: Primarily Avalonia UI framework supported Linux deployment often involves distribution-specific package management. The [Ubuntu deployment guide](Ubuntu/) provides instructions for Ubuntu-based distributions. ### Uno Platform Deployment Uno Platform enables deploying applications from a single codebase to multiple platforms: - **Package Distribution**: Core components available via NuGet with platform-specific redistributables - **Supported Platforms**: Windows, Android, iOS, macOS (Catalyst), WebAssembly, and Linux Desktop - **Architecture Support**: Varies by target platform - **Native Libraries**: Platform-specific redistributables required for each target - **UI Integration**: Uno-specific VideoView control adapts to each platform Uno Platform simplifies multi-platform development while leveraging native capabilities. See the [Uno Platform deployment guide](uno/) for comprehensive instructions. ### Runtime Requirements Target devices must meet these minimum requirements: - **Windows**: Windows 7 or later (x86 or x64) - **macOS**: macOS 10.15 (Catalina) or later (x64 or ARM64) - **iOS**: iOS 14.0 or later (ARM64) - **Android**: Android 7.0 (API level 24) or later - **Linux**: Ubuntu 20.04 LTS or later (x64 or ARM64) ## Common Deployment Challenges ### Native Library Loading Issues One of the most common deployment problems involves native library loading failures: - **Symptoms**: Runtime exceptions mentioning DllNotFoundException or similar - **Causes**: Incorrect architecture, missing dependencies, or improper extraction - **Solutions**: Verify package references, check deployment configuration, ensure libraries are in the correct location ### Permission and Security Constraints Modern operating systems enforce strict security policies: - **Camera Access**: Requires explicit permission on all mobile platforms - **Storage Access**: File system restrictions vary by platform - **Network Usage**: May require specific entitlements or manifest entries - **Background Operation**: Platform-specific rules for background media processing ### Performance Considerations Media processing can be resource-intensive: - **CPU Usage**: Implement appropriate threading to avoid UI freezing - **Memory Management**: Monitor and optimize memory usage for large media files - **Power Consumption**: Balance quality settings with battery life considerations ## Deployment Checklist Use this checklist to ensure a successful deployment: - ✅ Correct NuGet packages selected for target platform and architecture - ✅ Platform-specific dependencies installed and configured - ✅ SDK properly initialized and cleaned up - ✅ Appropriate video view controls integrated - ✅ Required permissions requested and justified - ✅ Application tested on target platform under realistic conditions - ✅ Performance metrics validated for acceptable user experience - ✅ Error handling implemented for graceful recovery ## Computer Vision Deployment Computer Vision SDK is a separate NuGet package. Check the [Computer Vision deployment guide](computer-vision/) for more information. ## Additional Resources - [VisioForge GitHub Repository](https://github.com/visioforge/.Net-SDK-s-samples) - Code samples and example projects - [API Documentation](https://api.visioforge.org/dotnet/) - Comprehensive API reference - [Support Portal](https://support.visioforge.com/) - Technical support and knowledge base ---END OF PAGE--- ## iOS Deployment Guide for VisioForge .NET Video SDKs **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/iOS/ **Description:** Deploy .NET apps to iOS with VisioForge SDK integration, permissions, architecture support, and cross-platform deployment best practices. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, VideoCaptureCoreX, iOS, MAUI, Capture, Encoding, C#, NuGet, Entitlements **API:** VideoView, IVideoView, VideoCaptureCoreX # Apple iOS Deployment Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Overview This comprehensive guide walks you through the process of deploying VisioForge SDK-powered applications to Apple iOS devices. The VisioForge SDK provides a powerful framework for building media-rich applications on iOS, offering robust support for video capture, editing, playback, and processing capabilities. The iOS deployment process involves several key considerations, from package management to permission handling and performance optimization. This document will guide you through each step to ensure a smooth deployment experience. ## System Requirements Before beginning your iOS deployment process, ensure your development environment meets the following requirements: ### Hardware Requirements - Apple Mac computer for development (required for iOS app signing) - iOS device for testing (strongly recommended over simulators) - Sufficient storage space for development tools and application assets ### Software Requirements - Apple iOS device running iOS 12 or later (latest version recommended) - Xcode 12 or later with iOS SDK installed - Apple Developer account (required for app signing and distribution) - Visual Studio for Mac, JetBrains Rider, or Visual Studio Code - .Net 7.0 SDK or later (we recommend the latest stable version) ## Architecture Support The VisioForge SDK for iOS provides native support for both major iOS device architectures: ### ARM64 Support - Compatible with all modern iOS devices (iPhone X and newer) - Optimized native libraries for maximum performance - Hardware-accelerated video processing where supported by the device ## Installation Process Follow these steps to properly set up and deploy your VisioForge-powered iOS application: 1. Install the .Net SDK for iOS development 2. Create a new iOS project in your preferred IDE (Visual Studio for Mac or JetBrains Rider recommended) 3. Add the required NuGet packages to your project (detailed in the next section) 4. Configure the necessary permissions and entitlements in your app's Info.plist file 5. Implement your application logic using the VisioForge SDK components 6. Build, sign, and deploy your application to test devices ## NuGet Packages The VisioForge SDK for iOS is distributed through NuGet packages: ### Core Packages - [VisioForge.DotNet.Core](https://www.nuget.org/packages/VisioForge.DotNet.Core) - Core package containing core classes and UI controls, including video playback and display components. This is platform-independent and can be used in any .Net project. ### UI Packages Each UI package has the same VideoView controls but different implementations for the target platform: #### .Net iOS target platform - [VisioForge.Core](https://www.nuget.org/packages/VisioForge.DotNet.Core) - Contains UI controls and all core classes for the iOS platform. #### .Net MAUI target platform - [VisioForge.DotNet.Core.UI.MAUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.MAUI) - Contains UI controls for the MAUI platform. ### Redist Packages - [VisioForge.CrossPlatform.Core.iOS](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.iOS) - Contains the core redistribution components required for any iOS application using VisioForge technologies. You can add these packages using the NuGet Package Manager in your IDE or by adding the following to your project file (use the latest versions): ``` ``` Note: Replace version numbers with the latest available releases. ## Required Permissions and Entitlements iOS applications require explicit permissions for accessing device features like cameras, microphones, and the photo library. Configure these permissions in your app's Info.plist file: ### Camera Access Required for video capture functionality: ``` NSCameraUsageDescription This app requires camera access for video recording ``` ### Microphone Access Required for audio recording: ``` NSMicrophoneUsageDescription This app requires microphone access for audio recording ``` ### Photo Library Access Required for saving videos to the device's photo library: ``` NSPhotoLibraryUsageDescription This app requires access to the photo library to save videos ``` ### Example Info.plist Configuration Here's a complete example of an Info.plist file with all necessary permissions: ``` LSRequiresIPhoneOS UIDeviceFamily 1 2 UIRequiredDeviceCapabilities arm64 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight XSAppIconAssets Assets.xcassets/appicon.appiconset NSCameraUsageDescription Camera access is required for video recording NSMicrophoneUsageDescription Microphone access is required for audio recording NSPhotoLibraryUsageDescription Photo library access is required to save videos ``` ## Runtime Permission Handling In addition to declaring permissions in your Info.plist file, you should also request permissions at runtime. Here's an example of how to request camera and microphone permissions: ``` using System.Diagnostics; using Photos; // Request camera permission private async Task RequestCameraPermissionAsync() { var status = await Permissions.RequestAsync(); if (status != PermissionStatus.Granted) { // Handle permission denial Debug.WriteLine("Camera permission denied"); } } // Request microphone permission private async Task RequestMicrophonePermissionAsync() { var status = await Permissions.RequestAsync(); if (status != PermissionStatus.Granted) { // Handle permission denial Debug.WriteLine("Microphone permission denied"); } } // Request photo library permission (iOS specific) private void RequestPhotoLibraryPermission() { PHPhotoLibrary.RequestAuthorization(status => { if (status == PHAuthorizationStatus.Authorized) { Debug.WriteLine("Photo library access granted"); } else { Debug.WriteLine("Photo library access denied"); } }); } ``` ## SDK Initialization Properly initialize the VisioForge SDK in your application's lifecycle: ``` // In your AppDelegate or application startup code public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // Initialize the VisioForge SDK VisioForge.Core.VisioForgeX.InitSDK(); // Your other initialization code return true; } // Clean up on application termination public override void WillTerminate(UIApplication application) { // Clean up VisioForge SDK resources VisioForge.Core.VisioForgeX.DestroySDK(); // Your other cleanup code } ``` ## Implementation Best Practices ### Using VideoView Controls The VisioForge SDK provides a `VideoView` control for displaying video content. On iOS `VideoView` is a Metal-accelerated `MTKView` subclass that implements `IVideoView` directly (use `VideoViewGL` if you need the legacy OpenGL-backed `UIView` variant): ``` // Create a VideoView instance — VideoView implements IVideoView, so no casting/helper call is needed var videoView = new VisioForge.Core.UI.Apple.VideoView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height)); View.AddSubview(videoView); // Pass the videoView itself where an IVideoView is expected var captureCore = new VideoCaptureCoreX(videoView); ``` You can add the VideoView using a storyboard or code. ### Resource Management iOS devices have limited resources compared to desktop computers. Follow these best practices: 1. Release resources when not in use 2. Use lower resolution settings for real-time processing 3. Implement proper lifecycle management in your ViewControllers 4. Test on actual devices, not just simulators ## Testing and Debugging ### Physical Device Testing While the iOS simulator can be useful for basic interface testing, it has significant limitations for media applications: - Simulator may have performance issues during video encoding at high resolutions - Camera and microphone are not available in the simulator - Hardware acceleration features may not be available or may behave differently **Always test your media application on physical iOS devices before release.** ### Common Performance Considerations When deploying media applications to iOS, consider these performance factors: 1. **Resolution and frame rate:** Lower these settings for better performance on older devices 2. **Encoder selection:** Use hardware-accelerated encoders when available 3. **Memory management:** Implement proper disposal of large objects and monitor memory usage 4. **Battery impact:** Media processing is power-intensive; implement power-saving measures ## Troubleshooting Common Issues ### Permission Denials If your app can't access the camera or microphone: 1. Verify all required permissions are in your Info.plist 2. Check that you're requesting permissions at runtime before attempting to use the hardware 3. Test if the user has manually denied permissions in iOS Settings ### Library Loading Errors If you encounter errors loading native libraries: 1. Verify all required NuGet packages are properly installed 2. Check for conflicting package versions 3. Ensure you're targeting the correct iOS architecture (ARM64) ## Additional Resources - Visit the [VisioForge GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for code samples and example projects - Browse the [VisioForge API documentation](https://api.visioforge.org/dotnet/api/index.html) for comprehensive SDK reference --- By following this deployment guide, you should be able to successfully create, configure, and deploy VisioForge-powered applications to iOS devices. For specific questions or advanced configuration needs, please contact VisioForge technical support. ---END OF PAGE--- ## Deploy VisioForge .NET SDK on macOS — Intel & Apple Silicon **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/macOS/ **Description:** Deploy VisioForge .NET SDK apps on macOS. NuGet packages, NSView integration, App Store publishing, and native library setup for x64 and ARM64. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, macOS, MAUI, GStreamer, C#, NuGet, Entitlements **API:** VideoView, VideoViewGL # Apple macOS Deployment Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction VisioForge's powerful .NET SDKs provide comprehensive media processing capabilities for macOS developers. Whether you're building video capture applications, media players, video editors, or complex media processing pipelines, our SDKs offer the tools you need to deliver high-quality solutions on Apple's platforms. The VisioForge SDK provides comprehensive support for macOS application development using .NET technologies. You can leverage this SDK to build robust media processing applications that run natively on macOS, including support for both Intel (x64) and Apple Silicon (ARM64) architectures. This guide covers everything you need to know to set up, configure, and deploy applications for macOS and MacCatalyst environments using the VisioForge SDK. Whether you're building traditional macOS applications or cross-platform solutions using frameworks like MAUI or Avalonia, this document will help you navigate the installation and deployment process. ## System Requirements Before starting the installation and deployment process, ensure your development environment meets the following requirements: ### Hardware Requirements - Mac computer with Intel processor (x64) or Apple Silicon (ARM64) - Minimum 8GB RAM (16GB recommended for video processing) - Sufficient disk space for development tools and application assets ### Software Requirements - macOS 10.15 (Catalina) or later (latest version recommended) - macOS Monterey (12.x) - macOS Ventura (13.x) - macOS Sonoma (14.x) - Future macOS releases (with ongoing updates) - Xcode 12 or later with Command Line Tools installed - .NET 6.0 SDK or later - Visual Studio for Mac or JetBrains Rider (recommended IDEs) To install XCode Command Line Tools, run the following in Terminal: ``` xcode-select --install ``` ## Architecture Support The VisioForge SDK for macOS supports both major processor architectures: ### Intel (x64) Support - Compatible with all Intel-based Mac computers - Uses native x64 libraries for optimal performance - Full feature support across all SDK components ### Apple Silicon (ARM64) Support - Native support for M1, M2, and newer Apple Silicon chips - Optimized ARM64 native libraries for maximum performance - Hardware acceleration leveraging Apple's Neural Engine where applicable ### Universal Binary Considerations When targeting both architectures, consider building universal binaries that include both x64 and ARM64 code. This approach ensures your application runs natively on either platform without relying on Rosetta 2 translation. For universal binary builds targeting both Intel and Apple Silicon: ``` osx-x64;osx-arm64 true ``` ## Core Technologies VisioForge .NET SDKs leverage several key technologies to deliver high-performance media capabilities on macOS: ### GStreamer Integration All VisioForge SDKs utilize GStreamer as the underlying framework for video/audio playback and encoding. GStreamer provides: - Hardware-accelerated media processing - Broad format compatibility - Optimized playback pipeline - Efficient encoding capabilities The GStreamer components are automatically installed through our redistributable packages, eliminating the need for manual configuration. ## Installation and NuGet Package Deployment The primary method for deploying VisioForge SDK components to macOS applications is through NuGet packages. These packages include all necessary managed and unmanaged libraries required for your application. ### Essential NuGet Packages For native macOS applications, add these core packages: 1. **Main SDK Package** (based on your needs): 2. `VisioForge.DotNet.VideoCapture` for camera capture applications 3. `VisioForge.DotNet.VideoEdit` for video editing applications 4. `VisioForge.DotNet.MediaPlayer` for media playback applications 5. `VisioForge.DotNet.MediaBlocks` for advanced media processing pipelines 6. **UI Package**: 7. `VisioForge.DotNet.Core` includes Apple-specific UI controls 8. **Platform Redistributable**: 9. `VisioForge.CrossPlatform.Core.macOS` for native libraries and dependencies ### macOS Applications For standard macOS applications targeting the `netX.0-macos` framework (where X represents the .NET version), use the following NuGet package: - [VisioForge.CrossPlatform.Core.macOS](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.macOS) This package contains: - Native libraries for media processing - GStreamer components for media playback and encoding - Interface assemblies for .NET integration - Both x64 and ARM64 binaries ### Getting Started with Native macOS Projects To begin developing native macOS applications with VisioForge SDKs: 1. **Create a new macOS project** in your preferred IDE (Visual Studio for Mac or JetBrains Rider) 2. **Add required NuGet packages** (as detailed above) 3. **Configure project settings** for your target architecture ## MacCatalyst and MAUI Applications ### Cross-Platform Development with .NET MAUI .NET Multi-platform App UI (MAUI) enables developing applications that run seamlessly across macOS, iOS, Android, and Windows from a single codebase. VisioForge provides comprehensive support for MAUI development through specialized packages and controls. For MacCatalyst applications (including MAUI projects) targeting the `netX.0-maccatalyst` framework, use: - [VisioForge.CrossPlatform.Core.macCatalyst](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.macCatalyst) ### MAUI Package Configuration For MAUI projects targeting macOS (through MacCatalyst), add these packages: ``` ``` ### MAUI Project Setup 1. **Initialize SDK in MauiProgram.cs**: ``` builder .UseMauiApp() .UseSkiaSharp() .ConfigureMauiHandlers(handlers => handlers.AddVisioForgeHandlers()); ``` 1. **Add VideoView Control in XAML**: ``` xmlns:vf="clr-namespace:VisioForge.Core.UI.MAUI;assembly=VisioForge.Core.UI.MAUI" ``` MacCatalyst applications require additional configuration to ensure native libraries are properly included in the application bundle. Add the following custom build target to your project file: ``` $(OutputPath)$(AssemblyName).app $(AppBundleDir)/Contents/MonoBundle ``` This target performs several crucial tasks: 1. Identifies the application bundle directory 2. Creates the MonoBundle directory if it doesn't exist 3. Copies all `.dylib` and `.so` native libraries to the MonoBundle directory 4. Outputs diagnostic information for troubleshooting For complete MAUI integration details, see our dedicated [MAUI](../../install/maui/) documentation page. ## UI Framework Options The VisioForge SDK supports multiple UI frameworks for macOS development: ### Native macOS UI For traditional macOS applications, the SDK provides `VideoViewGL` controls that integrate with the native AppKit framework. These controls provide high-performance video rendering using OpenGL. ### MAUI For cross-platform MAUI applications, use the [VisioForge.DotNet.Core.UI.MAUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.MAUI) package, which provides MAUI-compatible video views. ### Avalonia For Avalonia UI applications, the [VisioForge.DotNet.Core.UI.Avalonia](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.Avalonia) package offers Avalonia-compatible video controls. ## Development Environment Setup ### JetBrains Rider Integration JetBrains Rider provides an excellent development experience for macOS and iOS applications using VisioForge SDKs: 1. Create a new project in Rider targeting macOS or iOS 2. Add the required NuGet packages through the Package Manager 3. Configure project settings for your target platform 4. Add UI controls and implement SDK functionality For detailed Rider setup instructions, see our [Rider integration guide](../../install/rider/). ### Visual Studio for Mac Setup Despite its deprecation, Visual Studio for Mac still works for developing macOS and iOS applications with VisioForge SDKs: 1. Create a new project in Visual Studio for Mac 2. Add NuGet packages through the NuGet Package Manager 3. Configure necessary build settings 4. Add UI controls to your application's interface For detailed Visual Studio for Mac instructions, see our [Visual Studio for Mac guide](../../install/visual-studio-mac/). ## SDK Initialization and Cleanup X-engines in the VisioForge SDK require explicit initialization and cleanup to manage resources properly: ``` // Initialize SDK at application startup VisioForge.Core.VisioForgeX.InitSDK(); // Use SDK components... // Clean up resources before application exit VisioForge.Core.VisioForgeX.DestroySDK(); ``` For asynchronous initialization and cleanup, use the async variants: ``` // Async initialization await VisioForge.Core.VisioForgeX.InitSDKAsync(); // Async cleanup await VisioForge.Core.VisioForgeX.DestroySDKAsync(); ``` ## Troubleshooting Common Issues ### Native Library Loading Failures If your application fails to load native libraries: 1. Verify all required NuGet packages are properly installed 2. Check the application bundle structure to ensure libraries are in the correct location 3. Use the `dtruss` or `otool` commands to diagnose library loading issues 4. Ensure XCode Command Line Tools are properly installed ### MacCatalyst-Specific Issues For MacCatalyst deployment problems: 1. Verify the CopyNativeLibrariesToMonoBundle target is correctly implemented 2. Check that the MonoBundle directory contains all necessary native libraries 3. Ensure the application has appropriate entitlements for media access ### Performance Optimization For optimal performance: 1. Enable hardware acceleration when available 2. Adjust video resolution based on device capabilities 3. Close and dispose of SDK objects when no longer needed ## Additional Resources For code samples, example projects, and more technical resources: - Visit the [VisioForge GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for code samples - Join the VisioForge developer community for support and discussions Our samples repository contains comprehensive examples showing: - Video capture from cameras - Media playback implementations - Video editing workflows - Advanced media processing pipelines ## Conclusion VisioForge .NET SDKs provide powerful media capabilities for macOS and iOS developers, enabling the creation of sophisticated multimedia applications. By following this installation and deployment guide, you've established the foundation for building high-performance media applications across Apple's platforms. For any additional questions or support needs, please contact our technical support team or visit our forums for community assistance. --- *This documentation is regularly updated to reflect the latest SDK features and compatibility information.* ---END OF PAGE--- ## Deploy .NET Apps on Ubuntu with GStreamer and VisioForge SDK **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/Ubuntu/ **Description:** Deploy .NET multimedia apps on Ubuntu Linux with GStreamer setup, hardware configuration, and cross-platform performance optimization. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Linux, GStreamer, NuGet # Ubuntu Deployment Guide for VisioForge SDK Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction Deploying .NET applications with VisioForge SDKs on Ubuntu Linux offers multiple benefits, including cross-platform compatibility, access to Linux-specific hardware, and the ability to run your multimedia applications on environments ranging from server infrastructure to edge devices. This comprehensive guide will walk you through the complete process of configuring your Ubuntu environment, installing the necessary dependencies, and deploying your VisioForge-powered .NET application. The VisioForge SDK family works on Ubuntu and other Linux distributions that support `GStreamer` libraries. Additional supported platforms include `Nvidia Jetson` devices and `Raspberry Pi`, making it perfect for a wide range of applications from desktop multimedia software to IoT solutions. ## System Requirements Before deploying your application, ensure your Ubuntu environment meets these minimum requirements: - Ubuntu 20.04 LTS or later (22.04 LTS and later recommended) - .NET 7.0 or later runtime - At least 4GB RAM (8GB recommended for video processing) - x86\_64 or ARM64 architecture - Internet connection for package installation ## Installation and Setup ### Installing .NET Download the latest [.NET installer](https://dotnet.microsoft.com/en-us/download/dotnet) package from the Microsoft website and follow the installation instructions. ## GStreamer Installation GStreamer forms the multimedia backbone for VisioForge SDKs on Linux platforms. It provides essential functionality for audio and video capture, processing, and playback. ### Required GStreamer Packages Install the following GStreamer packages using apt-get. We require v1.22.0 or later, though v1.24.0+ is highly recommended for access to the latest features and optimizations: - `gstreamer1.0-plugins-base`: Essential baseline plugins - `gstreamer1.0-plugins-good`: High-quality, well-tested plugins - `gstreamer1.0-plugins-bad`: Newer plugins of varying quality - `gstreamer1.0-alsa`: ALSA audio support - `gstreamer1.0-gl`: OpenGL rendering support - `gstreamer1.0-pulseaudio`: PulseAudio integration - `libges-1.0-0`: GStreamer Editing Services - `gstreamer1.0-libav`: FFMPEG integration (OPTIONAL but recommended for broader format support) ### Complete Installation Script The following commands will update your package repositories and install all required GStreamer components: ``` sudo apt update ``` ``` sudo apt install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-pulseaudio gstreamer1.0-libav libges-1.0-0 ``` ### Raspberry Pi Additional Requirements For Raspberry Pi, additionally, you need to install the following packages: ``` sudo apt install gstreamer1.0-libcamera ``` ### Verifying GStreamer Installation After installation, verify your GStreamer setup by running: ``` gst-inspect-1.0 --version ``` This should display the installed GStreamer version. Ensure it meets the minimum requirement (1.22.0+) or ideally shows 1.24.0 or later. ## Required NuGet Packages When deploying your .NET application to Ubuntu, you'll need to include additional platform-specific NuGet packages that provide the necessary native libraries and bindings. ### Additional Core Linux Package The [VisioForge.CrossPlatform.Core.Linux.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Linux.x64) package contains essential native libraries and bindings for the .NET Linux platform. This package is mandatory for all VisioForge SDK deployments on Ubuntu. ### Development Environment You can use Rider to develop your project in Linux. Please check the [Rider](../../install/rider/) installation page for more information. ## Application Deployment Follow these steps to deploy your application on Ubuntu: ### Publishing Your Application To create a self-contained deployment that includes all .NET runtime dependencies: ``` dotnet publish -c Release -r linux-x64 --self-contained true ``` For smaller deployments where the target machine already has .NET installed: ``` dotnet publish -c Release -r linux-x64 --self-contained false ``` ### Deployment Structure Your deployment folder should contain: - Your application executable - Application DLLs - VisioForge SDK assemblies - Native Linux libraries from the VisioForge NuGet packages ### Setting Execution Permissions Ensure your application executable has the proper permissions: ``` chmod +x ./YourApplicationName ``` ## Hardware Considerations ### Camera Support Ubuntu supports various camera types: - **USB Webcams**: Most USB webcams work out of the box - **IP Cameras**: Supported via RTSP, HTTP streams - **Professional Cameras**: Many professional cameras with Linux drivers are supported - **Virtual Devices**: v4l2loopback can be used for virtual camera creation To list available camera devices: ``` v4l2-ctl --list-devices ``` ### Audio Devices Audio capture and playback is supported through: - ALSA (Advanced Linux Sound Architecture) - PulseAudio To list available audio devices: ``` arecord -L # For recording devices aplay -L # For playback devices ``` ## Troubleshooting ### Permission Issues Camera or audio device access issues can often be resolved by adding your user to the appropriate groups: ``` sudo usermod -a -G video,audio $USER ``` Remember to log out and back in for group changes to take effect. ### Performance Optimization For optimal performance on Ubuntu: - Use the latest GStreamer version (1.24.0+) - Enable hardware acceleration where available - For NVIDIA GPUs, install the appropriate CUDA and nvcodec packages - Adjust process priority using `nice` for resource-intensive applications ## Conclusion Deploying VisioForge SDK applications on Ubuntu provides a powerful, flexible environment for multimedia applications. By following this guide, you can ensure that your .NET application leverages the full capabilities of the VisioForge SDK ecosystem on Linux platforms. For specific deployment scenarios or troubleshooting assistance, refer to the comprehensive documentation available on the VisioForge website or contact our technical support team. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Uno Platform Deployment Guide for VisioForge .NET SDKs **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/uno/ **Description:** VisioForge .NET SDK Uno Platform deployment with VideoView integration, multi-platform support for Windows, Android, iOS, macOS, and Linux. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, C++, Windows, macOS, Linux, Android, iOS, Uno, GStreamer, Streaming, Webcam, C#, NuGet # Uno Platform Implementation and Deployment Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to VisioForge SDKs for Uno Platform Uno Platform is a powerful cross-platform UI framework that enables developers to build native applications for Windows, Android, iOS, macOS, and Linux from a single codebase. VisioForge provides comprehensive support for Uno Platform applications through the `VisioForge.DotNet.Core.UI.Uno` package, which contains specialized UI controls designed specifically for the Uno Platform. The Uno Platform deployment process requires special consideration for each target platform. This document provides detailed instructions to ensure your application runs smoothly across all supported platforms. ## Supported Platforms VisioForge SDKs support the following Uno Platform targets: | Platform | Framework Target | Status | | --- | --- | --- | | Windows Desktop | net10.0-windows10.0.19041.0 | ✔ Full Support | | Android | net10.0-android | ✔ Full Support | | iOS | net10.0-ios | ✔ Full Support | | macOS (Catalyst) | net10.0-maccatalyst | ✔ Full Support | | Linux Desktop (Skia) | net10.0-desktop | ✔ Full Support | ## System Requirements Before beginning your Uno Platform implementation, ensure your development environment meets the following requirements: ### Development Environment Requirements - Windows, Linux, or macOS computer - Visual Studio 2022 with Uno Platform extension, JetBrains Rider, or Visual Studio Code - .NET 10.0 SDK or later (latest stable version recommended) - Uno Platform templates installed ### Platform-Specific Requirements #### Windows - Windows 10 version 17763 or later - Windows App SDK 1.4+ #### Android - Android SDK with appropriate API levels - Android 5.0 (API 21) or later device - Java Development Kit (JDK) 11 or later #### iOS/macOS - Mac computer with Xcode 15+ installed (for iOS/macOS builds) - Apple Developer account (for device deployment) - iOS 15.0 or later / macOS 10.15 or later #### Linux - GStreamer runtime installed - X11 or Wayland display server ## Installation and Setup Process Follow these steps to properly set up and deploy your VisioForge-powered Uno Platform application: ### 1. Install Uno Platform Templates ``` dotnet new install Uno.Templates ``` ### 2. Install Required Workloads ``` # For Android dotnet workload install android # For iOS/macOS dotnet workload install ios maccatalyst ``` ### 3. Create a New Uno Platform Project ``` dotnet new unoapp -o MyMediaApp ``` ### 4. Add VisioForge NuGet Packages Add the following packages to your project: ``` ``` ### Platform-Specific Redistributables Add platform-specific redistributable packages to your project: #### Windows ``` ``` #### Android ``` ``` Additionally, you'll need to add the Java Bindings Library. Clone it from our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/AndroidDependency) and add a reference: ``` ``` #### iOS ``` ``` #### macOS (Catalyst) ``` ``` For macOS Catalyst, you also need to add a custom MSBuild target to copy native libraries to the app bundle: ``` $(OutputPath)$(AssemblyName).app $(AppBundleDir)/Contents/MonoBundle ``` #### Linux Desktop For Linux, you need to install GStreamer runtime on your system: ``` # Ubuntu/Debian sudo apt-get install gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav # Fedora sudo dnf install gstreamer1-plugins-base gstreamer1-plugins-good gstreamer1-plugins-bad-free gstreamer1-plugins-ugly-free ``` ### Complete Sample Project File Here is a complete example `.csproj` file for an Uno Platform application with VisioForge SDK: ``` net10.0-windows10.0.19041;net10.0-android net10.0-maccatalyst;net10.0-ios;net10.0-android Exe true true MyMediaApp com.yourcompany.mymediaapp 1.0 1 Your Company Media application powered by Uno Platform and VisioForge. Apple Development $(OutputPath)$(AssemblyName).app $(AppBundleDir)/Contents/MonoBundle ``` ## Platform-Specific Configuration ### Windows Configuration Windows applications use native WinUI 3 rendering and support hardware acceleration via DirectX. #### Required Capabilities Add required capabilities to your `Package.appxmanifest`: ``` ``` ### Android Configuration #### Permissions Add the necessary permissions to your `AndroidManifest.xml`: ``` ``` #### Runtime Permission Requests Request permissions at runtime in your code: ``` private async Task RequestPermissionsAsync() { var status = await Permissions.RequestAsync(); if (status != PermissionStatus.Granted) { // Handle permission denial } status = await Permissions.RequestAsync(); if (status != PermissionStatus.Granted) { // Handle permission denial } } ``` ### iOS Configuration #### Info.plist Settings Add required usage descriptions to your `Info.plist`: ``` NSCameraUsageDescription This app requires camera access for video capture NSMicrophoneUsageDescription This app requires microphone access for audio recording NSPhotoLibraryUsageDescription This app requires photo library access to save media ``` #### App Transport Security For HTTP streaming sources, configure App Transport Security: ``` NSAppTransportSecurity NSAllowsArbitraryLoads ``` ### macOS (Catalyst) Configuration macOS Catalyst applications share configuration with iOS. Additionally, configure runtime identifiers for both Intel and Apple Silicon: ``` maccatalyst-x64 maccatalyst-arm64 ``` ### Linux Desktop Configuration For Linux desktop applications using Skia: 1. Ensure GStreamer is installed on the target system 2. Set appropriate environment variables if needed: ``` export GST_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gstreamer-1.0 ``` ## Building for Different Platforms ### Windows ``` dotnet build -c Release -f net10.0-windows10.0.19041.0 ``` ### Android ``` dotnet build -c Release -f net10.0-android ``` ### iOS ``` dotnet build -c Release -f net10.0-ios ``` ### macOS ``` dotnet build -c Release -f net10.0-maccatalyst ``` ### Linux Desktop ``` dotnet build -c Release -f net10.0-desktop ``` ## Performance Considerations - **Hardware Acceleration**: Enable hardware-accelerated rendering where available (Windows DirectX, Apple VideoToolbox, Android MediaCodec) - **Physical Devices**: Always test on physical devices, especially for mobile platforms. Simulators may not accurately represent real-world performance - **Memory Management**: Monitor memory usage, particularly on mobile devices when processing large media files - **Network Streaming**: Use appropriate buffer sizes for network streaming to balance latency and smoothness ## Troubleshooting Common Issues ### Video Not Displaying 1. Verify the VideoView is properly initialized and added to the visual tree 2. Check that platform-specific redistributables are correctly installed 3. Ensure permissions are granted on mobile platforms ### Performance Issues 1. Check that hardware acceleration is enabled 2. Reduce video resolution for lower-powered devices 3. Monitor memory usage and optimize buffer sizes ### Build Errors 1. Verify all required workloads are installed 2. Check for NuGet package version compatibility 3. Ensure target framework versions match across all project references ---END OF PAGE--- ## Windows Deployment Guide for VisioForge Cross-Platform SDK **URL:** https://www.visioforge.com/help/docs/dotnet/deployment-x/Windows/ **Description:** VisioForge SDK .NET deployment for Windows with NuGet packages, dependencies, and x86/x64 architecture configuration for multimedia apps. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, USB3 Vision / GigE, NuGet **API:** AWSS3SinkBlock, CVDewarpBlock, CVDilateBlock, CVErodeBlock # Windows Installation and Deployment Guide for VisioForge Cross-Platform SDK [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to VisioForge SDK Installation and Deployment The VisioForge SDK suite provides powerful multimedia capabilities for your .NET applications, supporting video capture, editing, playback, and advanced media processing across multiple platforms. This comprehensive guide covers both installation and deployment for Windows applications. ## Installation SDKs are accessible in two forms: a setup file and NuGet packages. The setup file provides a straightforward installation process, ensuring that all necessary components are correctly configured. On the other hand, NuGet packages offer a flexible and modular approach to incorporating SDKs into your projects, allowing for easy updates and dependency management. We highly recommend utilizing NuGet packages due to their convenience and efficiency in managing project dependencies and updates. When building your application, you have the option to create both x86 and x64 versions. This allows your application to run on a wider range of systems, accommodating different hardware architectures. However, it's important to note that the setup file is exclusively available for the x64 architecture. This means that while you can develop and compile x86 builds, the initial setup and installation process will require an x64 system. ### IDEs For development, you can use powerful integrated development environments (IDEs) like JetBrains Rider or Visual Studio. Both IDEs offer robust tools and features to streamline the development process on Windows. To ensure a smooth setup, please refer to the respective installation guides. The [Rider installation page](../../install/rider/) provides detailed instructions for setting up JetBrains Rider, while the [Visual Studio installation page](../../install/visual-studio/) offers comprehensive guidance on installing and configuring Visual Studio. These resources will help you get started quickly and effectively, leveraging the full capabilities of these development environments. ## Distribution and Package Management VisioForge SDK components for Windows are distributed as NuGet packages, making integration straightforward with modern .NET development environments. You can add these packages to your project using any of the following tools: - Visual Studio Package Manager - JetBrains Rider NuGet Manager - Visual Studio Code with NuGet extensions - Direct command-line integration using the .NET CLI ## Required Base Packages Every Windows application built with VisioForge SDK requires the appropriate base package according to your application's target architecture. These packages contain the essential components for SDK functionality. ### Core Platform Packages - [VisioForge.CrossPlatform.Core.Windows.x86](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Windows.x86) - For 32-bit Windows applications - [VisioForge.CrossPlatform.Core.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Windows.x64) - For 64-bit Windows applications > **Note**: For applications targeting multiple architectures, you should include both packages and implement appropriate runtime selection logic. ## Optional Component Packages Depending on your application's requirements, you may need to include additional packages for specialized functionality. These optional components extend the SDK's capabilities in various domains. ### FFMPEG Media Processing (Recommended) These packages provide comprehensive codec support for a wide range of media formats through the FFMPEG library integration: - [VisioForge.CrossPlatform.Libav.Windows.x86](https://www.nuget.org/packages/VisioForge.CrossPlatform.Libav.Windows.x86) - 32-bit FFMPEG support - [VisioForge.CrossPlatform.Libav.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Libav.Windows.x64) - 64-bit FFMPEG support For applications with size constraints, compressed versions of these packages utilizing UPX compression are available: - [VisioForge.CrossPlatform.Libav.Windows.x86.UPX](https://www.nuget.org/packages/VisioForge.CrossPlatform.Libav.Windows.x86.UPX) - Compressed 32-bit FFMPEG support - [VisioForge.CrossPlatform.Libav.Windows.x64.UPX](https://www.nuget.org/packages/VisioForge.CrossPlatform.Libav.Windows.x64.UPX) - Compressed 64-bit FFMPEG support ### Cloud Integration - Amazon Web Services For applications requiring cloud storage integration with AWS S3: - [VisioForge.CrossPlatform.AWS.Windows.x86](https://www.nuget.org/packages/VisioForge.CrossPlatform.AWS.Windows.x86) - 32-bit AWS support - [VisioForge.CrossPlatform.AWS.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.AWS.Windows.x64) - 64-bit AWS support When using these packages, the following Media Block becomes available: - `AWSS3SinkBlock` - For storing media in S3 buckets ### Computer Vision with OpenCV For applications requiring advanced image processing and computer vision capabilities: - [VisioForge.CrossPlatform.OpenCV.Windows.x86](https://www.nuget.org/packages/VisioForge.CrossPlatform.OpenCV.Windows.x86) - 32-bit OpenCV support - [VisioForge.CrossPlatform.OpenCV.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.OpenCV.Windows.x64) - 64-bit OpenCV support The OpenCV integration provides access to Media Blocks in the `VisioForge.Core.MediaBlocks.OpenCV` namespace, including: - Image transformation: `CVDewarpBlock`, `CVDilateBlock`, `CVErodeBlock` - Edge and feature detection: `CVEdgeDetectBlock`, `CVLaplaceBlock`, `CVSobelBlock` - Face processing: `CVFaceBlurBlock`, `CVFaceDetectBlock` - Motion detection: `CVMotionCellsBlock` - Object recognition: `CVTemplateMatchBlock`, `CVHandDetectBlock` - Image enhancement: `CVEqualizeHistogramBlock`, `CVSmoothBlock` - Tracking and overlay: `CVTrackerBlock`, `CVTextOverlayBlock` ## Specialized Hardware Support Packages VisioForge SDK provides integration with professional camera systems and specialized hardware. Include the appropriate package when working with specific device types. ### Allied Vision Cameras For integrating with professional Allied Vision camera hardware: - [VisioForge.CrossPlatform.AlliedVision.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.AlliedVision.Windows.x64) ### Basler Cameras For applications working with Basler industrial cameras: - [VisioForge.CrossPlatform.Basler.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Basler.Windows.x64) ### Teledyne/FLIR Cameras (Spinnaker SDK) For thermal imaging and specialized FLIR cameras: - [VisioForge.CrossPlatform.Spinnaker.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Spinnaker.Windows.x64) ### GenICam Protocol Support (GigE/USB3 Vision) For cameras utilizing the standardized GenICam protocol: - [VisioForge.CrossPlatform.GenICam.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.GenICam.Windows.x64) ## Deployment Best Practices When deploying VisioForge-based applications for Windows, consider these recommendations: 1. Choose the appropriate architecture packages (x86 or x64) based on your target platform 2. Include the FFMPEG packages for comprehensive media format support 3. Only include specialized hardware packages when needed to minimize deployment size 4. For security-sensitive applications, consider using the UPX compressed versions to obfuscate native libraries 5. Always test your deployment on a clean system to ensure all dependencies are properly resolved ## Troubleshooting Common Issues ### Deployment Issues If you encounter issues after deployment: 1. Verify all required NuGet packages are properly included 2. Check that the architecture (x86/x64) matches your application target 3. Ensure native libraries are being extracted to the correct locations 4. Review Windows security and permission settings that might restrict media functionality ### WinForms RESX Files Build Issue Sometimes you can get the following error: `Error MSB3821: Couldn't process file Form1.resx due to its being in the Internet or Restricted zone or having the mark of the web on the file. Remove the mark of the web if you want to process these files.` Error MSB3821 occurs when Visual Studio or MSBuild cannot process a `.resx` resource file because it is marked as untrusted. This happens when the file has the "Mark of the Web" (MOTW), a security feature that flags files downloaded from the internet or received from untrusted sources. The MOTW places the file in the Internet or Restricted security zone, preventing it from being processed during a build. #### How to Fix It To resolve this error, you need to remove the MOTW from the affected file: ##### Unblock the File Manually - Right-click on Form1.resx in File Explorer. - Select Properties. - In the General tab, check for an Unblock button or checkbox at the bottom. - Click Unblock, then click OK. ##### Unblock via PowerShell (for multiple files) - Open PowerShell. - Navigate to your project directory. - Run the command: Get-ChildItem -Path . -Recurse | Unblock-File ##### Unblock the ZIP Before Extraction - If you downloaded the project as a ZIP file, right-click the ZIP file. - Select Properties. - Click Unblock, then extract the files. By unblocking the file, you remove the MOTW, allowing Visual Studio to process it normally during the build. For additional assistance, visit the [VisioForge support site](https://support.visioforge.com/) or consult the [API documentation](https://api.visioforge.org/dotnet/api/index.html). --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Audio Sample Grabber for .NET - Capture Raw Audio Frames **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-effects/audio-sample-grabber/ **Description:** Capture and process real-time audio frames using Audio Sample Grabber with X-engines and Classic engines in .NET SDK applications. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, VideoEditCore, Windows, Editing, C# **API:** AudioFrameBufferEventArgs, AudioSampleGrabberBlock # Working with Audio Sample Grabber in .NET SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Audio Sample Grabber The Audio Sample Grabber is a powerful feature available across our .NET SDKs that enables developers to access raw audio frames directly from both live sources and media files. This capability opens up a wide range of possibilities for audio processing, analysis, and manipulation in your applications. When working with audio processing, gaining access to individual audio frames is essential for tasks such as: - Real-time audio visualization - Custom audio effects processing - Speech recognition integration - Audio analysis and metrics - Custom audio format conversion - Sound detection algorithms The `OnAudioFrameBuffer` event is the core mechanism that provides access to these raw audio frames. This event fires each time a new audio frame is available, giving you direct access to unmanaged memory containing the decoded audio data. ## How Audio Sample Grabber Works The Audio Sample Grabber intercepts the audio pipeline during playback or capture, providing you with the raw audio data before it's rendered to the output device. This data is typically in PCM (Pulse Code Modulation) format, which is the standard format for uncompressed digital audio, but can occasionally be in IEEE floating-point format depending on the audio source. Each time the `OnAudioFrameBuffer` event fires, it provides an `AudioFrameBufferEventArgs` object containing critical information about the audio frame: - `Frame.Data`: An `IntPtr` pointing to the unmanaged memory block containing the raw audio data - `Frame.DataSize`: The size of the audio data in bytes - `Frame.Info`: A structure containing detailed information about the audio format, including: - Channel count (mono, stereo, etc.) - Sample rate (typically 44.1kHz, 48kHz, etc.) - Bits per sample (16-bit, 24-bit, etc.) - Audio format type (PCM, IEEE, etc.) - Timestamp information - Block alignment and other format-specific details ## Setting Up Audio Sample Grabber The setup process varies slightly depending on whether you're using our newer X-engines or the Classic engines. Let's explore both approaches: X-enginesClassic enginesMedia Blocks SDK For X-engines, setting up the Audio Sample Grabber is straightforward. You simply need to create an event handler for the `OnAudioFrameBuffer` event: ``` VideoCapture1.OnAudioFrameBuffer += OnAudioFrameBuffer; ``` The X-engines architecture automatically enables audio sample grabbing when you subscribe to this event, with no additional configuration required. When using Classic engines, you need to explicitly enable the Audio Sample Grabber functionality before creating the event handler: ``` VideoCapture1.Audio_Sample_Grabber_Enabled = true; ``` Then, as with X-engines, create your event handler: ``` VideoCapture1.OnAudioFrameBuffer += OnAudioFrameBuffer; ``` **Note**: The `Audio_Sample_Grabber_Enabled` property is not required for the VideoEditCore component, which has audio sample grabbing enabled by default. The Media Blocks SDK also supports audio sample grabbing. Use the `AudioSampleGrabberBlock` component to capture audio frames. ``` private AudioSampleGrabberBlock _audioSampleGrabberSink; ``` Then, as with X-engines, create your event handler, and specify the audio format: ``` _audioSampleGrabberBlock = new AudioSampleGrabberBlock(VisioForge.Core.Types.X.AudioFormatX.S16LE); _audioSampleGrabberBlock.OnAudioFrameBuffer += OnAudioFrameBuffer; ``` ## Processing Audio Frames Once you've set up the event handler, you can process the audio frames as they arrive. Here's a basic example of how to handle the `OnAudioFrameBuffer` event: ``` using VisioForge.Types; using System.Diagnostics; private void OnAudioFrameBuffer(object sender, AudioFrameBufferEventArgs e) { // Log audio frame information Debug.WriteLine($"Audio frame: {e.Frame.DataSize} bytes; Format: {e.Frame.Info}"); // Access to raw audio data through the unmanaged pointer IntPtr rawAudioData = e.Frame.Data; // Get audio format details. RAWBaseAudioInfo carries four fields: // Channels, SampleRate, BPS (bits-per-sample), Format (AudioFormat enum). int channelCount = e.Frame.Info.Channels; int sampleRate = e.Frame.Info.SampleRate; int bitsPerSample = e.Frame.Info.BPS; AudioFormat format = e.Frame.Info.Format; // Your custom audio processing code here // ... } ``` ## Working with Audio Data ### Converting Unmanaged Memory to Managed Arrays While the `e.Frame.Data` provides a pointer to unmanaged memory, you often need to work with the data in a more convenient form. The `AudioFrame` class provides a helpful `GetDataArray()` method that returns a copy of the audio data as a byte array: ``` private void VideoCapture1_OnAudioFrameBuffer(object sender, AudioFrameBufferEventArgs e) { // Get a managed copy of the audio data byte[] audioData = e.Frame.GetDataArray(); // Now you can work with the data using standard C# array operations // ... } ``` ### Converting PCM Data to Samples For many audio processing tasks, you'll want to convert the raw PCM bytes into actual audio sample values. Here's a helper method to convert a PCM byte array to an array of audio samples (assuming 16-bit samples): ``` private short[] ConvertBytesToSamples(byte[] audioData) { short[] samples = new short[audioData.Length / 2]; for (int i = 0; i < samples.Length; i++) { // Combine two bytes into one 16-bit sample samples[i] = (short)(audioData[i * 2] | (audioData[i * 2 + 1] << 8)); } return samples; } ``` ### Handling Multi-Channel Audio When working with stereo or multi-channel audio, the samples are typically interleaved. For a stereo stream, the data is arranged as: [Left0, Right0, Left1, Right1, ...]. You may want to separate these channels for processing: ``` private void ProcessStereoAudio(short[] samples, int channelCount) { if (channelCount != 2) return; // Create arrays for each channel int samplesPerChannel = samples.Length / 2; short[] leftChannel = new short[samplesPerChannel]; short[] rightChannel = new short[samplesPerChannel]; // Separate the channels for (int i = 0; i < samplesPerChannel; i++) { leftChannel[i] = samples[i * 2]; rightChannel[i] = samples[i * 2 + 1]; } // Process each channel separately // ... } ``` ## Common Audio Processing Scenarios ### Audio Level Metering A common use case for the Audio Sample Grabber is to implement audio level metering: ``` private void CalculateAudioLevel(short[] samples) { double sum = 0; // Calculate RMS (Root Mean Square) value foreach (short sample in samples) { sum += sample * sample; } double rms = Math.Sqrt(sum / samples.Length); // Convert to decibels double db = 20 * Math.Log10(rms / 32768); // Update UI with the level (you'll need to invoke if on a different thread) Debug.WriteLine($"Audio level: {db} dB"); } ``` ### Real-time FFT for Spectrum Analysis For frequency spectrum analysis, you might want to perform an FFT (Fast Fourier Transform) on the audio data: ``` // Note: You'll need a library for FFT calculation // This is a simplified example private void PerformFFTAnalysis(short[] samples) { // Typically you would use a library like Math.NET Numerics // Convert samples to complex numbers Complex[] complex = samples.Select(s => new Complex(s, 0)).ToArray(); // Perform FFT (pseudocode) // Complex[] fftResult = FFT.Forward(complex); // Process FFT results // ... } ``` ## Performance Considerations When working with the Audio Sample Grabber, keep these performance considerations in mind: 1. **Minimize Processing Time**: The `OnAudioFrameBuffer` event is called on the audio processing thread. Long-running operations can cause audio glitches. 2. **Consider Thread Safety**: If you need to update UI elements or interact with other components, use proper thread synchronization methods. 3. **Avoid Memory Allocations**: Frequent memory allocations in the event handler can lead to garbage collection pauses. Reuse arrays where possible. 4. **Buffer Copying**: The `GetDataArray()` method creates a copy of the audio data. For very high-performance scenarios, consider working directly with the unmanaged pointer. ## Conclusion The Audio Sample Grabber provides a powerful way to access and process raw audio data in real-time from both live sources and media files. By leveraging this functionality, you can implement sophisticated audio processing features in your applications, from simple level metering to complex audio analysis and effects processing. Whether you're building a professional audio application, implementing audio visualization, or integrating with speech recognition services, the Audio Sample Grabber gives you the raw data you need to bring your audio processing ideas to life. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Audio Effects in C# and .NET - EQ, Reverb, Filters, and More **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-effects/ **Description:** Apply real-time audio effects in C# and .NET with VisioForge SDKs. Equalizer, reverb, echo, noise reduction, pitch shift, and 30+ effects. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Playback, Streaming, Editing **API:** VolumeAudioEffect, Equalizer10AudioEffect, VideoCaptureCoreX, MediaPlayerCoreX, CompressorExpanderAudioEffect # Real-Time Audio Effects for .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) VisioForge Media Framework provides over 30 audio effects for real-time audio processing in C# and .NET applications. Built on GStreamer, the cross-platform effects include equalizers, reverb, echo, dynamic compression, filters, pitch shifting, AI-based noise reduction, and more — all running on Windows, macOS, Linux, iOS, and Android. ## SDKs and Platforms ### Cross-Platform Effects - **SDKs**: Media Blocks SDK, Video Capture SDK (VideoCaptureCoreX), Media Player SDK (MediaPlayerCoreX) - **Platforms**: Windows, macOS, Linux, iOS, Android - **Namespace**: `VisioForge.Core.Types.X.AudioEffects` ### Classic DSP Effects - **SDKs**: Video Capture SDK (VideoCaptureCore), Media Player SDK (MediaPlayerCore), Video Edit SDK (VideoEditCore) - **Platforms**: Windows only - **Namespace**: `VisioForge.Core.DSP` ### DirectSound Effects - **SDKs**: Video Capture SDK, Media Player SDK, Video Edit SDK (Classic cores) - **Platforms**: Windows only - **Namespace**: `VisioForge.Core.Types.X._Windows.AudioEffects` For detailed parameters and properties of each effect, see [Audio Effects Reference](reference/). ## Effect Categories ### Volume and Dynamics - **VolumeAudioEffect** — Basic volume control with mute functionality - **AmplifyAudioEffect** — Audio signal amplification with clipping control - **CompressorExpanderAudioEffect** — Dynamic range compression and expansion - **DynamicAmplifyAudioEffect** — Adaptive gain control with attack/release times ### Equalization - **Equalizer10AudioEffect** — 10-band graphic equalizer with fixed frequencies - **EqualizerParametricAudioEffect** — Parametric equalizer with configurable bands - **TrebleEnhancerAudioEffect** — High-frequency boost - **TrueBassAudioEffect** — Low-frequency boost ### Filters - **HighPassAudioEffect** — High-pass filter for removing low frequencies - **LowPassAudioEffect** — Low-pass filter for removing high frequencies - **BandPassAudioEffect** — Band-pass filter for specific frequency ranges - **NotchAudioEffect** — Notch filter for removing specific frequencies - **ChebyshevLimitAudioEffect** — Chebyshev low/high-pass filters with sharp cutoffs - **ChebyshevBandPassRejectAudioEffect** — Chebyshev band-pass/reject filters ### Spatial and Stereo - **BalanceAudioEffect** — Stereo balance control (pan left/right) - **WideStereoAudioEffect** — Stereo width enhancement - **Sound3DAudioEffect** — 3D spatial audio effects - **HRTFRenderAudioEffect** — Head-Related Transfer Function spatial audio - **PhaseInvertAudioEffect** — Phase inversion for polarity correction ### Time-Based Effects - **EchoAudioEffect** — Echo and delay effects - **RSAudioEchoAudioEffect** — Enhanced echo with advanced controls - **ReverberationAudioEffect** — Room reverberation (Freeverb algorithm) - **FadeAudioEffect** — Fade in/out volume automation ### Modulation Effects - **PhaserAudioEffect** — Phaser effect with LFO modulation - **FlangerAudioEffect** — Flanging effect with delay modulation ### Pitch and Tempo - **PitchShiftAudioEffect** — Pitch shifting without tempo change - **ScaleTempoAudioEffect** — Tempo change without pitch shift ### Special Effects - **KaraokeAudioEffect** — Vocal removal for karaoke - **RemoveSilenceAudioEffect** — Automatic silence detection and removal - **CsoundAudioEffect** — Advanced Csound-based audio processing ### Noise Reduction and Measurement - **AudioRNNoiseAudioEffect** — AI-based noise reduction using RNN - **AudioLoudNormAudioEffect** — EBU R128 loudness normalization - **EbuR128LevelAudioEffect** — EBU R128 loudness measurement ### Channel Management - **ChannelOrderAudioEffect** — Channel remapping and routing - **DownMixAudioEffect** — Multi-channel to stereo/mono downmixing ### DirectSound Effects (Windows Only, Classic SDKs) - **DS Chorus** — Multiple delayed and modulated copies - **DS Distortion** — Audio distortion/overdrive - **DS Gargle** — Gargling/tremolo modulation - **DS Reverb (I3DL2)** — Professional reverb with environmental modeling - **DS Waves Reverb** — Simplified reverb ## GStreamer Elements All cross-platform audio effects are built on top of GStreamer multimedia framework. Each effect wraps one or more GStreamer elements: | Category | GStreamer Elements | | --- | --- | | Volume/Dynamics | volume, audioamplify, audiodynamic | | Equalization | equalizer-10bands, equalizer-nbands | | Filters | audiocheblimit, audiochebband, audioiirfilter | | Spatial | audiopanorama, stereo, hrtfrender | | Time-Based | audioecho, rsaudioecho, freeverb | | Modulation | Custom phaser/flanger implementations | | Pitch/Tempo | scaletempo, pitch (SoundTouch) | | Special | audiokaraoke, csoundfilter, removesilence | | Noise Reduction | audiornnoise, audioloudnorm, ebur128level | | Channels | audioconvert, custom routing | ## Common Usage Patterns ### Adding Effects (Cross-Platform SDKs) ``` // Create an audio effect var volumeEffect = new VolumeAudioEffect(1.5); // 150% volume // VideoCaptureCoreX / MediaPlayerCoreX core.Audio_Effects_AddOrUpdate(volumeEffect); ``` ### Combining Multiple Effects Effects are processed in the order they are added: ``` // Create a processing chain core.Audio_Effects_AddOrUpdate(new HighPassAudioEffect(80)); // Remove rumble core.Audio_Effects_AddOrUpdate(new CompressorExpanderAudioEffect()); // Compress dynamics core.Audio_Effects_AddOrUpdate(new Equalizer10AudioEffect(levels)); // EQ adjustments core.Audio_Effects_AddOrUpdate(new ReverberationAudioEffect()); // Add reverb ``` ### Real-Time Parameter Updates Most effects support real-time parameter changes: ``` var volumeEffect = new VolumeAudioEffect(1.0); core.Audio_Effects_AddOrUpdate(volumeEffect); // Later, during playback: volumeEffect.Level = 0.5; // Reduce volume to 50% volumeEffect.Mute = true; // Mute audio core.Audio_Effects_AddOrUpdate(volumeEffect); // Apply changes ``` ### Media Blocks SDK Usage For Media Blocks SDK pipeline-based usage with dedicated audio effect blocks, see [Audio Processing and Effect Blocks](../../mediablocks/AudioProcessing/). ## Performance Considerations - **CPU Usage**: Complex effects like reverberation, Csound, and multiple equalizers can be CPU-intensive - **Effect Order**: Place computationally expensive effects after simpler ones to reduce processing load - **Real-Time Processing**: All effects are designed for real-time audio streaming ## Frequently Asked Questions What audio effects are available in VisioForge .NET SDKs? VisioForge provides 30+ audio effects including volume control, 10-band and parametric equalizers, reverb, echo, compressor/expander, high/low/band-pass filters, pitch shift, noise reduction (RNN-based), karaoke vocal removal, 3D spatial audio, and more. All cross-platform effects work on Windows, macOS, Linux, iOS, and Android. How do I add audio effects to my C# application? Create an effect instance and add it using `Audio_Effects_AddOrUpdate()`. For example: ``` // 10-band EQ: all bands at 0 dB (neutral) var eq = new Equalizer10AudioEffect(new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); core.Audio_Effects_AddOrUpdate(eq); ``` Effects can be added, updated, and removed during playback. For Media Blocks SDK, use the `AudioEffectsBlock`. Can I chain multiple audio effects together? Yes. Effects are processed in the order they are added. You can create complex processing chains combining filters, EQ, compression, reverb, and other effects. Each effect processes the audio output of the previous one. Do audio effects work in real-time during playback? Yes. All VisioForge audio effects support real-time parameter changes. You can adjust volume, EQ bands, reverb levels, and other parameters while audio is playing without interrupting the stream. What is the difference between cross-platform and DirectSound effects? Cross-platform effects (namespace `VisioForge.Core.Types.X.AudioEffects`) work on all platforms using GStreamer. DirectSound effects are Windows-only and available in the classic SDK cores. Cross-platform effects cover the same functionality and more. ## See Also - [Audio Effects Reference](reference/) - [Audio Sample Grabber](audio-sample-grabber/) - [Audio Encoders](../audio-encoders/) - [Audio Processing Blocks (Media Blocks SDK)](../../mediablocks/AudioProcessing/) ---END OF PAGE--- ## Audio Effects API Reference for .NET - Parameters & Examples **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-effects/reference/ **Description:** API reference for 30+ audio effects in VisioForge .NET SDKs. Volume, EQ, compressor, reverb, echo, filters, pitch shift, and noise reduction with C# examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaPlayerCoreX, VideoCaptureCoreX, VideoEditCore, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Playback, Streaming, Editing, Effects, C# **API:** VolumeAudioEffect, Equalizer10AudioEffect, BandPassAudioEffect, BalanceAudioEffect, WideStereoAudioEffect # Audio Effects API Reference [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Complete parameter reference for all audio effects available in VisioForge .NET SDKs. Each cross-platform effect wraps a GStreamer element and supports real-time parameter changes from C# code during playback. Cross-platform effects work on Windows, macOS, Linux, iOS, and Android. For an overview of effect categories and usage patterns, see [Audio Effects](../). ## Volume and Dynamics Effects ### VolumeAudioEffect **GStreamer Element**: `volume` **Purpose**: Control audio volume level with optional mute. **Parameters**: - `Level` (double): Volume multiplier - Range: 0.0 to unlimited - Default: 1.0 (100%) - Examples: 0.5 = 50%, 2.0 = 200% - `Mute` (bool): Mute audio output - Default: false **Usage**: ``` var effect = new VolumeAudioEffect(1.5); // 150% volume effect.Mute = true; // Temporarily mute ``` --- ### AmplifyAudioEffect **GStreamer Element**: `audioamplify` **Purpose**: Amplify audio with clipping control. **Parameters**: - `Level` (double): Amplification level - Range: 1.0 to 10.0 - Default: 1.0 - `ClippingMethod` (AmplifyClippingMethod): How to handle peaks - Options: Normal, WrapNegative, WrapPositive, NoClip - Default: Normal **Usage**: ``` var effect = new AmplifyAudioEffect(2.0); effect.ClippingMethod = AmplifyClippingMethod.NoClip; ``` --- ### CompressorExpanderAudioEffect **GStreamer Element**: `audiodynamic` **Purpose**: Dynamic range compression or expansion. **Parameters**: - `Threshold` (double): Activation threshold - Range: 0.0 to 1.0 - Default: 0.0 - `Ratio` (double): Compression/expansion ratio - Range: 1.0+ - Default: 1.0 - Typical: 2:1 to 10:1 for compression - `Mode` (AudioCompressorMode): Compressor or Expander - Default: Compressor - `Characteristics` (AudioDynamicCharacteristics): HardKnee or SoftKnee - Default: SoftKnee **Usage**: ``` var effect = new CompressorExpanderAudioEffect(); effect.Threshold = 0.5; effect.Ratio = 4.0; // 4:1 compression effect.Characteristics = AudioDynamicCharacteristics.SoftKnee; ``` --- ### DynamicAmplifyAudioEffect **Purpose**: Adaptive gain control. **Parameters**: - `AttackTime` (uint): Response time in ms - Typical: 10-100 ms - `MaxAmplification` (uint): Maximum gain - 10000 = 1x (no change) - 20000 = 2x amplification - Default: 10000 - `ReleaseTime` (TimeSpan): Time before resuming amplification - Typical: 100-1000 ms **Usage**: ``` var effect = new DynamicAmplifyAudioEffect(50, 20000, TimeSpan.FromMilliseconds(500)); ``` --- ## Equalization Effects ### Equalizer10AudioEffect **GStreamer Element**: `equalizer-10bands` **Purpose**: 10-band graphic equalizer with fixed frequencies. **Frequency Bands**: 1. 29 Hz (Sub-bass) 2. 59 Hz (Bass) 3. 119 Hz (Bass) 4. 237 Hz (Low midrange) 5. 474 Hz (Midrange) 6. 947 Hz (Midrange) 7. 1889 Hz (Upper midrange) 8. 3770 Hz (Presence) 9. 7523 Hz (Brilliance) 10. 15011 Hz (Air) **Parameters**: - `Levels` (double[]): Gain for each band in dB - Range per band: -24 to +12 dB - Array must contain exactly 10 values **Usage**: ``` var levels = new double[] { 3.0, // 29 Hz: +3 dB 2.0, // 59 Hz: +2 dB 0.0, // 119 Hz: 0 dB (no change) -2.0, // 237 Hz: -2 dB 0.0, // 474 Hz 0.0, // 947 Hz 1.0, // 1889 Hz: +1 dB 2.0, // 3770 Hz: +2 dB 3.0, // 7523 Hz: +3 dB 4.0 // 15011 Hz: +4 dB }; var effect = new Equalizer10AudioEffect(levels); ``` --- ### EqualizerParametricAudioEffect **GStreamer Element**: `equalizer-nbands` **Purpose**: Parametric equalizer with configurable bands. **Parameters**: - `Bands` (ParametricEqualizerBand[]): Array of bands - Count: 1 to 64 bands - Each band: Frequency, Gain, Width (bandwidth in Hz) **Usage**: ``` var effect = new EqualizerParametricAudioEffect(3); effect.Bands[0].Frequency = 100; // Hz effect.Bands[0].Gain = -6; // dB effect.Bands[0].Width = 1.0f; // bandwidth // Configure other bands... effect.Update(); // Apply changes ``` --- ### TrebleEnhancerAudioEffect **Purpose**: Boost high frequencies. **Parameters**: - `Frequency` (int): Starting frequency in Hz - Typical: 4000-8000 Hz - Frequencies above this are boosted - `Volume` (ushort): Boost amount - Range: 0 to 10000 - 0 = no effect **Usage**: ``` var effect = new TrebleEnhancerAudioEffect(6000, 5000); ``` --- ### TrueBassAudioEffect **Purpose**: Boost low frequencies. **Parameters**: - `Frequency` (int): Upper frequency limit in Hz - Typical: 100-300 Hz - Frequencies below this are boosted - `Volume` (ushort): Boost amount - Range: 0 to 10000 - 0 = no effect **Usage**: ``` var effect = new TrueBassAudioEffect(150, 5000); ``` --- ## Filter Effects ### HighPassAudioEffect **Implementation**: Custom DSP (IIR high-pass filter) **Purpose**: Remove low frequencies. **Parameters**: - `CutOff` (uint): Cutoff frequency in Hz - Frequencies below are attenuated - Typical: 80-200 Hz for voice, 40 Hz for music **Common Frequencies**: - 20-40 Hz: Sub-sonic removal - 60-80 Hz: Rumble removal - 100-150 Hz: Clarity improvement **Usage**: ``` var effect = new HighPassAudioEffect(100); // Remove frequencies below 100 Hz ``` --- ### LowPassAudioEffect **Implementation**: Custom DSP (IIR low-pass filter) **Purpose**: Remove high frequencies. **Parameters**: - `CutOff` (uint): Cutoff frequency in Hz - Frequencies above are attenuated - Typical: 8000-12000 Hz for hiss removal **Common Frequencies**: - 15000-20000 Hz: Gentle air reduction - 8000-10000 Hz: Warmth - 3000-5000 Hz: Telephone effect **Usage**: ``` var effect = new LowPassAudioEffect(10000); // Remove frequencies above 10 kHz ``` --- ### BandPassAudioEffect **Implementation**: Custom DSP (state-variable filter) **Purpose**: Allow only specific frequency range. **Parameters**: - `CutOffHigh` (float): Upper frequency boundary in Hz - `CutOffLow` (float): Lower frequency boundary in Hz **Usage**: ``` // Constructor: BandPassAudioEffect(cutOffHigh, cutOffLow) var effect = new BandPassAudioEffect(5000, 300); // Allow 300-5000 Hz ``` --- ### NotchAudioEffect **Implementation**: Custom DSP (band-reject filter) **Purpose**: Remove specific frequency. **Parameters**: - `CutOff` (uint): Center frequency to remove in Hz - Typical: 50/60 Hz for hum removal **Usage**: ``` var effect = new NotchAudioEffect(60); // Remove 60 Hz hum ``` --- ### ChebyshevLimitAudioEffect **GStreamer Element**: `audiocheblimit` **Purpose**: Sharp low/high-pass filtering with ripple control. **Parameters**: - `CutOffFrequency` (float): Cutoff frequency in Hz - `Mode` (ChebyshevLimitAudioEffectMode): LowPass or HighPass - `Poles` (int): Filter order (2-8 typical) - Default: 4 - More poles = steeper rolloff - `Ripple` (float): Passband ripple in dB - Default: 0.25 - `Type` (int): Chebyshev type (1 or 2) - Default: 1 **Usage**: ``` var effect = new ChebyshevLimitAudioEffect(); effect.CutOffFrequency = 100; effect.Mode = ChebyshevLimitAudioEffectMode.HighPass; effect.Poles = 6; ``` --- ### ChebyshevBandPassRejectAudioEffect **GStreamer Element**: `audiochebband` **Purpose**: Sharp band-pass or band-reject filtering. **Parameters**: - `LowerFrequency` (float): Lower band boundary in Hz - `UpperFrequency` (float): Upper band boundary in Hz - `Mode` (ChebyshevBandPassRejectAudioEffectMode): BandPass or BandReject - `Poles` (int): Filter order (2-8 typical) - Default: 4 - `Ripple` (float): Passband ripple in dB - Default: 0.25 - `Type` (int): Chebyshev type (1 or 2) - Default: 1 **Usage**: ``` var effect = new ChebyshevBandPassRejectAudioEffect(); effect.LowerFrequency = 300; effect.UpperFrequency = 3000; effect.Mode = ChebyshevBandPassRejectAudioEffectMode.BandPass; ``` --- ## Spatial and Stereo Effects ### BalanceAudioEffect **GStreamer Element**: `audiopanorama` **Purpose**: Stereo balance (pan) control. **Parameters**: - `Level` (double): Balance position - Range: -1.0 to 1.0 - -1.0 = full left - 0.0 = center - 1.0 = full right - Default: 0.0 **Usage**: ``` var effect = new BalanceAudioEffect(-0.5); // Pan 50% left ``` --- ### WideStereoAudioEffect **GStreamer Element**: `stereo` **Purpose**: Enhance stereo width. **Parameters**: - `Level` (float): Widening intensity - Range: 0.0+ - Default: 0.01 - Typical: 0.01 to 1.0 - Higher values = wider stereo field **Usage**: ``` var effect = new WideStereoAudioEffect(); effect.Level = 0.5f; ``` --- ### Sound3DAudioEffect **Purpose**: 3D spatial audio simulation. **Parameters**: - `Value` (uint): Spatial amplification - Range: 1 to 20000 - 1000 = neutral (disabled) - < 1000 = narrower stereo - > 1000 = wider stereo - > 10000 may distort **Usage**: ``` var effect = new Sound3DAudioEffect(2000); // 2x spatial width ``` --- ### PhaseInvertAudioEffect **Purpose**: Invert audio phase by 180 degrees. **Parameters**: None. **Usage**: ``` var effect = new PhaseInvertAudioEffect(); ``` --- ### HRTFRenderAudioEffect **GStreamer Element**: `hrtfrender` (rsaudiofx) **Purpose**: HRTF-based 3D spatial audio. **Parameters**: - `HrirFile` (string): Path to HRIR data file - `InterpolationSteps` (ulong): Interpolation quality - Default: 8 - `BlockLength` (ulong): Processing block size - Default: 512 - `DistanceGain` (float): Distance attenuation factor - Default: 1.0 **Usage**: ``` var effect = new HRTFRenderAudioEffect("/path/to/hrir.dat"); effect.InterpolationSteps = 16; // Higher quality ``` --- ## Time-Based Effects ### EchoAudioEffect **GStreamer Element**: `audioecho` **Purpose**: Echo and delay effects. **Parameters**: - `Delay` (TimeSpan): Echo delay time - Must not exceed MaxDelay - `MaxDelay` (TimeSpan): Maximum delay buffer - Must be >= Delay - Set before starting playback - `Intensity` (float): Echo volume - Range: 0.0 to 1.0 - Default: 1.0 - `Feedback` (float): Echo repetition amount - Range: 0.0 to 1.0 - Default: 0.0 - Higher = more echoes **Usage**: ``` var delay = TimeSpan.FromMilliseconds(500); var effect = new EchoAudioEffect(delay); effect.Intensity = 0.7f; effect.Feedback = 0.4f; ``` --- ### RSAudioEchoAudioEffect **GStreamer Element**: `rsaudioecho` (rsaudiofx) **Purpose**: Enhanced echo with advanced controls. **Parameters**: - `Delay` (TimeSpan): Echo delay time - `MaxDelay` (TimeSpan): Maximum delay buffer - `Intensity` (double): Echo intensity - Range: 0.0 to 1.0 - `Feedback` (double): Feedback amount - Range: 0.0 to 1.0 **Usage**: ``` var effect = new RSAudioEchoAudioEffect(); effect.Delay = TimeSpan.FromMilliseconds(750); effect.Intensity = 0.6; effect.Feedback = 0.3; ``` --- ### ReverberationAudioEffect **GStreamer Element**: `freeverb` **Purpose**: Room reverberation simulation. **Parameters**: - `RoomSize` (float): Virtual room size - Range: 0.0 to 1.0 - Default: 0.5 - Larger = longer reverb tail - `Damping` (float): High-frequency absorption - Range: 0.0 to 1.0 - Default: 0.2 - Higher = darker reverb - `Level` (float): Wet/dry mix - Range: 0.0 to 1.0 - Default: 0.5 - 0 = dry, 1 = wet - `Width` (float): Stereo width - Range: 0.0 to 1.0 - Default: 1.0 - 0 = mono, 1 = full stereo **Usage**: ``` var effect = new ReverberationAudioEffect(); effect.RoomSize = 0.8f; // Large room effect.Damping = 0.3f; effect.Level = 0.4f; ``` --- ### FadeAudioEffect **Purpose**: Volume fade in/out automation. **Parameters**: - `StartVolume` (uint): Volume at start time - `StopVolume` (uint): Volume at stop time - `StartTime` (TimeSpan): When fade begins - `StopTime` (TimeSpan): When fade completes **Usage**: ``` // Fade out over 3 seconds starting at 10 seconds var effect = new FadeAudioEffect( 100, 0, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(13) ); ``` --- ## Modulation Effects ### PhaserAudioEffect **Purpose**: Phaser effect with LFO modulation. **Parameters**: - `Depth` (byte): Sweep depth - Range: 0 to 255 - `DryWetRatio` (byte): Mix ratio - Range: 0 to 255 - 0 = dry, 255 = wet - `Feedback` (byte): Resonance - Range: -100 to 100 - `Frequency` (float): LFO speed in Hz - Typical: 0.1 to 5 Hz - `Stages` (byte): Number of stages - Range: 2 to 24 recommended - More = stronger effect - `StartPhase` (float): LFO start phase in radians **Usage**: ``` var effect = new PhaserAudioEffect( 150, // depth 128, // 50% mix 50, // feedback 0.5f, // 0.5 Hz LFO 6, // 6 stages 0f // start phase ); ``` --- ### FlangerAudioEffect **Purpose**: Flanging effect with delay modulation. **Parameters**: - `Delay` (TimeSpan): Base delay time - Typical: 1-15 ms - `Frequency` (float): LFO speed in Hz - Typical: 0.1 to 5 Hz - `PhaseInvert` (bool): Invert delayed signal phase - Default: false **Usage**: ``` var effect = new FlangerAudioEffect( TimeSpan.FromMilliseconds(5), 1.0f, false ); ``` --- ## Pitch and Tempo Effects ### PitchShiftAudioEffect **Purpose**: Change pitch without changing speed. **Parameters**: - `Pitch` (float): Pitch shift ratio - 1.0 = no change - 2.0 = one octave up - 0.5 = one octave down - Typical range: 0.5 to 2.0 **Musical Intervals**: - 0.5 = -12 semitones - 1.059 = +1 semitone - 1.122 = +2 semitones - 2.0 = +12 semitones **Usage**: ``` var effect = new PitchShiftAudioEffect(1.5f); // Up by a fifth ``` --- ### ScaleTempoAudioEffect **GStreamer Element**: `scaletempo` **Purpose**: Change tempo without changing pitch (WSOLA algorithm). **Parameters**: - `Rate` (double): Playback speed - 1.0 = normal - 2.0 = double speed - 0.5 = half speed - Default: 1.0 - `Stride` (TimeSpan): Processing stride - Default: 30 ms - `Overlap` (double): Overlap percentage - Range: 0.0 to 1.0 - Default: 0.2 - `Search` (TimeSpan): Search window - Default: 14 ms **Usage**: ``` var effect = new ScaleTempoAudioEffect(1.5); // 1.5x speed ``` --- ## Special Effects ### KaraokeAudioEffect **GStreamer Element**: `audiokaraoke` **Purpose**: Remove center-panned vocals. **Parameters**: - `FilterBand` (float): Center frequency in Hz - Default: 220 Hz - Typical: 80-400 Hz - `FilterWidth` (float): Filter bandwidth in Hz - Default: 100 Hz - `Level` (float): Effect intensity - Range: 0.0 to 1.0 - Default: 1.0 - `MonoLevel` (float): Mono channel level - Range: 0.0 to 1.0 - Default: 1.0 **Usage**: ``` var effect = new KaraokeAudioEffect(); effect.FilterBand = 250f; effect.Level = 1.0f; ``` --- ### RemoveSilenceAudioEffect **Purpose**: Automatically remove silent sections. **Parameters**: - `Threshold` (double): Silence detection threshold - Range: 0.0 to 1.0 - Default: 0.05 - Lower = more sensitive - `Squash` (bool): Remove vs. reduce silence - true = remove completely - false = reduce level - Default: true **Usage**: ``` var effect = new RemoveSilenceAudioEffect("silence-remover"); effect.Threshold = 0.02; effect.Squash = true; ``` --- ### CsoundAudioEffect **GStreamer Element**: `csoundfilter` **Purpose**: Csound-based audio programming. **Platforms**: Windows, macOS, Linux (requires Csound installation). **Parameters**: - `CsdText` (string): Csound CSD document as text - `Location` (string): Path to CSD file - `Loop` (bool): Loop score continuously - Default: false - `ScoreOffset` (double): Start time in seconds - Default: 0.0 **Usage**: ``` var csd = @" ; Your Csound code here ; Your score here "; var effect = new CsoundAudioEffect("my-csound", csd); effect.Loop = false; ``` --- ## Noise Reduction and Measurement ### AudioRNNoiseAudioEffect **GStreamer Element**: `audiornnoise` (rsaudiofx) **Purpose**: AI-based noise reduction. **Parameters**: - `VadThreshold` (float): Voice activity detection threshold - Range: 0.0 to 1.0 - Default: 0.0 - Higher = more sensitive to voice **Usage**: ``` var effect = new AudioRNNoiseAudioEffect(); effect.VadThreshold = 0.5f; ``` --- ### AudioLoudNormAudioEffect **GStreamer Element**: `audioloudnorm` (rsaudiofx) **Purpose**: EBU R128 loudness normalization. **Parameters**: - `LoudnessTarget` (double): Target loudness in LUFS - Range: -70.0 to -5.0 - Default: -24.0 - `LoudnessRangeTarget` (double): Target range in LU - Range: 1.0 to 20.0 - Default: 7.0 - `MaxTruePeak` (double): Max true peak in dbTP - Range: -9.0 to 0.0 - Default: -2.0 - `Offset` (double): Offset gain in LU - Range: -99.0 to 99.0 - Default: 0.0 **Usage**: ``` var effect = new AudioLoudNormAudioEffect(); effect.LoudnessTarget = -16.0; // Streaming standard effect.MaxTruePeak = -1.0; ``` --- ### EbuR128LevelAudioEffect **GStreamer Element**: `ebur128level` (rsaudiofx) **Purpose**: EBU R128 loudness measurement. **Parameters**: - `Mode` (EbuR128Mode): Measurement types to calculate - Options: Momentary, ShortTerm, Global, LoudnessRange, SamplePeak, TruePeak, All - Default: All - `PostMessages` (bool): Post measurement messages - Default: true - `Interval` (TimeSpan): Measurement update interval - Default: 1 second **Usage**: ``` var effect = new EbuR128LevelAudioEffect(); effect.Mode = EbuR128Mode.All; effect.Interval = TimeSpan.FromSeconds(0.5); ``` --- ## Channel Management ### ChannelOrderAudioEffect **Purpose**: Remap audio channels. **Parameters**: - `Orders` (byte[,]): 2D array of [target, source] pairs - Format: [[target0, source0], [target1, source1], ...] - Channels are zero-indexed **Usage**: ``` // Swap left and right channels var orders = new byte[2, 2] { { 0, 1 }, // Output channel 0 gets input channel 1 (right) { 1, 0 } // Output channel 1 gets input channel 0 (left) }; var effect = new ChannelOrderAudioEffect(orders); ``` --- ### DownMixAudioEffect **Implementation**: Custom DSP (channel averaging) **Purpose**: Reduce channel count (e.g., 5.1 to stereo). **Parameters**: None (automatic downmixing). **Usage**: ``` var effect = new DownMixAudioEffect(); ``` --- ## DirectSound Effects (Classic SDKs, Windows Only) The following effects are available only in Video Capture SDK (VideoCaptureCore), Media Player SDK (MediaPlayerCore), and Video Edit SDK (VideoEditCore) on Windows. They use DirectSound/DirectX technology. ### DS Chorus Creates a chorus effect with multiple delayed and modulated copies. **Properties**: - **WetDryMix** (float): Dry/wet mix (0-100) - **Depth** (float): Modulation depth (0-100) - **Feedback** (float): Feedback amount (0-100) - **Frequency** (float): LFO frequency (0-10 Hz) - **Waveform**: Sine or Triangle - **Delay** (float): Base delay (0-20 ms) - **Phase**: Phase relationship for stereo (-180 to 180 degrees) **Usage**: ``` // Signature: (int streamIndex, string name, float delay, float depth, // float feedback, float frequency, DSChorusPhase phase, // DSChorusWaveForm waveformTriangle, float wetDryMix) videoCaptureCore.Audio_Effects_DS_Chorus(0, "chorus", delay: 16, depth: 25, feedback: 25, frequency: 1.1f, phase: DSChorusPhase.Phase90, waveformTriangle: DSChorusWaveForm.Sine, wetDryMix: 50); ``` --- ### DS Distortion Adds distortion/overdrive to audio signal. **Properties**: - **Gain** (float): Pre-distortion gain (-60 to 0 dB) - **Edge** (float): Distortion amount (0-100%) - **PostEQCenterFrequency** (float): Post-EQ center (100-8000 Hz) - **PostEQBandwidth** (float): Post-EQ bandwidth (100-8000 Hz) - **PreLowpassCutoff** (float): Pre-distortion lowpass (100-8000 Hz) **Usage**: ``` // Signature: (int streamIndex, string name, float edge, float gain, // float postEQBandwidth, float postEQCenterFrequency, // float preLowpassCutOff) videoCaptureCore.Audio_Effects_DS_Distortion(0, "distortion", edge: 50, gain: -18, postEQBandwidth: 2400, postEQCenterFrequency: 2400, preLowpassCutOff: 8000); ``` --- ### DS Gargle Creates a gargling/tremolo modulation effect. **Properties**: - **RateHz** (int): Modulation rate (1-1000 Hz) - **WaveForm**: Triangle or Square wave **Usage**: ``` // Signature: (int streamIndex, string name, int rateHz, DSGargleWaveForm waveForm) videoCaptureCore.Audio_Effects_DS_Gargle(0, "gargle", rateHz: 20, waveForm: DSGargleWaveForm.Triangle); ``` --- ### DS Reverb (I3DL2) Professional reverb with environmental modeling. **Properties**: - **Room** (int): Room effect level (-10000 to 0 mB) - **RoomHF** (int): High-frequency room effect (-10000 to 0 mB) - **RoomRolloffFactor** (float): Rolloff factor (0 to 10) - **DecayTime** (float): Decay time (0.1 to 20 seconds) - **DecayHFRatio** (float): HF decay ratio (0.1 to 2.0) - **Reflections** (int): Early reflections (-10000 to 1000 mB) - **ReflectionsDelay** (float): Reflections delay (0 to 0.3 seconds) - **Reverb** (int): Late reverb level (-10000 to 2000 mB) - **ReverbDelay** (float): Reverb delay (0 to 0.1 seconds) - **Diffusion** (float): Diffusion (0 to 100%) - **Density** (float): Density (0 to 100%) - **HFReference** (float): Reference HF (20 to 20000 Hz) --- ### DS Waves Reverb Simplified reverb with basic parameters. **Properties**: - **InGain** (float): Input gain (0 to 96 dB) - **ReverbMix** (float): Reverb mix (0 to 96 dB) - **ReverbTime** (float): Reverb time (0.001 to 3000 ms) - **HighFreqRTRatio** (float): HF reverb time ratio (0.001 to 0.999) **Usage**: ``` // Signature: (int streamIndex, string name, float highFreqRTRatio, // float inGain, float reverbMix, float reverbTime) videoCaptureCore.Audio_Effects_DS_WavesReverb(0, "reverb", highFreqRTRatio: 0.001f, inGain: 0, reverbMix: -10, reverbTime: 1000); ``` --- ## Effects Availability Matrix | Effect | Cross-Platform SDKs | Classic SDKs | Platforms | | --- | --- | --- | --- | | **Volume/Level Control** | | | | | Volume | Yes | Yes | Cross-platform / Windows | | Amplify | Yes | Yes | Cross-platform / Windows | | **Stereo Processing** | | | | | Balance | Yes | No | Cross-platform | | Wide Stereo | Yes | No | Cross-platform | | Karaoke | Yes | No | Cross-platform | | **Delay and Modulation** | | | | | Echo | Yes | Yes | Cross-platform / Windows | | Reverberation (Freeverb) | Yes | No | Cross-platform | | Flanger | Yes | Yes | Cross-platform / Windows | | Phaser | Yes | Yes | Cross-platform / Windows | | **Pitch and Tempo** | | | | | Pitch Shift | Yes | Yes | Cross-platform / Windows | | Scale Tempo | Yes | No | Cross-platform | | Tempo | Yes | Yes | Cross-platform / Windows | | **Equalization** | | | | | Equalizer 10-band | Yes | No | Cross-platform | | Equalizer Parametric | Yes | Yes | Cross-platform / Windows | | **Filtering** | | | | | High-Pass | Yes | Yes | Cross-platform / Windows | | Low-Pass | Yes | Yes | Cross-platform / Windows | | Band-Pass | Yes | Yes | Cross-platform / Windows | | Notch | Yes | Yes | Cross-platform / Windows | | Chebyshev Band Pass/Reject | Yes | No | Cross-platform | | Chebyshev Limit | Yes | No | Cross-platform | | **Dynamic Processing** | | | | | Compressor/Expander | Yes | No | Cross-platform | | Dynamic Amplify | Yes | Yes | Cross-platform / Windows | | **Frequency Enhancement** | | | | | TrueBass | Yes | Yes | Cross-platform / Windows | | Treble Enhancer | Yes | Yes | Cross-platform / Windows | | **Advanced Effects** | | | | | Phase Invert | Yes | Yes | Cross-platform / Windows | | Sound 3D | Yes | Yes | Cross-platform / Windows | | Channel Order | Yes | Yes | Cross-platform / Windows | | Down Mix | Yes | Yes | Cross-platform / Windows | | Fade | Yes | Yes | Cross-platform / Windows | | **Noise Reduction** | | | | | Remove Silence | Yes | No | Cross-platform | | Audio RNNoise | Yes | No | Cross-platform (requires plugin) | | Audio Loud Norm | Yes | No | Cross-platform (requires plugin) | | **Analysis** | | | | | EBU R128 Level | Yes | No | Cross-platform (requires plugin) | | **Spatial Audio** | | | | | HRTF Render | Yes | No | Cross-platform (requires plugin) | | **Specialized** | | | | | RS Audio Echo | Yes | No | Cross-platform (requires plugin) | | Csound Filter | Yes | No | Windows/macOS/Linux (requires Csound) | | **DirectSound Effects (Windows Classic Only)** | | | | | DS Chorus | No | Yes | Windows only | | DS Distortion | No | Yes | Windows only | | DS Gargle | No | Yes | Windows only | | DS Reverb (I3DL2) | No | Yes | Windows only | | DS Waves Reverb | No | Yes | Windows only | **Legend**: - **Cross-platform SDKs** = Media Blocks SDK, Video Capture SDK (VideoCaptureCoreX), Media Player SDK (MediaPlayerCoreX) - **Classic SDKs** = Video Capture SDK (VideoCaptureCore), Media Player SDK (MediaPlayerCore), Video Edit SDK (VideoEditCore) — Windows only ## Audio Elements Reference | Effect | Audio Element | Plugin | | --- | --- | --- | | Volume | volume | coreelements | | Amplify | audioamplify | audiofx | | Balance | audiopanorama | audiofx | | Echo | audioecho | audiofx | | Karaoke | audiokaraoke | audiofx | | Wide Stereo | stereo | audiofx | | Reverberation | freeverb | freeverb | | Equalizer 10-band | equalizer-10bands | audiofx | | High-Pass | audiocheblimit | audiofx | | Low-Pass | audiocheblimit | audiofx | | Chebyshev Band | audiochebband | audiofx | | Chebyshev Limit | audiocheblimit | audiofx | | Compressor | audiodynamic | audiofx | | Scale Tempo | scaletempo | audiofx | | Pitch Shift | pitch | soundtouch | | Audio RNNoise | audiornnoise | rsaudiofx | | Audio Loud Norm | audioloudnorm | rsaudiofx | | EBU R128 Level | ebur128level | rsaudiofx | | RS Audio Echo | rsaudioecho | rsaudiofx | | HRTF Render | hrtfrender | rsaudiofx | | Csound Filter | csoundfilter | csound | ## Frequently Asked Questions What is the default value for audio effect parameters? Each effect has documented defaults that represent neutral/bypass behavior. For example, `VolumeAudioEffect` defaults to level 1.0 (100%), `Equalizer10AudioEffect` defaults all bands to 0 dB, and `ReverberationAudioEffect` defaults to a moderate room simulation. See each effect's parameter table above for specific defaults. How do I reset an audio effect to its default settings? Create a new instance of the effect with default constructor parameters and call `Audio_Effects_AddOrUpdate()` to replace the current settings. Each effect's default constructor initializes all parameters to their documented defaults. Can I use multiple instances of the same effect type? Yes. Effect **names** are used as unique identifiers, not effect types. To run multiple instances of the same type simultaneously, give each instance a distinct name. Calling `Audio_Effects_AddOrUpdate()` with an effect whose name matches an existing one replaces that instance; a new name adds a new instance to the chain. What sample rates and channel configurations are supported? All cross-platform audio effects support standard sample rates (8 kHz to 192 kHz) and channel configurations (mono, stereo, multi-channel). The effects automatically adapt to the audio format of the input stream. Some effects like `BalanceAudioEffect` and `WideStereoAudioEffect` require stereo input. How do I remove an audio effect during playback? Use the `Audio_Effects_Remove()` method with the effect type to remove it from the processing chain during playback. The change takes effect immediately without interrupting the audio stream. ## See Also - [Audio Effects Overview](../) - [Audio Sample Grabber](../audio-sample-grabber/) - [Audio Processing Blocks (Media Blocks SDK)](../../../mediablocks/AudioProcessing/) ---END OF PAGE--- ## AAC Audio Encoding with M4A Container Output in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/aac/ **Description:** Use avenc_aac, voaacenc, and Media Foundation backends with runtime detection. Bitrate 32-320 kbps, 5.1 surround, and M4A/MP4 containers. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Recording, Encoding, Editing, MP4, TS, MPEG-2, AAC, C# **API:** M4AOutput, AACObject, AVENCAACEncoderSettings, VOAACEncoderSettings, AACOutput # AAC encoder and M4A output [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The VisioForge SDK provides several AAC encoder implementations, each with unique characteristics and use cases. ## What is M4A Output? M4A is a file format used for storing audio data encoded with the Advanced Audio Coding (AAC) codec. VisioForge .Net SDKs provide robust support for creating high-quality M4A audio files through their dedicated M4AOutput class. This format is widely used for digital audio distribution due to its excellent compression efficiency and sound quality. ## Cross-platform M4A (AAC) output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The cross-platform capable SDKs (VideoCaptureCoreX, VideoEditCoreX, MediaBlocksPipeline) allow you to utilize several AAC encoder implementations via `M4AOutput`. This guide focuses on three main approaches using dedicated settings objects: 1. [AVENC AAC Encoder](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.AVENCAACEncoderSettings.html) - A feature-rich, cross-platform encoder. 2. [VO-AAC Encoder](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.VOAACEncoderSettings.html) - A streamlined, cross-platform encoder. 3. Media Foundation AAC Encoder - A Windows-specific system encoder, accessible on Windows platforms via `MFAACEncoderSettings`. ### AVENC AAC Encoder The AVENC AAC Encoder offers the most comprehensive configuration options for audio encoding. It provides advanced settings for stereo coding, prediction, and noise shaping. #### Key Features - Multiple coder strategies - Configurable stereo coding - Advanced noise and prediction techniques #### Coder Strategies The AVENC AAC Encoder supports three coder strategies: - `ANMR`: Advanced noise modeling and reduction method - `TwoLoop`: Two-loop searching method for optimization - `Fast`: Default fast search algorithm (recommended for most use cases) #### Sample Configuration ``` var aacSettings = new AVENCAACEncoderSettings { Coder = AVENCAACEncoderCoder.Fast, Bitrate = 192, IntensityStereo = true, ForceMS = AVENCAACTrilian.Auto, TNS = true }; ``` #### Supported Parameters - **Bitrates**: 0, 32, 64, 96, 128, 160, 192, 224, 256, 320 kbps - **Sample Rates**: 7350 to 96000 Hz - **Channels**: 1 to 6 channels ### VO-AAC Encoder Deprecated `VOAACEncoderSettings` is marked `[Obsolete]` in recent SDK releases — the underlying `voaacenc` element fails caps negotiation with `mpegtsmux` on iOS and is no longer recommended. Prefer `AVENCAACEncoderSettings` for new code; `MFAACEncoderSettings` remains a good choice on Windows. The VO-AAC Encoder is a more streamlined encoder with simpler configuration options. #### Key Features - Simplified configuration - Straightforward bitrate and sample rate controls - Limited to stereo audio #### Sample Configuration ``` var aacSettings = new VOAACEncoderSettings { Bitrate = 128 }; ``` #### Supported Parameters - **Bitrates**: 32, 64, 96, 128, 160, 192, 224, 256, 320 kbps - **Sample Rates**: 8000 to 96000 Hz - **Channels**: 1-2 channels ### Media Foundation AAC Encoder (Windows Only) This encoder is specific to Windows platforms and offers a limited but performance-optimized encoding solution. #### Key Features - Windows-specific implementation - Predefined bitrate options - Limited sample rate support #### Supported Parameters - **Bitrates**: 0 (Auto), 96, 128, 160, 192, 576, 768, 960, 1152 kbps - **Sample Rates**: 44100, 48000 Hz - **Channels**: 1, 2, 6 channels ### Encoder Availability and Selection Each encoder provides a static `IsAvailable()` method to check if the encoder can be used in the current environment. This is useful for runtime compatibility checks. ``` if (AVENCAACEncoderSettings.IsAvailable()) { // Use AVENC AAC Encoder } else if (VOAACEncoderSettings.IsAvailable()) { // Fallback to VO-AAC Encoder } ``` ### Getting Started with M4AOutput The cross-platform implementation uses the [M4AOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.M4AOutput.html) class as the foundation for M4A file creation. To begin using this feature, initialize the class with your desired output filename: ``` var output = new M4AOutput("output.m4a"); ``` ### Switching Between Encoders The default encoder selection is platform-dependent: - Windows environments: MF AAC - Other platforms: VO-AAC You can override this default selection by explicitly setting the `Audio` property: ``` // For VO-AAC encoder output.Audio = new VOAACEncoderSettings(); // For AVENC AAC encoder output.Audio = new AVENCAACEncoderSettings(); // For MF AAC encoder (Windows only) #if NET_WINDOWS output.Audio = new MFAACEncoderSettings(); #endif ``` ### Configuring MP4 Sink Settings Since M4A files are based on the MP4 container format, you can adjust various output parameters through the `Sink` property: ``` // Change the output filename output.Sink.Filename = "new_output.m4a"; ``` ### Advanced Audio Processing For workflows requiring specialized audio processing, the M4AOutput class supports custom audio processors: ``` // Implement your custom audio processing logic output.CustomAudioProcessor = new MyCustomAudioProcessor(); ``` ### Key Methods for File Management The M4AOutput class provides several methods for handling files and retrieving encoder information: ``` // Get current output filename string currentFile = output.GetFilename(); // Update the output filename output.SetFilename("updated_file.m4a"); // Retrieve available audio encoders var audioEncoders = output.GetAudioEncoders(); ``` ### Using M4A Output in Different SDKs Each VisioForge SDK has a slightly different approach to implementing M4A output: #### With Video Capture SDK ``` var core = new VideoCaptureCoreX(); core.Outputs_Add(output, true); ``` #### With Video Edit SDK ``` var core = new VideoEditCoreX(); core.Output_Format = output; ``` #### With Media Blocks SDK ``` var aac = new VOAACEncoderSettings(); var sinkSettings = new MP4SinkSettings("output.m4a"); var m4aOutput = new M4AOutputBlock(sinkSettings, aac); ``` ### Rate Control Considerations 1. **AVENC AAC Encoder**: 2. Most flexible rate control 3. Supports constant bitrate (CBR) 4. Multiple encoding strategies affect quality and performance 5. **VO-AAC Encoder**: 6. Simple constant bitrate control 7. Recommend for straightforward encoding needs 8. Limited advanced configuration 9. **Media Foundation Encoder**: 10. Limited to predefined bitrates 11. Good for quick Windows-based encoding 12. Auto bitrate option available ### Recommendations - For advanced audio encoding with maximum control, use AVENC AAC Encoder - For simple, cross-platform encoding, use VO-AAC Encoder - For Windows-specific, optimized encoding, use Media Foundation Encoder ### Performance and Quality Considerations - **Bitrate vs. Quality vs. File Size**: Higher bitrates generally result in better audio quality but also lead to larger file sizes. Experiment with different bitrates to find the optimal balance for your specific content and distribution needs. - **Sample Rate Matching**: Always try to choose sample rates that match your source audio. This avoids unnecessary resampling, which can potentially degrade audio quality. - **Encoder Characteristics**: - `AVENC AAC Encoder`: Offers the most extensive configuration options, allowing for fine-grained control over quality and performance. Ideal for advanced use cases. - `VO-AAC Encoder`: Provides a good balance of simplicity, cross-platform compatibility, and quality. A solid choice for many common scenarios. - `Media Foundation AAC Encoder`: Leverages built-in Windows audio processing capabilities. It can be efficient on Windows but offers less configuration flexibility than AVENC. - **Channel Configuration (Mono vs. Stereo)**: - For voice-only content, using mono encoding (1 channel) can significantly reduce file size without a noticeable loss in quality for speech. Check if your chosen encoder settings (e.g., `AVENCAACEncoderSettings.Channels`) allow explicit channel configuration. - For music and rich audio environments, stereo (2 channels) is generally preferred. - **Content-Specific Bitrate Ranges**: While higher is often better, the "best" bitrate depends on the audio content: - *Speech/Voice:* 64-96 kbps can be adequate. - *General Music:* 128-192 kbps is a common target for good quality. - *High-Fidelity Audio:* 256-320 kbps or higher might be used when pristine quality is critical. These are guidelines; always test with your specific audio. - **Target Audience and Platform**: Consider who will be listening and on what devices. For example, if the audio is primarily for web streaming to mobile devices, extremely high bitrates might lead to buffering issues or unnecessary data consumption. Tailor your encoder choice and settings accordingly. ### Sample Code - Check the [MP4 output](../../output-formats/mp4/) guide for sample code. - Check the [AAC encoder block](../../../mediablocks/AudioEncoders/) for sample code. ## Windows-only AAC output [VideoCaptureCore](#) [VideoEditCore](#) [M4AOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.M4AOutput.html) is the primary class for configuring M4A (AAC) output settings. It implements both `IVideoEditBaseOutput` and `IVideoCaptureBaseOutput` interfaces. ### Properties | Property | Type | Description | Default Value | | --- | --- | --- | --- | | Version | AACVersion | Specifies the AAC version (MPEG-2 or MPEG-4) | MPEG4 | | Object | AACObject | Defines the AAC object type | Low | | Output | AACOutput | Sets the AAC output mode | RAW | | Bitrate | int | Specifies the AAC bitrate in kbps | 128 | ### Methods #### `GetInternalTypeVC()` - Returns: `VideoCaptureOutputFormat.M4A` - Purpose: Gets the internal output format for video capture #### `GetInternalTypeVE()` - Returns: `VideoEditOutputFormat.M4A` - Purpose: Gets the internal output format for video editing #### `Save()` - Returns: JSON string representation of the M4AOutput object - Purpose: Serializes the current configuration to JSON #### `Load(string json)` - Parameters: JSON string containing M4AOutput configuration - Returns: New M4AOutput instance - Purpose: Creates a new M4AOutput instance from JSON configuration ### Supporting Enums #### AACVersion Defines the version of AAC to be used: | Value | Description | | --- | --- | | MPEG4 | MPEG-4 AAC (default) | | MPEG2 | MPEG-2 AAC | #### AACObject Specifies the AAC encoder stream object type: | Value | Description | | --- | --- | | Undefined | Not to be used | | Main | Main profile | | Low | Low Complexity profile (default) | | SSR | Scalable Sample Rate profile | | LTP | Long Term Prediction profile | #### AACOutput Determines the AAC encoder stream output type: | Value | Description | | --- | --- | | RAW | Raw AAC stream (default) | | ADTS | Audio Data Transport Stream format | ### Usage Example ``` // Create new M4A output configuration var core = new VideoCaptureCore(); core.Mode = VideoCaptureMode.VideoCapture; core.Output_Filename = "output.m4a"; var output = new M4AOutput { Bitrate = 192, Version = AACVersion.MPEG4, Object = AACObject.Low, Output = AACOutput.ADTS }; core.Output_Format = output; // core is an instance of VideoCaptureCore or VideoEditCore ``` ### Selecting the Right Bitrate The optimal bitrate depends on your content type and quality requirements: - **64-96 kbps**: Suitable for voice recordings and speech content - **128-192 kbps**: Recommended for general music and audio content - **256-320 kbps**: Ideal for high-fidelity music where quality is paramount ### Choosing the Appropriate Profile - Use `AACObject.Low` for most applications as it provides an excellent balance between quality and encoding efficiency - Reserve `AACObject.Main` for specialized use cases requiring maximum quality - Avoid `AACObject.Undefined` as it isn't a valid encoding option ### Container Format Selection - `AACOutput.ADTS` provides better compatibility with various players and devices - `AACOutput.RAW` is preferable when the AAC stream will be embedded within another container format ---END OF PAGE--- ## FLAC Lossless Audio Encoding and Recording in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/flac/ **Description:** Lossless recording with quality levels 0-9, sample rates up to 655 kHz, 8-channel surround, and LPC optimization. VisioForge SDK C# code examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, FLAC, C# **API:** FLACOutput, FLACEncoderSettings, VideoCaptureCoreX, VideoEditCoreX, CustomAudioProcessor # FLAC encoder and output [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The FLAC (Free Lossless Audio Codec) encoder provides high-quality lossless audio compression while preserving the original audio quality. ## Cross-platform FLAC output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ### Features The FLAC encoder supports a wide range of audio configurations: - Sample rates from 1 Hz to 655,350 Hz - Up to 8 audio channels (mono to 7.1 surround) - Lossless compression with adjustable quality settings - Streamable output support - Configurable block sizes and compression parameters ### Quality Settings The encoder provides a quality parameter ranging from 0 to 9: - 0: Fastest compression (lowest CPU usage) - 1-7: Balanced compression settings - 8: Highest compression (higher CPU usage) - 9: Insane compression (extremely CPU intensive) The default quality setting is 5, which offers a good balance between compression ratio and processing speed. ### Basic Settings The cross-platform [FLACEncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.FLACEncoderSettings.html) class offers advanced configuration options: ``` // Create FLAC encoder settings with default quality var flacSettings = new FLACEncoderSettings { // Default compression level Quality = 5, // Audio block size in samples BlockSize = 4608, // Enable streaming support StreamableSubset = true, // Enable stereo processing MidSideStereo = true }; ``` ### Advanced Compression Settings ``` // Create FLAC encoder settings with advanced configuration var advancedSettings = new FLACEncoderSettings { // Linear Prediction settings // Maximum LPC order for prediction MaxLPCOrder = 8, // Auto precision for coefficients QlpCoeffPrecision = 0, // Residual coding settings MinResidualPartitionOrder = 3, MaxResidualPartitionOrder = 3, // Search optimization settings // Disable expensive coefficient search ExhaustiveModelSearch = false, // Disable precision search QlpCoeffPrecSearch = false, // Disable escape code search EscapeCoding = false }; ``` ### Sample Code Add the FLAC output to the Video Capture SDK core instance: ``` // Create a Video Capture SDK core instance var core = new VideoCaptureCoreX(); // Create a FLAC output instance var flacOutput = new FLACOutput("output.flac"); // Set the quality of the FLAC encoder flacOutput.Audio.Quality = 5; // Add the FLAC output core.Outputs_Add(flacOutput, true); ``` Set the output format for the Video Edit SDK core instance: ``` // Create a Video Edit SDK core instance var core = new VideoEditCoreX(); // Create a FLAC output instance var flacOutput = new FLACOutput("output.flac"); // Set the quality flacOutput.Audio.Quality = 5; // Set the output format core.Output_Format = flacOutput; ``` Create a Media Blocks FLAC output instance: ``` // Create a FLAC encoder settings instance var flacSettings = new FLACEncoderSettings(); // Create a FLAC output instance var flacOutput = new FLACOutputBlock("output.flac", flacSettings); ``` ### FLACOutput class The `FLACOutput` class provides functionality for configuring FLAC (Free Lossless Audio Codec) output in the VisioForge SDKs. ``` // Create a new FLAC output instance var flacOutput = new FLACOutput("output.flac"); // Configure FLAC encoder settings (Quality: 0 fastest .. 8 highest, 9 insane) flacOutput.Audio.Quality = 5; ``` #### Filename - Set the output filename during initialization or via the `Filename` property - Or call `GetFilename()` / `SetFilename(string)` methods (equivalent — they back the `Filename` property) ``` // Set during initialization var flacOutput = new FLACOutput("audio_output.flac"); // Or via the property flacOutput.Filename = "new_output.flac"; // Or via the method accessors flacOutput.SetFilename("final.flac"); string currentPath = flacOutput.GetFilename(); // "final.flac" ``` #### Audio Settings The `Audio` property provides access to FLAC-specific encoding settings through the `FLACEncoderSettings` class: ``` flacOutput.Audio = new FLACEncoderSettings(); // Configure specific FLAC encoding parameters here ``` #### Custom Audio Processing You can set a custom audio processor using the `CustomAudioProcessor` property: ``` flacOutput.CustomAudioProcessor = new CustomMediaBlock(); ``` #### Implementation Notes - The class implements multiple interfaces: - `IVideoEditXBaseOutput` - `IVideoCaptureXBaseOutput` - `IOutputAudioProcessor` - Only FLAC audio encoding is supported (no video encoding capabilities) - Default FLAC encoder settings are automatically created during initialization Media Blocks SDK contains a dedicated [FLAC encoder block](../../../mediablocks/AudioEncoders/). ### Performance Considerations When configuring the FLAC encoder, consider these performance factors: 1. Higher quality settings (7-9) will significantly increase CPU usage 2. The `ExhaustiveModelSearch` option can greatly impact encoding speed 3. Larger block sizes may improve compression but increase memory usage 4. `StreamableSubset` should remain enabled unless you have specific requirements ### Compatibility The encoder supports the following configurations: - Audio channels: 1 to 8 channels - Sample rates: 1 Hz to 655,350 Hz - Bitrate: Variable (lossless compression) ### Error Handling Always check for encoder availability before use: ``` if (!FLACEncoderSettings.IsAvailable()) { // Handle unavailable encoder scenario Console.WriteLine("FLAC encoder is not available on this system"); return; } ``` ### Best Practices 1. Start with the default quality setting (5) and adjust based on your needs 2. Enable `MidSideStereo` for stereo content to improve compression 3. Use `SeekPoints` for longer audio files to enable quick seeking 4. Keep `StreamableSubset` enabled unless you have specific requirements 5. Avoid using `ExhaustiveModelSearch` unless compression ratio is critical ## Windows-only FLAC output [VideoCaptureCore](#) [VideoEditCore](#) The [FLACOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.FLACOutput.html) class provides Windows-only settings for the FLAC encoder. This class implements both `IVideoEditBaseOutput` and `IVideoCaptureBaseOutput` interfaces, making it suitable for both video editing and capture scenarios. ### Properties #### Compression Level - **Property**: `Level` - **Type**: `int` - **Range**: 0-8 - **Default**: 5 - **Description**: Controls the compression level, where 0 provides fastest compression and 8 provides highest compression. #### Block Size - **Property**: `BlockSize` - **Type**: `int` - **Default**: 4608 - **Valid Values**: For subset streams, must be one of: - 192, 256, 512, 576, 1024, 1152, 2048, 2304, 4096, 4608 - 8192, 16384 (only if sample rate > 48kHz) - **Description**: Specifies the block size in samples. The encoder uses the same block size for the entire stream. #### LPC Order - **Property**: `LPCOrder` - **Type**: `int` - **Default**: 8 - **Constraints**: - Must be ≤ 32 - For subset streams at ≤ 48kHz, must be ≤ 12 - **Description**: Specifies the maximum Linear Predictive Coding order. Setting to 0 disables generic linear prediction and uses only fixed predictors, which is faster but typically results in 5-10% larger files. #### Mid-Side Coding Options ##### Mid-Side Coding - **Property**: `MidSideCoding` - **Type**: `bool` - **Default**: `false` - **Description**: Enables mid-side coding for stereo streams. This typically increases compression by a few percent by encoding both stereo pair and mid-side versions of each block and selecting the smallest resulting frame. ##### Adaptive Mid-Side Coding - **Property**: `AdaptiveMidSideCoding` - **Type**: `bool` - **Default**: `false` - **Description**: Enables adaptive mid-side coding for stereo streams. This provides faster encoding than full mid-side coding but with slightly less compression by adaptively switching between independent and mid-side coding. #### Rice Parameters ##### Rice Minimum - **Property**: `RiceMin` - **Type**: `int` - **Default**: 3 - **Description**: Sets the minimum residual partition order. Works in conjunction with RiceMax to control how the residual signal is partitioned. ##### Rice Maximum - **Property**: `RiceMax` - **Type**: `int` - **Default**: 3 - **Description**: Sets the maximum residual partition order. The residual is partitioned into 2^min to 2^max pieces, each with its own Rice parameter. Optimal settings typically depend on block size, with best results when blocksize/(2^n)=128. #### Advanced Options ##### Exhaustive Model Search - **Property**: `ExhaustiveModelSearch` - **Type**: `bool` - **Default**: `false` - **Description**: Enables exhaustive model search for optimal encoding. When enabled, the encoder generates subframes for every order and uses the smallest, potentially improving compression by ~0.5% at the cost of significantly increased encoding time. ### Methods #### Constructor ``` public FLACOutput() ``` Initializes a new instance with default values: - Level = 5 - RiceMin = 3 - RiceMax = 3 - LPCOrder = 8 - BlockSize = 4608 ### Serialization #### Save() ``` public string Save() ``` Serializes the settings to a JSON string. #### Load(string json) ``` public static FLACOutput Load(string json) ``` Creates a new FLACOutput instance from a JSON string. ### Usage Example ``` var flacSettings = new FLACOutput { Level = 8, // Maximum compression BlockSize = 4608, // Default block size MidSideCoding = true, // Enable mid-side coding for better compression ExhaustiveModelSearch = true // Enable exhaustive search for best compression }; core.Output_Format = flacSettings; // Core is VideoCaptureCore or VideoEditCore ``` ### Best Practices #### Compression Level Selection - Use Level 0-3 for faster encoding with moderate compression - Use Level 4-6 for balanced compression/speed - Use Level 7-8 for maximum compression regardless of speed #### Block Size Considerations - Larger block sizes generally provide better compression - Stick to standard values (4608, 4096, etc.) for maximum compatibility - Consider memory constraints when selecting block size #### Mid-Side Coding - Enable for stereo content when compression is priority - Use adaptive mode when encoding speed is important - Disable for mono content as it has no effect #### Rice Parameters - Default values (3,3) are suitable for most use cases - Increase for potentially better compression at the cost of encoding speed - Values beyond 6 rarely provide significant benefits ---END OF PAGE--- ## Audio Encoders for .NET — AAC, FLAC, MP3, Opus Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/ **Description:** Implement AAC, FLAC, MP3, Opus, and other audio encoders in .NET with optimal settings, performance tips, and best practices. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming # Audio Encoders for .NET Development [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Audio Encoding in .NET Applications When developing media applications in .NET, choosing the right audio encoder is crucial for ensuring optimal performance, compatibility, and quality. VisioForge's suite of .NET SDKs provides developers with powerful tools for audio encoding across various formats, enabling the creation of professional-grade media applications. Audio encoders are essential components that convert raw audio data into compressed formats suitable for storage, streaming, or playback. Each encoder offers different advantages in terms of compression ratio, audio quality, processing requirements, and platform compatibility. This guide will help you navigate the various audio encoding options available in VisioForge's .NET SDKs. ## Quick Start — Pick an audio encoder Every encoder on the cross-platform engines is a settings class that you assign to the output's `Audio` property (or pass to a `*OutputBlock` in Media Blocks). The surrounding pipeline is the same — only the settings type changes. ``` using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Output; // MP4 container: encode audio with AAC. var mp4 = new MP4Output("output.mp4"); mp4.Audio = new VOAACEncoderSettings { Bitrate = 192 }; // 128/192/256 kbps typical // MKV container: swap in a different codec on the same Audio slot. var mkv = new MKVOutput("output.mkv"); mkv.Audio = new OPUSEncoderSettings { Bitrate = 128 }; // FLAC: lossless audio-only output. var flac = new FLACOutput("music.flac"); flac.Audio.Quality = 5; // 0 fastest .. 8 highest, 9 insane // Standalone formats (one encoder = one container): var mp3 = new MP3Output("song.mp3"); // MP3 var wav = new WAVOutput("raw.wav"); // uncompressed PCM var ogg = new OGGVorbisOutput("music.ogg"); // OGG + Vorbis // Attach to a VideoCaptureCoreX or VideoEditCoreX instance: // core.Outputs_Add(mp4, true); // VideoCaptureCoreX // core.Output_Format = mp4; // VideoEditCoreX ``` Pick the encoder that matches your target: **AAC** for broad compatibility (MP4, M4A, streaming), **Opus** for low-latency / low-bitrate voice or music, **MP3** for legacy distribution, **FLAC** for lossless archives, **Vorbis** for open-format WebM/OGG pipelines. Detailed per-encoder pages cover bitrate tables, sample-rate limits, and tuning parameters. ## Available Audio Encoders VisioForge's .NET SDKs include support for the following audio encoders, each designed for specific use cases: ### [AAC Encoder](aac/) Advanced Audio Coding (AAC) represents the industry standard for high-quality audio compression. It delivers excellent sound quality at lower bit rates compared to older formats like MP3. **Key features:** - Efficient compression with minimal quality loss - Wide device and platform compatibility - Variable bit rate support for optimized file sizes - Ideal for streaming applications and mobile devices - Support for multi-channel audio (up to 48 channels) AAC is particularly well-suited for applications where audio quality is paramount, such as music streaming services, video production tools, and professional media applications. ### [FLAC Encoder](flac/) Free Lossless Audio Codec (FLAC) provides lossless compression of audio data, preserving the original audio quality while reducing file size. **Key features:** - Lossless compression with no quality degradation - Open-source format with broad support - Typically reduces file sizes by 40-50% compared to uncompressed audio - Fast encoding and decoding performance - Supports metadata tags and seeking FLAC is ideal for archiving audio, professional audio editing applications, and audiophile-grade music playback systems where maintaining perfect audio fidelity is essential. ### [MP3 Encoder](mp3/) MPEG Audio Layer III (MP3) remains one of the most widely used audio formats due to its universal compatibility and acceptable quality-to-size ratio. **Key features:** - Nearly universal compatibility across devices and platforms - Configurable bit rates from 8 to 320 Kbps - Joint stereo mode for improved compression efficiency - Variable bit rate (VBR) encoding for optimized quality - Fast encoding and minimal processing requirements MP3 is best for applications where wide compatibility is more important than achieving the absolute highest audio quality, such as podcasts, basic music applications, and legacy system integration. ### [Opus Encoder](opus/) Opus is a highly versatile audio codec designed to handle both speech and music with excellent quality at low bit rates. **Key features:** - Superior performance at low bit rates (6-64 Kbps) - Low algorithmic delay for real-time applications - Seamless quality adjustment based on available bandwidth - Excellent for both speech and music content - Open standard with growing adoption Opus excels in real-time communication applications, VoIP systems, live streaming, and scenarios where bandwidth efficiency is critical. ### [Speex Encoder](speex/) Speex is an audio compression format specifically optimized for speech encoding, making it ideal for voice-centric applications. **Key features:** - Designed specifically for human voice compression - Variable bit rates from 2 to 44 Kbps - Voice activity detection and comfort noise generation - Low latency for real-time applications - Open source with minimal patent concerns Speex is particularly effective for voice chat applications, voice recording tools, and telephony systems where speech clarity is the priority. ### [Vorbis Encoder](vorbis/) Vorbis is an open-source, patent-free audio compression format that offers quality comparable to AAC at similar bit rates. **Key features:** - Free and open format without licensing restrictions - Excellent quality-to-size ratio for music - Variable and average bit rate encoding modes - Strong support in open-source software ecosystems - Multi-channel audio support Vorbis is well-suited for applications where licensing costs are a concern, such as open-source projects, indie game development, and web applications. ### [WavPack Encoder](wavpack/) WavPack offers a unique hybrid approach to audio compression, providing both lossless and high-quality lossy compression options. **Key features:** - Hybrid mode combining lossy and lossless techniques - Correction files to restore lossy files to lossless quality - Fast decoding with minimal CPU requirements - Support for high-resolution audio up to 32-bit/192kHz - Robust error correction capabilities WavPack is excellent for applications requiring flexible quality options, archival purposes, and systems where decoding performance is more critical than encoding speed. ### [Windows Media Audio Encoder](wma/) Windows Media Audio (WMA) provides a set of audio codecs developed by Microsoft, offering good integration with Windows platforms. **Key features:** - Native integration with Windows environments - Multiple codec variants (WMA Standard, Pro, Lossless) - Good performance on Windows devices and Xbox platforms - Professional variant supports multi-channel surround sound - Digital rights management capabilities WMA is particularly useful for Windows-centric applications, enterprise solutions, and scenarios where DRM protection is required. ## Choosing the Right Audio Encoder Selecting the appropriate audio encoder depends on several factors: 1. **Quality Requirements**: For archiving or professional applications, consider lossless options like FLAC or WavPack. For general-purpose use, AAC or Vorbis provide excellent quality at reasonable sizes. 2. **Platform Compatibility**: If your application needs to work across many devices, MP3 offers the widest compatibility, while AAC is well-supported on modern platforms. 3. **Content Type**: For speech-focused applications, Speex or Opus at lower bitrates excel. For music, AAC, Vorbis, or MP3 at higher bitrates are preferable. 4. **Bandwidth Considerations**: For streaming over limited connections, Opus provides excellent quality at very low bitrates. 5. **Licensing Requirements**: If your project requires open-source or patent-free solutions, focus on FLAC, Vorbis, or Opus. ## Implementation Considerations When implementing audio encoders in your .NET application: - **Threading**: Consider encoding audio on background threads to prevent UI freezing during processing. - **Buffer Management**: Properly manage audio buffers to prevent memory leaks during encoding operations. - **Error Handling**: Implement robust error handling for encoding failures or corrupt input data. - **Metadata**: Most formats support metadata tags—use them to enhance the user experience. - **Preprocessing**: Consider implementing audio normalization or other preprocessing before encoding for optimal results. ## Performance Optimization To achieve the best performance when using audio encoders: - Match encoding quality to your application's needs—higher quality settings require more processing power - Implement caching strategies for frequently accessed audio - Consider hardware acceleration when available, particularly for real-time encoding - Batch process audio files when possible rather than encoding on demand - Monitor memory usage, especially when processing long audio files ## Getting Started To begin implementing audio encoders in your .NET application using VisioForge SDKs, follow these steps: 1. Install the appropriate VisioForge SDK via NuGet or direct download 2. Reference the SDK in your project 3. Initialize the encoder with your desired configuration settings 4. Process audio through the encoder using the provided API methods 5. Handle the encoded output as needed for your application Each encoder has specific initialization parameters and optimal settings, which are detailed in their respective documentation pages. By understanding the strengths and appropriate use cases for each audio encoder, .NET developers can make informed decisions that optimize their media applications for quality, performance, and compatibility. ---END OF PAGE--- ## MP3 Audio Encoder in C# .NET — LAME Bitrate Settings **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/mp3/ **Description:** LAME encoder with CBR, ABR, and quality-based VBR modes. Joint stereo, voice optimization, bitrate 8-320 kbps. VisioForge SDK capture and editing examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, MP3, C# **API:** MP3Output, MP3EncoderSettings, MP3EncoderRateControl, MP3ChannelsMode, MP3EncodingQuality # Mastering MP3 Audio: Record, Capture & Edit in C# and .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The VisioForge SDK empowers developers to seamlessly record, capture, and edit MP3 audio within C# applications. This guide explores how to leverage our robust .NET SDK for high-quality MP3 audio processing. Whether you need to capture media streams, record MP3 files, or edit audio waveforms, our C# media toolkit provides comprehensive tools using the LAME library. MP3, a widely adopted lossy audio compression format, is ideal for audio streaming and efficient storage. You can utilize the MP3 encoder to integrate audio capture and recording functionalities into various container formats such as MP4, AVI, and MKV, enhancing your audio capture projects. Our SDK works seamlessly with Visual Studio for a smooth development experience. SDK contains MP3 audio encoder that can be used to encode audio streams to MP3 format using the LAME library. MP3 is a lossy audio compression format that is widely used in audio streaming and storage. You can use MP3 encode to encode audio in MP4, AVI, MKV, and other containers. ## Cross-platform MP3 Audio Capture and Recording [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The [MP3EncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.MP3EncoderSettings.html) class provides developers with a streamlined approach to configure MP3 encoding for C# audio capture projects. This cross-platform solution supports various rate controls and quality settings, making it ideal for record .NET MP3 applications across different operating systems. ### Supported Formats and Specifications for C# MP3 Recording - Input Format: S16LE (Signed 16-bit Little Endian) - Sample Rates: 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 Hz - Channels: Mono (1) or Stereo (2) ### Rate Control Modes The encoder supports three rate control modes: 1. **CBR (Constant Bit Rate)** 2. Fixed bitrate throughout the entire encoding process 3. Supported bitrates: 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 Kbit/s 4. Best for streaming MP3 and when consistent file size is important 5. **ABR (Average Bit Rate)** 6. Maintains an average bitrate while allowing some variation 7. More efficient than CBR while still maintaining predictable file sizes 8. Useful for streaming services that need approximate file size estimates 9. **Quality-based VBR** 10. Variable Bit Rate based on sound complexity 11. Quality setting ranges from 0 (best) to 10 12. Most efficient for storage and best quality-to-size ratio ### C# MP3 Encoding Examples Create basic MP3 encoder settings with CBR. ``` // Create basic MP3 encoder settings using Constant Bit Rate mode var mp3Settings = new MP3EncoderSettings { // Set to Constant Bit Rate - provides consistent file size and streaming reliability RateControl = MP3EncoderRateControl.CBR, // 192 kbps offers good quality for most music content while keeping file size reasonable Bitrate = 192, // Standard quality offers a good balance between encoding speed and output quality EncodingEngineQuality = MP3EncodingQuality.Standard, // Keep stereo channels (false) - set to true if you want to convert to mono ForceMono = false }; ``` Quality-based VBR configuration for high-quality .NET MP3 editing. ``` // Configure MP3 encoder with Variable Bit Rate for optimal quality-to-size ratio var vbrSettings = new MP3EncoderSettings { // Quality-based VBR adjusts bitrate dynamically based on audio complexity RateControl = MP3EncoderRateControl.Quality, // Quality scale: 0 (best) to 10 (worst) - 2.0 provides excellent quality with reasonable file size Quality = 2.0f, // High quality encoding uses more CPU but produces better results EncodingEngineQuality = MP3EncodingQuality.High }; ``` Add the MP3 output to capture C# MP3 audio with the Video Capture SDK: The [MP3Output](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MP3Output.html) class implements multiple interfaces: - IVideoEditXBaseOutput - IVideoCaptureXBaseOutput - IOutputAudioProcessor ``` // Create a Video Capture SDK core instance for recording var core = new VideoCaptureCoreX(); // Initialize MP3 output with target filename var mp3Output = new MP3Output("output.mp3"); // Configure audio encoding settings mp3Output.Audio.RateControl = MP3EncoderRateControl.CBR; // Use Constant Bit Rate for reliable streaming mp3Output.Audio.Bitrate = 128; // 128 kbps is suitable for general audio recording // Add the MP3 output to the capture pipeline core.Outputs_Add(mp3Output, true); ``` Set the output format for the Video Edit SDK core instance: ``` // Initialize Video Edit SDK for processing existing media var core = new VideoEditCoreX(); // Create MP3 output with target filename var mp3Output = new MP3Output("output.mp3"); // Configure Variable Bit Rate encoding for better quality-to-size ratio mp3Output.Audio.RateControl = MP3EncoderRateControl.Quality; mp3Output.Audio.Quality = 5.0f; // Middle quality setting (0-10 scale) - good balance of quality and size // Set as the primary output format for the editor core.Output_Format = mp3Output; ``` ### Initialization To create a new MP3Output instance, you need to provide the output filename: ``` // Initialize MP3 output with destination filename var mp3Output = new MP3Output("output.mp3"); ``` ### Audio Settings The `Audio` property provides access to MP3 encoder settings: ``` // Create default MP3 encoder settings object mp3Output.Audio = new MP3EncoderSettings(); // Additional configuration can be applied to mp3Output.Audio properties ``` ### Custom Audio Processing You can set a custom audio processor using the `CustomAudioProcessor` property to handle waveform manipulations: ``` // Attach a custom audio processor for advanced audio manipulation mp3Output.CustomAudioProcessor = new MediaBlock(); // The MediaBlock can be configured for effects, filtering, or other audio processing ``` ### Filename Operations There are multiple ways to work with the output filename: ``` // Retrieve the current output filename string currentFile = mp3Output.GetFilename(); // Change the output destination mp3Output.SetFilename("newoutput.mp3"); // Alternative way to set the filename via property mp3Output.Filename = "another.mp3"; ``` ### Audio Encoders The MP3Output class supports MP3 encoding exclusively. You can verify the available encoders: ``` // Get information about available audio encoders var audioEncoders = mp3Output.GetAudioEncoders(); // Returns a list of tuples containing encoder names and their setting types // For MP3Output, this will contain a single entry for MP3 ``` ### MP3OutputBlock class The [MP3OutputBlock](../../../mediablocks/AudioEncoders/) class provides a more flexible way to configure MP3 encoding. Create a Media Blocks MP3 output instance: ``` // Create MP3 encoder settings with desired configuration var mp3Settings = new MP3EncoderSettings(); // Initialize MP3 output block with destination file and settings var mp3Output = new MP3OutputBlock("output.mp3", mp3Settings); ``` Check if MP3 encoding is available. ``` // Check if MP3 encoding is available on the current system if (!MP3EncoderSettings.IsAvailable()) { // Handle case where MP3 encoding is not available // This might occur if LAME or other required libraries are missing } ``` ### Encoding Quality Levels The encoder supports three quality presets that affect the encoding speed and CPU usage: - `Fast`: Quickest encoding, lower CPU usage - `Standard`: Balanced speed and quality (default) - `High`: Best quality, higher CPU usage ### Common Scenarios #### High-Quality Music Capture in C ``` // Configure settings for high-quality music recording var highQualitySettings = new MP3EncoderSettings { // Use quality-based Variable Bit Rate for optimal audio fidelity RateControl = MP3EncoderRateControl.Quality, // Highest quality setting (0.0f) for maximum audio fidelity Quality = 0.0f, // Use high-quality encoding algorithm (more CPU intensive but better results) EncodingEngineQuality = MP3EncodingQuality.High }; ``` #### Streaming Audio ``` // Configure settings optimized for audio streaming applications var streamingSettings = new MP3EncoderSettings { // Use Constant Bit Rate for predictable streaming performance RateControl = MP3EncoderRateControl.CBR, // 128 kbps provides good quality for most content while being bandwidth-friendly Bitrate = 128, // Fast encoding reduces CPU usage, important for real-time streaming EncodingEngineQuality = MP3EncodingQuality.Fast }; ``` ## Windows-only MP3 output [VideoCaptureCore](#) [VideoEditCore](#) The [MP3 file output](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MP3Output.html) class provides advanced configuration options for MP3 encoding in C# audio video capture and editing scenarios. ### Key Features - Flexible channel mode selection - VBR and CBR encoding support for optimal .NET MP3 recording - Advanced encoding parameters for professional audio applications - Quality control settings for perfect C# MP3 editing results ### Basic Configuration #### CBR\_Bitrate Controls the Constant Bit Rate (CBR) setting for MP3 encoding. - For MPEG-1 (32, 44.1, 48 kHz): Valid values are 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 kbps - For MPEG-2 (16, 22.05, 24 kHz): Valid values are 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 kbps - Default values: 128 kbps (MPEG-1) or 64 kbps (MPEG-2) #### SampleRate Specifies the audio sampling frequency in Hz. Common values are: - 44100 Hz (CD quality, default) - 48000 Hz (professional audio) - 32000 Hz (broadcast) - 22050 Hz (lower quality) - 16000 Hz (voice) #### ChannelsMode Determines how audio channels are encoded. Options include: 1. StandardStereo: Independent channel encoding with dynamic bit allocation 2. JointStereo: Exploits correlation between channels using mid/side encoding 3. DualStereo: Independent encoding with fixed 50/50 bit allocation (ideal for dual language) 4. Mono: Single channel output (downmixes stereo input) ### Variable Bit Rate (VBR) Settings #### VBR\_Mode Enables Variable Bit Rate encoding when set to true (default). VBR allows the encoder to adjust bitrate based on audio complexity. #### VBR\_MinBitrate Sets the minimum allowed bitrate for VBR encoding (default: 96 kbps). #### VBR\_MaxBitrate Sets the maximum allowed bitrate for VBR encoding (default: 192 kbps). #### VBR\_Quality Controls VBR encoding quality (0-9): - Lower values (0-4): Higher quality, slower encoding - Middle values (5-6): Balanced quality and speed - Higher values (7-9): Lower quality, faster encoding ### Quality and Performance #### EncodingQuality Determines the algorithmic quality of encoding (0-9): - 0-1: Best quality, slowest encoding - 2: Recommended for high quality - 5: Default, good balance of speed and quality - 7: Fast encoding with acceptable quality - 9: Fastest encoding, lowest quality ### Special Features #### ForceMono When enabled, automatically downmixes multi-channel audio to mono. #### VoiceEncodingMode Experimental mode optimized for voice content. #### KeepAllFrequencies Disables automatic frequency filtering, preserving all frequencies at the cost of efficiency. #### DisableShortBlocks Forces use of long blocks only, which may improve quality at very low bitrates but can cause pre-echo artifacts. ### MP3 Frame Flags #### Copyright Sets the copyright bit in MP3 frames. #### Original Marks the stream as original content. #### CRCProtected Enables CRC error detection at the cost of 16 bits per frame. #### EnableXingVBRTag Adds VBR information headers for better player compatibility. #### StrictISOCompliance Enforces strict ISO MP3 standard compliance. ### Example MP3 Recording and Editing Configurations Basic settings for C# MP3 capture applications. ``` // Configure basic MP3 output with standard settings var mp3Output = new MP3Output { // 192 kbps provides good quality for most music content CBR_Bitrate = 192, // CD-quality sample rate SampleRate = 44100, // Joint stereo mode provides better compression for most stereo content ChannelsMode = MP3ChannelsMode.JointStereo, }; // Set as the output format for capture or editing core.Output_Format = mp3Output; // Core is VideoCaptureCore or VideoEditCore ``` VBR configuration. ``` // Configure MP3 output with Variable Bit Rate for better quality/size balance var mp3Output = new MP3Output { // Enable Variable Bit Rate encoding VBR_Mode = true, // Set minimum bitrate floor to ensure acceptable quality VBR_MinBitrate = 96, // Limit maximum bitrate to control file size VBR_MaxBitrate = 192, // Quality level 6 provides a good balance between quality and file size VBR_Quality = 6, }; // Set as the output format for capture or editing core.Output_Format = mp3Output; // Core is VideoCaptureCore or VideoEditCore ``` #### Basic Stereo MP3 Encoding ``` // Configure standard stereo MP3 encoding with fixed bitrate var mp3Output = new MP3Output { // 192 kbps provides good quality for most music while keeping file size reasonable CBR_Bitrate = 192, // Standard stereo mode encodes left and right channels independently ChannelsMode = MP3ChannelsMode.StandardStereo, // CD-quality sample rate SampleRate = 44100, // Disable Variable Bit Rate to ensure consistent file size and playback VBR_Mode = false }; ``` #### Voice-Optimized Encoding ``` // Configure MP3 settings optimized for voice recordings var voiceMP3 = new MP3Output { // Enable voice-optimized encoding algorithms VoiceEncodingMode = true, // Use mono for voice to reduce file size (most voice doesn't benefit from stereo) ChannelsMode = MP3ChannelsMode.Mono, // Lower sample rate is sufficient for voice content SampleRate = 22050, // Enable Variable Bit Rate for better quality/size ratio VBR_Mode = true, // Better quality setting for voice clarity while keeping file size reasonable VBR_Quality = 4 }; ``` #### High-Quality Music Encoding ``` // Configure high-quality MP3 settings for music archiving var highQualityMP3 = new MP3Output { // Enable Variable Bit Rate for optimal quality-to-size ratio VBR_Mode = true, // Set minimum bitrate to ensure good quality even in simple passages VBR_MinBitrate = 128, // Allow high bitrate for complex passages to preserve audio detail VBR_MaxBitrate = 320, // Use high quality setting (2) for excellent audio fidelity VBR_Quality = 2, // Set encoder algorithm to high quality mode EncodingQuality = 2, // Joint stereo provides better compression for most music content ChannelsMode = MP3ChannelsMode.JointStereo, // Professional audio sample rate captures full audible spectrum SampleRate = 48000, // Add VBR header for better player compatibility and seeking EnableXingVBRTag = true }; ``` ### Advanced Settings - **CRC Protection**: Adds error detection capability at the cost of 16 bits per frame - **Short Blocks**: Can be disabled to potentially increase quality at very low bitrates - **Frequency Range**: Option to keep all frequencies (disables automatic lowpass filtering) - **Voice Mode**: Experimental mode optimized for voice content ### Best Practices 1. **Choosing Rate Control for Different Applications** 2. Use CBR for streaming and real-time C# MP3 capturing 3. Use Quality-based VBR for archival and highest quality .NET MP3 recording 4. Use ABR when you need a balance between consistent size and quality 5. **Quality Settings for Different Use Cases** 6. For archival: Use VBR with quality 0-2 7. For general C# audio video capture: VBR with quality 3-5 or CBR 192-256kbps 8. For voice recording in .NET: Consider using voice encoding mode with lower bitrates 9. **Channel Mode Selection** 10. Use Joint Stereo for most music content 11. Use Standard Stereo for critical listening and complex stereo mixes 12. Use Mono for voice recordings or when bandwidth is critical 13. **Performance Optimization** 14. Use Fast encoding quality for real-time applications 15. Use Standard quality for general purpose encoding 16. Use High quality only for archival purposes where encoding time is not critical ### Notes on Default Values The class constructor sets these default values: - CBR\_Bitrate = 192 kbps - VBR\_MinBitrate = 96 kbps - VBR\_MaxBitrate = 192 kbps - VBR\_Quality = 6 - EncodingQuality = 6 - SampleRate = 44100 Hz - ChannelsMode = MP3ChannelsMode.StandardStereo - VBR\_Mode = true ---END OF PAGE--- ## Opus Audio Encoder in C# .NET — Bitrate, VBR, DTX Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/opus/ **Description:** VBR, CBR, and CVBR rate control modes. Bitrate 6-510 kbps, 5 ms latency, complexity tuning, and DTX for speech. OGG/WebM output with C# examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, WebM, OGG, Opus, C# **API:** OPUSEncoderSettings, VideoCaptureCoreX, VideoEditCoreX, OPUSOutput, OGGOpusOutputBlock # Mastering OPUS Audio Encoding in .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to OPUS Audio Encoding OPUS stands as one of the most versatile and efficient audio codecs available for modern software development. VisioForge .NET SDKs include a royalty-free OPUS encoder that transforms audio into the highly adaptable Opus format. This encoded audio can be encapsulated in various containers including Ogg, Matroska, WebM, or RTP streams, making it ideal for both streaming applications and stored media. Developed by the Internet Engineering Task Force (IETF), OPUS combines the best elements of the SILK and CELT codecs to deliver exceptional performance across a wide range of audio requirements. The codec excels in both speech and music encoding at bitrates from as low as 6 kbps to as high as 510 kbps, offering developers remarkable flexibility in balancing quality against bandwidth constraints. ## Why Choose OPUS for Your .NET Applications OPUS has become the preferred choice for many audio applications for several compelling reasons: - **Low Latency**: With encoding delays as low as 5ms, OPUS is perfect for real-time communication applications - **Adaptive Bitrate**: Seamlessly switches between speech and music optimization - **Wide Bitrate Range**: Functions effectively from 6 kbps to 510 kbps - **Superior Compression**: Offers better quality than MP3, AAC, and other codecs at equivalent bitrates - **Open Standard**: Royalty-free and open-source, reducing licensing concerns - **Cross-Platform Support**: Works across all major platforms and browsers These advantages make OPUS particularly valuable for developers building applications that require efficient audio streaming, VoIP solutions, or any scenario where audio quality and bandwidth efficiency are crucial considerations. ## Implementing OPUS in Cross-Platform .NET Applications [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) When working with VisioForge's cross-platform X-engines, developers can leverage the [OPUSEncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.OPUSEncoderSettings.html) class to configure OPUS encoding parameters precisely for their application needs. ### Essential OPUS Encoder Configuration Properties To achieve optimal results with the OPUS encoder, understanding and configuring these key properties is essential: - **Bitrate**: Sets the target bitrate in Kbps, determining the balance between quality and file size - **Rate Control Mode**: Selects between Variable Bitrate (VBR), Constant Bitrate (CBR), or Constrained Variable Bitrate (CVBR) - **Complexity**: Controls encoding complexity on a scale from 0-10, where higher values produce better quality at the expense of increased CPU usage - **Frame Duration**: Configures the frame size (2.5, 5, 10, 20, 40, or 60ms), with shorter frames providing lower latency at the cost of encoding efficiency - **Application Type**: Optimizes for either voice or music content, allowing the encoder to apply specialized techniques - **Forward Error Correction**: Enables packet loss resilience for streaming applications - **DTX (Discontinuous Transmission)**: Reduces bandwidth during silence periods Each of these parameters can significantly impact audio quality, processing requirements, and bandwidth consumption, making them critical considerations for developers optimizing for specific application scenarios. ## Understanding Bitrate Control Modes in Depth One of the most important decisions when implementing OPUS encoding is selecting the appropriate bitrate control strategy. OPUS offers three primary modes, each with distinct advantages for different use cases. ### Variable Bitrate (VBR) VBR represents the most efficient approach for quality optimization, allowing the encoder to dynamically adjust bitrate based on audio complexity. This results in higher bitrates for complex passages and lower bitrates for simpler content. ``` // Create an instance of the OPUSEncoderSettings class. var opus = new OPUSEncoderSettings(); // Set rate control mode to VBR opus.RateControl = OPUSRateControl.VBR; // Set audio bitrate for the codec (in Kbps) opus.Bitrate = 128; ``` **Best for**: On-demand audio streaming, podcast distribution, music applications, and any scenario where consistent bandwidth isn't a primary concern. **Key advantage**: Provides the highest quality-to-size ratio by allocating more bits to complex audio sections. ### Constant Bitrate (CBR) CBR mode attempts to maintain a consistent bitrate throughout the encoding process. While OPUS is inherently a variable bitrate codec, its CBR implementation keeps fluctuations minimal, typically within 5% of the target. ``` // Create an instance of the OPUSEncoderSettings class. var opus = new OPUSEncoderSettings(); // Set rate control mode to CBR opus.RateControl = OPUSRateControl.CBR; // Set audio bitrate for the codec (in Kbps) opus.Bitrate = 128; ``` **Best for**: Live streaming applications, VoIP systems, videoconferencing, and scenarios where network bandwidth predictability is critical. **Key advantage**: Maintains consistent bandwidth utilization, making it easier to plan network capacity and ensure reliable transmission. ### Constrained Variable Bitrate (CVBR) CVBR offers a middle-ground approach, allowing bitrate variations based on content complexity while imposing constraints to prevent extreme fluctuations. This provides many of VBR's quality benefits while keeping bandwidth requirements more predictable. ``` // Create an instance of the OPUSEncoderSettings class. var opus = new OPUSEncoderSettings(); // Set rate control mode to Constrained VBR opus.RateControl = OPUSRateControl.ConstrainedVBR; // Set audio bitrate for the codec (in Kbps) opus.Bitrate = 128; ``` **Best for**: Adaptive streaming applications, mixed-content broadcasting, and scenarios where quality is important but bandwidth constraints still exist. **Key advantage**: Balances quality optimization with reasonable bandwidth predictability. ## Bitrate Selection Guidelines Setting an appropriate bitrate involves balancing quality requirements against bandwidth limitations. For OPUS encoding, consider these channel-specific recommendations: **For Mono Audio:** - 6-12 kbps: Acceptable for low-bitrate speech - 16-24 kbps: Good quality speech - 32-64 kbps: High-quality speech and acceptable music - 64-128 kbps: High-quality music **For Stereo Audio:** - 16-32 kbps: Low-quality stereo - 48-64 kbps: Good quality stereo speech - 64-128 kbps: Standard quality stereo music - 128-256 kbps: High-quality stereo music While OPUS can technically support bitrates up to 510 kbps, most applications achieve excellent results well below 192 kbps due to the codec's exceptional efficiency. ## Practical Implementation Examples ### Implementing OPUS in Video Capture Applications The following example demonstrates how to add OPUS output to a Video Capture SDK core instance: ``` // Create a Video Capture SDK core instance var core = new VideoCaptureCoreX(); // Create a OPUS output instance var opusOutput = new OPUSOutput("output.opus"); // Set the bitrate and rate control mode opusOutput.Audio.RateControl = OPUSRateControl.CBR; opusOutput.Audio.Bitrate = 128; // Add the OPUS output core.Outputs_Add(opusOutput, true); ``` ### Configuring OPUS for Video Editing Workflows When working with the Video Edit SDK, you can configure OPUS as your output format: ``` // Create a Video Edit SDK core instance var core = new VideoEditCoreX(); // Create a OPUS output instance var opusOutput = new OPUSOutput("output.opus"); // Set the bitrate for high-quality music encoding opusOutput.Audio.RateControl = OPUSRateControl.VBR; opusOutput.Audio.Bitrate = 192; // Set the output format core.Output_Format = opusOutput; ``` ### Creating OPUS Outputs with Media Blocks SDK The Media Blocks SDK offers flexible options for creating OPUS outputs in different container formats: ``` // Create a OPUS encoder settings instance with specific configuration var opusSettings = new OPUSEncoderSettings { Bitrate = 128, RateControl = OPUSRateControl.VBR, Complexity = 8 }; // Create an Ogg OPUS output instance (opus + ogg container) var oggOpusOutput = new OGGOpusOutputBlock("output.ogg", opusSettings); ``` ## Performance Optimization Tips To achieve the best results with OPUS encoding in your .NET applications: 1. **Match Complexity to Your Hardware**: For real-time applications on limited hardware, use lower complexity values (3-6). For offline encoding or on powerful systems, higher values (7-10) will yield better quality. 2. **Select Appropriate Frame Duration**: Shorter frames (2.5-10ms) minimize latency for real-time communication, while longer frames (20-60ms) improve compression efficiency for music and stored content. 3. **Consider Input Sample Rate**: OPUS performs optimally with 48kHz input. If your source is at a different sample rate, consider resampling to 48kHz before encoding. 4. **Optimize for Content Type**: Use the Application property to tell the encoder whether you're primarily encoding speech or music for content-specific optimizations. 5. **Enable DTX for Speech**: For voice communications with frequent silence, enabling DTX can significantly reduce bandwidth requirements without noticeable quality impact. ## Conclusion The OPUS codec offers .NET developers an exceptional tool for creating high-quality, bandwidth-efficient audio applications. With VisioForge's SDKs, implementing OPUS encoding becomes straightforward while still providing the flexibility to fine-tune every aspect of the encoding process. By understanding the bitrate control modes, selecting appropriate parameters, and following the implementation examples provided, you can leverage OPUS to deliver superior audio experiences in your .NET applications regardless of whether you're building real-time communication tools, media players, or content creation software. ---END OF PAGE--- ## Speex Speech Audio Encoder Integration for .NET SDK **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/speex/ **Description:** Implement Speex speech compression in .NET with optimized voice encoding settings, quality controls, and cross-platform audio capture. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, Speex, C# **API:** SpeexEncoderSettings, VideoCaptureCoreX, VideoEditCoreX, MediaBlocksPipeline, SpeexOutput # Speex Audio Encoder for .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Speex Speex is a patent-free audio codec specifically designed for speech encoding in .NET applications. Whether you need to capture, edit, or record audio in C#, Speex provides excellent compression while maintaining voice quality across various bitrates. VisioForge integrates this powerful encoder into its .NET SDKs, offering developers flexible configuration options for speech-based applications. The codec is particularly well-suited for C# developers looking to implement high-quality audio capture and recording features in their applications. ## Core Functionality The Speex encoder in VisioForge SDKs supports: - Multiple frequency bands for different quality levels - Variable and fixed bitrate encoding - Voice activity detection and silence compression - Adjustable complexity and quality settings - Cross-platform compatibility across Windows, macOS, and Linux - Seamless integration with dotnet applications ## Cross-platform Implementation [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ### Encoder Modes Speex offers four operation modes optimized for different frequency ranges: | Mode | Value | Optimal Sample Rate | | --- | --- | --- | | Auto | 0 | Automatic selection based on input | | Ultra Wide Band | 1 | 32 kHz | | Wide Band | 2 | 16 kHz | | Narrow Band | 3 | 8 kHz | The encoder automatically adjusts internal parameters based on the selected mode. For most speech applications, Wide Band (mode 2) offers an excellent balance between quality and bandwidth usage. ## Technical Specifications ### Supported Sample Rates Speex works with three standard sampling frequencies: - 8,000 Hz - Best for telephone-quality audio (Narrow Band) - 16,000 Hz - Recommended for most voice applications (Wide Band) - 32,000 Hz - Highest quality speech encoding (Ultra Wide Band) ### Channel Configuration The encoder handles both: - Mono (1 channel) - Ideal for speech recordings - Stereo (2 channels) - For multi-speaker or immersive audio ## Rate Control Methods ### Quality-Based Encoding For consistent perceptual quality, use the `Quality` parameter: ``` var settings = new SpeexEncoderSettings { Quality = 8.0f, // Range from 0 (lowest) to 10 (highest) VBR = false // Fixed quality mode }; ``` Higher quality values produce better audio at the expense of increased file size. Most speech applications work well with quality values between 5-8. ### Variable Bit Rate (VBR) VBR dynamically adjusts the bitrate based on speech complexity: ``` var settings = new SpeexEncoderSettings { VBR = true, Quality = 8.0f // Target quality level }; ``` This approach typically saves bandwidth while maintaining consistent perceived quality, making it ideal for streaming applications. ### Average Bit Rate (ABR) ABR maintains a target bitrate over time while allowing quality fluctuations: ``` var settings = new SpeexEncoderSettings { ABR = 15.0f, // Target bitrate in kbps VBR = true // Required for ABR mode }; ``` This option works well when you need predictable file sizes or bandwidth usage. ### Fixed Bitrate Encoding For consistent data rates throughout the encoding process: ``` var settings = new SpeexEncoderSettings { Bitrate = 24.6f, // Fixed rate in kbps VBR = false }; ``` Supported bitrates range from 2.15 kbps to 24.6 kbps: - 2.15 kbps - Ultra-compressed speech (limited quality) - 3.95 kbps - Low bandwidth voice - 5.95 kbps - Basic speech clarity - 8.00 kbps - Standard voice quality - 11.0 kbps - Good speech reproduction - 15.0 kbps - Near-transparent speech - 18.2 kbps - High-quality voice - 24.6 kbps - Maximum quality speech ## Voice Optimization Features ### Voice Activity Detection (VAD) VAD identifies the presence of speech in audio signals: ``` var settings = new SpeexEncoderSettings { VAD = true, // Enable voice detection DTX = true // Recommended with VAD }; ``` This feature improves bandwidth efficiency by focusing encoding resources on actual speech segments. ### Discontinuous Transmission (DTX) DTX reduces data transmission during silence periods: ``` var settings = new SpeexEncoderSettings { DTX = true // Enable silence compression }; ``` For VoIP and real-time communications, enabling DTX can significantly reduce bandwidth requirements. ### Encoding Complexity Control CPU usage versus encoding quality: ``` var settings = new SpeexEncoderSettings { Complexity = 3 // Range: 1 (fastest) to 10 (highest quality) }; ``` Lower values prioritize speed and reduce CPU load, while higher values improve audio quality at the cost of performance. ## Implementation Examples ### Checking Encoder Availability Always verify encoder availability before implementing Speex in your C# application: ``` if (!SpeexEncoderSettings.IsAvailable()) { throw new InvalidOperationException("Speex encoder not available on this system."); } ``` ### Basic Configuration for Audio Capture Here's how to set up basic Speex encoding for audio capture in dotnet: ``` var encoderSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.WideBand, SampleRate = 16000, Channels = 1, Quality = 7.0f }; ``` ### Optimized for Voice Recording For voice recording applications in .NET, use these optimized settings: ``` var voipSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.WideBand, SampleRate = 16000, Channels = 1, VBR = true, VAD = true, DTX = true, Quality = 6.0f, Complexity = 4 }; ``` ### Highest Quality Audio Capture For maximum quality audio capture in dotnet: ``` var highQualitySettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.UltraWideBand, SampleRate = 32000, Channels = 2, Bitrate = 24.6f, Complexity = 8 }; ``` ## SDK Integration ### Video Capture SDK Integration Learn how to capture audio using Speex in your C# application: ``` using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.Sources; // Create a Video Capture SDK core instance var core = new VideoCaptureCoreX(); // Set the audio input device, filter by API var api = AudioCaptureDeviceAPI.DirectSound; var audioInputDevice = (await DeviceEnumerator.Shared.AudioSourcesAsync()).FirstOrDefault(x => x.API == api); if (audioInputDevice == null) { MessageBox.Show("No audio input device found."); return; } var audioInput = new AudioCaptureDeviceSourceSettings(api, audioInputDevice, audioInputDevice.GetDefaultFormat()); core.Audio_Source = audioInput; // Configure Speex settings var speexSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.WideBand, SampleRate = 16000, Channels = 1, VBR = true, Quality = 7.0f }; var speexOutput = new SpeexOutput("output.spx", speexSettings); // Add the Speex output core.Outputs_Add(speexOutput, true); // Set the audio record mode core.Audio_Record = true; core.Audio_Play = false; // Start the capture await core.StartAsync(); // Stop after 10 seconds await Task.Delay(10000); // Stop the capture await core.StopAsync(); ``` ### Video Edit SDK Integration Edit and process audio files using Speex in dotnet: ``` using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.Sources; // Create a Video Edit SDK core instance var core = new VideoEditCoreX(); // Add the audio source file var audioFile = new AudioFileSource(@"c:\samples\!audio.mp3"); core.Input_AddAudioFile(audioFile, null); // Configure Speex settings var speexSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.WideBand, SampleRate = 16000, Channels = 1, VBR = true, Quality = 7.0f }; var speexOutput = new SpeexOutput(@"output.spx", speexSettings); // Add the Speex output core.Output_Format = speexOutput; // Catch OnStop event core.OnStop += (s, e) => { // Handle the stop event here MessageBox.Show("Editing complete."); }; core.OnProgress += (s, e) => { // Handle progress updates here Debug.WriteLine($"Progress: {e.Progress}%"); }; core.OnError += (s, e) => { // Handle errors here Debug.WriteLine($"Error: {e.Message}"); }; // Start the editing core.Start(); ``` ### Media Blocks SDK Integration Process audio streams using Speex in your .NET application: ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AudioEncoders; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.Sources; // Create a new pipeline var pipeline = new MediaBlocksPipeline(); // Add universal source to read audio file var sourceSettings = await UniversalSourceSettings.CreateAsync(@"c:\samples\!audio.mp3", renderVideo: false, renderAudio: true); var source = new UniversalSourceBlock(sourceSettings); // Add Speex output var speexSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.NarrowBand, SampleRate = 8000, DTX = true, VAD = true }; var speexOutput = new OGGSpeexOutputBlock("output.spx", speexSettings); // Connect pipeline.Connect(source.AudioOutput, speexOutput.Input); // Add OnStop event handler pipeline.OnStop += (sender, e) => { // Do something when the pipeline stops MessageBox.Show("Conversion complete"); }; // Start await pipeline.StartAsync(); ``` ## Performance Optimization When implementing Speex encoding, consider these optimization strategies: 1. **Match sample rate to content** - Use Narrow Band (8 kHz) for telephone audio, Wide Band (16 kHz) for most voice applications, and Ultra Wide Band (32 kHz) only when maximum quality is required 2. **Enable VBR with VAD/DTX** for speech content - This combination provides optimal bandwidth efficiency for typical voice recordings 3. **Adjust complexity based on platform** - Mobile applications may benefit from lower complexity values (2-4), while desktop applications can use higher values (5-8) 4. **Use ABR for streaming** - Average Bit Rate provides predictable bandwidth usage while maintaining quality flexibility 5. **Test different quality settings** - Often a quality setting of 5-7 provides excellent results without excessive file size ## Use Cases Speex encoding excels in these developer scenarios: - VoIP applications and internet telephony - Voice chat features in games and collaboration tools - Podcast creation and distribution - Speech recognition preprocessing - Voice note applications - Audio archiving of speech content ## Installation and Setup To get started with Speex in your dotnet application, check the main installation guide [here](../../../install/). ## Common Use Cases ### Audio Capture and Recording For streaming applications, use these optimized settings: ``` var streamingSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.WideBand, SampleRate = 16000, Channels = 1, VBR = true, VAD = true, DTX = true, Quality = 6.0f, Complexity = 3 }; ``` ### Voice Over IP Applications For VoIP applications, prioritize low latency and bandwidth efficiency: ``` var voipSettings = new SpeexEncoderSettings { Mode = SpeexEncoderMode.NarrowBand, SampleRate = 8000, Channels = 1, VBR = true, VAD = true, DTX = true, Quality = 5.0f, Complexity = 2 }; ``` ## Licensing and Community Speex is released under the BSD license, making it free for both commercial and non-commercial use. The codec is actively maintained by the open-source community, with regular updates and improvements. ## Frequently Asked Questions ### What is the best bitrate for voice recording? For most voice applications, a bitrate between 8-15 kbps provides excellent quality while maintaining reasonable file sizes. Use VBR mode for optimal results. ### How does Speex compare to other codecs? Speex offers superior speech quality compared to many other codecs at similar bitrates, especially for voice content. It's particularly effective for low-bitrate applications. ### Can I use Speex for music encoding? While Speex can encode music, it's specifically optimized for speech. For music content, consider using other codecs like AAC or MP3. ## Conclusion The VisioForge implementation of Speex provides .NET developers with a powerful tool for capturing, editing, and recording audio in C# applications. Whether you're building a new voice capture application or enhancing an existing one, Speex delivers exceptional results with minimal resource usage. The codec's flexibility and performance make it an excellent choice for any .NET developer working with audio processing. ---END OF PAGE--- ## Vorbis Audio Encoding Guide for .NET SDK Development **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/vorbis/ **Description:** Implement Vorbis audio encoding in .NET with quality optimization, cross-platform support, and efficient compression for streaming. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, WebM, OGG, Vorbis, C# **API:** OGGVorbisOutput, VorbisEncoderSettings, WebMOutput, VideoCaptureCore, VideoEditCore # Vorbis Audio Encoding for .NET Developers [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Vorbis in VisioForge SDK The VisioForge SDK suite offers powerful Vorbis audio encoding capabilities that enable developers to implement high-quality audio compression in their .NET applications. Vorbis, an open-source audio codec, delivers exceptional audio fidelity with efficient compression ratios, making it ideal for streaming applications, multimedia content, and web audio. This guide will help you navigate the various Vorbis implementation options available in the VisioForge SDK ecosystem, providing practical code examples and optimization strategies for different use cases. ## Vorbis Encoder Options The SDK exposes three distinct APIs for Vorbis encoding. Two are Windows-classic (`VideoCaptureCore` / `VideoEditCore`) and one is cross-platform (`VideoCaptureCoreX` / `VideoEditCoreX` / `MediaBlocksPipeline`). ### Implementation Options #### 1. WebM Container with Vorbis Audio (Windows classic) The [`WebMOutput`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.WebMOutput.html) class in namespace `VisioForge.Core.Types.X.Output` encapsulates Vorbis audio within the WebM container format. Runs on Windows only (DirectShow). #### 2. OGG Vorbis Dedicated Output (Windows classic) The [`OGGVorbisOutput`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.OGGVorbisOutput.html) class in namespace `VisioForge.Core.Types.X.Output` provides detailed control over VBR/bitrate modes for OGG-containerised Vorbis. Windows only. #### 3. Flexible VorbisEncoderSettings (cross-platform) The [`VorbisEncoderSettings`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.VorbisEncoderSettings.html) class in namespace `VisioForge.Core.Types.X.AudioEncoders` drives Vorbis encoding on the X engines (`VideoCaptureCoreX`, `VideoEditCoreX`) and Media Blocks (`VorbisEncoderBlock`). This is the recommended path for cross-platform projects. ### Rate Control Strategies Choosing the appropriate rate control mode is crucial for balancing audio quality against file size requirements. Vorbis encoding in VisioForge supports two primary approaches: #### Quality-Based Variable Bit Rate (VBR) Quality-based VBR is the recommended approach for most applications, as it dynamically adjusts bitrate to maintain consistent perceptual quality throughout the audio stream. WebMOutputOGGVorbisOutputVorbisEncoderSettings WebMOutput implements a simplified quality-based approach with an easy-to-understand scale: ``` // Create and configure WebM output with high-quality Vorbis audio var webmOutput = new WebMOutput(); // Quality range: 20 (lowest) to 100 (highest) // Values 70-80 provide excellent quality for most content webmOutput.Audio_Quality = 80; // Higher values produce better audio quality with larger files // Lower values prioritize file size over audio fidelity ``` Key considerations: - Quality setting directly impacts perceived audio quality and file size - Values around 70-80 work well for most professional content - Lower settings (40-60) may be suitable for voice-only recordings OGGVorbisOutput offers more explicit quality mode selection: ``` // Initialize OGG Vorbis output for quality-focused encoding var oggOutput = new OGGVorbisOutput(); // Set the encoding mode to quality-based VBR oggOutput.Mode = VorbisMode.Quality; // Configure quality level (range: 20-100) // 80: High quality for music and complex audio // 60: Good quality for general purpose use // 40: Acceptable quality for voice recordings oggOutput.Quality = 80; ``` This implementation gives you direct control over the quality-to-size tradeoff, making it ideal for applications with varying content types. VorbisEncoderSettings uses the native Vorbis quality scale: ``` // Create Vorbis encoder with quality-based rate control var vorbisEncoder = new VorbisEncoderSettings(); // Set rate control mode to quality-based VBR vorbisEncoder.RateControl = VorbisEncoderRateControl.Quality; // Configure quality level using Vorbis scale (-1 to 10) // -1: Very low quality (~45 kbps) // 3: Good quality (~112 kbps) // 5: Very good quality (~160 kbps) // 8: Excellent quality (~224 kbps) // 10: Highest quality (~320 kbps) vorbisEncoder.Quality = 5; ``` The VorbisEncoderSettings implementation provides the most precise quality control, using the established Vorbis quality scale that audio engineers are familiar with. #### Bitrate-Constrained Encoding For scenarios with specific bandwidth limitations or target file sizes, bitrate-constrained encoding offers more predictable output sizes. WebMOutputOGGVorbisOutputVorbisEncoderSettings WebMOutput does not support explicit bitrate control for Vorbis audio. Developers should use the quality parameter instead and test to determine the resulting bitrates. OGGVorbisOutput provides comprehensive bitrate management tools: ``` // Set up OGG output with specific bitrate constraints var oggOutput = new OGGVorbisOutput(); // Enable bitrate-controlled encoding mode oggOutput.Mode = VorbisMode.Bitrate; // Configure bitrate parameters (all values in Kbps) oggOutput.MinBitRate = 96; // Minimum bitrate floor oggOutput.AvgBitRate = 160; // Target average bitrate oggOutput.MaxBitRate = 240; // Maximum bitrate ceiling // These settings create a controlled VBR encode that // averages 160 Kbps but can fluctuate between limits ``` This approach is ideal for streaming applications where bandwidth prediction is important. VorbisEncoderSettings offers the most detailed bitrate control options: ``` // Initialize Vorbis encoder with bitrate constraints var vorbisEncoder = new VorbisEncoderSettings(); // Set rate control mode to bitrate-based vorbisEncoder.RateControl = VorbisEncoderRateControl.Bitrate; // Configure bitrate parameters (all values in Kbps; valid range 16-240) vorbisEncoder.Bitrate = 192; // Target average bitrate vorbisEncoder.MinBitrate = 128; // Minimum allowed bitrate vorbisEncoder.MaxBitrate = 240; // Maximum allowed bitrate // These settings are ideal for applications requiring // predictable file sizes or streaming bandwidth ``` The flexible bitrate controls allow for precise audio encoding tailored to specific delivery requirements. Check the [VorbisEncoderBlock](../../../mediablocks/AudioEncoders/) and [OGGSinkBlock](../../../mediablocks/Sinks/) for more information. ### Best Practices for Developers To achieve optimal results with Vorbis encoding in your .NET applications, consider these developer-focused recommendations: #### Choosing the Right Encoding Mode 1. **Default choice: Quality-based VBR** 2. Produces consistent perceived quality across varying content 3. Automatically optimizes bitrate based on audio complexity 4. Simplifies configuration with a single quality parameter 5. **When to use Bitrate-constrained mode:** 6. Streaming applications with bandwidth limitations 7. Storage-constrained environments with fixed size allocations 8. Content delivery networks with predictable bandwidth requirements #### Recommended Settings for Common Use Cases | Content Type | Recommended Settings | | --- | --- | | Music (high quality) | WebM: Audio\_Quality = 80 OGG: Quality = 80 VorbisEncoder: Quality = 6 | | Voice recordings | WebM: Audio\_Quality = 60 OGG: Quality = 60 VorbisEncoder: Quality = 3 | | Mixed content | WebM: Audio\_Quality = 70 OGG: Quality = 70 VorbisEncoder: Quality = 4 | | Streaming audio | OGG: Mode = Bitrate, AvgBitRate = 128 VorbisEncoder: RateControl = Bitrate, Bitrate = 128 | ## Windows-only output [VideoCaptureCore](#) [VideoEditCore](#) The `OGGVorbisOutput` class provides configuration and functionality for encoding audio using the Vorbis codec. ### Class Details ``` public sealed class OGGVorbisOutput : IVideoEditBaseOutput, IVideoCaptureBaseOutput ``` The class implements two interfaces: - `IVideoEditBaseOutput`: Enables use in video editing scenarios - `IVideoCaptureBaseOutput`: Enables use in video capture scenarios ### Bitrate Controls When operating in Bitrate mode, these properties control the output bitrate constraints: #### AvgBitRate - Type: `int` - Default Value: 128 (Kbps) - Description: Specifies the target average bitrate for the encoded audio stream. This value represents the general quality level and file size trade-off. #### MaxBitRate - Type: `int` - Default Value: 192 (Kbps) - Description: Defines the maximum allowed bitrate during encoding. Useful for ensuring the encoded audio doesn't exceed bandwidth constraints. #### MinBitRate - Type: `int` - Default Value: 64 (Kbps) - Description: Sets the minimum allowed bitrate during encoding. Helps maintain a baseline quality level even during simple audio passages. ### Quality Controls #### Quality - Type: `int` - Default Value: 80 - Valid Range: 10-100 - Description: When operating in Quality mode, this value determines the encoding quality. Higher values result in better audio quality but larger file sizes. #### Mode - Type: `VorbisMode` (enum) - Default Value: `VorbisMode.Bitrate` - Options: - `VorbisMode.Quality`: Encoding focuses on maintaining a consistent quality level - `VorbisMode.Bitrate`: Encoding focuses on maintaining specified bitrate constraints ### Constructor ``` public OGGVorbisOutput() ``` Initializes a new instance with default values: - MinBitRate: 64 kbps - AvgBitRate: 128 kbps - MaxBitRate: 192 kbps - Quality: 80 - Mode: VorbisMode.Bitrate ### Serialization Methods #### Save() ``` public string Save() ``` Serializes the current configuration to a JSON string, allowing settings to be saved and restored later. #### Load(string json) ``` public static OGGVorbisOutput Load(string json) ``` Creates a new instance with settings deserialized from the provided JSON string. ### Usage Examples #### Basic Usage with Default Settings ``` var oggOutput = new OGGVorbisOutput(); // Ready to use with default settings (Bitrate mode, 128kbps average) ``` #### Quality-Based Encoding ``` var oggOutput = new OGGVorbisOutput { Mode = VorbisMode.Quality, Quality = 90 // High quality setting }; ``` #### Constrained Bitrate Encoding ``` var oggOutput = new OGGVorbisOutput { Mode = VorbisMode.Bitrate, MinBitRate = 96, // Minimum 96kbps AvgBitRate = 160, // Target 160kbps MaxBitRate = 240 // Maximum 240kbps }; ``` #### Saving and Loading Configuration ``` // Save configuration var oggOutput = new OGGVorbisOutput(); string savedConfig = oggOutput.Save(); ``` ``` // Load configuration var loadedOutput = OGGVorbisOutput.Load(savedConfig); ``` #### Apply settings to core instances ``` var core = new VideoCaptureCore(); core.Output_Filename = "output.ogg"; core.Output_Format = oggOutput; ``` ``` var core = new VideoEditCore(); core.Output_Filename = "output.ogg"; core.Output_Format = oggOutput; ``` ## Performance Considerations When implementing Vorbis encoding in production environments: - Encoding quality directly impacts CPU usage; higher quality settings require more processing power - The VorbisEncoderSettings implementation offers the best balance of flexibility and performance - Pre-configured profiles can help standardize output quality across different content types - Consider multi-threaded encoding for batch processing applications ## Conclusion Vorbis encoding provides an excellent open-source solution for high-quality audio compression in .NET applications. By understanding the different implementation options and configuration strategies available in the VisioForge SDK, developers can effectively balance audio quality, file size, and performance requirements for their specific use cases. Whether you're building a streaming application, a media processing tool, or integrating audio capabilities into a larger software ecosystem, the Vorbis encoders in VisioForge's .NET SDKs offer the flexibility and performance needed for professional audio processing. ---END OF PAGE--- ## WAV PCM Audio Encoder Settings and Code Examples for .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/wav/ **Description:** Implement WAV audio processing in .NET with sample rates, channel configuration, PCM format selection, and cross-platform support. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, WAV, C# **API:** WAVEncoderSettings, VideoCaptureCoreX, VideoEditCoreX, MediaBlocksPipeline, WAVOutput # Implementing WAV Audio in .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## What is WAV Format? WAV (Waveform Audio File Format) functions as an uncompressed audio container format rather than a codec. It stores raw PCM (Pulse-Code Modulation) audio data in its native form. When working with VisioForge SDKs, the WAV output functionality allows developers to create high-quality audio files with configurable PCM settings. Since WAV preserves audio without compression, it maintains original sound quality at the cost of larger file sizes compared to compressed formats like MP3 or AAC. ## How WAV Files Work The WAV format stores audio samples in their raw form. When your application outputs to WAV format, it performs three key operations: 1. Organizing raw PCM audio data into the WAV container structure 2. Defining interpretation parameters (sample rate, bit depth, and channel count) 3. Generating appropriate WAV headers and metadata This uncompressed nature means file sizes are predictable and directly calculated from the audio parameters: ``` File size (bytes) = Sample Rate × Bit Depth × Channels × Duration / 8 ``` For example, a one-minute stereo WAV file sampled at 44.1kHz with 16-bit samples consumes approximately 10.1 MB: ``` 44100 × 16 × 2 × 60 / 8 = 10,584,000 bytes ``` ## Cross-Platform WAV Implementation [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ### Key Features - Flexible audio format configuration (default: S16LE) - Adjustable sample rates ranging from 8kHz to 192kHz - Support for both mono and stereo channel configurations - Consistent audio quality across different platforms ### Configuration Parameters #### Audio Format Options The WAV encoder supports multiple audio formats through the `AudioFormatX` enum, with S16LE (16-bit Little-Endian) serving as the default format for maximum compatibility. #### Sample Rate Selection - Available range: 8,000 Hz to 192,000 Hz - Default setting: 48,000 Hz - Increment values: 8,000 Hz steps #### Channel Configuration - Available options: 1 (mono) or 2 (stereo) - Default setting: 2 (stereo) ### Implementation Examples #### Basic Implementation ``` // Initialize WAV encoder with default settings var wavEncoder = new WAVEncoderSettings(); ``` ``` // Initialize with custom configuration var customWavEncoder = new WAVEncoderSettings( format: AudioFormatX.S16LE, sampleRate: 44100, channels: 2 ); ``` #### Integration with Video Capture SDK ``` // Initialize Video Capture SDK core var core = new VideoCaptureCoreX(); // Create WAV output with file path var wavOutput = new WAVOutput("output.wav"); // Add output to the capture pipeline core.Outputs_Add(wavOutput, true); ``` #### Integration with Video Edit SDK ``` // Initialize Video Edit SDK core var core = new VideoEditCoreX(); // Create WAV output instance var wavOutput = new WAVOutput("output.wav"); // Configure core to use WAV output core.Output_Format = wavOutput; ``` #### Media Blocks Pipeline Configuration ``` // Initialize WAV encoder settings var wavSettings = new WAVEncoderSettings(); // Create encoder block var wavOutput = new WAVEncoderBlock(wavSettings); // Add File Sink block for output var fileSink = new FileSinkBlock("output.wav"); // Connect encoder to file sink in pipeline pipeline.Connect(wavOutput.Output, fileSink.Input); // pipeline is MediaBlocksPipeline ``` #### Verifying Encoder Availability ``` if (WAVEncoderSettings.IsAvailable()) { // Encoder is available, proceed with encoding var encoder = new WAVEncoderSettings(); // Configure and use encoder } else { // Handle unavailability Console.WriteLine("WAV encoder is not available on this system"); } ``` #### Advanced Configuration ``` var wavEncoder = new WAVEncoderSettings { Format = AudioFormatX.S16LE, SampleRate = 96000, Channels = 1 // Configure for mono audio }; ``` #### Creating an Encoder Block ``` var settings = new WAVEncoderSettings(); MediaBlock encoderBlock = settings.CreateBlock(); // Integrate the encoder block into your media pipeline ``` #### Retrieving Supported Parameters ``` // Get list of supported audio formats IEnumerable formats = WAVEncoderSettings.GetFormatList(); // Get available sample rates var settings = new WAVEncoderSettings(); int[] sampleRates = settings.GetSupportedSampleRates(); // Returns array ranging from 8000 to 192000 in 8000 Hz increments // Get supported channel configurations int[] channels = settings.GetSupportedChannelCounts(); // Returns [1, 2] for mono and stereo options ``` ## Windows-Specific WAV Implementation [VideoCaptureCore](#) [VideoEditCore](#) ### Enumerating Available Audio Codecs ``` // core is an instance of VideoCaptureCore or VideoEditCore foreach (var codec in core.Audio_Codecs) { cbAudioCodecs.Items.Add(codec); } ``` ### Configuring Audio Settings ``` // Initialize ACM output for WAV var acmOutput = new ACMOutput(); // Configure audio parameters acmOutput.Channels = 2; acmOutput.BPS = 16; acmOutput.SampleRate = 44100; acmOutput.Name = "PCM"; // codec name // Set as output format core.Output_Format = acmOutput; ``` ### Specifying Output File ``` // Set output file path core.Output_Filename = "output.wav"; ``` ### Starting Processing ``` // Begin capture or conversion operation await core.StartAsync(); ``` ## Best Practices for WAV Implementation ### Sample Rate Selection Guidelines The sample rate significantly impacts audio quality and file size: - 8kHz: Suitable for basic voice recordings and telephony applications - 16kHz: Improved voice quality for speech recognition systems - 44.1kHz: Standard for CD-quality audio and music production - 48kHz: Professional audio standard used in video production - 96kHz+: High-resolution audio for professional sound engineering For most applications, 44.1kHz or 48kHz provides excellent quality without excessive file sizes. ### Channel Configuration Strategy Your channel selection should align with content requirements: - **Mono (1 channel)**: Ideal for voice recordings, podcasts, or when storage space is limited - **Stereo (2 channels)**: Essential for music, spatial audio, or any content where directional sound matters ### Format Selection Considerations When selecting audio formats: - S16LE (16-bit Little-Endian) offers the best compatibility across platforms - Higher bit depths (24-bit, 32-bit) provide greater dynamic range for professional audio work - Consider your target system's requirements and hardware capabilities ## Technical Limitations and Considerations ### File Size Implications WAV files grow linearly with recording duration, which can present challenges: - A 10-minute stereo recording at 44.1kHz/16-bit requires approximately 100MB - For mobile or web applications, consider implementing size limits or compression options - When streaming is required, compressed formats may be more appropriate ### Performance Factors WAV processing has specific performance characteristics: - Lower CPU usage during encoding compared to compressed formats - Higher disk I/O requirements due to larger data volumes - Memory buffer considerations for long recordings ## Conclusion The WAV format provides developers with a reliable, high-quality audio output option within VisioForge .NET SDKs. Its uncompressed nature ensures pristine audio quality, making it ideal for applications where audio fidelity is paramount. By leveraging the configuration options and implementation approaches outlined above, developers can effectively integrate WAV audio functionality into their .NET applications while maintaining optimal performance and quality. For most professional audio applications, WAV remains the format of choice during production and editing stages, even if compressed formats are used for final distribution. The flexibility and cross-platform compatibility of the VisioForge SDK's WAV implementation make it a valuable tool in any developer's audio processing toolkit. ---END OF PAGE--- ## WavPack Audio Encoder Settings and Configuration in .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/wavpack/ **Description:** Implement WavPack lossless and hybrid lossy audio compression in .NET with quality settings, correction modes, and stereo encoding. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, WavPack, C# **API:** WavPackEncoderSettings, VideoCaptureCoreX, VideoEditCoreX, MediaBlocksPipeline, WavPackOutput # WavPack Audio Encoder for .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ## Introduction to WavPack WavPack is a powerful audio codec that offers both lossless and hybrid lossy compression capabilities, making it highly versatile for different application requirements. The VisioForge.Core library provides a robust implementation of this codec for .NET developers seeking high-quality audio compression solutions. With support for various quality levels, correction modes, and stereo encoding options, the WavPack encoder can handle multiple channel configurations while delivering excellent compression across a wide range of bitrates and sample rates. ## Getting Started with WavPack ### Basic Configuration To begin using the WavPack encoder, you'll need to create an instance of the `WavPackEncoderSettings` class with your desired parameters: ``` var encoder = new WavPackEncoderSettings { Mode = WavPackEncoderMode.Normal, JointStereoMode = WavPackEncoderJSMode.Auto, CorrectionMode = WavPackEncoderCorrectionMode.Off, MD5 = false }; ``` This simple configuration uses balanced compression settings and automatic stereo encoding mode selection, suitable for most general use cases. ### Compression Modes Explained WavPack offers four distinct compression modes that balance processing speed against compression efficiency: ``` public enum WavPackEncoderMode { Fast = 1, // Prioritizes encoding speed Normal = 2, // Balanced compression (default) High = 3, // Higher compression ratio VeryHigh = 4 // Maximum compression } ``` For applications where file size is critical, you can implement higher compression settings: ``` var encoder = new WavPackEncoderSettings { Mode = WavPackEncoderMode.High, ExtraProcessing = 1 // Enables advanced filters for better compression }; ``` ## Quality Control Options ### Bitrate-Based Encoding The most straightforward method for controlling output quality is to specify a target bitrate: ``` var encoder = new WavPackEncoderSettings { Bitrate = 192000 // 192 kbps }; ``` Key specifications for bitrate control: - Valid range: 24,000 to 9,600,000 bits/second - Setting values below 24,000 disables lossy encoding - Enables the lossy encoding mode automatically ### Bits Per Sample Control For more precise quality control, especially when maintaining consistent quality across different sample rates is important: ``` var encoder = new WavPackEncoderSettings { BitsPerSample = 16.0 // Equivalent to 16-bit quality }; ``` Important notes: - Values below 2.0 disable lossy encoding - This approach maintains more consistent quality regardless of sample rate variations ## Advanced Encoding Features ### Stereo Encoding Options WavPack provides three methods for encoding stereo content, each with different characteristics: ``` var encoder = new WavPackEncoderSettings { JointStereoMode = WavPackEncoderJSMode.Auto }; ``` Available stereo encoding modes: - `Auto`: Intelligently selects the optimal encoding method based on content - `LeftRight`: Uses traditional left/right channel separation - `MidSide`: Implements mid/side encoding which often yields better compression for stereo material ### Hybrid Correction Mode One of WavPack's unique features is its hybrid mode, which generates a correction file alongside the main compressed file: ``` var encoder = new WavPackEncoderSettings { CorrectionMode = WavPackEncoderCorrectionMode.Optimized, Bitrate = 192000 // Required when using correction modes }; ``` The available correction options: - `Off`: Standard operation with no correction file - `On`: Generates a standard correction file - `Optimized`: Creates an optimization-focused correction file Note that correction modes only function when lossy encoding is active, making them ideal for applications where initial file size is important but future lossless restoration might be needed. ## Technical Specifications The WavPack encoder supports: - Sample rates from 6,000 Hz to 192,000 Hz - 1 to 8 audio channels - Optional MD5 hash storage of raw samples for verification - Additional processing options for quality enhancement Before implementation, you can verify encoder availability in your environment: ``` if (WavPackEncoderSettings.IsAvailable()) { // Configure and use the encoder var encoder = new WavPackEncoderSettings { Mode = WavPackEncoderMode.Normal, Bitrate = 192000, MD5 = true }; } ``` ## Implementation Examples ### Video Capture SDK Integration ``` // Initialize the Video Capture SDK core var core = new VideoCaptureCoreX(); // Create a WavPack output instance var wavPackOutput = new WavPackOutput("output.wv"); // Add the WavPack output to the capture pipeline core.Outputs_Add(wavPackOutput, true); ``` ### Video Edit SDK Integration ``` // Initialize the Video Edit SDK core var core = new VideoEditCoreX(); // Create a WavPack output instance var wavPackOutput = new WavPackOutput("output.wv"); // Set the output format core.Output_Format = wavPackOutput; ``` ### Media Blocks SDK Integration ``` // Configure WavPack encoder settings var wavPackSettings = new WavPackEncoderSettings(); // Create the encoder block var wavPackOutput = new WavPackEncoderBlock(wavPackSettings); // Create a file output destination var fileSink = new FileSinkBlock("output.wv"); // Connect the encoder to the file sink in the pipeline pipeline.Connect(wavPackOutput.Output, fileSink.Input); // pipeline is MediaBlocksPipeline ``` ## Optimization Strategies ### Performance vs. Quality For optimal encoder performance and quality balance: DefaultArchivalStreaming - Use `Normal` mode for everyday encoding tasks - Enable `ExtraProcessing` only when encoding time isn't critical - Maintain `JointStereoMode` as `Auto` for most content types - Implement `High` or `VeryHigh` mode for archival purposes - Enable MD5 hash generation for content verification - Consider lossless encoding for critical audio preservation - Use `Fast` mode for real-time encoding scenarios - Select an appropriate bitrate based on bandwidth constraints - Disable additional processing features to minimize latency ## Best Practices When implementing WavPack in your applications: 1. **Balance quality and performance** by selecting the appropriate compression mode based on your use case 2. **Leverage hybrid mode** when distributing lossy files that may need lossless restoration later 3. **Consider format compatibility** with your target platforms and playback environments 4. **Test thoroughly** across different audio content types to ensure optimal settings ## Conclusion The WavPack encoder provides a versatile solution for audio compression in .NET applications. Whether you need archival-grade lossless compression or efficient lossy compression with future upgrade potential, the implementation in VisioForge's SDKs offers the flexibility and performance required by professional audio applications. By understanding the various configuration options and implementation strategies outlined in this guide, you can effectively integrate WavPack encoding into your software development projects and deliver high-quality audio processing capabilities to your users. ---END OF PAGE--- ## Windows Media Audio (WMA) Encoder Integration Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/audio-encoders/wma/ **Description:** Implement WMA audio encoding in .NET with cross-platform and Windows-specific approaches, bitrate controls, and codec configuration. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, MP3, WMA, C# **API:** WMAOutput, WMAEncoderSettings, VideoCaptureCore, VideoEditCore, VideoCaptureCoreX # Windows Media Audio encoder [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Windows Media Audio (WMA) is a popular audio codec developed by Microsoft for efficient audio compression. This documentation covers the WMA encoder implementations available in the VisioForge .Net SDKs. ## Overview The VisioForge SDK provides two distinct approaches for WMA encoding: the platform-specific [WMAOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.WMAOutput.html) for Windows environments and the cross-platform [WMAEncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.AudioEncoders.WMAEncoderSettings.html). Let's explore both implementations in detail to understand their capabilities and use cases. ## Cross-platform WMA output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The `WMAEncoderSettings` provides a cross-platform solution for WMA encoding. This implementation is built on SDK and offers consistent behavior across different operating systems. ### Key Features The encoder supports the following audio configurations: - Sample rates: 44.1 kHz and 48 kHz - Bitrates: 128, 192, 256, and 320 Kbps - Channel configurations: Mono (1) and Stereo (2) ### Rate Control The WMA encoder implements constant bitrate (CBR) encoding, allowing you to specify a fixed bitrate from the supported values. This ensures consistent audio quality and predictable file sizes throughout the encoded content. ### Usage Example Add the WMA output to the Video Capture SDK core instance: ``` // Create a Video Capture SDK core instance var core = new VideoCaptureCoreX(); // Create a WMA output var wmaOutput = new WMAOutput("output.wma"); wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; wmaOutput.Audio.Bitrate = 320; // Add the WMA output core.Outputs_Add(wmaOutput, true); ``` Set the output format for the Video Edit SDK core instance: ``` // Create a Video Edit SDK core instance var core = new VideoEditCoreX(); // Create a WMA output var wmaOutput = new WMAOutput("output.wma"); wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; wmaOutput.Audio.Bitrate = 320; // Add the WMA output core.Output_Format = wmaOutput; ``` Create a Media Blocks WMA output instance: ``` // Create a WMA encoder settings instance var wmaSettings = new WMAEncoderSettings(); // Create a WMA output instance var wmaOutput = new WMAEncoderBlock(wmaSettings); // Create a ASF output instance var asfOutput = new ASFSinkBlock(new ASFSinkSettings("output.wma")); // Connect the WMA encoder to the ASF output pipeline.Connect(wmaOutput.Output, asfOutput.Input); // pipeline is MediaBlocksPipeline ``` Check if WMA encoding is available before you build the pipeline: ``` if (!WMAEncoderSettings.IsAvailable()) { // Handle error — the WMA encoder plugin is missing on this platform. } ``` ## Windows-only WMA output [VideoCaptureCore](#) [VideoEditCore](#) The `WMAOutput` class provides a comprehensive Windows-specific implementation with advanced features and configuration options. This implementation leverages the Windows Media Format SDK for optimal performance on Windows systems. ### Key Features The Windows-specific implementation offers: - Multiple profile support (internal, external, and custom) - Language and localization settings - Quality-based encoding - Advanced bitrate control with peak bitrate settings - Buffer size configuration ### Configuration Modes The classic Windows implementation selects its encoder source via the `WMVMode` enum on `WMAOutput.Mode`: - `WMVMode.InternalProfile` — pick a predefined Windows Media profile by name (simplest). - `WMVMode.ExternalProfile` — load a `.prx` profile file from disk. - `WMVMode.ExternalProfileFromText` — pass profile XML inline as a string. - `WMVMode.CustomSettings` — drive all encoder parameters manually (quality, peak bitrate, buffer, etc.) through the `Custom_Audio_*` properties. - `WMVMode.V8SystemProfile` — use a Windows Media Video 8 system profile for compatibility with older Windows Media systems (lower compression efficiency than WMV9; only when targeting legacy systems). Rate control (CBR / VBR / quality-based VBR) is expressed through those `Custom_Audio_*` properties or baked into the chosen profile — it is not a separate enum. ### Usage Example Here's how to set up the Windows-specific WMA encoder: Use an internal profile for simple configuration ``` var wmaOutput = new WMAOutput { // Use an internal profile for simple configuration Mode = WMVMode.InternalProfile, Internal_Profile_Name = "Windows Media Audio 9 High (192K)" }; core.Output_Format = wmaOutput; // Core is VideoCaptureCore or VideoEditCore ``` Or configure custom settings ``` var wmaOutput = new WMAOutput { Mode = WMVMode.CustomSettings, Custom_Audio_StreamPresent = true, Custom_Audio_Quality = 98, // High quality setting Custom_Audio_PeakBitrate = 320, // Maximum bitrate in Kbps Custom_Audio_PeakBufferSize = 3 // Buffer size for streaming }; core.Output_Format = wmaOutput; // Core is VideoCaptureCore or VideoEditCore ``` ### Profile Management The Windows implementation supports three profile modes: 1. Internal Profiles: 2. Pre-configured profiles for common use cases 3. Access through `Internal_Profile_Name` 4. External Profiles: 5. Load profiles from external files 6. Configure using `External_Profile_FileName` or `External_Profile_Text` 7. Custom Profiles: 8. Fine-grained control over encoding parameters 9. Configure through Custom\_\* properties ## Best Practices When implementing WMA encoding in your application: 1. For Windows applications requiring advanced features: 2. Use WMAOutput for access to Windows-specific optimizations 3. Consider saving configurations to JSON for reuse 4. Implement proper error handling for profile loading 5. For cross-platform applications: 6. Stick to WMAEncoderSettings for consistent behavior 7. Verify supported rates before setting configuration 8. Use the highest supported sample rate and bitrate for best quality This documentation provides a foundation for implementing WMA encoding in your applications. The choice between cross-platform and Windows-specific implementations should be based on your application's requirements for platform support, encoding features, and quality control. ---END OF PAGE--- ## Using Third-Party DirectShow Video Filters in .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/3rd-party-video-effects/ **Description:** Implement third-party DirectShow video filters in .NET with code examples, best practices, and troubleshooting for Video SDK platforms. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, Windows, C# # Use Third-Party Video Filters in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction Third-party video processing filters provide powerful capabilities for manipulating video streams in .NET applications. These filters can be seamlessly integrated into various SDK platforms including Video Capture SDK .Net, Media Player SDK .Net, and Video Edit SDK .Net to enhance your applications with advanced video processing features. This guide explores how to implement, configure, and optimize third-party DirectShow filters within your .NET projects, providing you with the knowledge needed to create sophisticated video processing applications. ## Understanding DirectShow Filters DirectShow filters are COM-based components that process media data within the DirectShow framework. They can perform various operations including: - Video effects and transitions - Color correction and grading - Frame rate conversion - Resolution changes - Noise reduction - Special effects processing Before using third-party filters, it's important to understand how they operate within the DirectShow pipeline and how they interact with our SDK components. ## Prerequisites To successfully implement third-party video processing filters in your .NET applications, you'll need: 1. The appropriate SDK (.NET Video Capture, Media Player, or Video Edit) 2. Third-party DirectShow filters of your choice 3. Administrative access for filter registration 4. Basic understanding of DirectShow architecture ## Filter Registration Process DirectShow filters must be properly registered on the system before they can be used in your applications. This is typically done using the Windows registration utility: ``` regsvr32.exe path\to\your\filter.dll ``` Alternative COM registration methods can also be used, particularly in scenarios where: - You need to register filters during application installation - You're working in environments with limited user permissions - You require silent registration as part of a deployment process ### Registration Troubleshooting If filter registration fails, verify: 1. You have administrator privileges 2. The filter DLL is compatible with your system architecture (x86/x64) 3. All dependencies of the filter are available on the system 4. The filter is properly implemented as a COM object ## Implementation Guide ### Enumerating Available DirectShow Filters Before adding filters to your processing chain, you may want to discover what filters are available on the system: ``` // DirectShow_Filters() returns ObservableCollection — each entry is the filter name foreach (var filterName in VideoCapture1.DirectShow_Filters()) { Console.WriteLine($"Filter Name: {filterName}"); Console.WriteLine("----------------------------"); } ``` This code snippet allows you to inspect all registered DirectShow filters, helping you identify the correct filters to use in your application. ### Managing the Filter Chain Before adding new filters, you may want to clear any existing filters from the processing chain: ``` // Remove all currently applied filters VideoCapture1.Video_Filters_Clear(); ``` This ensures you're starting with a clean processing pipeline and prevents unexpected interactions between filters. ### Adding Filters to Your Application To add a third-party filter to your video processing pipeline: ``` // Ctor: CustomProcessingFilter(string name, Guid? clsid = null, bool beforeEffects = false) // Use the filter name as registered in DirectShow; the SDK resolves the CLSID automatically. var myFilter = new CustomProcessingFilter("My Effect Filter"); // Add the filter to the processing chain VideoCapture1.Video_Filters_Add(myFilter); ``` `CustomProcessingFilter` only exposes `Name`, `CLSID`, and `BeforeEffects` — filter-specific parameters are configured on the underlying COM filter (see the Filter Parameters section below). You can add multiple filters in sequence to create complex processing chains. The order of filters matters, as each filter processes the output of the previous one. ## Advanced Filter Configuration ### Filter Parameters Most third-party filters expose configurable parameters via their own COM interfaces (e.g. `IPropertyBag`, `ISpecifyPropertyPages`, or a vendor-specific `ISomethingFilter`). These interfaces are reached through the underlying `IBaseFilter` instance once the graph is built — not through `CustomProcessingFilter`, which only carries the registration identity (`Name` / `CLSID`). Consult the filter vendor's documentation for the concrete interface and property names. ### Filter Ordering The sequence of filters in your processing chain significantly impacts the final result: ``` // Example of a multi-filter processing chain VideoCapture1.Video_Filters_Add(new CustomProcessingFilter("Noise Reduction")); VideoCapture1.Video_Filters_Add(new CustomProcessingFilter("Color Enhancement")); VideoCapture1.Video_Filters_Add(new CustomProcessingFilter("Sharpening")); ``` Experiment with different filter arrangements to achieve the desired effect. For example, applying noise reduction before sharpening usually produces better results than the reverse order. ## Performance Considerations Third-party filters can impact application performance. Consider these optimization strategies: 1. Only enable filters when necessary 2. Use lower complexity filters for real-time processing 3. Consider the resolution and frame rate when applying multiple filters 4. Test performance with your target hardware configurations 5. Use profile-guided optimization when available ## Common Issues and Solutions ### Thread Safety When working with filters in multi-threaded applications, ensure proper synchronization: ``` private readonly object _filterLock = new object(); public void RebuildFilterChain(IEnumerable filters) { lock (_filterLock) { // VideoCaptureCore only exposes Add/Clear — rebuild the chain instead of removing a single filter. VideoCapture1.Video_Filters_Clear(); foreach (var filter in filters) { VideoCapture1.Video_Filters_Add(filter); } } } ``` ## Required Components To successfully deploy applications that use third-party video processing filters, ensure you include: - SDK redistributables for your chosen platform - Any dependencies required by the third-party filters - Proper installation and registration scripts for the filters ## Conclusion Third-party video processing filters offer powerful capabilities for enhancing your .NET video applications. By following the guidelines in this document, you can successfully integrate these filters into your projects, creating sophisticated video processing solutions. Remember to test thoroughly with your target environment configurations to ensure optimal performance and compatibility. --- For more code samples and implementation details, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## ASF and WMV File Indexing for .NET SDK Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/asf-wmv-files-indexing/ **Description:** Learn why ASF, WMV, and WMA files need indexing for reliable seeking, and how to add indexes before opening them in VisioForge .NET apps. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, Windows, WinForms, Streaming, WMV, WMA, C# # ASF and WMV File Indexing in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) When working with Windows Media files in your .NET applications, you may encounter seeking problems with ASF, WMV, or WMA files that were produced without a proper index. This page explains the underlying issue and points to the right tool for building the index before VisioForge consumes the file. ## Understanding the indexing problem ASF (Advanced Systems Format) is Microsoft's container format designed for streaming media; WMV (Windows Media Video) and WMA (Windows Media Audio) are built on it. Files lacking an index exhibit: - Choppy or unpredictable seeking behaviour - Inability to jump to specific timestamps - Inconsistent playback when navigating through the file - High overhead during random access An ASF index is a lookup table that maps timestamps (or frame numbers) to byte offsets in the file. When present, players can jump directly to any point in the stream; when absent, they must fall back to sequential parsing. ## Building an ASF index VisioForge consumes ASF/WMV/WMA files once they are indexed, but it does not ship a public indexer on the managed surface. Build the index with one of the following external tools before handing the file to the SDK: - **Windows Media Format SDK** (`IWMWriterFileSink` / `IWMIndexer` COM interfaces, available via `Microsoft.Windows.WindowsMedia.Format`). This is the canonical Microsoft path for offline indexing; the `IWMIndexer::StartIndexing` method writes a `WM/Index` object into the file. - **Windows Media File Editor** (`WMFileEditor.exe`, part of the Windows Media Encoder 9 tools) for ad-hoc indexing during development. - **`ffmpeg -i input.wmv -c copy -map 0 -f asf output.wmv`** — muxing through ffmpeg will rewrite the ASF container with a fresh index in most cases, without re-encoding. Once the file carries a valid index, all VisioForge engines (`MediaPlayerCore`, `MediaPlayerCoreX`, `VideoEditCore`, `VideoEditCoreX`) will seek accurately and report consistent durations through the usual `Duration`/`Position_Get*` APIs. ## Best practices for ASF/WMV workflows 1. **Detect missing indexes up front.** If `Duration` is reported as zero or seeking returns the wrong frame, suspect a missing or corrupt ASF index. 2. **Index once per file.** Indexing rewrites the file on disk; do it as part of ingest, not at playback time. 3. **Cache indexed copies.** When a user loads an unindexed file, persist the indexed version to disk and point future sessions at it instead of re-indexing. 4. **Run indexing off the UI thread.** Large files can take several seconds to index; pipe the operation through `Task.Run` to keep your UI responsive. 5. **Prefer MP4 for new recordings.** If you control the capture pipeline, VisioForge's `MP4Output` produces seekable files without a separate indexing step. ## System requirements Indexing is a Windows-only workflow because the ASF container itself is Windows Media technology: - Windows Media Format SDK runtime (bundled with Windows 7 and later) - Write access to the target file - Enough free disk to rewrite the container (indexing appends metadata and, in some cases, re-serialises the stream) ## See also - [WMV encoding reference](../../output-formats/wmv/) — configure VisioForge's WMV output to produce indexed files on capture. - [Windows Media Format SDK — IWMIndexer](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/api/wmsdkidl/nn-wmsdkidl-iwmindexer) - [MP4 output](../../output-formats/mp4/) — a seek-friendly alternative for new projects. --- For more code samples and advanced media processing techniques, check out our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## Custom DirectShow Filter Interfaces Guide for .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/custom-filter-interface/ **Description:** Implement custom DirectShow filter interfaces in .NET with IBaseFilter access and manipulation for multimedia applications. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, VideoCaptureCore, Windows, Capture, C#, NuGet **API:** IBaseFilter, FilterEventArgs, VideoCaptureCore # Use Custom DirectShow Filter Interfaces [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) *Note: The API shown in this guide is the same across all our SDK products, including Video Capture SDK .Net, Video Edit SDK .Net, and Media Player SDK .Net.* DirectShow is a powerful multimedia framework that allows developers to perform complex operations on media streams. One of its key strengths is the ability to work with custom filter interfaces, giving you precise control over media processing. This guide will walk you through implementing and utilizing custom DirectShow filter interfaces in your .NET applications. ## Understanding DirectShow Filters DirectShow uses a filter-based architecture where each filter performs a specific operation on the media stream. These filters are connected in a graph, creating a pipeline for media processing. ### Key DirectShow Components - **Filter**: A component that processes media data - **Pin**: Connection points between filters - **Filter Graph**: The complete pipeline of connected filters - **IBaseFilter**: The fundamental interface that all DirectShow filters implement ## Getting Started with Custom Filter Interfaces To work with DirectShow filters in .NET, you'll need to: 1. Add the proper references to your project 2. Access the filter through appropriate events 3. Cast the filter to the interface you need 4. Implement your custom logic ### Required Project References To access DirectShow functionality, include the appropriate package in your project: ``` ``` You can also add the `VisioForge.Core` assembly reference directly to your project. ## Implementing Custom Filter Interface Access Our SDK provides several events that give you access to filters as they're added to the filter graph. Here's how to use them effectively: ### Accessing Filters in Video Capture SDK The Video Capture SDK offers the `OnFilterAdded` event that fires whenever a filter is added to the graph. This event provides access to each filter through its event arguments. ``` // Subscribe to the OnFilterAdded event videoCaptureCore.OnFilterAdded += VideoCaptureCore_OnFilterAdded; // Event handler implementation private void VideoCaptureCore_OnFilterAdded(object sender, FilterEventArgs eventArgs) { // Access the DirectShow filter interface IBaseFilter baseFilter = eventArgs.Filter as IBaseFilter; // Now you can work with the filter through the IBaseFilter interface if (baseFilter != null) { // Custom filter manipulation code goes here } } ``` ## Working with IBaseFilter Interface The `IBaseFilter` interface is the foundation of DirectShow filters. Here's what you can do with it: ### Retrieving Filter Information ``` private void GetFilterInfo(IBaseFilter filter) { FilterInfo filterInfo = new FilterInfo(); int hr = filter.QueryFilterInfo(out filterInfo); if (hr >= 0) { Console.WriteLine($"Filter Name: {filterInfo.achName}"); // Don't forget to release the reference to the filter graph if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } } ``` ### Enumerating Filter Pins ``` private void EnumerateFilterPins(IBaseFilter filter) { IEnumPins enumPins; int hr = filter.EnumPins(out enumPins); if (hr >= 0 && enumPins != null) { IPin[] pins = new IPin[1]; int fetched; while (enumPins.Next(1, pins, out fetched) == 0 && fetched > 0) { PinInfo pinInfo = new PinInfo(); pins[0].QueryPinInfo(out pinInfo); Console.WriteLine($"Pin Name: {pinInfo.name}, Direction: {pinInfo.dir}"); // Release pin and info if (pinInfo.filter != null) Marshal.ReleaseComObject(pinInfo.filter); Marshal.ReleaseComObject(pins[0]); } Marshal.ReleaseComObject(enumPins); } } ``` ## Identifying the Right Filter When working with the `OnFilterAdded` event, remember that it can be called multiple times as various filters are added to the graph. To work with a specific filter, you'll need to identify it correctly: ``` private void VideoCaptureCore_OnFilterAdded(object sender, FilterEventArgs eventArgs) { IBaseFilter baseFilter = eventArgs.Filter as IBaseFilter; if (baseFilter != null) { FilterInfo filterInfo = new FilterInfo(); baseFilter.QueryFilterInfo(out filterInfo); // Check if this is the filter we're looking for if (filterInfo.achName == "Video Capture Device") { // This is our target filter, perform specific operations ConfigureVideoCaptureFilter(baseFilter); } // Release the filter graph reference if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } } ``` ## Advanced Filter Configuration Once you have access to the filter interface, you can perform advanced configurations: ### Setting Filter Properties ``` private void SetFilterProperty(IBaseFilter filter, Guid propertySet, int propertyId, object propertyValue) { IKsPropertySet propertySetInterface = filter as IKsPropertySet; if (propertySetInterface != null) { // Convert property value to byte array byte[] propertyData = ConvertToByteArray(propertyValue); // Set the property int hr = propertySetInterface.Set( propertySet, propertyId, IntPtr.Zero, 0, propertyData, propertyData.Length ); Marshal.ReleaseComObject(propertySetInterface); } } ``` ### Retrieving Filter Properties ``` private object GetFilterProperty(IBaseFilter filter, Guid propertySet, int propertyId, Type propertyType) { IKsPropertySet propertySetInterface = filter as IKsPropertySet; object result = null; if (propertySetInterface != null) { int dataSize = Marshal.SizeOf(propertyType); byte[] propertyData = new byte[dataSize]; int returnedDataSize; // Get the property int hr = propertySetInterface.Get( propertySet, propertyId, IntPtr.Zero, 0, propertyData, propertyData.Length, out returnedDataSize ); if (hr >= 0) { result = ConvertFromByteArray(propertyData, propertyType); } Marshal.ReleaseComObject(propertySetInterface); } return result; } ``` ## Common Use Cases for Custom Filter Interfaces ### Video Processing Filters When working with video, you might need to access specific properties of camera devices: ``` private void ConfigureVideoCaptureFilter(IBaseFilter captureFilter) { // Access and set camera properties IAMCameraControl cameraControl = captureFilter as IAMCameraControl; if (cameraControl != null) { // Set exposure cameraControl.Set(CameraControlProperty.Exposure, 0, CameraControlFlags.Manual); // Set focus cameraControl.Set(CameraControlProperty.Focus, 0, CameraControlFlags.Manual); Marshal.ReleaseComObject(cameraControl); } } ``` ### Audio Processing Filters For audio processing, you might want to adjust volume or audio quality settings: ``` private void ConfigureAudioFilter(IBaseFilter audioFilter) { // Access volume interface IBasicAudio basicAudio = audioFilter as IBasicAudio; if (basicAudio != null) { // Set volume (0 to -10000, where 0 is max and -10000 is min) basicAudio.put_Volume(-2000); // 80% volume Marshal.ReleaseComObject(basicAudio); } } ``` ## Handling Resources Properly When working with DirectShow interfaces, it's crucial to properly release COM objects to prevent memory leaks: ``` private void ReleaseComObject(object comObject) { if (comObject != null) { Marshal.ReleaseComObject(comObject); } } ``` ## Complete Example Here's a more complete example that demonstrates finding and configuring a video capture filter: ``` using System; using System.Runtime.InteropServices; using VisioForge.Libs.DirectShowLib; // Public namespace — IBaseFilter, FilterInfo, IPin, etc. public class CustomFilterExample { private VideoCaptureCore captureCore; public void Initialize() { captureCore = new VideoCaptureCore(); captureCore.OnFilterAdded += CaptureCore_OnFilterAdded; // Configure source // ... // Start capture captureCore.Start(); } private void CaptureCore_OnFilterAdded(object sender, FilterEventArgs eventArgs) { IBaseFilter baseFilter = eventArgs.Filter as IBaseFilter; if (baseFilter != null) { // Get filter information FilterInfo filterInfo = new FilterInfo(); baseFilter.QueryFilterInfo(out filterInfo); Console.WriteLine($"Filter added: {filterInfo.achName}"); // Check if this is the video capture filter if (filterInfo.achName.Contains("Video Capture")) { ConfigureVideoCaptureFilter(baseFilter); } // Release filter graph reference if (filterInfo.pGraph != null) { Marshal.ReleaseComObject(filterInfo.pGraph); } } } private void ConfigureVideoCaptureFilter(IBaseFilter captureFilter) { // Your filter configuration code here } public void Cleanup() { if (captureCore != null) { captureCore.Stop(); captureCore.OnFilterAdded -= CaptureCore_OnFilterAdded; captureCore.Dispose(); captureCore = null; } } } ``` ## Required System Components To use DirectShow functionality in your application, ensure your end-users have the following components installed: - DirectX Runtime (included with Windows) - SDK redistributable components ## Conclusion Working with custom DirectShow filter interfaces gives you powerful capabilities for media processing in your .NET applications. By following the patterns described in this guide, you can access and manipulate the underlying DirectShow components to achieve precise control over your multimedia applications. For additional assistance with implementing these techniques, please contact our support team. Visit our GitHub repository for more code samples and implementation examples. ---END OF PAGE--- ## Creating Custom Real-Time Video Effects in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/custom-video-effects/ **Description:** Implement custom video effects in C# with OnVideoFrameBitmap and OnVideoFrameBuffer events for real-time video processing and overlays. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, C# **API:** VideoFrameBitmapEventArgs, VideoFrameBufferEventArgs # Creating Custom Real-time Video Effects in C# Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction to Video Frame Processing When developing video applications, you often need to apply custom effects or overlays to video streams in real-time. The .NET SDK provides two powerful events for this purpose: `OnVideoFrameBitmap` and `OnVideoFrameBuffer`. These events give you direct access to each video frame, allowing you to modify pixels before they're rendered or encoded. ## Implementation Methods There are two primary approaches to implementing custom video effects: 1. **Using OnVideoFrameBitmap**: Process frames as Bitmap objects with GDI+ - easier to use but with moderate performance 2. **Using OnVideoFrameBuffer**: Manipulate raw RGB24 image buffer directly - offers better performance but requires more low-level code ## Code Examples for Custom Video Effects ### Text Overlay Implementation Adding text overlays to video is useful for watermarking, displaying information, or creating captions. This example demonstrates how to add simple text to your video frames: ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { Graphics grf = Graphics.FromImage(e.Frame); grf.DrawString("Hello!", new Font(FontFamily.GenericSansSerif, 20), new SolidBrush(Color.White), 20, 20); grf.Dispose(); e.UpdateData = true; } ``` ### Grayscale Effect Implementation Converting video to grayscale is a fundamental image processing technique. This example shows how to access and modify individual pixel values: ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { Bitmap bmp = e.Frame; Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = Math.Abs(bmpData.Stride) * bmp.Height; byte[] rgbValues = new byte[bytes]; System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); // Apply standard luminance formula (0.3R + 0.59G + 0.11B) for accurate grayscale conversion for (int i = 0; i < rgbValues.Length; i += 3) { int gray = (int)(rgbValues[i] * 0.3 + rgbValues[i + 1] * 0.59 + rgbValues[i + 2] * 0.11); rgbValues[i] = (byte)gray; rgbValues[i + 1] = (byte)gray; rgbValues[i + 2] = (byte)gray; } System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); bmp.UnlockBits(bmpData); e.UpdateData = true; } ``` ### Brightness Adjustment Implementation This example demonstrates how to adjust the brightness of video frames - a common requirement in video processing applications: ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { float brightness = 1.2f; // Values > 1 increase brightness, < 1 decrease it Bitmap bmp = e.Frame; Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = Math.Abs(bmpData.Stride) * bmp.Height; byte[] rgbValues = new byte[bytes]; System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); // Apply brightness adjustment to each color channel for (int i = 0; i < rgbValues.Length; i++) { int newValue = (int)(rgbValues[i] * brightness); rgbValues[i] = (byte)Math.Min(255, Math.Max(0, newValue)); } System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes); bmp.UnlockBits(bmpData); e.UpdateData = true; } ``` ### Timestamp Overlay Implementation Adding timestamps to video frames is essential for surveillance and logging applications. This example shows how to create a professional-looking timestamp with a semi-transparent background: ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { Graphics grf = Graphics.FromImage(e.Frame); // Create a semi-transparent background for better readability Rectangle textBackground = new Rectangle(10, e.Frame.Height - 50, 250, 40); grf.FillRectangle(new SolidBrush(Color.FromArgb(128, 0, 0, 0)), textBackground); // Display current date and time string dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); grf.DrawString(dateTime, new Font(FontFamily.GenericSansSerif, 16), new SolidBrush(Color.White), 15, e.Frame.Height - 45); grf.Dispose(); e.UpdateData = true; } ``` ## Performance Optimization Tips ### Working with Raw Buffer Data For high-performance applications, processing raw buffer data offers significant speed advantages: ``` // OnVideoFrameBuffer event example (pseudo-code) private void VideoCapture1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { // e.Frame.Data is an IntPtr to the native buffer (length = e.Frame.DataSize). // Dimensions and stride live in e.Frame.Info; actual pixel layout is in // e.Frame.Info.Colorspace (RGB24/RGB32/YUY2/NV12/...). Don't assume RGB24. int width = e.Frame.Info.Width; int height = e.Frame.Info.Height; int stride = e.Frame.Info.Stride; var colorspace = e.Frame.Info.Colorspace; // Process e.Frame.Data in place for maximum performance, then set // e.UpdateData = true so the modified buffer flows downstream. } ``` ### Best Practices for Frame Processing - **Memory Management**: Always dispose Graphics objects and unlock bitmapped data - **Performance Considerations**: For real-time processing, keep operations lightweight - **Buffer Processing**: We strongly recommend processing RAW data in the OnVideoFrameBuffer event for optimal performance - **External Libraries**: Consider using Intel IPP or other optimized image-processing libraries for complex operations --- ## Additional Resources Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to access more code samples and complete project examples. ---END OF PAGE--- ## Implementing Dynamic Text Overlays on Video Frames **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/draw-multitext-onvideoframebuffer/ **Description:** Create multiple text overlays on video frames with OnVideoFrameBuffer event for customizable text properties and dynamic updates in .NET. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, C# **API:** VideoFrameBufferEventArgs # Implementing Dynamic Text Overlays on Video Frames in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction Adding text overlays to video content has become essential for various applications, from adding watermarks and timestamps to creating informative annotations and captions. While many SDKs offer built-in text overlay capabilities, these functions might not always provide the level of customization or flexibility required for advanced projects. This guide demonstrates how to implement custom text overlays using the `OnVideoFrameBuffer` event. This approach gives you full control over the text appearance, position, and behavior, allowing for more sophisticated overlay implementations than what's possible with standard API methods. ## Why Use Custom Text Overlays? Standard text overlay APIs often have limitations in areas such as: - Number of concurrent text elements - Font customization options - Dynamic text updates - Animation capabilities - Precise positioning control - Alpha channel management By leveraging the `OnVideoFrameBuffer` event and working directly with bitmap data, you can overcome these limitations and implement exactly what your application needs. ## Understanding the Approach The technique demonstrated in this article involves: 1. Creating a transparent bitmap with the same dimensions as the video frame 2. Drawing text elements onto this bitmap using GDI+ (System.Drawing) 3. Converting the bitmap to a memory buffer 4. Overlaying this buffer onto the video frame data 5. Optionally updating text elements dynamically This provides a powerful method for text overlay creation while maintaining good performance. ## Basic Implementation The following code sample shows a straightforward implementation for drawing multiple text overlays on video frames: ``` // Image private Bitmap logoImage = null; // Image RGB32 buffer private IntPtr logoImageBuffer = IntPtr.Zero; private int logoImageBufferSize = 0; private string text1 = "Hello World"; private string text2 = "Hey-hey"; private string text3 = "Ocean of pancakes"; private void SDK_OnVideoFrameBuffer(Object sender, VideoFrameBufferEventArgs e) { // draw text to image if (logoImage == null) { logoImage = new Bitmap(e.Frame.Info.Width, e.Frame.Info.Height, PixelFormat.Format32bppArgb); using (var grf = Graphics.FromImage(logoImage)) { // antialiasing mode grf.TextRenderingHint = TextRenderingHint.AntiAlias; // drawing mode grf.InterpolationMode = InterpolationMode.HighQualityBicubic; // smoothing mode grf.SmoothingMode = SmoothingMode.HighQuality; // text 1 var brush1 = new SolidBrush(Color.Blue); var font1 = new Font("Arial", 30, FontStyle.Regular); grf.DrawString(text1, font1, brush1, 100, 100); // text 2 var brush2 = new SolidBrush(Color.Red); var font2 = new Font("Times New Roman", 35, FontStyle.Strikeout); grf.DrawString(text2, font2, brush2, e.Frame.Info.Width / 2, e.Frame.Info.Height / 2); // text 3 var brush3 = new SolidBrush(Color.Green); var font3 = new Font("Verdana", 40, FontStyle.Italic); grf.DrawString(text3, font3, brush3, 200, 200); } } // create image buffer if not allocated or have zero size if (logoImageBuffer == IntPtr.Zero || logoImageBufferSize == 0) { if (logoImageBuffer == IntPtr.Zero) { logoImageBufferSize = ImageHelper.GetStrideRGB32(logoImage.Width) * logoImage.Height; logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } else { logoImageBufferSize = ImageHelper.GetStrideRGB32(logoImage.Width) * logoImage.Height; Marshal.FreeCoTaskMem(logoImageBuffer); logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } BitmapHelper.BitmapToIntPtr(logoImage, logoImageBuffer, logoImage.Width, logoImage.Height, PixelFormat.Format32bppArgb); } // Draw image FastImageProcessing.Draw_RGB32OnRGB24(logoImageBuffer, logoImage.Width, logoImage.Height, e.Frame.Data, e.Frame.Info.Width, e.Frame.Info.Height, 0, 0); e.UpdateData = true; } ``` ### Key Components Explained 1. **Bitmap Creation**: We create a 32-bit bitmap (with alpha channel) matching the video frame dimensions 2. **Graphics Settings**: We configure anti-aliasing, interpolation, and smoothing for high-quality text rendering 3. **Text Configuration**: Each text element gets its own font, color, and position 4. **Memory Management**: We allocate unmanaged memory for the bitmap buffer 5. **Bitmap to Buffer Conversion**: We convert the bitmap to a memory buffer using `BitmapHelper.BitmapToIntPtr` 6. **Buffer Overlay**: We draw the RGBA buffer onto the video frame using `FastImageProcessing.Draw_RGB32OnRGB24` 7. **Frame Update Flag**: We set `e.UpdateData = true` to inform the SDK that the frame data has been modified ## Advanced Implementation with Dynamic Updates For more interactive applications, you might need to update text overlays dynamically. The following implementation supports on-the-fly updates of text content, fonts, and colors: ``` // Image Bitmap logoImage = null; // Image RGB32 buffer IntPtr logoImageBuffer = IntPtr.Zero; int logoImageBufferSize = 0; // text settings string text1 = "Hello World"; Font font1 = new Font("Arial", 30, FontStyle.Regular); SolidBrush brush1 = new SolidBrush(Color.Blue); string text2 = "Hey-hey"; Font font2 = new Font("Times New Roman", 35, FontStyle.Strikeout); SolidBrush brush2 = new SolidBrush(Color.Red); string text3 = "Ocean of pancakes"; Font font3 = new Font("Verdana", 40, FontStyle.Italic); SolidBrush brush3 = new SolidBrush(Color.Green); // update flag bool textUpdate = false; object textLock = new object(); // Update text overlay, index is [1..3] void UpdateText(int index, string text, Font font, SolidBrush brush) { lock (textLock) { textUpdate = true; } switch (index) { case 1: text1 = text; font1 = font; brush1 = brush; break; case 2: text2 = text; font2 = font; brush2 = brush; break; case 3: text3 = text; font3 = font; brush3 = brush; break; default: return; } } private void SDK_OnVideoFrameBuffer(Object sender, VideoFrameBufferEventArgs e) { lock (textLock) { if (textUpdate) { logoImage.Dispose(); logoImage = null; } // draw text to image if (logoImage == null) { logoImage = new Bitmap(e.Frame.Info.Width, e.Frame.Info.Height, PixelFormat.Format32bppArgb); using (var grf = Graphics.FromImage(logoImage)) { // antialiasing mode grf.TextRenderingHint = TextRenderingHint.AntiAlias; // drawing mode grf.InterpolationMode = InterpolationMode.HighQualityBicubic; // smoothing mode grf.SmoothingMode = SmoothingMode.HighQuality; // text 1 grf.DrawString(text1, font1, brush1, 100, 100); // text 2 grf.DrawString(text2, font2, brush2, e.Frame.Info.Width / 2, e.Frame.Info.Height / 2); // text 3 grf.DrawString(text3, font3, brush3, 200, 200); } } // create image buffer if not allocated or have zero size if (logoImageBuffer == IntPtr.Zero || logoImageBufferSize == 0) { if (logoImageBuffer == IntPtr.Zero) { logoImageBufferSize = ImageHelper.GetStrideRGB32(e.Frame.Info.Width) * e.Frame.Info.Height; logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } else { logoImageBufferSize = ImageHelper.GetStrideRGB32(e.Frame.Info.Width) * e.Frame.Info.Height; Marshal.FreeCoTaskMem(logoImageBuffer); logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } BitmapHelper.BitmapToIntPtr(logoImage, logoImageBuffer, logoImage.Width, logoImage.Height, PixelFormat.Format32bppArgb); } if (textUpdate) { textUpdate = false; BitmapHelper.BitmapToIntPtr(logoImage, logoImageBuffer, logoImage.Width, logoImage.Height, PixelFormat.Format32bppArgb); } // Draw image FastImageProcessing.Draw_RGB32OnRGB24(logoImageBuffer, logoImage.Width, logoImage.Height, e.Frame.Data, e.Frame.Info.Width, e.Frame.Info.Height, 0, 0); e.UpdateData = true; } } private void btUpdateText1_Click(object sender, EventArgs e) { UpdateText(1, "Hello world", new Font("Arial", 48, FontStyle.Underline), new SolidBrush(Color.Aquamarine)); } ``` ### New Features in the Advanced Implementation 1. **Thread Safety**: We use a lock object to prevent concurrent access to shared resources 2. **Update Mechanism**: The `UpdateText` method provides a clean interface for changing text properties 3. **Text Property Storage**: Each text element has its own variables for content, font, and color 4. **Change Detection**: We use a flag (`textUpdate`) to indicate when text properties have changed 5. **Resource Management**: We dispose of the old bitmap when text properties change 6. **Buffer Update**: We update the memory buffer when text properties change 7. **UI Integration**: A sample button click handler demonstrates how to trigger text updates ## Performance Optimization Tips When implementing text overlays with this method, consider these performance optimizations: 1. **Minimize Bitmap Recreations**: Only recreate the bitmap when necessary (text changes, resolution changes) 2. **Cache Font Objects**: Font creation is expensive; create fonts once and reuse them 3. **Use Memory Efficiently**: Free unmanaged memory when it's no longer needed 4. **Optimize Drawing Operations**: Use hardware acceleration when available 5. **Consider Update Frequency**: For frequent updates, consider double-buffering techniques 6. **Profile Your Code**: Use performance profiling tools to identify bottlenecks ## Advanced Features to Consider This basic implementation can be extended with additional features: 1. **Text Animation**: Implement text movement, fading, or other animations 2. **Text Formatting**: Add support for rich text formatting (bold, italic, etc.) 3. **Text Effects**: Implement shadows, outlines, or glow effects 4. **Text Alignment**: Add support for different text alignment options 5. **Multi-Line Text**: Implement proper handling of multi-line text with wrapping 6. **Localization**: Add support for different languages and text directions 7. **Performance Monitoring**: Add diagnostics to monitor rendering performance ## Memory Management Considerations When working with unmanaged memory, it's crucial to handle resource cleanup properly: 1. Implement the `IDisposable` pattern in your class 2. Free unmanaged memory in the `Dispose` method 3. Consider using `SafeHandle` or similar constructs for safer resource management 4. Set buffer pointers to `IntPtr.Zero` after freeing them 5. Use structured exception handling around memory operations ## Cleanup Example ``` protected override void Dispose(bool disposing) { if (disposing) { // Dispose managed resources if (logoImage != null) { logoImage.Dispose(); logoImage = null; } } // Free unmanaged resources if (logoImageBuffer != IntPtr.Zero) { Marshal.FreeCoTaskMem(logoImageBuffer); logoImageBuffer = IntPtr.Zero; logoImageBufferSize = 0; } base.Dispose(disposing); } ``` ## Required Dependencies - SDK redistributable components ## Conclusion Implementing custom text overlays using the `OnVideoFrameBuffer` event provides a powerful and flexible solution for applications that require advanced text display capabilities. While it requires more code than using built-in API methods, the additional flexibility and control make it worthwhile for sophisticated video applications. By following the patterns demonstrated in this guide, you can create dynamic, high-quality text overlays that can be updated in real-time, providing a rich user experience in your video applications. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Render Live Video in WinForms PictureBox — C# .NET Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/draw-video-picturebox/ **Description:** Thread-safe frame updates, bitmap disposal, and double buffering to prevent flicker. Frame skipping for high-FPS sources. VisioForge SDK zoom and size modes. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, C# **API:** VideoFrameBitmapEventArgs # Drawing Video on PictureBox in .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction to Video Rendering in WinForms Displaying video content in desktop applications is a common requirement for many software developers working with multimedia. Whether you're building applications for video surveillance, media players, video editing tools, or any software that processes video streams, understanding how to effectively render video is crucial. The PictureBox control is one of the most straightforward ways to display video frames in Windows Forms applications. While it wasn't specifically designed for video playback, with proper implementation, it can provide smooth video rendering with minimal resource consumption. This guide focuses on implementing video rendering on PictureBox controls in .NET WinForms applications. We'll cover the entire process from setup to implementation, addressing common pitfalls and optimization techniques. ## Why Use PictureBox for Video Display? Before diving into implementation details, let's examine the advantages of using PictureBox for video display: - **Simplicity**: PictureBox is a straightforward control that most .NET developers are already familiar with. - **Flexibility**: It allows customization of how images are displayed through its SizeMode property. - **Integration**: It integrates seamlessly with other WinForms controls. - **Low overhead**: For many applications, it provides sufficient performance without requiring more complex DirectX or OpenGL implementations. However, it's important to note that PictureBox wasn't designed specifically for high-performance video playback. For applications requiring professional-grade video performance or hardware acceleration, more specialized rendering approaches might be necessary. ## Prerequisites To implement video rendering on a PictureBox, you'll need: - Basic knowledge of C# and .NET WinForms development - Visual Studio or another IDE for .NET development - A video source (from Video Capture SDK, Video Edit SDK, or Media Player SDK) - Understanding of event-driven programming ## Setting Up Your Environment ### Configuring the PictureBox Control 1. Add a PictureBox control to your form through the designer or programmatically. 2. Configure the basic properties for optimal video display: ``` // Configure PictureBox for video display pictureBox1.BackColor = Color.Black; pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; ``` The `BackColor` property set to `Black` provides a clean background for video display, especially during initialization or when the video has black borders. The `SizeMode` property determines how the video frame fits within the control: - `StretchImage`: Stretches the image to fill the PictureBox (may distort aspect ratio) - `Zoom`: Maintains aspect ratio while filling the control - `CenterImage`: Centers the image without scaling - `Normal`: Displays the image at its original size For most video applications, `StretchImage` or `Zoom` work best, depending on whether maintaining aspect ratio is important. ## Implementation Steps ### Step 1: Prepare Your Class with Required Variables Add a boolean class member to track when an image is being applied to the PictureBox. This prevents race conditions when multiple frames arrive in quick succession: ``` private bool applyingPictureBoxImage = false; ``` ### Step 2: Initialize Video Settings in the Start Handler When starting your video capture or playback, ensure the flag is properly initialized: ``` private async void btnStart_Click(object sender, EventArgs e) { // Reset the flag before starting capture/playback. applyingPictureBoxImage = false; // Subscribe to OnVideoFrameBitmap before starting so the first frame is not missed. // The event is EventHandler, fired from a worker thread. videoCapture1.OnVideoFrameBitmap += VideoCapture1_OnVideoFrameBitmap; // Video Capture SDK example — swap for MediaPlayer1 / VideoEdit1 if you are using those engines. videoCapture1.Video_CaptureDevice = new VideoCaptureSource("USB Camera"); videoCapture1.Mode = VideoCaptureMode.VideoPreview; videoCapture1.Audio_RecordAudio = false; await videoCapture1.StartAsync(); } ``` The same `OnVideoFrameBitmap` event exists on all three engines — `VideoCaptureCore`, `MediaPlayerCore`, and `VideoEditCore` — so the handler below works unchanged no matter which SDK raised it. ### Step 3: Implement the Frame Handler The core of video rendering is the frame handler. This event fires each time a new video frame is available. Here's how to implement it efficiently: ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { // Prevent concurrent updates that could cause threading issues if (applyingPictureBoxImage) { return; } applyingPictureBoxImage = true; try { // Store current image for proper disposal var currentImage = pictureBox1.Image; // Create a new bitmap from the frame pictureBox1.Image = new Bitmap(e.Frame); // Properly dispose of the previous image to prevent memory leaks currentImage?.Dispose(); } catch (Exception ex) { // Consider logging the exception Console.WriteLine($"Error updating frame: {ex.Message}"); } finally { // Ensure flag is reset even if an exception occurs applyingPictureBoxImage = false; } } ``` This implementation includes several important concepts: 1. **Thread safety**: Using the `applyingPictureBoxImage` flag prevents concurrent updates. 2. **Memory management**: Properly disposing of the previous image prevents memory leaks. 3. **Exception handling**: Catching exceptions prevents application crashes during rendering. ### Step 4: Implement Cleanup When Stopping Video When stopping video capture or playback, you need to clean up resources properly: ``` private void btnStop_Click(object sender, EventArgs e) { // Your video stop code here // videoCapture1.Stop(); or similar SDK call // Wait until any in-progress frame updates complete while (applyingPictureBoxImage) { Thread.Sleep(50); } // Clean up resources if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); pictureBox1.Image = null; } } ``` This cleanup process: 1. Waits for any in-progress frame updates to complete 2. Properly disposes of the image 3. Sets the PictureBox image to null for visual cleanup ## Advanced Implementation Considerations ### Handling High Frame Rates For high-frame-rate video sources, you might want to implement frame skipping to maintain application responsiveness: ``` private DateTime lastFrameTime = DateTime.MinValue; private TimeSpan frameInterval = TimeSpan.FromMilliseconds(33); // About 30fps private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { // Skip frames if they're coming too quickly if (DateTime.Now - lastFrameTime < frameInterval) { return; } if (applyingPictureBoxImage) { return; } applyingPictureBoxImage = true; lastFrameTime = DateTime.Now; // Frame processing code as before... } ``` ### Cross-Thread Invocation When handling video frames from background threads, you'll need to use cross-thread invocation: ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { if (applyingPictureBoxImage) { return; } applyingPictureBoxImage = true; if (pictureBox1.InvokeRequired) { pictureBox1.BeginInvoke(new Action(() => { var currentImage = pictureBox1.Image; pictureBox1.Image = new Bitmap(e.Frame); currentImage?.Dispose(); applyingPictureBoxImage = false; })); } else { // Direct update code as before... } } ``` ## Performance Optimization Tips ### Reduce Bitmap Creation Overhead Creating a new Bitmap for each frame can be expensive. Consider reusing Bitmap objects: ``` private Bitmap displayBitmap; private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { if (applyingPictureBoxImage) { return; } applyingPictureBoxImage = true; try { // Initialize bitmap if needed if (displayBitmap == null || displayBitmap.Width != e.Frame.Width || displayBitmap.Height != e.Frame.Height) { displayBitmap?.Dispose(); displayBitmap = new Bitmap(e.Frame.Width, e.Frame.Height); } // Copy frame to display bitmap using (Graphics g = Graphics.FromImage(displayBitmap)) { g.DrawImage(e.Frame, 0, 0, e.Frame.Width, e.Frame.Height); } // Update display var oldImage = pictureBox1.Image; pictureBox1.Image = displayBitmap; oldImage?.Dispose(); } finally { applyingPictureBoxImage = false; } } ``` ### Consider Using Double Buffering For smoother display, enable double buffering on your form: ``` // In your form constructor this.DoubleBuffered = true; ``` ## Troubleshooting Common Issues ### Memory Leaks If your application experiences increasing memory usage, check: - Proper disposal of old Bitmap objects - References to frames that might prevent garbage collection - Whether frames are being skipped when necessary ### Flickering Display If video display flickers: - Ensure double buffering is enabled - Check if multiple threads are updating the PictureBox simultaneously - Consider implementing a more sophisticated frame synchronization mechanism ### High CPU Usage If rendering causes high CPU usage: - Implement frame skipping as shown above - Consider reducing the frame rate of the source if possible - Optimize bitmap handling to reduce GC pressure ## Required Dependencies To implement this solution, you'll need: - .NET Framework or .NET Core/5+ - SDK redist files for the specific video SDK you're using ## Conclusion Implementing video rendering on a PictureBox control provides a straightforward way to display video in Windows Forms applications. By following the patterns outlined in this guide, you can achieve smooth video display while avoiding common pitfalls like memory leaks, thread safety issues, and performance bottlenecks. Remember that while PictureBox is suitable for many applications, high-performance video applications might benefit from more specialized rendering approaches using DirectX or OpenGL. --- For more code samples, visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) repository. ---END OF PAGE--- ## How to Exclude DirectShow Filters in .NET Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/exclude-filters/ **Description:** Identify and exclude problematic DirectShow filters from multimedia pipelines in .NET video capture, editing, and playback applications. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, VideoCaptureCore, Windows, Capture, Playback, Streaming, Encoding, Decoding, Mixing, Conversion, C# **API:** VideoCaptureCore # Excluding DirectShow Filters in .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction When developing multimedia applications in .NET, you'll frequently interact with DirectShow — Microsoft's framework for multimedia streaming. DirectShow uses a filter-based architecture where individual components (filters) process media data. However, not all filters are created equal. Some can cause performance issues, compatibility problems, or simply don't meet your application's specific needs. This guide explores how to effectively identify and exclude problematic DirectShow filters from your application's processing pipeline. ## Understanding DirectShow Filters DirectShow filters are COM objects that perform specific operations on media data, such as: - **Source filters**: Read media from files, capture devices, or network streams - **Transform filters**: Process or convert media data (decoders, encoders, effects) - **Renderer filters**: Display video or play audio When DirectShow builds a filter graph, it automatically selects filters based on merit (priority) and compatibility. This automatic selection sometimes includes third-party filters that may: - Reduce performance - Cause stability issues - Introduce compatibility problems - Override preferred processing methods ## Common Issues with DirectShow Filters ### Decoder Conflicts Multiple decoders installed on a system can compete to handle the same media formats. For example: - NVIDIA's video decoder might conflict with Intel's hardware decoder - Third-party codec packs might introduce low-quality decoders - Legacy decoders might be selected over newer, more efficient ones ### Performance Bottlenecks Some filters can significantly impact performance: - Non-optimized video processing filters - Filters without hardware acceleration support - Debugging filters that add logging overhead ### Compatibility Problems Not all filters work well together: - Version mismatches between filters - Filters with different pixel format expectations - Non-standard implementation of interfaces ## When to Exclude DirectShow Filters Consider excluding DirectShow filters when: 1. You notice unexplained performance issues during media playback or processing 2. Your application crashes when handling specific media formats 3. Media quality is unexpectedly poor 4. You want to enforce consistent behavior across different user systems 5. You're implementing a custom processing pipeline with specific requirements ## Implementing Filter Exclusion Our .NET SDKs provide a straightforward API for managing DirectShow filter exclusions. ### Clearing the Blacklist Before setting up your exclusion list, you may want to clear any previously blacklisted filters: ``` // Clear any existing blacklisted filters videoProcessor.DirectShow_Filters_Blacklist_Clear(); ``` This ensures you're starting with a clean slate and your exclusion list contains only the filters you explicitly specify. ### Adding Filters to the Blacklist To exclude specific filters, you'll use the `DirectShow_Filters_Blacklist_Add` method with the exact filter name: ``` // Exclude specific filters by name videoProcessor.DirectShow_Filters_Blacklist_Add("NVIDIA NVENC Encoder"); videoProcessor.DirectShow_Filters_Blacklist_Add("Intel® Hardware H.264 Encoder"); videoProcessor.DirectShow_Filters_Blacklist_Add("Fraunhofer IIS MPEG Audio Layer 3 Decoder"); ``` ### Complete Code Example Here's a more complete example demonstrating filter exclusion in a video processing application: ``` using System; using VisioForge.Core.VideoCapture; using VisioForge.Core.VideoEdit; using VisioForge.Core.MediaPlayer; public class FilterExclusionExample { private VideoCaptureCore captureCore; public void SetupFilterExclusions() { captureCore = new VideoCaptureCore(); // Clear any existing blacklisted filters captureCore.DirectShow_Filters_Blacklist_Clear(); // Add problematic filters to the blacklist captureCore.DirectShow_Filters_Blacklist_Add("SampleGrabber"); captureCore.DirectShow_Filters_Blacklist_Add("Overlay Mixer"); captureCore.DirectShow_Filters_Blacklist_Add("VirtualDub H.264 Decoder"); Console.WriteLine("DirectShow filters successfully excluded."); } // Additional application logic... } ``` ## Best Practices for Filter Exclusion ### Identify Before Excluding Before blacklisting filters, identify which ones are causing issues: 1. Use DirectShow diagnostic tools like GraphEdit or GraphStudio 2. Enable logging in your application to track which filters are being used 3. Test with different filter configurations to isolate problematic components ### Be Specific with Filter Names Use exact, case-sensitive filter names when excluding: ``` // Correct - uses exact filter name videoProcessor.DirectShow_Filters_Blacklist_Add("ffdshow Video Decoder"); // Incorrect - may exclude unintended filters or none at all videoProcessor.DirectShow_Filters_Blacklist_Add("ffdshow"); ``` ### Consider Alternative Approaches Filter exclusion is not always the best solution: - **Merit adjustment**: SDK allows adjusting filter merit instead of complete exclusion - **Explicit graph building**: Build the filter graph manually with preferred filters - **Alternative frameworks**: Consider MediaFoundation for newer applications ## Troubleshooting ### Filter Still Being Used Despite Blacklisting If a filter continues to be used despite being blacklisted: 1. Verify you're using the exact filter name (case-sensitive) 2. Ensure the blacklist is set before building the filter graph 3. Check if the filter is being inserted through an alternative method ### Performance Issues After Blacklisting If performance degrades after blacklisting certain filters: 1. The blacklisted filter might have been providing hardware acceleration 2. The replacement filter might be less efficient 3. The filter graph might be more complex without the excluded filter ### Application Crashes After Filter Exclusion If your application becomes unstable after filter exclusion: 1. Some filters might be required for proper operation 2. The alternative filter path might have compatibility issues 3. The filter graph might be incomplete without certain filters ## Conclusion Excluding problematic DirectShow filters provides a powerful tool for optimizing and stabilizing your multimedia applications. By carefully identifying and blacklisting problematic filters, you can ensure consistent behavior, better performance, and higher quality media processing across different user systems. Remember to test thoroughly after implementing filter exclusions, as the DirectShow filter graph may behave differently when certain components are unavailable. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples and implementation examples. ---END OF PAGE--- ## Process Video Frames in C# .NET — OnVideoFrameBuffer Event **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/image-onvideoframebuffer/ **Description:** Access the raw video frame buffer in C# / .NET via the OnVideoFrameBuffer event. Modify pixels, draw images, apply custom blends — full frame control. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, MediaPlayerCoreX, VideoCaptureCoreX, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Playback, Encoding, C# **API:** VideoFrameXBufferEventArgs, VideoCaptureCoreX, MediaPlayerCoreX, VideoCaptureCore, VideoFrameBufferEventArgs # Drawing Images with OnVideoFrameBuffer in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction The `OnVideoFrameBuffer` event gives direct, pixel-level access to every video frame as it passes through the pipeline. Event handlers receive a raw buffer and can inspect, modify, or overwrite pixels before the frame continues to the next stage (preview, encoder, file output). Drawing an image onto the frame — for a watermark, logo, debug overlay, or computer-vision annotation — is the most common use case and the one this guide walks through. Looking for the high-level overlay feature? If you just need to drop a static or animated image on the video (PNG / JPG / GIF / BMP), use the dedicated [image overlay effect](../../video-effects/image-overlay/) — one line of code via `Video_Effects_Add(new VideoEffectImageLogo(...))`. Use `OnVideoFrameBuffer` (this page) when you need **pixel-level control**: custom blend modes, per-frame logic, CV annotations, or integration with third-party imaging libraries. ### Supported engines The `OnVideoFrameBuffer` event is exposed on both engine families: | Engine | Event args type | Frame pixel format | | --- | --- | --- | | `VideoCaptureCore` (DirectShow, Windows) | `VideoFrameBufferEventArgs` | RGB24 / RGB32 | | `VideoCaptureCoreX` (GStreamer, cross-platform) | `VideoFrameXBufferEventArgs` | BGRA (most common) | | `MediaPlayerCoreX` (GStreamer, cross-platform) | `VideoFrameXBufferEventArgs` | BGRA (most common) | Both engines follow the same pattern — subscribe to the event, read `e.Frame.Data` (an `IntPtr`) along with `Width` / `Height` / `Stride`, optionally modify the buffer in place, and set `e.UpdateData = true` to have the changes propagated downstream. ## Understanding the process When working with video frames you need to: 1. Load your image (logo, watermark, etc.) into memory. 2. Convert the image to a compatible buffer format (RGB24/RGB32 for the legacy engine, BGRA for the X engines). 3. Subscribe to the `OnVideoFrameBuffer` event. 4. Draw the image onto each video frame as it is processed. 5. Set `e.UpdateData = true` so the modified frame replaces the original downstream. ## VideoCaptureCore (DirectShow) example Let's walk through the implementation step by step: ### Step 1: Load Your Image First, load the image file you want to overlay on the video: ``` // Bitmap loading from file private Bitmap logoImage = new Bitmap(@"logo24.jpg"); // You can also use PNG with alpha channel for transparency //private Bitmap logoImage = new Bitmap(@"logo32.png"); ``` ### Step 2: Prepare Memory Buffers Initialize pointers for the image buffer: ``` // Logo RGB24/RGB32 buffer private IntPtr logoImageBuffer = IntPtr.Zero; private int logoImageBufferSize = 0; ``` ### Step 3: Implement the OnVideoFrameBuffer Event Handler The full event handler implementation: ``` private void VideoCapture1_OnVideoFrameBuffer(Object sender, VideoFrameBufferEventArgs e) { // Create logo buffer if not allocated or have zero size if (logoImageBuffer == IntPtr.Zero || logoImageBufferSize == 0) { if (logoImageBuffer == IntPtr.Zero) { if (logoImage.PixelFormat == PixelFormat.Format32bppArgb) { logoImageBufferSize = ImageHelper.GetStrideRGB32(logoImage.Width) * logoImage.Height; logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } else { logoImageBufferSize = ImageHelper.GetStrideRGB24(logoImage.Width) * logoImage.Height; logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } } else { if (logoImage.PixelFormat == PixelFormat.Format32bppArgb) { logoImageBufferSize = ImageHelper.GetStrideRGB32(logoImage.Width) * logoImage.Height; Marshal.FreeCoTaskMem(logoImageBuffer); logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } else { logoImageBufferSize = ImageHelper.GetStrideRGB24(logoImage.Width) * logoImage.Height; Marshal.FreeCoTaskMem(logoImageBuffer); logoImageBuffer = Marshal.AllocCoTaskMem(logoImageBufferSize); } } if (logoImage.PixelFormat == PixelFormat.Format32bppArgb) { BitmapHelper.BitmapToIntPtr(logoImage, logoImageBuffer, logoImage.Width, logoImage.Height, PixelFormat.Format32bppArgb); } else { BitmapHelper.BitmapToIntPtr(logoImage, logoImageBuffer, logoImage.Width, logoImage.Height, PixelFormat.Format24bppRgb); } } // Draw image — the classic VideoFrame struct keeps Width/Height/Stride inside Frame.Info if (logoImage.PixelFormat == PixelFormat.Format32bppArgb) { FastImageProcessing.Draw_RGB32OnRGB24(logoImageBuffer, logoImage.Width, logoImage.Height, e.Frame.Data, e.Frame.Info.Width, e.Frame.Info.Height, 0, 0); } else { FastImageProcessing.Draw_RGB24OnRGB24Old(logoImageBuffer, logoImage.Width, logoImage.Height, e.Frame.Data, e.Frame.Info.Width, e.Frame.Info.Height, 0, 0); } e.UpdateData = true; } ``` ## Detailed Explanation ### Memory Management The code handles both 24-bit and 32-bit image formats. Here's what happens: 1. **Buffer Initialization Check**: The code first checks if the logo buffer needs to be created or recreated. 2. **Format Detection**: It determines whether to use RGB24 or RGB32 format based on the loaded image: 3. RGB24: Standard 24-bit color (8 bits each for R, G, B) 4. RGB32: 32-bit color with alpha channel for transparency (8 bits each for R, G, B, A) 5. **Memory Allocation**: Allocates unmanaged memory using `Marshal.AllocCoTaskMem()` to store the image data. 6. **Image Conversion**: Converts the Bitmap to raw pixel data in the allocated buffer using `BitmapHelper.BitmapToIntPtr()`. ### Drawing Process Once the buffer is prepared, drawing takes place: 1. **Format-Specific Drawing**: The code selects the appropriate drawing method based on the image format: 2. `FastImageProcessing.Draw_RGB32OnRGB24()` for 32-bit images with transparency 3. `FastImageProcessing.Draw_RGB24OnRGB24Old()` for standard 24-bit images (8-arg form) or `Draw_RGB24OnRGB24S()` when source/destination strides are known 4. **Position Parameters**: The `0, 0` parameters specify where to draw the image (top-left corner in this example). 5. **Frame Update**: Setting `e.UpdateData = true` ensures the modified frame data is used for display or further processing. ## VideoCaptureCoreX / MediaPlayerCoreX (X engines) example On the cross-platform X engines the event signature changes to `VideoFrameXBufferEventArgs` and the frame buffer typically arrives in **BGRA** format (4 bytes per pixel). The same pattern applies — subscribe, inspect, modify, flag updates. The example below uses SkiaSharp to wrap the raw buffer and draw a PNG logo on top; SkiaSharp is already a transitive dependency of the X engines, so no extra NuGet package is needed. ``` using SkiaSharp; // Load logo once (PNG with alpha works well for watermarks) private SKBitmap _logo = SKBitmap.Decode(@"logo.png"); // Subscribe after constructing VideoCaptureCoreX / MediaPlayerCoreX _videoCapture.OnVideoFrameBuffer += VideoCapture_OnVideoFrameBuffer; private void VideoCapture_OnVideoFrameBuffer(object sender, VideoFrameXBufferEventArgs e) { if (e.Frame == null || e.Frame.Data == IntPtr.Zero) { return; } // Wrap the raw BGRA buffer in a SkiaSharp canvas (no extra allocation) var info = new SKImageInfo(e.Frame.Width, e.Frame.Height, SKColorType.Bgra8888, SKAlphaType.Premul); using (var pixmap = new SKPixmap(info, e.Frame.Data, e.Frame.Stride)) using (var surface = SKSurface.Create(pixmap)) { var canvas = surface.Canvas; // Draw the logo at bottom-right with 16px padding var x = e.Frame.Width - _logo.Width - 16; var y = e.Frame.Height - _logo.Height - 16; canvas.DrawBitmap(_logo, x, y); canvas.Flush(); } // Propagate the modified frame downstream e.UpdateData = true; } ``` **Why BGRA matters.** The X engines request BGRA by default for frame callbacks because it maps 1:1 to SkiaSharp, System.Drawing, and most GPU-friendly interop paths. If you need a different format (I420, NV12, RGB24), request a format conversion block upstream of your handler rather than converting on every frame. **Alternative imaging stacks.** You can also use `System.Drawing.Bitmap` via `new Bitmap(width, height, stride, PixelFormat.Format32bppArgb, data)` on Windows, or manual byte writes via `Marshal.Copy` / `Span` for maximum control. SkiaSharp is the recommended option on macOS / Linux / iOS / Android. **Engine-level parity.** Everything documented in the [Memory Management](#memory-management), [Error Handling](#error-handling), and [Performance Optimization](#performance-optimization) sections below applies equally to the X engines — the event fires on a processing thread, `UpdateData` toggles whether the buffer is re-used downstream, and heavy work should be offloaded to avoid dropping frames. ## Best Practices for Image Overlay For optimal performance when overlaying images on video frames: 1. **Memory Management**: Always free allocated memory when it's no longer needed to prevent memory leaks. 2. **Buffer Reuse**: Create the buffer once and reuse it for subsequent frames rather than recreating it for each frame. 3. **Image Size Considerations**: Use appropriately sized images; overlaying large images can impact performance. 4. **Format Selection**: 5. Use PNG (RGB32) when you need transparency 6. Use JPG (RGB24) when transparency isn't required (more efficient) 7. **Position Calculation**: For dynamic positioning, calculate coordinates based on frame dimensions. On the classic engine (`VideoFrameBufferEventArgs`) Width/Height live on `e.Frame.Info`; on the X engines (`VideoFrameXBufferEventArgs`) they're flat on `e.Frame`. ``` // Classic engine — Width/Height live on e.Frame.Info int xPos = e.Frame.Info.Width - logoImage.Width - 10; int yPos = e.Frame.Info.Height - logoImage.Height - 10; ``` ## Error Handling When implementing this functionality, consider adding error handling: ``` try { // Your existing implementation } catch (OutOfMemoryException ex) { // Handle memory allocation failures Console.WriteLine("Failed to allocate memory: " + ex.Message); } catch (Exception ex) { // Handle other exceptions Console.WriteLine("Error during frame processing: " + ex.Message); } finally { // Optional cleanup code } ``` ## Performance Optimization For high-performance applications, consider these optimizations: 1. **Buffer Pre-allocation**: Initialize buffers during application startup rather than during video processing. 2. **Conditional Processing**: Only process frames that need the overlay (e.g., skip processing for certain frames). 3. **Parallel Processing**: For complex operations, consider using parallel processing techniques. ## Conclusion The `OnVideoFrameBuffer` event gives direct access to every raw frame on both the legacy `VideoCaptureCore` engine (RGB24/RGB32 via `VideoFrameBufferEventArgs`) and the cross-platform X engines (`VideoCaptureCoreX` / `MediaPlayerCoreX`, BGRA via `VideoFrameXBufferEventArgs`). This is the right tool when you need pixel-level control — custom blend modes, per-frame CV annotations, or integration with third-party imaging libraries. For static or animated image overlays without writing a per-frame handler, the one-line [image overlay effect](../../video-effects/image-overlay/) is usually the better choice. ## Related documentation - [Image overlay effect](../../video-effects/image-overlay/) — high-level, declarative watermark / logo overlay without writing a callback. - [Text overlay via OnVideoFrameBuffer](../text-onvideoframebuffer/) — same technique applied to text instead of images. - [Drawing video in a PictureBox](../draw-video-picturebox/) — WinForms rendering pattern that often pairs with pixel-level frame work. --- Looking for more code samples? Visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for additional examples and resources. ---END OF PAGE--- ## Essential .NET SDK Code Samples for Media Developers **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/ **Description:** Implementation examples for DirectShow filters, audio/video processing, rendering, and media manipulation in .NET SDK applications. **Tags:** .NET, DirectShow, Editing # .NET SDK Code Samples: Practical Implementation Guide In this guide, you'll find a collection of practical code samples and implementation techniques for working with our .NET SDKs. These examples address common development scenarios and demonstrate how to leverage our libraries effectively for media processing applications. ## DirectShow Filter Implementation DirectShow provides a powerful framework for handling multimedia streams. Our SDKs simplify working with these components through well-designed interfaces and helper methods. ### Media Indexing and Format Handling - [ASF and WMV Files Indexing](asf-wmv-files-indexing/) - Learn techniques for properly indexing Windows Media formats to enable seeking and efficient playback position control. This sample demonstrates how to establish accurate navigation points within media files and handle large ASF/WMV content effectively. ### Custom Filter Integration - [Custom DirectShow Filter Interface Usage](custom-filter-interface/) - This tutorial walks through the process of implementing and connecting custom DirectShow filters within your application. You'll learn how to create filter interfaces that integrate seamlessly with the existing DirectShow architecture while adding your own specialized functionality. ### Third-Party Integration - [Integrating Third-Party Video Processing Filters](3rd-party-video-effects/) - Discover how to incorporate external video processing components into your DirectShow filter graph. This example demonstrates proper filter registration, connection methods, and parameter configuration for third-party video effects and transformations. ### Filter Management - [Manual DirectShow Filter Uninstallation](uninstall-directshow-filter/) - This guide explains the registry entries, COM object registration, and system directories involved in completely removing DirectShow filters when standard uninstallation isn't sufficient or available. - [Excluding Specific DirectShow Filters](exclude-filters/) - Learn techniques for selectively bypassing certain DirectShow filters in your filter graph construction. This sample shows how to exclude specific decoders, encoders, or processing filters while maintaining proper media handling. ## Audio and Video Processing Techniques Manipulating audio and video streams is a core requirement for many media applications. These samples demonstrate different approaches to accessing and modifying media data. ### Real-time Video Effects - [Custom Video Effects Using Frame Events](custom-video-effects/) - Learn two powerful approaches for implementing real-time video effects through the OnVideoFrameBitmap and OnVideoFrameBuffer events. This comprehensive sample demonstrates how to access video frames, apply effects, and optimize performance. ### Advanced Overlay Techniques - [Multi-text Overlay Drawing](draw-multitext-onvideoframebuffer/) - This sample demonstrates techniques for rendering multiple text elements on video frames with precise positioning and style control. You'll learn how to handle text formatting, alpha blending, and performance optimization. - [Text Overlay Implementation](text-onvideoframebuffer/) - A focused tutorial on adding dynamic text annotations to video content. This example covers font selection, positioning, and real-time updates of overlay text. - [Image Overlay Integration](image-onvideoframebuffer/) - Learn how to composite images onto video frames with proper scaling, alpha blending, and positioning. This example shows techniques for watermarking, logo placement, and dynamic image overlays. ### Video Transformation - [Manual Zoom Effect Implementation](zoom-onvideoframebuffer/) - This detailed example demonstrates how to implement a custom zoom functionality by directly manipulating video frame buffers. You'll learn techniques for region selection, scaling algorithms, and smooth transitions between zoom levels. ### Bitmap-Based Frame Processing - [OnVideoFrameBitmap Event Usage](onvideoframebitmap-usage/) - This guide explores the bitmap-based approach to video frame processing, which offers simplified access to frame data through GDI+ compatible objects. Learn how this differs from buffer-based processing and when to choose each approach. ## Video Rendering Solutions Displaying video content with flexibility and performance requires understanding various rendering techniques. These samples demonstrate different approaches for visual presentation. ### Windows Forms Integration - [PictureBox Video Rendering](draw-video-picturebox/) - This sample demonstrates how to properly render video content within a standard Windows Forms PictureBox control. You'll learn about frame timing, aspect ratio preservation, and performance considerations. ### Multi-Display Functionality - [Multiple Renderer Zoom Configuration](zoom-video-multiple-renderer/) - Learn techniques for independently controlling zoom levels across multiple video renderers. This sample is essential for applications requiring synchronized but visually distinct video outputs. - [WPF Multi-screen Video Output](multiple-screens-wpf/) - This example shows how to implement multiple independent video display surfaces within a WPF application. You'll learn proper control initialization, resource management, and synchronization techniques. ### Renderer Selection and Customization - [Video Renderer Selection (WinForms)](select-video-renderer-winforms/) - This tutorial explains how to choose and configure the most appropriate video renderer for your Windows Forms application. You'll understand the tradeoffs between EVR, VMR9, and other renderer types. ### User Interaction - [Mouse Wheel Event Integration](mouse-wheel-usage/) - Learn how to handle mouse wheel events for interactive video displays. This sample demonstrates zoom control, timeline scrubbing, and other wheel-based interactions. - [Custom Image Video View](video-view-set-custom-image/) - This guide shows how to replace the standard video frame with a custom image for scenarios like connection loss, buffering states, or application-specific messaging. ## Media Information and Visualization These samples demonstrate how to extract information from media files and create useful visualizations. ### File Analysis - [Media File Information Extraction](read-file-info/) - Learn techniques for reading detailed metadata, stream properties, and format information from media files. This example shows how to access duration, bitrate, codec information, and other essential media properties. ### Audio Visualization - [VU Meter and Waveform Visualization](vu-meters/) - This comprehensive sample demonstrates how to create real-time audio visualizations including volume unit meters and waveform displays. You'll learn about audio level analysis, drawing techniques, and synchronization with playback. ## Performance Optimization Each sample in this collection is designed with performance considerations in mind. You'll find techniques for efficient buffer handling, memory management, and processing optimizations that help you build responsive media applications, even when working with high-resolution content or applying complex effects. ## Cross-Platform Considerations While focusing on .NET implementations, many of the concepts demonstrated in these samples apply to other platforms as well. Where appropriate, we've noted platform-specific considerations and alternative approaches for cross-platform development scenarios. ## Getting Started To use these examples effectively, we recommend reviewing the appropriate SDK documentation for your specific product version. Each sample includes the necessary references and initialization code, but may require configuration based on your development environment and target platform. These code samples serve as building blocks for your media applications, providing proven implementation patterns that you can adapt and extend for your specific requirements. ---END OF PAGE--- ## Mouse Wheel Event Handling in .NET Video Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/mouse-wheel-usage/ **Description:** Handle mouse wheel events in .NET video apps for zooming, scrolling, and timeline navigation with best practices and optimization techniques. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, Editing, C# # Implementing Mouse Wheel Events in .NET SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction to Mouse Wheel Events Mouse wheel events provide an intuitive way for users to interact with video content in multimedia applications. Whether you're developing a video player, editor, or capture application, implementing proper mouse wheel event handling enhances user experience by allowing smooth zooming, scrolling, or timeline navigation. In .NET applications, the `MouseWheel` event is triggered when the user rotates the mouse wheel. This event provides crucial information about the direction and intensity of the wheel movement through the `MouseEventArgs` parameter. ## Why Implement Mouse Wheel Events? Mouse wheel functionality offers several benefits to your video applications: - **Improved User Experience**: Enables intuitive zoom functionality in video viewers - **Enhanced Navigation**: Allows quick timeline scrubbing in video editors - **Volume Control**: Provides convenient volume adjustment in media players - **Efficient UI Interaction**: Reduces reliance on on-screen controls ## Basic Implementation ### Setting Up Event Handlers To implement mouse wheel functionality in your .NET application, you need to set up three key event handlers: 1. `MouseEnter`: Ensures the control gains focus when the mouse enters 2. `MouseLeave`: Releases focus when the mouse leaves 3. `MouseWheel`: Handles the actual wheel rotation event Here's a basic implementation: ``` private void VideoView1_MouseEnter(object sender, EventArgs e) { if (!VideoView1.Focused) { VideoView1.Focus(); } } private void VideoView1_MouseLeave(object sender, EventArgs e) { if (VideoView1.Focused) { VideoView1.Parent.Focus(); } } private void VideoView1_MouseWheel(object sender, MouseEventArgs e) { mmLog.Text += "Delta: " + e.Delta + Environment.NewLine; } ``` The `MouseWheel` event handler receives a `MouseEventArgs` parameter that includes the `Delta` property. This value indicates the direction and distance the wheel has rotated: - **Positive Delta**: The wheel rotated forward (away from the user) - **Negative Delta**: The wheel rotated backward (toward the user) - **Delta Magnitude**: Indicates the intensity of the rotation ## Advanced Implementation Techniques ### Implementing Zoom Functionality One common use of the mouse wheel in video applications is to zoom in and out. Here's how you might implement zoom functionality: ``` private void VideoView1_MouseWheel(object sender, MouseEventArgs e) { // Determine zoom direction based on delta if (e.Delta > 0) { // Zoom in code ZoomIn(0.1); // Increase zoom by 10% } else { // Zoom out code ZoomOut(0.1); // Decrease zoom by 10% } } private double _zoomRatio = 1.0; private void ZoomIn(double factor) { // Zoom is exposed on the renderer (classic engine) or via a ZoomEffect on the X engine, // not on VideoView. The classic engine uses `videoCapture1.Video_Renderer.Zoom_Ratio` // (and Zoom_ShiftX / Zoom_ShiftY for the centre offset). _zoomRatio = Math.Min(_zoomRatio + factor, 3.0); // Max zoom of 300% videoCapture1.Video_Renderer.Zoom_Ratio = _zoomRatio; videoCapture1.Video_Renderer_Update(); } private void ZoomOut(double factor) { _zoomRatio = Math.Max(_zoomRatio - factor, 0.5); // Min zoom of 50% videoCapture1.Video_Renderer.Zoom_Ratio = _zoomRatio; videoCapture1.Video_Renderer_Update(); } ``` ### Timeline Navigation For video editing applications, the mouse wheel can be used to navigate through the timeline: ``` private void TimelineControl_MouseWheel(object sender, MouseEventArgs e) { // Calculate how much to move based on delta and timeline length double moveFactor = e.Delta / 120.0; // Normalize to increments of 1.0 double moveAmount = moveFactor * 5.0; // 5 seconds per wheel "click" // Move position double newPosition = TimelineControl.CurrentPosition + moveAmount; // Ensure we stay within bounds newPosition = Math.Max(0, Math.Min(newPosition, TimelineControl.Duration)); // Apply the new position TimelineControl.CurrentPosition = newPosition; } ``` ### Volume Control Another common use case is controlling volume in media player applications: ``` private void VideoView1_MouseWheel(object sender, MouseEventArgs e) { // Volume is engine-level (not on VideoView). The classic engine exposes // Audio_OutputDevice_Volume in 0–100 percent range; the X engine exposes // Audio_OutputDevice_Volume in 0.0–1.0 range. Sample below targets the // classic VideoCaptureCore / MediaPlayerCore — adjust the percent math // to a 0–1 ratio if you are on the X engine. int volumeChangePercent = (int)Math.Round(e.Delta / 120.0 * 5.0); // 5 percentage points per wheel "click" int newVolume = videoCapture1.Audio_OutputDevice_Volume + volumeChangePercent; newVolume = Math.Max(0, Math.Min(newVolume, 100)); videoCapture1.Audio_OutputDevice_Volume = newVolume; // Optional: Display volume indicator (0–1 ratio for the indicator UI) ShowVolumeIndicator(newVolume / 100f); } ``` ## Handling Focus Management Proper focus management is crucial for mouse wheel events to work correctly. The example code shows a basic implementation, but in more complex applications, you may need a more sophisticated approach: ``` private void VideoView1_MouseEnter(object sender, EventArgs e) { // Store the previously focused control _previouslyFocused = Form.ActiveControl; // Focus our control VideoView1.Focus(); // Optional: Visual indication that the control has focus VideoView1.BorderStyle = BorderStyle.FixedSingle; } private void VideoView1_MouseLeave(object sender, EventArgs e) { // Return focus to previous control if appropriate if (_previouslyFocused != null && _previouslyFocused.CanFocus) { _previouslyFocused.Focus(); } else { // If no previous control, focus the parent VideoView1.Parent.Focus(); } // Reset visual indication VideoView1.BorderStyle = BorderStyle.None; } ``` ## Performance Considerations When implementing mouse wheel events, consider these performance tips: 1. **Debounce Wheel Events**: Mouse wheels can generate many events in quick succession 2. **Optimize Calculations**: Avoid complex calculations in the wheel event handler 3. **Use Animation**: For smooth zooming, consider using animation rather than abrupt changes Here's an example of debouncing wheel events: ``` private DateTime _lastWheelEvent = DateTime.MinValue; private const int DebounceMs = 50; private void VideoView1_MouseWheel(object sender, MouseEventArgs e) { // Check if enough time has passed since the last event TimeSpan elapsed = DateTime.Now - _lastWheelEvent; if (elapsed.TotalMilliseconds < DebounceMs) { return; // Ignore event if it's too soon } // Process the wheel event ProcessWheelEvent(e.Delta); // Update the last event time _lastWheelEvent = DateTime.Now; } ``` ## Cross-Platform Considerations If you're developing cross-platform .NET applications, be aware that mouse wheel behavior can vary: - **Windows**: Typically 120 units per "click" - **macOS**: May have different sensitivity settings - **Linux**: Can vary based on distribution and configuration Your code should account for these differences: ``` private void VideoView1_MouseWheel(object sender, MouseEventArgs e) { // Normalize delta based on platform double normalizedDelta; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { normalizedDelta = e.Delta / 120.0; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { normalizedDelta = e.Delta / 100.0; } else { normalizedDelta = e.Delta / 120.0; // Default for Linux and others } // Use normalized delta for calculations ApplyZoom(normalizedDelta); } ``` ## Troubleshooting Common Issues ### Mouse Wheel Events Not Firing If your mouse wheel events aren't firing, check: 1. **Focus Issues**: Ensure the control has focus when the mouse is over it 2. **Event Registration**: Verify the event handler is properly registered 3. **Control Properties**: Some controls need specific properties set to receive wheel events ### Inconsistent Behavior If wheel events behave inconsistently: 1. **Delta Normalization**: Ensure you're properly normalizing delta values 2. **User Settings**: Account for user-specific mouse settings 3. **Hardware Variations**: Different mouse hardware can produce different delta values ## Conclusion Mouse wheel event handling is an essential aspect of creating intuitive and user-friendly video applications. By implementing the techniques outlined in this guide, you can enhance your .NET video applications with smooth, intuitive controls that improve the overall user experience. The implementation can vary depending on your specific requirements, but the core principles remain the same: handle focus properly, normalize wheel delta values, and apply appropriate changes based on user input. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Multiple Video Screens in WPF — C# .NET Multi-Display Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/multiple-screens-wpf/ **Description:** Create multi-display video applications in WPF with Image controls, event handling, memory management, and performance optimization techniques. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, WPF, C# **API:** VideoCaptureCore, VideoCaptureSource, VideoFrameBufferEventArgs, MultiscreenVideoView, VideoView # Implementing Multiple Video Output Screens in WPF Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) When developing WPF applications that require handling multiple video feeds simultaneously, developers often face challenges with performance, synchronization, and resource management. This guide provides a comprehensive approach to implementing multiple video output screens in your WPF applications using C# and the Image control. ## Getting Started with Multiple Video Screens Check the installation guide for WPF [here](../../../install/). To begin implementing multiple video outputs in your WPF application, you'll need to: 1. Add the appropriate Video View control to your application 2. Set up event handling for video frame processing 3. Configure your rendering pipeline for optimal performance ### Two supported patterns To show the same video feed on multiple views in WPF, pick one of these two real patterns: 1. **`MultiscreenVideoView` + `OnVideoFrameBuffer`** — one SDK engine pushes each frame into as many `MultiscreenVideoView` controls as you like. Use this when a single capture/playback engine drives several on-screen copies. 2. **One engine per `VideoView`** — each display gets its own `VideoCaptureCore` / `MediaPlayerCore` / `VideoEditCore` instance bound to its own regular `VideoView`. Use this when the displays show **different** sources (e.g. a four-camera security grid). See the [Four-Camera Security System](#practical-example-four-camera-security-system) example below. Regular `VisioForge.Core.UI.WPF.VideoView` does not expose a `RenderFrame` method — it is driven automatically by the engine it's bound to via `CreateAsync(IVideoView)`. Frame fan-out requires `MultiscreenVideoView`. ### Setting Up Your WPF Project for Frame Fan-out Drop one or more `VisioForge.Core.UI.WPF.MultiscreenVideoView` controls on your WPF window. Give them descriptive names (e.g. `multiView1`, `multiView2`). These are the controls that accept pushed frames. ### Handling Video Frames Subscribe to the SDK engine's `OnVideoFrameBuffer` event. The event args carry a `VideoFrameBufferEventArgs` that each `MultiscreenVideoView` can render. ## Implementing the Video Frame Handler ``` private void VideoCapture1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { multiView1.RenderFrame(e); } ``` `MultiscreenVideoView.RenderFrame(VideoFrameBufferEventArgs)` copies the frame into its own internal surface, so the engine's buffer can be released when the handler returns. ## Advanced Implementation Techniques ### Creating Dynamic MultiscreenVideoViews For applications requiring a variable number of video outputs, dynamically create `MultiscreenVideoView` controls: ``` private List multiViews = new List(); private void CreateMultiView(Grid container, int row, int column) { var view = new VisioForge.Core.UI.WPF.MultiscreenVideoView(); Grid.SetRow(view, row); Grid.SetColumn(view, column); container.Children.Add(view); multiViews.Add(view); } // Usage example: // CreateMultiView(mainGrid, 0, 0); // CreateMultiView(mainGrid, 0, 1); ``` ### Distributing Video Frames to Multiple Views Fan out incoming frames to every registered `MultiscreenVideoView`: ``` private void VideoCapture1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { // Render to all MultiscreenVideoView instances foreach (var view in multiViews) { view.RenderFrame(e); } } ``` ## Performance Optimization Strategies ### Reducing Render Load For multiple video views, consider these optimization techniques: 1. **Frame skipping**: Not every view needs to update at full frame rate 2. **Hide off-screen views**: WPF culls rendering for collapsed controls — use `Visibility.Collapsed` on views that aren't visible ``` private int frameCounter; private void VideoCapture1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { // Primary view gets every frame primaryMultiView.RenderFrame(e); // Secondary views get every second frame if (frameCounter % 2 == 0) { foreach (var view in secondaryMultiViews) { view.RenderFrame(e); } } frameCounter++; } ``` ## Practical Example: Four-Camera Security System Here's a more complete example of implementing a four-camera security system using the Video Capture SDK's `VideoCaptureCore` engine. Each camera gets its own engine instance bound to a dedicated `VideoView`. ``` using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using VisioForge.Core.Types; using VisioForge.Core.Types.VideoCapture; using VisioForge.Core.UI.WPF; using VisioForge.Core.VideoCapture; public partial class SecurityMonitorWindow : Window { private readonly List _cameraViews = new List(); private readonly List _cameras = new List(); public SecurityMonitorWindow() { InitializeComponent(); } public async Task InitializeCamerasAsync(IEnumerable deviceNames) { // Enumerate the first four capture devices if names aren't provided. var names = deviceNames?.Take(4).ToList(); // Build a 2x2 grid of VideoView controls paired with VideoCaptureCore engines. int i = 0; for (int row = 0; row < 2; row++) { for (int col = 0; col < 2; col++, i++) { var view = new VideoView(); Grid.SetRow(view, row); Grid.SetColumn(view, col); mainGrid.Children.Add(view); _cameraViews.Add(view); // The classic engine uses a constructor; CreateAsync is the X-engine pattern. // For VideoCaptureCoreX use `await VideoCaptureCoreX.CreateAsync(view)` instead. var camera = new VideoCaptureCore(view); _cameras.Add(camera); if (names != null && i < names.Count) { camera.Video_CaptureDevice = new VideoCaptureSource(names[i]); camera.Video_CaptureDevice.Format_UseBest = true; camera.Mode = VideoCaptureMode.VideoPreview; camera.Audio_PlayAudio = false; camera.Audio_RecordAudio = false; } } } } public async Task StartCamerasAsync() { foreach (var camera in _cameras) { await camera.StartAsync(); } } public async Task StopCamerasAsync() { foreach (var camera in _cameras) { await camera.StopAsync(); } foreach (var camera in _cameras) { camera.Dispose(); } } } ``` Enumerate available devices with `camera.Video_CaptureDevices()` (or its async variant) to populate the `deviceNames` argument at runtime — see [the device enumeration guide](../../../videocapture/video-sources/video-capture-devices/enumerate-and-select/). ## Troubleshooting Common Issues ### Handling Frame Synchronization If you experience frame timing issues across multiple displays: ``` private readonly object syncLock = new object(); private void VideoCapture1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { lock (syncLock) { foreach (var view in multiViews) { view.RenderFrame(e); } } } ``` --- For more code samples and advanced implementation techniques, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## OnVideoFrameBitmap — Real-Time Video Frame Access in .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/onvideoframebitmap-usage/ **Description:** Access and modify video frames in real-time with OnVideoFrameBitmap events for advanced video manipulation in C# applications. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, C# **API:** VideoFrameBitmapEventArgs # OnVideoFrameBitmap Real-Time Frame Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) The `OnVideoFrameBitmap` event is a powerful feature in .NET video processing libraries that allows developers to access and modify video frames in real-time. This guide explores the practical applications, implementation techniques, and performance considerations when working with bitmap frame manipulation in C# applications. ## Understanding OnVideoFrameBitmap Events The `OnVideoFrameBitmap` event provides a direct interface to access video frames as they're processed by the SDK. This capability is essential for applications that require: - Real-time video analysis - Frame-by-frame manipulation - Dynamic overlay implementation - Custom video effects - Computer vision integration When the event fires, it delivers a bitmap representation of the current video frame, allowing for pixel-level access and manipulation before the frame continues through the processing pipeline. ## Basic Implementation `OnVideoFrameBitmap` exists on the Windows-only engines: `VideoCaptureCore`, `MediaPlayerCore`, and `VideoEditCore`. In the snippets below, `VideoCapture1` is a `VideoCaptureCore` instance — swap in `MediaPlayer1` or `VideoEdit1` if you are using a different engine. Subscribe before starting the pipeline so the first frame is not missed: ``` // Event type: EventHandler. Fires on a worker thread. VideoCapture1.OnVideoFrameBitmap += VideoCapture1_OnVideoFrameBitmap; // Implement the event handler private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { // e.Frame — the current frame as a System.Drawing.Bitmap (owned by the SDK; do not dispose). // Set e.UpdateData = true if you mutate the bitmap in place. } ``` ## Manipulating Video Frames ### Simple Bitmap Overlay Example The following example demonstrates how to overlay an image on each video frame: ``` Bitmap bmp = new Bitmap(@"c:\samples\pics\1.jpg"); using (Graphics g = Graphics.FromImage(e.Frame)) { g.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height); e.UpdateData = true; } bmp.Dispose(); ``` In this code: 1. We create a `Bitmap` object from an image file 2. We use the `Graphics` class to draw onto the frame bitmap 3. We set `e.UpdateData = true` to inform the SDK that we've modified the frame 4. We dispose of our resources properly to prevent memory leaks > **Important:** Always set `e.UpdateData = true` when you modify the frame bitmap. This signals the SDK to use your modified frame instead of the original. ### Adding Text Overlays Text overlays are commonly used for timestamps, captions, or informational displays: ``` using (Graphics g = Graphics.FromImage(e.Frame)) { // Create a semi-transparent background for text using (SolidBrush brush = new SolidBrush(Color.FromArgb(150, 0, 0, 0))) { g.FillRectangle(brush, 10, 10, 200, 30); } // Add text overlay using (Font font = new Font("Arial", 12)) using (SolidBrush textBrush = new SolidBrush(Color.White)) { g.DrawString(DateTime.Now.ToString(), font, textBrush, new PointF(15, 15)); } e.UpdateData = true; } ``` ## Performance Considerations When working with `OnVideoFrameBitmap`, it's crucial to optimize your code for performance. Each frame processing operation must complete quickly to maintain smooth video playback. ### Resource Management Proper resource management is essential: ``` // Poor performance approach private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { Bitmap overlay = new Bitmap(@"c:\logo.png"); Graphics g = Graphics.FromImage(e.Frame); g.DrawImage(overlay, 0, 0); e.UpdateData = true; // Memory leak! Graphics and Bitmap not disposed } // Optimized approach private Bitmap _cachedOverlay; private void InitializeResources() { _cachedOverlay = new Bitmap(@"c:\logo.png"); } private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { using (Graphics g = Graphics.FromImage(e.Frame)) { g.DrawImage(_cachedOverlay, 0, 0); e.UpdateData = true; } } private void CleanupResources() { _cachedOverlay?.Dispose(); } ``` ### Optimizing Processing Time To maintain smooth video playback: 1. **Pre-compute where possible**: Prepare resources before processing begins 2. **Cache frequently used objects**: Avoid creating new objects for each frame 3. **Process only when necessary**: Add conditional logic to skip frames or perform less intensive operations when needed 4. **Use efficient drawing operations**: Choose appropriate GDI+ methods based on your needs ``` private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { // Only process every second frame if (_frameCounter % 2 == 0) { using (Graphics g = Graphics.FromImage(e.Frame)) { // Your frame processing code e.UpdateData = true; } } _frameCounter++; } ``` ## Advanced Frame Manipulation Techniques ### Applying Filters and Effects You can implement custom image processing filters: ``` private void ApplyGrayscaleFilter(Bitmap bitmap) { Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); BitmapData bmpData = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = Math.Abs(bmpData.Stride) * bitmap.Height; byte[] rgbValues = new byte[bytes]; Marshal.Copy(ptr, rgbValues, 0, bytes); // Process pixel data for (int i = 0; i < rgbValues.Length; i += 4) { byte gray = (byte)(0.299 * rgbValues[i + 2] + 0.587 * rgbValues[i + 1] + 0.114 * rgbValues[i]); rgbValues[i] = gray; // Blue rgbValues[i + 1] = gray; // Green rgbValues[i + 2] = gray; // Red } Marshal.Copy(rgbValues, 0, ptr, bytes); bitmap.UnlockBits(bmpData); } ``` ## Integration with Computer Vision Libraries The `OnVideoFrameBitmap` event can be combined with popular computer vision libraries: ``` // Example using a hypothetical computer vision library private void VideoCapture1_OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { // Convert bitmap to format needed by CV library byte[] imageData = ConvertBitmapToByteArray(e.Frame); // Process with CV library var results = _computerVisionProcessor.DetectFaces(imageData, e.Frame.Width, e.Frame.Height); // Draw results back onto frame using (Graphics g = Graphics.FromImage(e.Frame)) { foreach (var face in results) { g.DrawRectangle(new Pen(Color.Yellow, 2), face.X, face.Y, face.Width, face.Height); } e.UpdateData = true; } } ``` ## Troubleshooting Common Issues ### Memory Leaks If you experience memory growth during prolonged video processing: 1. Ensure all `Graphics` objects are disposed 2. Properly dispose of any temporary `Bitmap` objects 3. Avoid capturing large objects in lambda expressions ### Performance Degradation If frame processing becomes sluggish: 1. Profile your event handler to identify bottlenecks 2. Consider reducing processing frequency 3. Optimize GDI+ operations or consider DirectX for performance-critical applications ## SDK Integration The `OnVideoFrameBitmap` event is available in the following SDKs: ## Required Dependencies To use the functionality described in this guide, you'll need: - SDK redistribution package - System.Drawing (included in .NET Framework) - Windows GDI+ support --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples and projects demonstrating these techniques in action. ---END OF PAGE--- ## Read Video File Info in C# .NET — Duration, Codec, Streams **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/read-file-info/ **Description:** MediaInfoReader API returns video/audio stream details, subtitle tracks, FOURCC codes, and ID3 tags. Cross-platform file analysis with VisioForge SDK. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, Metadata, MP4, C# **API:** MediaInfoReader # Reading Media File Information in C [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction Accessing detailed information embedded within media files is essential for developing sophisticated applications like media players, video editors, content management systems, and file analysis tools. Understanding properties such as codecs, resolution, frame rate, bitrate, duration, and embedded tags allows developers to build more intelligent and user-friendly software. This guide demonstrates how to read comprehensive information from video and audio files using C# and the `MediaInfoReader` class. The techniques shown are applicable across various .NET projects and provide a foundation for handling media files programmatically. ## Why Extract Media File Information? Media file information serves multiple purposes in application development: - **User Experience**: Display technical details to users in media players - **Compatibility Checks**: Verify if files meet required specifications - **Automated Processing**: Configure encoding parameters based on source properties - **Content Organization**: Catalog media libraries with accurate metadata - **Quality Assessment**: Evaluate media files for potential issues ## Implementation Guide Let's explore the process of extracting media file information in a step-by-step approach. The examples assume a WinForms application with a `TextBox` control named `mmInfo` for displaying the extracted information. ### Step 1: Initialize the Media Information Reader The first step involves creating an instance of the `MediaInfoReader` class: ``` // Import the necessary namespace using VisioForge.Core.MediaInfo; // Namespace for MediaInfoReader using VisioForge.Core.Helpers; // Namespace for TagLibHelper (optional) // Create an instance of MediaInfoReader var infoReader = new MediaInfoReader(); ``` This initialization prepares the reader to process media files. ### Step 2: Verify File Playability (Optional) Before diving into detailed analysis, it's often useful to check if the file is supported: ``` // Define variables to hold potential error information FilePlaybackError errorCode; string errorText; // Specify the path to the media file string filename = @"C:\path\to\your\mediafile.mp4"; // Replace with your actual file path // Check if the file is playable if (MediaInfoReader.IsFilePlayable(filename, out errorCode, out errorText)) { // Display success message mmInfo.Text += "Status: This file appears to be playable." + Environment.NewLine; } else { // Display error message including the error code and description mmInfo.Text += $"Status: This file might not be playable. Error: {errorCode} - {errorText}" + Environment.NewLine; } mmInfo.Text += "------------------------------------" + Environment.NewLine; ``` This verification provides early feedback on file integrity and compatibility. ### Step 3: Extract Detailed Stream Information Now we can extract the rich metadata from the file: ``` try { // Assign the filename to the reader infoReader.Filename = filename; // Read the file information (true for full analysis) infoReader.ReadFileInfo(true); // Process Video Streams mmInfo.Text += $"Found {infoReader.VideoStreams.Count} video stream(s)." + Environment.NewLine; for (int i = 0; i < infoReader.VideoStreams.Count; i++) { var stream = infoReader.VideoStreams[i]; mmInfo.Text += Environment.NewLine; mmInfo.Text += $"--- Video Stream #{i + 1} ---" + Environment.NewLine; mmInfo.Text += $" Codec: {stream.Codec}" + Environment.NewLine; mmInfo.Text += $" Duration: {stream.Duration}" + Environment.NewLine; mmInfo.Text += $" Dimensions: {stream.Width}x{stream.Height}" + Environment.NewLine; mmInfo.Text += $" FOURCC: {stream.FourCC}" + Environment.NewLine; if (stream.AspectRatio != null && stream.AspectRatio.Item1 > 0 && stream.AspectRatio.Item2 > 0) { mmInfo.Text += $" Aspect Ratio: {stream.AspectRatio.Item1}:{stream.AspectRatio.Item2}" + Environment.NewLine; } // VideoFrameRate is a struct (numerator/denominator) and not IFormattable — format via .Value (double). mmInfo.Text += $" Frame Rate: {stream.FrameRate.Value:F2} fps" + Environment.NewLine; mmInfo.Text += $" Bitrate: {stream.Bitrate / 1000.0:F0} kbps" + Environment.NewLine; mmInfo.Text += $" Frames Count: {stream.FramesCount}" + Environment.NewLine; } // Process Audio Streams mmInfo.Text += Environment.NewLine; mmInfo.Text += $"Found {infoReader.AudioStreams.Count} audio stream(s)." + Environment.NewLine; for (int i = 0; i < infoReader.AudioStreams.Count; i++) { var stream = infoReader.AudioStreams[i]; mmInfo.Text += Environment.NewLine; mmInfo.Text += $"--- Audio Stream #{i + 1} ---" + Environment.NewLine; mmInfo.Text += $" Codec: {stream.Codec}" + Environment.NewLine; mmInfo.Text += $" Codec Info: {stream.CodecInfo}" + Environment.NewLine; mmInfo.Text += $" Duration: {stream.Duration}" + Environment.NewLine; mmInfo.Text += $" Bitrate: {stream.Bitrate / 1000.0:F0} kbps" + Environment.NewLine; mmInfo.Text += $" Channels: {stream.Channels}" + Environment.NewLine; mmInfo.Text += $" Sample Rate: {stream.SampleRate} Hz" + Environment.NewLine; mmInfo.Text += $" Bits Per Sample (BPS): {stream.BPS}" + Environment.NewLine; mmInfo.Text += $" Language: {stream.Language}" + Environment.NewLine; } // Process Subtitle Streams mmInfo.Text += Environment.NewLine; mmInfo.Text += $"Found {infoReader.Subtitles.Count} subtitle stream(s)." + Environment.NewLine; for (int i = 0; i < infoReader.Subtitles.Count; i++) { var stream = infoReader.Subtitles[i]; mmInfo.Text += Environment.NewLine; mmInfo.Text += $"--- Subtitle Stream #{i + 1} ---" + Environment.NewLine; mmInfo.Text += $" Codec/Format: {stream.Codec}" + Environment.NewLine; mmInfo.Text += $" Name: {stream.Name}" + Environment.NewLine; mmInfo.Text += $" Language: {stream.Language}" + Environment.NewLine; } } catch (Exception ex) { // Handle potential errors during file reading mmInfo.Text += $"{Environment.NewLine}Error reading file info: {ex.Message}{Environment.NewLine}"; } finally { // Important: Dispose the reader to release file handles and resources infoReader.Dispose(); } ``` The code iterates through each collection (`VideoStreams`, `AudioStreams`, and `Subtitles`), extracting and displaying relevant information for every stream found. ### Step 4: Extract Metadata Tags Beyond technical stream information, media files often contain metadata tags: ``` // Read Metadata Tags mmInfo.Text += Environment.NewLine + "--- Metadata Tags ---" + Environment.NewLine; try { // Use TagLibHelper to read tags from the file var tags = TagLibHelper.ReadTags(filename); // Check if tags were successfully read if (tags != null) { mmInfo.Text += $"Title: {tags.Title}" + Environment.NewLine; mmInfo.Text += $"Artist(s): {string.Join(", ", tags.Performers ?? new string[0])}" + Environment.NewLine; mmInfo.Text += $"Album: {tags.Album}" + Environment.NewLine; mmInfo.Text += $"Year: {tags.Year}" + Environment.NewLine; mmInfo.Text += $"Genre: {string.Join(", ", tags.Genres ?? new string[0])}" + Environment.NewLine; mmInfo.Text += $"Comment: {tags.Comment}" + Environment.NewLine; } else { mmInfo.Text += "No standard metadata tags found or readable." + Environment.NewLine; } } catch (Exception ex) { // Handle errors during tag reading mmInfo.Text += $"Error reading tags: {ex.Message}" + Environment.NewLine; } ``` ## Best Practices for Media File Analysis When implementing media file analysis in your applications, consider these best practices: ### Error Handling Always wrap file operations in appropriate try-catch blocks. Media files can be corrupted, inaccessible, or in unexpected formats, which might cause exceptions. ``` try { // Media file operations } catch (Exception ex) { // Log error and provide user feedback } ``` ### Resource Management Properly dispose of objects that access file resources to prevent file locking issues: ``` using (var infoReader = new MediaInfoReader()) { // Use the reader } // Or manually in a finally block try { // Operations } finally { infoReader.Dispose(); } ``` ### Performance Considerations For large media libraries, consider: 1. Implementing caching mechanisms for repeated analysis 2. Using background threads for processing to keep UI responsive 3. Limiting the depth of analysis for initial quick scans ## Required Components For successful implementation, ensure your project includes the necessary dependencies as specified in the SDK documentation. ## Conclusion Extracting information from media files is a powerful capability for developers building applications that work with audio and video content. With the techniques outlined in this guide, you can access detailed technical properties and metadata tags to enhance your application's functionality. The `MediaInfoReader` class provides a convenient and efficient way to extract the necessary metadata, allowing you to build more sophisticated media handling features in your C# applications. For more advanced scenarios, explore the full capabilities of the SDK and consult the detailed documentation. You can find additional code samples and examples on GitHub to further expand your media file processing capabilities. ---END OF PAGE--- ## Video Renderer in C# .NET — EVR, Direct2D, WPF, MadVR **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/select-video-renderer-winforms/ **Description:** Configure video rendering in C# / .NET across WinForms, WPF, and WinUI 3. EVR, Direct2D, madVR, native HWND, callback modes — setup and hardware acceleration. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, MediaPlayerCoreX, VideoCaptureCoreX, VideoEditCore, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Playback, Streaming, Encoding, Editing, Conversion, C# **API:** VideoRenderer, VideoRendererMode, VideoView, VideoRendererStretchMode, VideoCaptureCoreX # Video Renderer Options in C# .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction The classic engines (`VideoCaptureCore`, `VideoEditCore`, `MediaPlayerCore`) expose **10 video renderer modes** through the `VideoRendererMode` enum. Choosing the right one controls how frames reach the screen: raw DirectShow filters, Direct2D GPU surfaces, native HWND embedded in WPF, frame callbacks for custom rendering, WinUI 3 controls, or the third-party madVR renderer. This guide walks through each mode with minimal enable code, platform availability, and a decision guide at the top so you can skip straight to the mode your app needs. Classic engines only This page covers the DirectShow-based classic engines. The cross-platform `VideoCaptureCoreX` / `MediaPlayerCoreX` engines use a `VideoView` control with GStreamer sinks and do not expose a `VideoRendererMode` enum — rendering there is handled automatically by the UI control binding. ## Quick pick — which renderer for which app? | Mode | UI framework | Best for | | --- | --- | --- | | `VideoRenderer` (legacy GDI) | WinForms | Maximum compatibility on very old hardware | | `VMR9` | WinForms | Windows XP / Vista, software + light HW accel | | `EVR` | WinForms | Default pick on modern Windows (Vista+) | | `Direct2D` | WinForms, WPF | GPU-accelerated 2D, 4K+ content, modern apps | | `Direct2DManaged` | WPF | Managed Direct2D with WPF-aware pause on minimize | | `WPF_NativeHWND` | WPF | Native HWND embedded in WPF for higher perf than pure WPF | | `WPF_WinUI_Callback` (`FrameCallback`) | WPF, WinUI, custom | Per-frame callbacks for CV, AI, custom rendering | | `WinUI` | WinUI 3 | Native WinUI 3 apps (Windows 10/11) | | `MadVR` | WinForms | Reference-grade scaling + color, needs external madVR install | | `None` | any | Headless / audio-only / file conversion without preview | ## Understanding Available Video Renderer Options The detailed sections below describe each mode, starting with the three classic DirectShow renderers. ### Legacy Video Renderer (GDI-based) The Video Renderer is the oldest option in the DirectShow ecosystem. It relies on GDI (Graphics Device Interface) for drawing operations. **Key characteristics:** - Software-based rendering without hardware acceleration - Compatible with older systems and configurations - Lower performance ceiling compared to modern alternatives - Simple implementation with minimal configuration options **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.VideoRenderer; ``` **When to use:** - Compatibility is the primary concern - Application targets older hardware or operating systems - Minimal video processing requirements - Troubleshooting issues with newer renderers ### Video Mixing Renderer 9 (VMR9) VMR9 represents a significant improvement over the legacy renderer, introducing support for hardware acceleration and advanced features. **Key characteristics:** - Hardware-accelerated rendering through DirectX 9 - Support for multiple video streams mixing - Advanced deinterlacing options - Alpha blending and compositing capabilities - Custom video effects processing **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.VMR9; ``` **When to use:** - Modern applications requiring good performance - Video editing or composition features are needed - Multiple video stream scenarios - Applications that need to balance performance and compatibility ### Enhanced Video Renderer (EVR) EVR is the most advanced option, available in Windows Vista and later operating systems. It leverages the Media Foundation framework rather than pure DirectShow. **Key characteristics:** - Latest hardware acceleration technologies - Superior video quality and performance - Enhanced color space processing - Better multi-monitor support - More efficient CPU usage - Improved synchronization mechanisms **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.EVR; ``` **When to use:** - Modern applications targeting Windows Vista or later - Maximum performance and quality are required - Applications handling HD or 4K content - When advanced synchronization is important - Multiple display environments ### Direct2D Renderer Direct2D provides high-performance 2D rendering with GPU acceleration. It is available on both WinForms and WPF hosts and is the recommended modern choice when you need hardware-accelerated rendering with simple rotation, flip, and stretch controls. **Key characteristics:** - Hardware-accelerated via Direct2D / Direct3D 11 - Works on both WinForms and WPF - Supports rotation (0 / 90 / 180 / 270), horizontal and vertical flip - Clean stretch mode integration (`Stretch` / `Letterbox`) - Low CPU overhead, scales well to 4K / 8K content **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.Direct2D; VideoCapture1.Video_Renderer.RotationAngle = 0; VideoCapture1.Video_Renderer.StretchMode = VideoRendererStretchMode.Letterbox; VideoCapture1.Video_Renderer.Flip_Horizontal = false; VideoCapture1.Video_Renderer.Flip_Vertical = false; await VideoCapture1.Video_Renderer_UpdateAsync(); ``` **When to use:** - Modern WinForms or WPF apps that want GPU-accelerated rendering - 4K / 8K sources where CPU-based paths would bottleneck - Apps that need run-time rotation or flip controls ### Direct2DManaged Renderer (WPF) A WPF-specific managed variant of Direct2D. Integrates more cleanly with the WPF object model and automatically pauses rendering when the window is minimized — useful for long-running playback apps where you don't want GPU work on hidden windows. **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.Direct2DManaged; VideoCapture1.Video_Renderer.StretchMode = VideoRendererStretchMode.Letterbox; await VideoCapture1.Video_Renderer_UpdateAsync(); ``` Rotation, flip, and stretch options are shared with the regular `Direct2D` mode. Pause-on-minimize is handled automatically by the WPF `VideoView` control. **When to use:** - WPF apps where you want Direct2D performance with WPF-friendly lifecycle - Multi-window dashboards where inactive windows should not consume GPU cycles ### WPF Native HWND Renderer Hosts a native Win32 HWND inside the WPF `VideoView` control. Gives you raw DirectShow renderer performance in a WPF layout at the cost of standard WPF-render-chain quirks (airspace issues with overlapping controls). **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.WPF_NativeHWND; await VideoCapture1.Video_Renderer_UpdateAsync(); ``` **When to use:** - WPF apps that need maximum DirectShow rendering performance - Apps embedding legacy filters that expect a HWND target - You don't need to overlay WPF controls on top of the video surface ### FrameCallback Renderer (WPF\_WinUI\_Callback) A callback-based rendering mode. Instead of drawing frames directly, the engine delivers each frame to your code via events, letting you render with any library (SkiaSharp, `System.Drawing`, custom OpenGL/DirectX, WriteableBitmap) or feed a non-visual pipeline (computer vision, AI inference, streaming to a remote endpoint). `FrameCallback` is an alias for `WPF_WinUI_Callback` — the same mode with a more self-descriptive name. **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.FrameCallback; await VideoCapture1.Video_Renderer_UpdateAsync(); // Subscribe to frame events VideoCapture1.OnVideoFrameBitmap += (sender, e) => { // e.Frame is a System.Drawing.Bitmap — render to a PictureBox, WriteableBitmap, etc. }; VideoCapture1.OnVideoFrameBuffer += (sender, e) => { // e.Frame.Data is IntPtr — wrap with SkiaSharp / Marshal.Copy for pixel-level work }; ``` See [Image drawing via OnVideoFrameBuffer](../image-onvideoframebuffer/) and [Text drawing via OnVideoFrameBuffer](../text-onvideoframebuffer/) for detailed per-frame processing examples. **When to use:** - Computer-vision / ML pipelines that consume raw frames - Custom rendering with SkiaSharp, DirectX, or OpenGL - WPF / WinUI / MAUI apps that render into a `WriteableBitmap` manually - Apps with no preview surface at all (frames shipped to a server, encoder, etc.) ### WinUI 3 Renderer Native rendering for WinUI 3 apps on Windows 10/11. Use this mode when your shell is `Microsoft.UI.Xaml` and you host a `VisioForge.Core.UI.WinUI.VideoView` control. **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.WinUI; await VideoCapture1.Video_Renderer_UpdateAsync(); ``` **When to use:** - WinUI 3 apps (Windows App SDK, not the old WinUI 2 / UWP) - You want native look-and-feel consistency with other WinUI content ### madVR Renderer (third-party) [madVR](https://www.madvr.com/) is a reference-quality external video renderer popular with home-theatre PCs and high-end video software. It delivers superior scaling algorithms, color management, and deinterlacing at the cost of higher GPU load. Supported only on WinForms hosts; requires a separate madVR installation on the target machine (the CLSID-registered DirectShow filter must be present). **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.MadVR; await VideoCapture1.Video_Renderer_UpdateAsync(); ``` **Runtime requirement:** ensure madVR is installed on the target system. If the filter is missing, `Video_Renderer_UpdateAsync` will fail — use the fallback pattern shown in [Renderer Compatibility Problems](#renderer-compatibility-problems) below to degrade gracefully to EVR. **When to use:** - Reference-grade video quality for mastering, HTPC, or media server UIs - Audiences with GPUs that can absorb the extra rendering cost - You can ship / document a separate madVR install step ### None (headless) Disables rendering entirely. The capture / edit / playback graph still runs — frames flow to encoders, file outputs, streaming endpoints, or callbacks — but no preview surface is allocated. **Implementation example:** ``` VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.None; await VideoCapture1.Video_Renderer_UpdateAsync(); ``` **When to use:** - Audio-only capture (microphone-to-file) when the SDK has both audio and video branches - File conversion / transcoding without a preview window - Server-side rendering pipelines - Unit tests and headless CI runs ## Advanced Configuration Options Beyond just selecting a renderer, the SDK provides various configuration options to fine-tune video presentation. ### Working with Deinterlacing Modes When displaying interlaced video content (common in broadcast sources), proper deinterlacing improves visual quality significantly. The SDK supports various deinterlacing algorithms depending on the renderer chosen. First, retrieve the available deinterlacing modes. `Video_Renderer_Deinterlace_Modes()` returns the VMR-9 mode names auto-discovered from the current driver: ``` // Populate a dropdown with the available VMR-9 modes foreach (string deinterlaceMode in VideoCapture1.Video_Renderer_Deinterlace_Modes()) { cbDeinterlaceModes.Items.Add(deinterlaceMode); } ``` Deinterlacing is configured on the two renderers separately. VMR-9 takes a mode-name string; EVR takes a `VideoRendererEVRDeinterlaceMode` enum value: ``` // VMR-9 — set the mode string selected by the user VideoCapture1.Video_Renderer.Deinterlace_VMR9_Mode = cbDeinterlaceModes.SelectedItem.ToString(); VideoCapture1.Video_Renderer.Deinterlace_VMR9_UseDefault = false; // EVR — use the enum instead // VideoCapture1.Video_Renderer.Deinterlace_EVR_Mode = VideoRendererEVRDeinterlaceMode.Auto; VideoCapture1.Video_Renderer_Update(); ``` VMR9 and EVR support various deinterlacing algorithms including: - Bob (simple line doubling) - Weave (field interleaving) - Motion adaptive - Motion compensated (highest quality) The availability of specific algorithms depends on the video card capabilities and driver implementation. ### Managing Aspect Ratio and Stretch Modes When displaying video in a window or control that doesn't match the source's native aspect ratio, you need to decide how to handle this discrepancy. The SDK provides multiple stretch modes to address different scenarios. #### Stretch Mode This mode stretches the video to fill the entire display area, potentially distorting the image: ``` VideoCapture1.Video_Renderer.StretchMode = VideoRendererStretchMode.Stretch; VideoCapture1.Video_Renderer_Update(); ``` **Use cases:** - When aspect ratio is not critical - Filling the entire display area is more important than proportions - Source and display have similar aspect ratios - User interface constraints require full-area usage #### Letterbox Mode This mode preserves the original aspect ratio by adding black borders as needed: ``` VideoCapture1.Video_Renderer.StretchMode = VideoRendererStretchMode.Letterbox; VideoCapture1.Video_Renderer_Update(); ``` **Use cases:** - Maintaining correct proportions is essential - Professional video applications - Content where distortion would be noticeable or problematic - Cinema or broadcast content viewing #### LetterboxToFill Mode This mode fills the display area while preserving aspect ratio, cropping any overflow on one axis: ``` VideoCapture1.Video_Renderer.StretchMode = VideoRendererStretchMode.LetterboxToFill; VideoCapture1.Video_Renderer_Update(); ``` **Use cases:** - Consumer video applications where filling the screen is preferred - Content where edges are less important than center - Social media-style video display - When trying to eliminate letterboxing in already letterboxed content ### Aspect-Ratio Override To force a specific display aspect ratio (e.g. show 4:3 content letterboxed inside a 16:9 container), enable the override and set the ratio components: ``` VideoCapture1.Video_Renderer.Aspect_Ratio_Override = true; VideoCapture1.Video_Renderer.Aspect_Ratio_X = 4; VideoCapture1.Video_Renderer.Aspect_Ratio_Y = 3; VideoCapture1.Video_Renderer_Update(); ``` ### Zoom and Pan `VideoRendererSettings` exposes zoom/shift properties useful for digital PTZ on a preview: ``` VideoCapture1.Video_Renderer.Zoom_Ratio = 150; // 150% VideoCapture1.Video_Renderer.Zoom_ShiftX = 0; VideoCapture1.Video_Renderer.Zoom_ShiftY = 0; VideoCapture1.Video_Renderer_Update(); ``` ### Flip and Rotation ``` VideoCapture1.Video_Renderer.Flip_Horizontal = true; VideoCapture1.Video_Renderer.Flip_Vertical = false; // RotationAngle is only respected by the Direct2D renderer and accepts 0, 90, 180, or 270. VideoCapture1.Video_Renderer.RotationAngle = 90; VideoCapture1.Video_Renderer_Update(); ``` ## Troubleshooting Common Issues ### Renderer Compatibility Problems If you encounter issues with a specific renderer, try falling back to a more compatible option: ``` try { // Try using EVR first VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.EVR; VideoCapture1.Video_Renderer_Update(); } catch { try { // Fall back to VMR9 VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.VMR9; VideoCapture1.Video_Renderer_Update(); } catch { // Last resort - legacy renderer VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.VideoRenderer; VideoCapture1.Video_Renderer_Update(); } } ``` ## Best Practices and Recommendations 1. **Choose the right renderer for your target environment**: 2. For modern Windows: EVR 3. For broad compatibility: VMR9 4. For legacy systems: Video Renderer 5. **Test on various hardware configurations**: Video rendering can behave differently across GPU vendors and driver versions. 6. **Implement renderer fallback logic**: Always have a backup plan if the preferred renderer fails. 7. **Consider your video content**: Higher resolution or interlaced content will benefit more from advanced renderers. 8. **Balance quality vs. performance**: The highest quality settings might not always deliver the best user experience if they impact performance. ## Required Dependencies To ensure proper functionality of these renderers, make sure to include: - SDK redistributable packages - DirectX End-User Runtime (latest version recommended) - .NET Framework runtime appropriate for your application ## Conclusion The classic engines offer 10 renderer modes covering WinForms, WPF, and WinUI 3. **EVR** is the safe default for WinForms, **Direct2D** for modern GPU-accelerated rendering on either WinForms or WPF, **FrameCallback** for custom pipelines (CV / AI / bespoke rendering), **WinUI** for WinUI 3 shells, and **madVR** for reference-quality scenarios that can accommodate the external install. `None` is the right mode when there is no preview at all. For applications built on the cross-platform `VideoCaptureCoreX` / `MediaPlayerCoreX` engines, renderer choice is handled by the `VideoView` control and does not use this enum. ## Related documentation - [Image drawing via OnVideoFrameBuffer](../image-onvideoframebuffer/) — pixel-level frame processing, the canonical use case for `FrameCallback`. - [Text drawing via OnVideoFrameBuffer](../text-onvideoframebuffer/) — text overlays with `FrameCallback`. - [Rendering video in a PictureBox](../draw-video-picturebox/) — WinForms rendering pattern that pairs well with `FrameCallback`. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Draw Text on Video Frames in C# .NET — OnVideoFrameBuffer **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/text-onvideoframebuffer/ **Description:** Draw dynamic text on video frames in C# / .NET using the OnVideoFrameBuffer event. Timestamps, sensor data, custom fonts — pixel-level rendering. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, MediaPlayerCoreX, VideoCaptureCoreX, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Playback, C# **API:** VideoEffectTextLogo, VideoFrameBufferEventArgs, VideoFrameXBufferEventArgs, VideoCaptureCoreX, MediaPlayerCoreX # Creating Custom Text Overlays with OnVideoFrameBuffer in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction The `OnVideoFrameBuffer` event gives direct, pixel-level access to every video frame as it passes through the pipeline. Drawing text onto the frame — timestamps, sensor readings, debug telemetry, or custom branding — is one of the most common uses. This guide shows how to render text on raw frames with full control over font, color, position, and per-frame logic. Looking for the high-level text overlay feature? If you just need a static, animated, or clock-driven text overlay with standard positioning, use the dedicated [text overlay effect](../../video-effects/text-overlay/) — one line of code via `Video_Effects_Add(new VideoEffectTextLogo(...))`. Use `OnVideoFrameBuffer` (this page) when you need **pixel-level control**: custom fonts, advanced layout, per-frame dynamic content, or integration with third-party text/graphics libraries. ### Supported engines The `OnVideoFrameBuffer` event is exposed on both engine families: | Engine | Event args type | Frame pixel format | | --- | --- | --- | | `VideoCaptureCore` (DirectShow, Windows) | `VideoFrameBufferEventArgs` | RGB24 / RGB32 | | `VideoCaptureCoreX` (GStreamer, cross-platform) | `VideoFrameXBufferEventArgs` | BGRA (most common) | | `MediaPlayerCoreX` (GStreamer, cross-platform) | `VideoFrameXBufferEventArgs` | BGRA (most common) | Both engines follow the same pattern — subscribe to the event, read `e.Frame.Data` (an `IntPtr`) with `Width` / `Height` / `Stride`, render into the buffer in place, and set `e.UpdateData = true` to propagate changes downstream. ## Understanding the OnVideoFrameBuffer Event The OnVideoFrameBuffer event is a powerful hook that gives developers direct access to the video frame buffer during processing. This event fires for each frame of video, providing an opportunity to modify the frame data before it's displayed or encoded. Key benefits of using OnVideoFrameBuffer for text overlays include: - **Frame-level access**: Modify individual frames with pixel-perfect precision - **Dynamic content**: Update text based on real-time data or timestamps - **Custom styling**: Apply custom fonts, colors, and effects beyond what built-in APIs offer - **Performance optimizations**: Implement efficient rendering techniques for high-performance applications ## Implementation Overview The technique presented here uses the following components: 1. An event handler for OnVideoFrameBuffer that processes each video frame 2. A VideoEffectTextLogo object to define text properties 3. The FastImageProcessing API to render text onto the frame buffer This approach is particularly useful when you need to: - Display dynamic data like timestamps, metadata, or sensor readings - Create animated text effects - Position text with pixel-perfect accuracy - Apply custom styling not available through standard APIs ## Sample Code Implementation The following C# example demonstrates how to implement a basic text overlay system using the OnVideoFrameBuffer event: ``` private void SDK_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { if (!logoInitiated) { logoInitiated = true; InitTextLogo(); } // AddTextLogo(context, pixels, pixels32bit, pixels32tmp, frameWidth, frameHeight, // ref textLogo, timeStamp, frameNumber) // Pass pixels32bit: false + pixels32tmp: IntPtr.Zero for RGB24 frames. FastImageProcessing.AddTextLogo( context: null, pixels: e.Frame.Data, pixels32bit: false, pixels32tmp: IntPtr.Zero, frameWidth: e.Frame.Info.Width, frameHeight: e.Frame.Info.Height, textLogo: ref textLogo, timeStamp: e.Frame.Timestamp, frameNumber: 0); } private bool logoInitiated = false; private VideoEffectTextLogo textLogo = null; private void InitTextLogo() { textLogo = new VideoEffectTextLogo(true); textLogo.Text = "Hello world!"; textLogo.Left = 50; textLogo.Top = 50; } ``` ## Detailed Code Explanation Let's break down the key components of this implementation: ### The Event Handler ``` private void SDK_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) ``` This method is triggered for each video frame. The VideoFrameBufferEventArgs provides access to: - Frame data (pixel buffer) - Frame dimensions (width and height) - Timestamp information ### Initialization Logic ``` if (!logoInitiated) { logoInitiated = true; InitTextLogo(); } ``` This code ensures the text logo is only initialized once, preventing unnecessary object creation for each frame. This pattern is important for performance when processing video at high frame rates. ### Text Logo Setup ``` private void InitTextLogo() { textLogo = new VideoEffectTextLogo(true); textLogo.Text = "Hello world!"; textLogo.Left = 50; textLogo.Top = 50; } ``` The VideoEffectTextLogo class is used to define the properties of the text overlay: - The text content ("Hello world!") - Position coordinates (50 pixels from both left and top) ### Rendering the Text Overlay ``` FastImageProcessing.AddTextLogo( context: null, pixels: e.Frame.Data, pixels32bit: false, // true when the engine delivers RGB32 pixels32tmp: IntPtr.Zero, // optional scratch buffer; IntPtr.Zero lets the helper allocate on demand frameWidth: e.Frame.Info.Width, frameHeight: e.Frame.Info.Height, textLogo: ref textLogo, timeStamp: e.Frame.Timestamp, frameNumber: 0); ``` The 9-arg signature mirrors `FastImageProcessing.AddTextLogo` exactly. Width/height live inside `e.Frame.Info` on the classic `VideoFrame` struct; the timestamp lives on `e.Frame.Timestamp`. Pass `pixels32bit: true` when your source is RGB32. ## Advanced Customization Options While the basic example demonstrates a simple static text overlay, the VideoEffectTextLogo class supports numerous customization options: ### Text Formatting ``` // Font is a full System.Drawing.Font — any typeface + style combo works. textLogo.Font = new System.Drawing.Font("Arial", 24, System.Drawing.FontStyle.Bold); textLogo.FontColor = System.Drawing.Color.White; textLogo.TransparencyLevel = 200; // 0 (fully transparent) - 255 (opaque) ``` ### Background and Borders ``` textLogo.BackgroundTransparent = false; textLogo.BackgroundColor = System.Drawing.Color.Black; // Border ring is configured via BorderMode + per-ring colors and sizes (inner/outer). // TextEffectMode values: None, Inner, Outer, InnerAndOuter, Embossed, Outline, FilledOutline, Halo. textLogo.BorderMode = TextEffectMode.InnerAndOuter; textLogo.BorderInnerColor = System.Drawing.Color.Yellow; textLogo.BorderInnerSize = 2; textLogo.BorderOuterColor = System.Drawing.Color.Black; textLogo.BorderOuterSize = 1; ``` ### Animation and Dynamic Content For dynamic content that changes per frame: ``` private void SDK_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { if (!logoInitiated) { logoInitiated = true; InitTextLogo(); } // Timestamp lives on e.Frame.Timestamp (TimeSpan) textLogo.Text = $"Timestamp: {e.Frame.Timestamp:hh\\:mm\\:ss\\.fff}"; // Animate position textLogo.Left = 50 + (int)(Math.Sin(e.Frame.Timestamp.TotalSeconds) * 50); FastImageProcessing.AddTextLogo( context: null, pixels: e.Frame.Data, pixels32bit: false, pixels32tmp: IntPtr.Zero, frameWidth: e.Frame.Info.Width, frameHeight: e.Frame.Info.Height, textLogo: ref textLogo, timeStamp: e.Frame.Timestamp, frameNumber: 0); } ``` ## Performance Considerations When implementing custom text overlays, consider these performance best practices: 1. **Initialize objects once**: Create the VideoEffectTextLogo object only once, not per frame 2. **Minimize text changes**: Update text content only when necessary 3. **Use efficient fonts**: Simple fonts render faster than complex ones 4. **Consider resolution**: Higher resolution videos require more processing power 5. **Test on target hardware**: Ensure your implementation performs well on production systems ## Multiple Text Elements To display multiple text elements on the same frame: ``` private VideoEffectTextLogo titleLogo = null; private VideoEffectTextLogo timestampLogo = null; private void InitTextLogos() { titleLogo = new VideoEffectTextLogo(true); titleLogo.Text = "Camera Feed"; titleLogo.Left = 50; titleLogo.Top = 50; timestampLogo = new VideoEffectTextLogo(true); timestampLogo.Left = 50; timestampLogo.Top = 100; } private void SDK_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { if (!logosInitiated) { logosInitiated = true; InitTextLogos(); } // Update dynamic content timestampLogo.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); // Render both text elements FastImageProcessing.AddTextLogo(null, e.Frame.Data, false, IntPtr.Zero, e.Frame.Info.Width, e.Frame.Info.Height, ref titleLogo, e.Frame.Timestamp, 0); FastImageProcessing.AddTextLogo(null, e.Frame.Data, false, IntPtr.Zero, e.Frame.Info.Width, e.Frame.Info.Height, ref timestampLogo, e.Frame.Timestamp, 0); } ``` ## VideoCaptureCoreX / MediaPlayerCoreX (X engines) example On the cross-platform X engines the event signature is `VideoFrameXBufferEventArgs` and the frame buffer typically arrives in **BGRA** format (4 bytes per pixel). The example below uses SkiaSharp to wrap the raw buffer and draw text on top; SkiaSharp is a transitive dependency of the X engines, so no extra NuGet package is needed. ``` using SkiaSharp; // Create paints once, reuse across frames private SKPaint _textPaint = new SKPaint { Color = SKColors.White, TextSize = 32, IsAntialias = true, Typeface = SKTypeface.FromFamilyName("Arial", SKFontStyle.Bold) }; private SKPaint _shadowPaint = new SKPaint { Color = SKColors.Black.WithAlpha(160), TextSize = 32, IsAntialias = true, Typeface = SKTypeface.FromFamilyName("Arial", SKFontStyle.Bold) }; // Subscribe after constructing VideoCaptureCoreX / MediaPlayerCoreX _videoCapture.OnVideoFrameBuffer += VideoCapture_OnVideoFrameBuffer; private void VideoCapture_OnVideoFrameBuffer(object sender, VideoFrameXBufferEventArgs e) { if (e.Frame == null || e.Frame.Data == IntPtr.Zero) { return; } // Wrap the raw BGRA buffer in a SkiaSharp surface (no extra allocation) var info = new SKImageInfo(e.Frame.Width, e.Frame.Height, SKColorType.Bgra8888, SKAlphaType.Premul); using (var pixmap = new SKPixmap(info, e.Frame.Data, e.Frame.Stride)) using (var surface = SKSurface.Create(pixmap)) { var canvas = surface.Canvas; // Dynamic content built per frame var timestamp = e.Frame.Timestamp.ToString(@"hh\:mm\:ss\.fff"); var line = $"REC {timestamp}"; // Draw shadow first, then main text for legibility on any background canvas.DrawText(line, 18, 42, _shadowPaint); canvas.DrawText(line, 16, 40, _textPaint); canvas.Flush(); } // Propagate the modified frame downstream e.UpdateData = true; } ``` **Why BGRA matters.** The X engines request BGRA by default for frame callbacks because it maps 1:1 to SkiaSharp, System.Drawing, and most GPU-friendly interop paths. If you need a different format, request a format conversion block upstream rather than converting on every frame. **Measuring and positioning text.** Use `_textPaint.MeasureText(line)` to compute width for right- or center-alignment. SkiaSharp also exposes `SKFontMetrics` via `_textPaint.FontMetrics` for baseline / ascent / descent to position text precisely against frame edges. **Alternative imaging stacks.** You can also use `System.Drawing.Graphics` wrapping a `Bitmap` constructed over the raw buffer on Windows, or direct byte writes with `Marshal.Copy` / `Span` for full control. SkiaSharp is the recommended option on macOS / Linux / iOS / Android. **Engine-level parity.** Everything in [Performance Considerations](#performance-considerations) and [Multiple Text Elements](#multiple-text-elements) applies equally to the X engines — the event fires on a processing thread, `UpdateData` propagates changes, and heavy work should be offloaded to avoid dropping frames. ## Required Components To implement this solution, you'll need: - SDK redist package installed in your application (NuGet on the X engines, installer on `VideoCaptureCore`). - Reference to the appropriate SDK (Video Capture SDK, Video Edit SDK, or Media Player SDK — X or classic). - For the X-engine sample: a transitive SkiaSharp reference (already pulled in by the SDK) or your own text-rendering library. ## Conclusion The `OnVideoFrameBuffer` event gives direct access to every raw frame on both the classic `VideoCaptureCore` engine (RGB24/RGB32 via `VideoFrameBufferEventArgs` + `FastImageProcessing`) and the cross-platform X engines (`VideoCaptureCoreX` / `MediaPlayerCoreX`, BGRA via `VideoFrameXBufferEventArgs` + SkiaSharp). This is the right tool when you need pixel-level text rendering — custom fonts, per-frame dynamic content, anti-aliasing you control, or integration with third-party text/graphics libraries. For static or clock-driven text overlays without writing a per-frame handler, the one-line [text overlay effect](../../video-effects/text-overlay/) is usually the better choice. ## Related documentation - [Text overlay effect](../../video-effects/text-overlay/) — high-level, declarative text overlay without writing a callback. - [Image drawing via OnVideoFrameBuffer](../image-onvideoframebuffer/) — same technique applied to images instead of text. - [Drawing video in a PictureBox](../draw-video-picturebox/) — WinForms rendering pattern that often pairs with pixel-level frame work. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Uninstall DirectShow Filters in Windows Using regsvr32 **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/uninstall-directshow-filter/ **Description:** Properly uninstall DirectShow filters with manual techniques, troubleshooting steps, and best practices for .NET multimedia applications. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, DirectShow, Windows, Playback # Remove DirectShow Filters in Windows [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) DirectShow filters are essential components for multimedia applications in Windows environments. They enable software to process audio and video data efficiently. However, there may be situations where you need to uninstall these filters, such as when upgrading your application, resolving conflicts, or completely removing a software package. This guide provides detailed instructions on how to properly uninstall DirectShow filters from your system. ## Understanding DirectShow Filters DirectShow is a multimedia framework and API designed by Microsoft for software developers to perform various operations with media files. It's built on the Component Object Model (COM) architecture and uses a modular approach where each processing step is handled by a separate component called a filter. Filters are categorized into three main types: - **Source filters**: Read data from files, capture devices, or network streams - **Transform filters**: Process or modify the data (compression, decompression, effects) - **Rendering filters**: Display video or play audio When SDK components are installed, they register DirectShow filters in the Windows Registry, making them available to any application that uses the DirectShow framework. ## Why Uninstall DirectShow Filters? There are several reasons why you might need to uninstall DirectShow filters: 1. **Version conflicts**: Newer versions of the SDK might require removing older filters 2. **System cleanup**: Removing unused components to maintain system efficiency 3. **Troubleshooting**: Resolving issues with multimedia applications 4. **Complete software removal**: Ensuring no components remain after uninstalling the main application 5. **Re-registration**: Sometimes uninstalling and reinstalling filters can resolve registration issues ## Methods for Uninstalling DirectShow Filters ### Method 1: Using the SDK Installer (Recommended) The most straightforward way to uninstall DirectShow filters is through the SDK (or redist) installer itself. SDK packages include uninstallation routines that properly remove all components, including DirectShow filters. ### Method 2: Manual Unregistration with regsvr32 If automatic uninstallation isn't possible or you need to unregister specific filters, you can use the `regsvr32` command-line tool: 1. Open Command Prompt as Administrator (right-click on Command Prompt and select "Run as administrator") 2. Use the following command syntax to unregister a filter: ``` regsvr32 /u "C:\path\to\filter.dll" ``` 1. Replace `C:\path\to\filter.dll` with the actual path to the DirectShow filter file 2. Press Enter to execute the command For example, to unregister a filter located at `C:\Program Files\Common Files\FilterFolder\example_filter.dll`, you would use: ``` regsvr32 /u "C:\Program Files\Common Files\FilterFolder\example_filter.dll" ``` You should see a confirmation dialog indicating successful unregistration. ## Finding DirectShow Filter Locations Before you can manually unregister filters, you need to know their locations. Here are several methods to find installed DirectShow filters: ### Using GraphStudio [GraphStudio](https://github.com/cplussharp/graph-studio-next) is a powerful open-source tool for working with DirectShow filters. To find filter locations: 1. Download and install GraphStudio 2. Launch the application with administrator privileges 3. Go to "Graph > Insert Filters" 4. Browse through the list of installed filters 5. Right-click on a filter and select "Properties" 6. Note the "File:" path shown in the properties dialog This method provides the exact file path needed for manual unregistration. ### Using System Registry You can also find DirectShow filters through the Windows Registry: 1. Press `Win + R` to open the Run dialog 2. Type `regedit` and press Enter to open Registry Editor 3. Navigate to `HKEY_CLASSES_ROOT\CLSID` 4. Use the Search function (Ctrl+F) to find filter names 5. Look for the "InprocServer32" key under the filter's CLSID, which contains the file path ## Platform Considerations (x86 vs x64) DirectShow filters are platform-specific, meaning 32-bit (x86) and 64-bit (x64) versions are separate components. If you've installed both versions, you need to unregister each one separately. For x64 systems: - 64-bit filters are typically installed in `C:\Windows\System32` - 32-bit filters are typically installed in `C:\Windows\SysWOW64` Use the appropriate version of `regsvr32` for each platform: - For 64-bit filters: `C:\Windows\System32\regsvr32.exe` - For 32-bit filters: `C:\Windows\SysWOW64\regsvr32.exe` ## Troubleshooting Filter Uninstallation If you encounter issues during filter uninstallation, try these troubleshooting steps: ### Unable to Unregister Filter If you receive an error like "DllUnregisterServer failed with error code 0x80004005": 1. Ensure you're running Command Prompt as Administrator 2. Verify that the path to the filter is correct 3. Check if the filter file exists and isn't in use by any application 4. Close any applications that might be using DirectShow filters 5. In some cases, a system restart may be necessary before unregistration ### Filter Still Present After Unregistration If a filter appears to be still registered after attempting to unregister it: 1. Use GraphStudio to check if the filter is still listed 2. Look for multiple instances of the filter in different locations 3. Check both 32-bit and 64-bit registry locations 4. Try using the Microsoft-provided tool "OleView" to inspect COM registrations ## Verifying Successful Uninstallation After uninstalling DirectShow filters, verify the removal was successful: 1. Use GraphStudio to check if the filters no longer appear in the available filters list 2. Check the registry for any remaining entries related to the filters 3. Test any applications that previously used the filters to ensure they handle the absence gracefully --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples and implementation examples for working with DirectShow and multimedia applications in .NET. ---END OF PAGE--- ## Setting Custom Placeholder Images for VideoView .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/video-view-set-custom-image/ **Description:** Display custom placeholder images in VideoView controls when no video is playing for professional branding and enhanced user experience in .NET. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, Playback, C# **API:** VideoView, VideoPlayerForm # Setting Custom Images for VideoView Controls in .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction When developing media applications in .NET, it's often necessary to display a custom image within your VideoView control when no video content is playing. This capability is essential for creating professional-looking applications that maintain visual appeal during inactive states. Custom images can serve as placeholders, branding opportunities, or informational displays to enhance the user experience. This guide explores the implementation of custom image functionality for VideoView controls across various .NET SDK applications. ## Understanding VideoView Custom Images The VideoView control is a versatile component that displays video content in your application. However, when the control is not actively playing video, it typically shows a blank or default display. By implementing custom images, you can: - Display your application or company logo - Show preview thumbnails of available content - Present instructional information to users - Maintain visual consistency across your application - Indicate the video's status (paused, stopped, loading, etc.) It's important to note that the custom image is only visible when the control is not playing any video content. Once playback begins, the video stream automatically replaces the custom image. ## Implementation Process The process of setting a custom image for a VideoView control involves three primary operations: 1. Creating a picture box with appropriate dimensions 2. Setting the desired image 3. Cleaning up resources when no longer needed Let's explore each of these steps in detail. ## Step 1: Creating the Picture Box The first step is to initialize a picture box within your VideoView control with the appropriate dimensions. This operation should be performed once during the setup phase: ``` VideoView1.PictureBoxCreate(VideoView1.Width, VideoView1.Height); ``` This method call creates an internal picture box component that will host your custom image. The parameters specify the width and height of the picture box, which should typically match the dimensions of your VideoView control to ensure proper display without stretching or distortion. ### Best Practices for Picture Box Creation - **Timing Considerations**: Create the picture box during form initialization or after the control has been sized appropriately - **Dynamic Sizing**: If your application supports resizing, consider recreating the picture box when the control size changes - **Error Handling**: Implement try-catch blocks to handle potential exceptions during creation ## Step 2: Setting the Custom Image After creating the picture box, you can set your custom image. Note that there appears to be a duplication in the original documentation - the correct code for setting the image should use the `PictureBoxSetImage` method: `PictureBoxSetImage` takes a `System.Drawing.Bitmap`, so load the file as `Bitmap` (or cast) rather than `Image`: ``` // Load an image from a file as Bitmap Bitmap customImage = new Bitmap("path/to/your/image.jpg"); VideoView1.PictureBoxSetImage(customImage); ``` Alternatively, you can use built-in resources or dynamically generated images: ``` // Using a Bitmap resource (the resource must be declared as Bitmap, not Image) VideoView1.PictureBoxSetImage(Properties.Resources.MyCustomImage); // Or creating a dynamic image using (Bitmap dynamicImage = new Bitmap(VideoView1.Width, VideoView1.Height)) { using (Graphics g = Graphics.FromImage(dynamicImage)) { // Draw on the image g.Clear(Color.DarkBlue); g.DrawString("Ready to Play", new Font("Arial", 24), Brushes.White, new PointF(50, 50)); } VideoView1.PictureBoxSetImage((Bitmap)dynamicImage.Clone()); } ``` ### Image Format Considerations The image format you choose can impact performance and visual quality: - **PNG**: Best for images with transparency - **JPEG**: Suitable for photographic content - **BMP**: Uncompressed format with higher memory usage - **GIF**: Supports simple animations but with limited color depth ### Image Size Optimization For optimal performance, consider these factors when preparing your custom images: 1. **Match Dimensions**: Resize your image to match the VideoView dimensions to avoid scaling operations 2. **Resolution Awareness**: Consider display DPI for crisp images on high-resolution displays 3. **Memory Consumption**: Large images consume more memory, which may impact application performance ## Step 3: Cleaning Up Resources When the custom image is no longer required, it's important to clean up the resources to prevent memory leaks: ``` VideoView1.PictureBoxDestroy(); ``` This method should be called when: - The application is closing - The control is being disposed - You're switching to video playback mode and won't need the custom image anymore ### Resource Management Best Practices Proper resource management is crucial for maintaining application stability: - **Explicit Cleanup**: Always call `PictureBoxDestroy()` when you're done with the custom image - **Disposal Timing**: Include the cleanup call in your form's `Dispose` or `Closing` events - **State Tracking**: Keep track of whether a picture box has been created to avoid destroying a non-existent resource ## Advanced Scenarios ### Dynamic Image Updates In some applications, you may need to update the custom image dynamically: ``` private void UpdateCustomImage(string imagePath) { // Ensure picture box exists if (VideoView1.PictureBoxExists()) { // Update image Bitmap newImage = new Bitmap(imagePath); VideoView1.PictureBoxSetImage(newImage); } else { // Create picture box first VideoView1.PictureBoxCreate(VideoView1.Width, VideoView1.Height); Bitmap newImage = new Bitmap(imagePath); VideoView1.PictureBoxSetImage(newImage); } } ``` ### Handling Control Resizing If your application allows resizing of the VideoView control, you'll need to handle image scaling: ``` private void VideoView1_SizeChanged(object sender, EventArgs e) { // Recreate picture box with new dimensions if (VideoView1.PictureBoxExists()) { VideoView1.PictureBoxDestroy(); } VideoView1.PictureBoxCreate(VideoView1.Width, VideoView1.Height); // Set image again with appropriate scaling SetScaledCustomImage(); } ``` ### Multiple VideoView Controls When working with multiple VideoView controls, ensure proper management for each: ``` private void InitializeAllVideoViews() { // Initialize each VideoView with appropriate custom images VideoView1.PictureBoxCreate(VideoView1.Width, VideoView1.Height); VideoView1.PictureBoxSetImage(Properties.Resources.Camera1Placeholder); VideoView2.PictureBoxCreate(VideoView2.Width, VideoView2.Height); VideoView2.PictureBoxSetImage(Properties.Resources.Camera2Placeholder); // Additional VideoView controls... } ``` ## Troubleshooting Common Issues ### Image Not Displaying If your custom image isn't appearing: 1. **Check Timing**: Ensure you're setting the image after the picture box is created 2. **Verify Video State**: Confirm the control isn't currently playing video 3. **Image Loading**: Verify the image path is correct and accessible 4. **Control Visibility**: Ensure the VideoView control is visible in the UI ### Memory Leaks To prevent memory leaks: 1. **Dispose Images**: Always dispose Image objects after they're no longer needed 2. **Destroy Picture Box**: Call `PictureBoxDestroy()` when appropriate 3. **Resource Tracking**: Implement proper tracking of created resources ## Complete Implementation Example Here's a complete implementation example that demonstrates the proper lifecycle management: ``` public partial class VideoPlayerForm : Form { private bool isPictureBoxCreated = false; public VideoPlayerForm() { InitializeComponent(); this.Load += VideoPlayerForm_Load; this.FormClosing += VideoPlayerForm_FormClosing; } private void VideoPlayerForm_Load(object sender, EventArgs e) { InitializeCustomImage(); } private void InitializeCustomImage() { try { VideoView1.PictureBoxCreate(VideoView1.Width, VideoView1.Height); isPictureBoxCreated = true; // PictureBoxSetImage expects System.Drawing.Bitmap — declare the resource as Bitmap (or cast from Image). using (Bitmap customImage = (Bitmap)Properties.Resources.VideoPlaceholder) { VideoView1.PictureBoxSetImage(customImage); } } catch (Exception ex) { // Handle exceptions MessageBox.Show($"Error setting custom image: {ex.Message}"); } } private void btnPlay_Click(object sender, EventArgs e) { // Play video logic here // The custom image will automatically be replaced during playback } private void VideoPlayerForm_FormClosing(object sender, FormClosingEventArgs e) { CleanupResources(); } private void CleanupResources() { if (isPictureBoxCreated) { VideoView1.PictureBoxDestroy(); isPictureBoxCreated = false; } } } ``` ## Conclusion Implementing custom images for VideoView controls enhances the user experience and professional appearance of your .NET media applications. By following the steps outlined in this guide, you can effectively display branded or informative content when videos aren't playing. Remember the key points: 1. Create the picture box with the appropriate dimensions 2. Set your custom image with proper resource management 3. Clean up resources when they're no longer needed 4. Handle resizing and other special scenarios as required With these techniques, you can create more polished and user-friendly video applications in .NET. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples and implementation examples. ---END OF PAGE--- ## Implementing Audio VU Meters & Waveform Visualizers **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/vu-meters/ **Description:** Build VU meters and waveform visualizers in WinForms and WPF for real-time audio level monitoring with mono and stereo channel support in .NET. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, WinForms, WPF, C# **API:** AudioLevelEventArgs, VUMeterMaxSampleEventArgs # Audio Visualization: Implementing VU Meters and Waveform Displays in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) Audio visualization is a crucial component of modern media applications, providing users with visual feedback about audio levels and waveform patterns. This guide demonstrates how to implement VU (Volume Unit) meters and waveform visualizers in both WinForms and WPF applications. ## Understanding Audio Visualization Components Before diving into implementation, it's important to understand the two main visualization tools we'll be working with: ### VU Meters VU meters display the instantaneous audio level of a signal, typically showing how loud the audio is at any given moment. They provide real-time feedback about audio levels, helping users monitor signal strength and prevent distortion or clipping. ### Waveform Painters Waveform visualizers display the audio signal as a continuous line that represents amplitude changes over time. They provide a more detailed representation of the audio content, showing patterns and characteristics that might not be apparent from listening alone. ## Implementation in WinForms Applications WinForms provides a straightforward way to implement audio visualization components with minimal code. Let's explore the implementation of both VU meters and waveform painters. ### WinForms VU Meter Implementation Implementing a VU meter in WinForms requires just a few steps: 1. **Add the VU Meter Control**: First, add the VU meter control to your form. For stereo audio, you'll typically add two controls—one for each channel. ``` // Add this to your form design VisioForge.Core.UI.WinForms.VolumeMeterPro.VolumeMeter volumeMeter1; VisioForge.Core.UI.WinForms.VolumeMeterPro.VolumeMeter volumeMeter2; // For stereo ``` 1. **Enable VU Meter in Your Media Control**: Before starting playback or capture, enable the VU meter functionality in your media control. ``` // Enable VU meter before starting playback/capture mediaPlayer.Audio_VUMeter_Pro_Enabled = true; ``` 1. **Implement the Event Handler**: Add an event handler to process the audio level data and update the VU meter display. ``` private void VideoCapture1_OnAudioVUMeterProVolume(object sender, AudioLevelEventArgs e) { volumeMeter1.Amplitude = e.ChannelLevelsDb[0]; if (e.ChannelLevelsDb.Length > 1) { volumeMeter2.Amplitude = e.ChannelLevelsDb[1]; } } ``` With these steps, your VU meter will dynamically update based on the audio levels of your media playback or capture. ### WinForms Waveform Painter Implementation The waveform painter implementation follows a similar pattern: 1. **Add the Waveform Painter Control**: Add the waveform painter control to your form. For stereo audio, add two controls. ``` // Add this to your form design VisioForge.Core.UI.WinForms.VolumeMeterPro.WaveformPainter waveformPainter1; VisioForge.Core.UI.WinForms.VolumeMeterPro.WaveformPainter waveformPainter2; // For stereo ``` 1. **Enable VU Meter Processing**: Enable the VU meter functionality to provide data for the waveform painter. ``` // Enable VU meter before starting playback/capture mediaPlayer.Audio_VUMeter_Pro_Enabled = true; ``` 1. **Implement the Event Handler**: Add an event handler to process the audio data and update the waveform display. ``` private void VideoCapture1_OnAudioVUMeterProVolume(object sender, AudioLevelEventArgs e) { waveformPainter1.AddMax(e.ChannelLevelsDb[0]); if (e.ChannelLevelsDb.Length > 1) { waveformPainter2.AddMax(e.ChannelLevelsDb[1]); } } ``` ## Implementation in WPF Applications WPF requires a slightly different approach due to its threading model and UI framework. Let's look at how to implement both visualization types in WPF. ### WPF VU Meter Implementation 1. **Add the VU Meter Control**: Add the VU meter control to your XAML layout. For stereo audio, add two controls. ``` ``` 1. **Enable VU Meter Processing and Start the Meters**: ``` VideoCapture1.Audio_VUMeter_Pro_Enabled = true; volumeMeter1.Start(); volumeMeter2.Start(); ``` 1. **Implement the Event Handler with Dispatcher**: In WPF, you need to use the Dispatcher to update UI elements from non-UI threads. ``` private delegate void AudioVUMeterProVolumeDelegate(AudioLevelEventArgs e); private void AudioVUMeterProVolumeDelegateMethod(AudioLevelEventArgs e) { volumeMeter1.Amplitude = e.ChannelLevelsDb[0]; volumeMeter1.Update(); if (e.ChannelLevelsDb.Length > 1) { volumeMeter2.Amplitude = e.ChannelLevelsDb[1]; volumeMeter2.Update(); } } private void VideoCapture1_OnAudioVUMeterProVolume(object sender, AudioLevelEventArgs e) { Dispatcher.BeginInvoke(new AudioVUMeterProVolumeDelegate(AudioVUMeterProVolumeDelegateMethod), e); } ``` 1. **Clean Up After Playback**: When playback stops, clean up the VU meters to release resources. ``` volumeMeter1.Stop(); volumeMeter1.Clear(); volumeMeter2.Stop(); volumeMeter2.Clear(); ``` ### WPF Waveform Painter Implementation 1. **Add the Waveform Painter Control**: Add the waveform painter control to your XAML layout. ``` ``` 1. **Enable VU Meter Processing and Start the Waveform Painter**: ``` VideoCapture1.Audio_VUMeter_Pro_Enabled = true; waveformPainter.Start(); ``` 1. **Implement the Maximum Calculated Event Handler**: For waveform painters in WPF, we use a different event. ``` private delegate void AudioVUMeterProMaximumCalculatedDelegate(VUMeterMaxSampleEventArgs e); private void AudioVUMeterProMaximumCalculatedelegateMethod(VUMeterMaxSampleEventArgs e) { waveformPainter.AddValue(e.MaxSample, e.MinSample); } private void VideoCapture1_OnAudioVUMeterProMaximumCalculated(object sender, VUMeterMaxSampleEventArgs e) { Dispatcher.BeginInvoke(new AudioVUMeterProMaximumCalculatedDelegate(AudioVUMeterProMaximumCalculatedelegateMethod), e); } ``` 1. **Clean Up After Playback**: When playback stops, clean up the waveform painter. ``` waveformPainter.Stop(); waveformPainter.Clear(); ``` ## Advanced Customization Options Both the VU meter and waveform painter controls offer extensive customization options to match your application's design and user experience requirements. ### Customizing VU Meters The `VolumeMeter` control exposes the following real properties: - **`MinDb` / `MaxDb`**: decibel range displayed by the meter - **`Boost`**: gain multiplier applied before rendering - **`Orientation`**: horizontal or vertical bar direction - **`ForeColor`**: bar color (inherited from `Control`) - **`MinimalUpdateInterval`** (WPF only): throttles redraws Example of customizing a VU meter: ``` volumeMeter1.MinDb = -60; volumeMeter1.MaxDb = 6; volumeMeter1.Boost = 1.0f; volumeMeter1.ForeColor = System.Drawing.Color.Green; // WinForms volumeMeter1.Orientation = System.Windows.Forms.Orientation.Vertical; ``` ### Customizing Waveform Painters The `WaveformPainter` control has a small real surface: - **`Boost`** (WinForms): pre-render gain multiplier - **`ForeColor` / `BackColor`**: line and background colors (inherited from `Control`) - **`Clear()`**: resets the painted history - **`AddMax(float)`** (WinForms) / **`AddValue(float, float)`** (WPF): append a new sample Example of customizing a waveform painter: ``` waveformPainter.ForeColor = System.Drawing.Color.SkyBlue; waveformPainter.BackColor = System.Drawing.Color.Black; waveformPainter.Boost = 1.5f; ``` ## Performance Considerations When implementing audio visualization, consider these performance tips: 1. **Update Frequency**: Balance visual responsiveness with CPU usage by adjusting how frequently you update the visuals 2. **UI Thread Management**: Always update UI elements on the appropriate thread (especially important in WPF) 3. **Resource Cleanup**: Properly stop and clear visualization controls when not in use 4. **Buffering**: Consider implementing buffering for smoother visualization during high CPU usage ## Conclusion Implementing VU meters and waveform painters adds valuable visual feedback to media applications. Whether you're developing in WinForms or WPF, these audio visualization components help users monitor and understand audio levels and patterns more intuitively. By following the implementation steps outlined in this guide, you can enhance your .NET media applications with professional-quality audio visualization features that improve the overall user experience. --- For more code examples and related SDKs, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## Zoom Effects in C# .NET Video Apps with Pan Control **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/zoom-onvideoframebuffer/ **Description:** Apply zoom and pan effects in C# / .NET with VideoEffectZoom and VideoEffectPan — runtime-adjustable focal point for capture, playback, and editing. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, C# **API:** VideoEffectZoom, VideoEffectPan # Implementing Zoom Effects in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction Zoom and pan are a built-in video effect in the VisioForge classic (Windows / DirectShow) engines — `VideoCaptureCore`, `MediaPlayerCore`, and `VideoEditCore`. The `VideoEffectZoom` and `VideoEffectPan` classes handle scaling, centering, and runtime adjustments without touching the frame buffer directly. This is the recommended path when you want zoom. You only need to drop down to `OnVideoFrameBuffer` when `VideoEffectZoom` cannot express what you need — for example, a custom non-affine warp or integration with an external image library. ## Applying VideoEffectZoom (recommended) `VideoEffectZoom` gets added to the pipeline once and can be tweaked while video is playing. It scales every frame automatically — no per-frame C# code. ``` using VisioForge.Core.Types.VideoEffects; var zoomEffect = new VideoEffectZoom( zoomX: 2.0, // 2.0 = 200% horizontal zoom (1.0 = no zoom) zoomY: 2.0, // 2.0 = 200% vertical zoom — keep equal to zoomX for uniform scaling shiftX: 0, // Pixel offset from centre; positive shifts right shiftY: 0, // Pixel offset from centre; positive shifts down enabled: true, name: "Zoom"); // VideoCapture1 is a VideoCaptureCore instance (same API on MediaPlayerCore / VideoEditCore). VideoCapture1.Video_Effects_Enabled = true; VideoCapture1.Video_Effects_Add(zoomEffect); ``` ### Adjust zoom at runtime Keep a reference to the effect and modify its properties while the pipeline is running — the SDK picks up the new values on the next frame: ``` zoomEffect.ZoomX = 3.0; zoomEffect.ZoomY = 3.0; zoomEffect.ShiftX = 200; // Pan focus 200 px to the right of centre zoomEffect.ShiftY = -100; // And 100 px up ``` Toggling without removing: ``` zoomEffect.Enabled = false; // Bypass on the fly zoomEffect.Enabled = true; // Re-enable later ``` ### Interpolation quality `InterpolationMode` defaults to `VideoInterpolationMode.Bilinear`. For sharper results at higher zoom factors set it to a higher-quality mode; for lowest CPU set `NearestNeighbor`. ``` zoomEffect.InterpolationMode = VideoInterpolationMode.Bicubic; ``` ## Pairing with VideoEffectPan If you want smooth pan animation across a source that is larger than the output (for example, "Ken Burns" slow zoom over a still image), combine `VideoEffectZoom` with `VideoEffectPan` from the same namespace. Drive both from a timer or animation curve. ## Dropping down to OnVideoFrameBuffer Implement a custom zoom by hand only when `VideoEffectZoom` can't do what you need — for example, a non-affine warp, per-pixel magnification around the cursor, or integration with a third-party imaging library. You get the raw frame bytes, transform them in place (or into `e.Frame.Data`), and set `e.UpdateData = true` so the modified pixels flow downstream. ``` using System.Runtime.InteropServices; private void SDK_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { // e.Frame.Data — IntPtr to the pixel buffer // e.Frame.DataSize — buffer size in bytes // e.Frame.Info.Width / Info.Height / Info.Stride — frame dimensions (RAWBaseVideoInfo) // e.Frame.Timestamp — per-frame TimeSpan // 1. Read/copy bytes into your own scratch buffer: byte[] scratch = new byte[e.Frame.DataSize]; Marshal.Copy(e.Frame.Data, scratch, 0, e.Frame.DataSize); // 2. Apply whatever custom transform you need on the bytes of `scratch` // (resample, warp, composite, etc.). Keep the output size == input size // because the SDK will not negotiate a new resolution mid-pipeline. // 3. Write the result back into the original buffer: Marshal.Copy(scratch, 0, e.Frame.Data, e.Frame.DataSize); // 4. Tell the pipeline we mutated the pixels. e.UpdateData = true; } ``` ### X-engine note On the cross-platform X engines (`VideoCaptureCoreX`, `MediaPlayerCoreX`) the buffer arrives in `VideoFrameXBufferEventArgs`. Flat dimensions live directly on `e.Frame.Width` / `Height` / `Stride`, and frames are typically BGRA. For heavy pixel math, wrap the buffer in `SKPixmap` (SkiaSharp is already a transitive dependency of the X engines). ## Performance Considerations - Prefer `VideoEffectZoom` over the frame-buffer path — the native scaler is faster and thread-safe. - Reuse scratch buffers instead of allocating per frame. - Keep the output resolution equal to the input resolution from the handler — the pipeline does not renegotiate caps mid-stream. - Offload heavy CV / AI work to a worker thread; return quickly from the event handler to avoid back-pressure. ## Conclusion For virtually every application, `VideoEffectZoom` (optionally paired with `VideoEffectPan`) is the right tool — it's one line of setup, runtime-adjustable, and implemented in native code. `OnVideoFrameBuffer` remains available for the cases where you genuinely need to own the bytes. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Setting Zoom Parameters for Multiple Video Renderers **URL:** https://www.visioforge.com/help/docs/dotnet/general/code-samples/zoom-video-multiple-renderer/ **Description:** Configure independent zoom and position parameters for multiple video renderers across multi-screen displays in .NET multimedia applications. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET, Windows, C# **API:** VideoRendererType # Configuring Zoom Settings for Multiple Video Renderers in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) When developing multimedia applications that utilize multiple video renderers, controlling the zoom and position parameters independently for each display is essential for creating professional-quality user interfaces. This guide covers the implementation details, parameter configurations, and best practices for setting up multiple video renderers with customized zoom settings in your .NET applications. ## Understanding Multiple Renderer Configurations Multiple renderer support (also known as multiscreen functionality) allows your application to display video content across different display areas simultaneously. Each renderer can be configured with its own: - Zoom ratio (magnification level) - Horizontal shift (X-axis positioning) - Vertical shift (Y-axis positioning) This capability is particularly valuable for applications such as: - Video surveillance systems displaying multiple camera feeds - Media production software with preview and output windows - Medical imaging applications requiring different zoom levels for analysis - Multi-display kiosk systems with synchronized content ## Implementing the MultiScreen\_SetZoom Method The SDK provides the `MultiScreen_SetZoom` method which takes four key parameters: 1. **Screen Index** (zero-based): Identifies which renderer to configure 2. **Zoom Ratio**: Controls the magnification percentage 3. **Shift X**: Adjusts the horizontal positioning (pixels or percentage) 4. **Shift Y**: Adjusts the vertical positioning (pixels or percentage) ### Method Signature and Parameters ``` // Method signature void MultiScreen_SetZoom(int screenIndex, int zoomRatio, int shiftX, int shiftY); ``` | Parameter | Description | Valid Range | | --- | --- | --- | | screenIndex | Zero-based index of the target renderer | 0 to (number of renderers - 1) | | zoomRatio | Magnification percentage | 1 to 1000 (%) | | shiftX | Horizontal offset | -1000 to 1000 | | shiftY | Vertical offset | -1000 to 1000 | ## Code Sample: Configuring Multiple Renderers The following example demonstrates how to set different zoom and positioning values for three separate renderers: ``` // Configure the primary renderer (index 0) // 50% zoom with no horizontal or vertical shift VideoCapture1.MultiScreen_SetZoom(0, 50, 0, 0); // Configure the secondary renderer (index 1) // 20% zoom with slight horizontal and vertical shift VideoCapture1.MultiScreen_SetZoom(1, 20, 10, 20); // Configure the tertiary renderer (index 2) // 30% zoom with no horizontal shift but significant vertical shift VideoCapture1.MultiScreen_SetZoom(2, 30, 0, 30); ``` ## Best Practices for Multiple Renderer Management When implementing multiple renderer configurations, consider these best practices: ### 1. Initialize All Renderers Before Setting Zoom Always ensure that all renderers are properly initialized before applying zoom settings: ``` // Initialize multiple renderers VideoCapture1.MultiScreen_Enabled = true; // Add 3 renderers VideoCapture1.MultiScreen_AddScreen(videoView1, 1280, 720); VideoCapture1.MultiScreen_AddScreen(videoView2, 1920, 1080); VideoCapture1.MultiScreen_AddScreen(videoView3, 1280, 720); // Now safe to configure zoom settings VideoCapture1.MultiScreen_SetZoom(0, 50, 0, 0); VideoCapture1.MultiScreen_SetZoom(1, 20, 10, 20); VideoCapture1.MultiScreen_SetZoom(2, 30, 0, 30); // Additional configurations... ``` ### 2. Handle Resolution Changes Appropriately If the source format changes mid-session, read the current resolution from the `OnVideoFrameBuffer` callback (`e.Frame.Info.Width` / `e.Frame.Info.Height`) and re-apply zoom. Track the screen count yourself — `VideoCaptureCore` doesn't expose a `MultiScreen_Count` property; you know how many screens you added because you called `MultiScreen_AddScreen` yourself. ``` private int _multiScreenCount = 0; // incremented after each MultiScreen_AddScreen call private void VideoCapture1_OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { int newZoom = CalculateOptimalZoom(e.Frame.Info.Width, e.Frame.Info.Height); // Apply to all renderers you registered for (int i = 0; i < _multiScreenCount; i++) { VideoCapture1.MultiScreen_SetZoom(i, newZoom, 0, 0); } } ``` ### 3. Provide User Controls for Zoom Adjustment For interactive applications, consider implementing UI controls that allow users to adjust zoom settings: ``` private void zoomTrackBar_ValueChanged(object sender, EventArgs e) { int selectedRenderer = rendererComboBox.SelectedIndex; int zoomValue = zoomTrackBar.Value; int shiftX = horizontalShiftTrackBar.Value; int shiftY = verticalShiftTrackBar.Value; // Apply new zoom settings to selected renderer VideoCapture1.MultiScreen_SetZoom(selectedRenderer, zoomValue, shiftX, shiftY); } ``` ## Advanced Zoom Configurations ### Dynamic Zoom Transitions For smooth zoom transitions, consider implementing gradual zoom changes: ``` async Task AnimateZoomAsync(int screenIndex, int startZoom, int targetZoom, int duration) { int steps = 30; // Number of animation steps int delay = duration / steps; // Milliseconds between steps for (int i = 0; i <= steps; i++) { // Calculate intermediate zoom value int currentZoom = startZoom + ((targetZoom - startZoom) * i / steps); // Apply current zoom value VideoCapture1.MultiScreen_SetZoom(screenIndex, currentZoom, 0, 0); // Wait for next step await Task.Delay(delay); } } // Usage await AnimateZoomAsync(0, 50, 100, 1000); // Animate from 50% to 100% over 1 second ``` ## Optimizing Performance with Multiple Renderers When working with multiple renderers, be mindful of performance implications: 1. **Limit Frequent Updates**: Avoid rapidly changing zoom settings as it can impact performance 2. **Consider Hardware Acceleration**: Enable hardware acceleration when available 3. **Monitor Memory Usage**: Multiple high-resolution renderers can consume significant memory ``` // Use EVR renderer for hardware-accelerated composition on Windows. Renderer settings // live inside Video_Renderer (a VideoRendererSettings bag), not on the core directly. VideoCapture1.Video_Renderer.VideoRenderer = VideoRendererMode.EVR; VideoCapture1.Video_Renderer.Deinterlace_EVR_Mode = VideoRendererEVRDeinterlaceMode.Auto; ``` ## Troubleshooting Common Issues ### Issue: Renderers Show Black Screen After Zoom Changes This can occur when zoom values exceed valid ranges or when renderers aren't properly initialized: ``` // Reset zoom settings to default for all renderers you registered public void ResetZoomSettings() { for (int i = 0; i < _multiScreenCount; i++) { VideoCapture1.MultiScreen_SetZoom(i, 100, 0, 0); // 100% zoom, no shift } } ``` ### Issue: Distorted Image After Zoom Extreme zoom values can cause distortion. Implement boundaries for zoom values: ``` public void SetSafeZoom(int screenIndex, int requestedZoom, int shiftX, int shiftY) { // Clamp values to safe ranges int safeZoom = Math.Clamp(requestedZoom, 10, 200); // 10% to 200% int safeShiftX = Math.Clamp(shiftX, -100, 100); int safeShiftY = Math.Clamp(shiftY, -100, 100); VideoCapture1.MultiScreen_SetZoom(screenIndex, safeZoom, safeShiftX, safeShiftY); } ``` ## Conclusion Properly configured multiple video renderers with independent zoom settings can significantly enhance the user experience in multimedia applications. By following the guidelines and best practices outlined in this document, you can implement sophisticated video display configurations tailored to your specific application requirements. For additional code examples and implementation guidance, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## Record Another App's Audio on Android in C# and .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/guides/android-audio-playback-capture/ **Description:** Capture audio played by other Android apps in C# using AudioPlaybackCapture and MediaProjection with VideoCaptureCoreX and MediaBlocksPipeline. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, VideoCaptureCoreX, MediaBlocksPipeline, Android, MediaProjection, AudioPlaybackCapture, Capture, Recording, Audio, AAC, M4A, C#, NuGet **API:** VideoCaptureCoreX, MediaBlocksPipeline, AndroidAudioPlaybackCaptureSourceSettings, AndroidAudioPlaybackCaptureSourceBlock, M4AOutput # Record Another App's Audio on Android in C# and .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction This guide shows how to record the audio played by **another application** on Android in C# and .NET. The capture uses Android's `AudioPlaybackCapture` API together with a `MediaProjection` consent token (Android 10 / API 29 and newer) and writes the result to an AAC `.m4a` file. VisioForge exposes the feature through two engines, so you can pick the one that fits your app: the high-level `VideoCaptureCoreX` (declarative recording) and the low-level `MediaBlocksPipeline` (full graph control). For installation and package setup, see the [installation guide](../../../install/). The Android sample projects that this guide is based on ship with the SDK under `Video Capture SDK X/Android/Audio Playback Capture` and `Media Blocks SDK/Android/Audio Playback Capture`. ## How does audio playback capture work on Android? Android routes the audio of other apps through a special `REMOTE_SUBMIX` source that you can only open after the user grants a screen/audio capture consent dialog. Your app requests that consent, receives a `MediaProjection` token, and hands the token to the VisioForge source. The source opens the playback-capture `AudioRecord`, the SDK encodes the stream to AAC, and a muxer writes the `.m4a` file. ``` graph LR; app["Other app audio"] --> submix["REMOTE_SUBMIX (AudioPlaybackCapture)"]; submix --> src["AndroidAudioPlaybackCaptureSourceSettings / Block"]; src --> enc["AAC encoder"]; enc --> sink["M4A / MP4 file"]; ``` **Capture is restricted by design.** Only apps that publish audio with `usage` of `Media`, `Game`, or `Unknown` are capturable, and only when the app has **not** opted out via `android:allowAudioPlaybackCapture="false"`. Protected players (Spotify, Netflix, and most DRM-backed apps) opt out, so they produce silence. Test with locally played video or music files, or with your own app. ## Prerequisites and permissions - **Android 10 (API level 29) or newer.** Set `29.0` in the `.csproj`. - **Permissions and a foreground service** declared in `AndroidManifest.xml`. The service must use the `mediaProjection` foreground type, and on Android 14+ it must be started **after** the consent is granted. ``` ``` `RECORD_AUDIO` is a runtime permission — request it before starting capture. `INTERNET` is only needed if you stream the result; a pure file recorder can drop it. ## Requesting the MediaProjection token The token flow is identical for both engines. The order matters on Android 14+: request consent, then start the foreground service, then call `GetMediaProjection` once the service is in the foreground. First, kick off the system consent dialog when the user taps Start: ``` // _projectionManager = (MediaProjectionManager)GetSystemService(MediaProjectionService); StartActivityForResult(_projectionManager.CreateScreenCaptureIntent(), REQUEST_MEDIA_PROJECTION); ``` The foreground service exposes a `TaskCompletionSource` that is completed from `OnStartCommand`, so the activity can wait until the service is actually in the foreground state: ``` [Service(ForegroundServiceType = ForegroundService.TypeMediaProjection, Exported = false)] public class AudioCaptureService : Service { public static TaskCompletionSource ForegroundStarted { get; set; } public override IBinder OnBind(Intent intent) => null; public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { CreateNotificationChannel(); var notification = BuildNotification(); var tcs = ForegroundStarted; ForegroundStarted = null; try { if (Build.VERSION.SdkInt >= BuildVersionCodes.Q) { StartForeground(NOTIFICATION_ID, notification, ForegroundService.TypeMediaProjection); } else { StartForeground(NOTIFICATION_ID, notification); } tcs?.TrySetResult(true); } catch (Exception ex) { Android.Util.Log.Error("AudioCaptureService", ex.ToString()); tcs?.TrySetResult(false); } return StartCommandResult.Sticky; } } ``` Finally, in `OnActivityResult`, start the service and obtain the token after it is foregrounded: ``` protected override void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_MEDIA_PROJECTION && resultCode == Android.App.Result.Ok && data != null) { var projResultCode = (int)resultCode; var fgsTcs = new TaskCompletionSource(); AudioCaptureService.ForegroundStarted = fgsTcs; // Start the foreground service AFTER consent (required on Android 14+ / targetSDK 34+). var serviceIntent = new Intent(this, typeof(AudioCaptureService)); StartForegroundService(serviceIntent); _ = Task.Run(async () => { // Wait until the service reaches the foreground state. var completed = await Task.WhenAny(fgsTcs.Task, Task.Delay(5000)); if (completed != fgsTcs.Task) { return; } // GetMediaProjection must be called AFTER the FGS is in foreground state. _mediaProjection = _projectionManager.GetMediaProjection(projResultCode, data); await StartCaptureAsync(); }); } } ``` With `_mediaProjection` in hand, hand it to either engine below. ## How do I record app audio with VideoCaptureCoreX? `VideoCaptureCoreX` is the recommended path: you set the audio source and add an output, and the engine builds the graph for you. Because there is no camera here, create the engine without a `VideoView` and run it audio-only. ``` using VisioForge.Core.Types.X.Android.Sources; using VisioForge.Core.Types.X.Output; using VisioForge.Core.VideoCaptureX; private async Task StartCaptureCoreAsync() { // Audio-only capture: no VideoView, no video source. _core = new VideoCaptureCoreX(); _core.OnError += Core_OnError; // Audio playback capture source (records the audio of other apps via MediaProjection). _core.Audio_Source = new AndroidAudioPlaybackCaptureSourceSettings(_mediaProjection); _core.Audio_Play = false; // do not play the captured audio back through the speaker _core.Audio_Record = true; // route it into the output var musicDir = GetExternalFilesDir(Android.OS.Environment.DirectoryMusic); musicDir.Mkdirs(); _recordingFilename = Path.Combine(musicDir.AbsolutePath, $"appaudio_{DateTime.Now:yyyyMMdd_HHmmss}.m4a"); // M4A (AAC) audio-only output. autostart: true -> recording begins with StartAsync. _core.Outputs_Add(new M4AOutput(_recordingFilename), true); await _core.StartAsync(); } ``` To stop and finalize the file, stop and dispose the engine: ``` private async Task StopCaptureCoreAsync() { var core = Interlocked.Exchange(ref _core, null); if (core != null) { core.OnError -= Core_OnError; await core.StopAsync(); await core.DisposeAsync(); } StopService(new Intent(this, typeof(AudioCaptureService))); } ``` `M4AOutput` defaults to the `AVENCAACEncoderSettings` AAC encoder inside an MP4 container, so the result is a standard `.m4a` file. ## How do I record app audio with MediaBlocksPipeline? `MediaBlocksPipeline` gives you the explicit graph. You create the source, encoder, and sink blocks yourself and connect their pads. Use this when you need to insert custom processing (for example a volume block, a tee, or a network sink) between capture and the file. ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AudioEncoders; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.Types.X.Android.Sources; using VisioForge.Core.Types.X.Sinks; private async Task StartCaptureCoreAsync() { _pipeline = new MediaBlocksPipeline(); _pipeline.OnError += Pipeline_OnError; // Audio playback capture source (records the audio of other apps). var settings = new AndroidAudioPlaybackCaptureSourceSettings(_mediaProjection); _audioSource = new AndroidAudioPlaybackCaptureSourceBlock(settings); // AAC encoder + MP4/M4A sink. _audioEncoder = new AACEncoderBlock(); var musicDir = GetExternalFilesDir(Android.OS.Environment.DirectoryMusic); musicDir.Mkdirs(); _recordingFilename = Path.Combine(musicDir.AbsolutePath, $"appaudio_{DateTime.Now:yyyyMMdd_HHmmss}.m4a"); _sink = new MP4SinkBlock(new MP4SinkSettings(_recordingFilename)); // source -> encoder -> sink _pipeline.Connect(_audioSource.Output, _audioEncoder.Input); _pipeline.Connect(_audioEncoder.Output, (_sink as IMediaBlockDynamicInputs).CreateNewInput(MediaBlockPadMediaType.Audio)); await _pipeline.StartAsync(); } ``` ``` graph LR; src[AndroidAudioPlaybackCaptureSourceBlock] --> enc[AACEncoderBlock]; enc --> sink[MP4SinkBlock]; ``` Stop the pipeline the same way you stop any Media Blocks graph: ``` private async Task StopCaptureCoreAsync() { var pipeline = Interlocked.Exchange(ref _pipeline, null); if (pipeline != null) { pipeline.OnError -= Pipeline_OnError; await pipeline.StopAsync(force: false); await pipeline.DisposeAsync(); } StopService(new Intent(this, typeof(AudioCaptureService))); } ``` ## Which engine should I choose? Both engines use the same `AndroidAudioPlaybackCaptureSourceSettings` and produce the same kind of `.m4a` file. The difference is how much of the graph you manage. | Aspect | VideoCaptureCoreX | MediaBlocksPipeline | | --- | --- | --- | | Source | `Audio_Source = new AndroidAudioPlaybackCaptureSourceSettings(token)` | `new AndroidAudioPlaybackCaptureSourceBlock(settings)` | | Output | `Outputs_Add(new M4AOutput(file), true)` | `AACEncoderBlock` → `MP4SinkBlock` connected by hand | | Graph | Built by the engine | You connect every pad | | Best for | Quick recording with minimal code | Custom processing, multiple outputs, streaming | | Start / stop | `StartAsync` / `StopAsync` / `DisposeAsync` | `StartAsync` / `StopAsync` / `DisposeAsync` | Start with `VideoCaptureCoreX`; move to `MediaBlocksPipeline` when you need to branch the audio or add elements the high-level output does not expose. ## Saving the file to the device library Both samples write to the app's private external `Music` directory (`GetExternalFilesDir(DirectoryMusic)`) and then copy the finished file into the shared media library through `MediaStore` so it appears in music apps and file managers: ``` var values = new ContentValues(); values.Put(MediaStore.Audio.Media.InterfaceConsts.DisplayName, fileName); values.Put(MediaStore.Audio.Media.InterfaceConsts.MimeType, "audio/mp4"); values.Put(MediaStore.Audio.Media.InterfaceConsts.RelativePath, Android.OS.Environment.DirectoryMusic); var uri = ContentResolver.Insert(MediaStore.Audio.Media.ExternalContentUri, values); using var output = ContentResolver.OpenOutputStream(uri); using var input = new FileStream(filePath, FileMode.Open, FileAccess.Read); input.CopyTo(output); ``` ## Frequently Asked Questions ### Can I record audio from Spotify, Netflix, or YouTube? Generally no. Apps that play protected or DRM content set `android:allowAudioPlaybackCapture="false"` (or publish audio with a non-capturable `usage`), which excludes them from `AudioPlaybackCapture`. Capturing them produces silence. Test with locally played media or apps that allow capture. ### Does audio playback capture require root? No. It uses the public `AudioPlaybackCapture` API and a user-granted `MediaProjection` consent dialog. No root, no system signature, and no special OEM permission is needed. ### What is the minimum Android version? Android 10 (API level 29). `AudioPlaybackCapture` did not exist before API 29, so set `SupportedOSPlatformVersion` to `29.0`. On older devices the playback-capture source reports that it is not available and the capture cannot start. ### Can I capture another app's audio and the microphone at the same time? The source in this guide captures only playback audio. Mixing it with a microphone source requires adding a second audio source and an audio mixer to the graph — that is a separate topic and is best built on `MediaBlocksPipeline` for full control. ### Why is my recording silent? The two common causes are: the source app opted out of playback capture (protected content), or it simply was not producing sound during the capture window. Confirm with a plain local audio/video file playing audibly, and verify `RECORD_AUDIO` was granted and the foreground service started before `GetMediaProjection` was called. ## See Also - [Installation guide](../../../install/) — add the VisioForge .NET packages to your project - [Android implementation and deployment](../../../deployment-x/Android/) — NuGet setup and packaging for Android apps - [Audio capture and system sound recording](../../../videocapture/audio-capture/) — record the microphone and system audio in C# - [Audio encoder blocks](../../../mediablocks/AudioEncoders/) — AAC, MP3, FLAC, and Opus encoders for the Media Blocks pipeline - [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) — the high-level `VideoCaptureCoreX` engine - [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) — the low-level `MediaBlocksPipeline` engine ---END OF PAGE--- ## Capture Video to MPEG-TS with Hardware Encoding in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/guides/video-capture-to-mpegts/ **Description:** Capture video and audio to MPEG-TS files in C# with hardware acceleration, format selection, and cross-platform support for .NET applications. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Webcam, HLS, TS, H.264, AAC, C# **API:** VideoCaptureCoreX, MediaBlocksPipeline, DeviceEnumerator, MediaBlockPadMediaType, VideoView # Video Capture to MPEG-TS in C# and .NET: Complete Guide ## Introduction This technical guide demonstrates how to capture C# TS video from cameras and microphones using two powerful VisioForge multimedia solutions: Video Capture SDK .NET with VideoCaptureCoreX engine and Media Blocks SDK .NET with MediaBlocksPipeline engine. Both SDKs provide robust capabilities for capturing, recording, and editing TS (MPEG Transport Stream) files in .NET applications. We'll explore detailed code samples for implementing video/audio capture to TS in C# with optimized performance and quality. ## Installation and deployment Please refer to the [installation guide](../../../install/) for detailed instructions on how to install the VisioForge .NET SDKs on your system. ## Video Capture SDK .NET (VideoCaptureCoreX) - Capture MPEG-TS in C VideoCaptureCoreX provides a streamlined approach to capture TS video and audio in C#. Its component-based architecture handles the complex media pipeline, allowing developers to focus on configuration rather than lower-level implementation details when working with TS files in .NET. ### Core Components 1. **VideoCaptureCoreX**: Main engine for managing video capture, rendering, and TS output. 2. **VideoView**: UI component for real-time video rendering during capture. 3. **DeviceEnumerator**: Class for discovering video/audio devices. 4. **VideoCaptureDeviceSourceSettings**: Configuration for camera input when capturing MPEG-TS. 5. **AudioRendererSettings**: Configuration for audio playback with AAC support. 6. **MPEGTSOutput**: Configuration specifically for MPEG-TS file output. ### Implementation Example Here's a complete C# implementation to capture and record MPEG-TS files: ``` // Class instance for video capture engine VideoCaptureCoreX videoCapture; private async Task StartCaptureAsync() { // Initialize the VisioForge SDK await VisioForgeX.InitSDKAsync(); // Create VideoCaptureCoreX instance and associate with UI VideoView control videoCapture = new VideoCaptureCoreX(videoView: VideoView1); // Get list of available video capture devices var videoSources = await DeviceEnumerator.Shared.VideoSourcesAsync(); // Initialize video source settings VideoCaptureDeviceSourceSettings videoSourceSettings = null; // Get first available video capture device var videoDevice = videoSources[0]; // Try to get HD resolution and frame rate capabilities from device var videoFormat = videoDevice.GetHDVideoFormatAndFrameRate(out VideoFrameRate frameRate); if (videoFormat != null) { // Configure video source with HD format videoSourceSettings = new VideoCaptureDeviceSourceSettings(videoDevice) { Format = videoFormat.ToFormat() }; // Set capture frame rate videoSourceSettings.Format.FrameRate = frameRate; } // Configure video capture device with settings videoCapture.Video_Source = videoSourceSettings; // Configure audio capture (microphone) // Initialize audio source settings IVideoCaptureBaseAudioSourceSettings audioSourceSettings = null; // Get available audio capture devices using DirectSound API var audioApi = AudioCaptureDeviceAPI.DirectSound; var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync(audioApi); // Get first available audio capture device var audioDevice = audioDevices[0]; if (audioDevice != null) { // Get default audio format supported by device var audioFormat = audioDevice.GetDefaultFormat(); if (audioFormat != null) { // Configure audio source with default format audioSourceSettings = audioDevice.CreateSourceSettingsVC(audioFormat); } } // Configure audio capture device with settings videoCapture.Audio_Source = audioSourceSettings; // Configure audio playback device // Get first available audio output device var audioOutputDevice = (await DeviceEnumerator.Shared.AudioOutputsAsync())[0]; // Configure audio renderer for playback through selected device videoCapture.Audio_OutputDevice = new AudioRendererSettings(audioOutputDevice); // Enable audio monitoring and recording videoCapture.Audio_Play = true; // Enable real-time audio monitoring videoCapture.Audio_Record = true; // Enable audio recording to output file // Configure MPEG Transport Stream output var mpegtsOutput = new MPEGTSOutput("output.ts"); // Configure video encoder with hardware acceleration if available if (NVENCH264EncoderSettings.IsAvailable()) { // Use NVIDIA hardware encoder mpegtsOutput.Video = new NVENCH264EncoderSettings(); } else if (QSVH264EncoderSettings.IsAvailable()) { // Use Intel Quick Sync hardware encoder mpegtsOutput.Video = new QSVH264EncoderSettings(); } else if (AMFH264EncoderSettings.IsAvailable()) { // Use AMD hardware encoder mpegtsOutput.Video = new AMFH264EncoderSettings(); } else { // Fallback to software encoder mpegtsOutput.Video = new OpenH264EncoderSettings(); } // Configure audio encoder for MPEG-TS output // mpegtsOutput.Audio = ... // Add MPEG-TS output to capture pipeline // autostart: true means output starts automatically with capture videoCapture.Outputs_Add(mpegtsOutput, autostart: true); // Start the capture process await videoCapture.StartAsync(); } private async Task StopCaptureAsync() { // Stop all capture and encoding await videoCapture.StopAsync(); // Clean up resources await videoCapture.DisposeAsync(); } ``` ### VideoCaptureCoreX Advanced Features for MPEG-TS Recording 1. **Hardware Acceleration**: Support for NVIDIA (NVENC), Intel (QSV), and AMD (AMF) hardware encoding. 2. **Format Selection**: The SDK provides access to the native camera formats and frame rates. 3. **Audio Configuration**: Provides volume control and format selection. 4. **Multiple Outputs**: Ability to add multiple output formats simultaneously. ## Media Blocks SDK .NET (MediaBlocksPipeline) - Capture TS in C The MediaBlocksPipeline engine in Media Blocks SDK .Net takes a different architectural approach, focusing on a modular block-based system where each component (block) has specific responsibilities in the media processing pipeline. ### Core Blocks 1. **MediaBlocksPipeline**: The main container and controller for the media blocks pipeline. 2. **SystemVideoSourceBlock**: Captures video from webcams. 3. **SystemAudioSourceBlock**: Captures audio from microphones. 4. **VideoRendererBlock**: Renders the video to a VideoView control. 5. **AudioRendererBlock**: Handles audio playback. 6. **TeeBlock**: Splits media streams for simultaneous processing (e.g., display and encoding). 7. **H264EncoderBlock**: Encodes video using H.264. 8. **AACEncoderBlock**: Encodes audio using AAC. 9. **MPEGTSSinkBlock**: Saves encoded streams to an MPEG-TS file. ### Implementation Example Here's how to implement advanced capture of TS files in C#: ``` // Pipeline instance MediaBlocksPipeline pipeline; private async Task StartCaptureAsync() { // Initialize the SDK await VisioForgeX.InitSDKAsync(); // Create new pipeline instance pipeline = new MediaBlocksPipeline(); // Get first available video device and configure HD format var device = (await DeviceEnumerator.Shared.VideoSourcesAsync())[0]; var formatItem = device.GetHDVideoFormatAndFrameRate(out VideoFrameRate frameRate); var videoSourceSettings = new VideoCaptureDeviceSourceSettings(device) { Format = formatItem.ToFormat() }; videoSourceSettings.Format.FrameRate = frameRate; // Create video source block with configured settings var videoSource = new SystemVideoSourceBlock(videoSourceSettings); // Get first available audio device and configure default format var audioDevice = (await DeviceEnumerator.Shared.AudioSourcesAsync())[0]; var audioFormat = audioDevice.GetDefaultFormat(); var audioSourceSettings = audioDevice.CreateSourceSettings(audioFormat); var audioSource = new SystemAudioSourceBlock(audioSourceSettings); // Create video renderer block and connect to UI VideoView control var videoRenderer = new VideoRendererBlock(pipeline, videoView: VideoView1) { IsSync = false }; // Create audio renderer block for playback var audioRenderer = new AudioRendererBlock() { IsSync = false }; // Note: IsSync is false to maximize encoding performance // Create video and audio tees var videoTee = new TeeBlock(2, MediaBlockPadMediaType.Video); var audioTee = new TeeBlock(2, MediaBlockPadMediaType.Audio); // Create MPEG-TS muxer var muxer = new MPEGTSSinkBlock(new MPEGTSSinkSettings("output.ts")); // Create video and audio encoders with hardware acceleration if available var videoEncoder = new H264EncoderBlock(); var audioEncoder = new AACEncoderBlock(); // Connect video processing blocks: // Source -> Tee -> Renderer (preview) and Encoder -> Muxer pipeline.Connect(videoSource.Output, videoTee.Input); pipeline.Connect(videoTee.Outputs[0], videoRenderer.Input); pipeline.Connect(videoTee.Outputs[1], videoEncoder.Input); pipeline.Connect(videoEncoder.Output, (muxer as IMediaBlockDynamicInputs).CreateNewInput(MediaBlockPadMediaType.Video)); // Connect audio processing blocks: // Source -> Tee -> Renderer (playback) and Encoder -> Muxer pipeline.Connect(audioSource.Output, audioTee.Input); pipeline.Connect(audioTee.Outputs[0], audioRenderer.Input); pipeline.Connect(audioTee.Outputs[1], audioEncoder.Input); pipeline.Connect(audioEncoder.Output, (muxer as IMediaBlockDynamicInputs).CreateNewInput(MediaBlockPadMediaType.Audio)); // Start the pipeline processing await pipeline.StartAsync(); } private async Task StopCaptureAsync() { // Stop all pipeline processing await pipeline.StopAsync(); // Clean up resources await pipeline.DisposeAsync(); pipeline = null; } ``` ### MediaBlocksPipeline Advanced Features 1. **Fine-Grained Control**: Direct control over each processing step in the pipeline. 2. **Dynamic Pipeline Construction**: Ability to create complex processing pipelines by connecting blocks. 3. **Multiple Processing Paths**: Using TeeBlock to split streams for different processing paths. 4. **Custom Blocks**: Ability to create and integrate custom processing blocks. 5. **Granular Error Handling**: Error events at each block level. ## TS Output Configuration with AAC Audio Both SDKs provide robust support for MPEG-TS output, which is particularly useful for broadcasting and streaming applications due to its error resilience and low latency characteristics. ### File Splitting for MPEG-TS Recording Both SDKs support automatic file splitting for MPEG-TS output, enabling segmented recording based on duration, file size, or timecode. This is essential for: - **HLS Streaming**: Create segmented files for HTTP Live Streaming - **Storage Management**: Limit file sizes and implement rolling buffers - **DVR Functionality**: Record continuous streams with automatic file rotation - **Time-Lapse Recording**: Split recordings at regular intervals #### Using File Splitting with VideoCaptureCoreX ``` using VisioForge.Core.Types.X.Sinks; // Create split settings for 5-minute segments var mpegtsOutput = new MPEGTSOutput("recording_%05d.ts", useAAC: true); mpegtsOutput.Sink = new MPEGTSSplitSinkSettings("recording_%05d.ts") { SplitDuration = TimeSpan.FromMinutes(5), // New file every 5 minutes SplitMaxFiles = 12, // Keep only last 12 files (1 hour total) M2TSMode = false }; // Add to capture pipeline videoCapture.Outputs_Add(mpegtsOutput, autostart: true); ``` #### Using File Splitting with MediaBlocksPipeline ``` using VisioForge.Core.Types.X.Sinks; using VisioForge.Core.MediaBlocks.Sinks; // Create MPEG-TS muxer with split settings var splitSettings = new MPEGTSSplitSinkSettings("output_%05d.ts") { SplitDuration = TimeSpan.FromMinutes(10), // Split every 10 minutes SplitFileSize = 100 * 1024 * 1024, // Or when file reaches 100 MB SplitMaxFiles = 6, // Keep last 6 files StartIndex = 0 }; var muxer = new MPEGTSSinkBlock(splitSettings); // Connect video and audio encoders to the muxer pipeline.Connect(videoEncoder.Output, (muxer as IMediaBlockDynamicInputs).CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(audioEncoder.Output, (muxer as IMediaBlockDynamicInputs).CreateNewInput(MediaBlockPadMediaType.Audio)); ``` #### Split Configuration Options The `MPEGTSSplitSinkSettings` class provides several options: - **SplitDuration**: Maximum duration per file (TimeSpan) - **SplitFileSize**: Maximum file size in bytes (ulong) - **SplitMaxSizeTimecode**: Split based on timecode difference (string, format: "HH:MM:SS:FF") - **SplitMaxFiles**: Maximum number of files to keep; older files are automatically deleted (uint, 0 = unlimited) - **StartIndex**: Starting index for segment numbering (int) - **M2TSMode**: Use Blu-ray M2TS format with 192-byte packets (bool) Files will be split when **any** of the configured criteria (duration, size, or timecode) is met first. #### Filename Pattern The filename pattern uses printf-style formatting for segment numbers: - `"video_%05d.ts"` → `video_00000.ts`, `video_00001.ts`, ... - `"stream_%02d.ts"` → `stream_00.ts`, `stream_01.ts`, ... Read more about video and audio encoders available for TS capture in .NET: - [H264 encoders](../../video-encoders/h264/) - [HEVC encoders](../../video-encoders/hevc/) - [AAC encoders](../../audio-encoders/aac/) - [MP3 encoders](../../audio-encoders/mp3/) - [MPEG-TS output](../../output-formats/mpegts/) ## Cross-Platform Considerations Both SDKs offer cross-platform capabilities, but with different approaches: 1. **VideoCaptureCoreX**: Provides a unified API across platforms with platform-specific implementations. 2. **MediaBlocksPipeline**: Uses a consistent block-based architecture across platforms, with blocks handling platform differences internally. ## Sample applications - [VideoCaptureCoreX Sample Application](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Video%20Capture%20SDK%20X/WPF/CSharp/Simple%20Video%20Capture) - [MediaBlocksPipeline Sample Application](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK/WPF/CSharp/Simple%20Capture%20Demo) ## Conclusion: Choosing the Right SDK for C# MPEG-TS Capture VisioForge offers two powerful solutions for recording MPEG-TS files in C# and .NET: - **VideoCaptureCoreX** provides a streamlined API for quick implementation of MPEG-TS capture in C#, ideal for projects where ease of use is essential. - **MediaBlocksPipeline** offers maximum flexibility for complex MPEG-TS recording and editing scenarios in .NET through its modular block architecture. Both SDKs excel at capturing video from cameras and audio from microphones, with comprehensive support for MPEG-TS output, making them valuable tools for developing a wide range of multimedia applications. Choose VideoCaptureCoreX for rapid implementation of standard TS capture scenarios, or MediaBlocksPipeline for advanced editing and custom processing workflows with TS files in your .NET applications. ---END OF PAGE--- ## WMA Audio Recording and Editing in .NET SDK with C# **URL:** https://www.visioforge.com/help/docs/dotnet/general/guides/wma-recording-editing/ **Description:** Record WMA audio from microphone and edit WMA files in .NET with VideoCaptureCoreX and VideoEditCoreX classes for Windows Media Audio capture and editing. **Tags:** Video Capture SDK, Video Edit SDK, .NET, VideoCaptureCoreX, VideoEditCoreX, Windows, WinForms, GStreamer, Capture, Encoding, Editing, Effects, MP3, WMA, C#, NuGet **API:** VideoEditCoreX, VideoCaptureCoreX, WMAOutput, WMAEncoderSettings, AudioFileSource # Record and Edit WMA Files in C# and .NET: A Comprehensive Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) ## Introduction to WMA Recording and Editing in .NET This article provides a comprehensive guide for developers working with Windows Media Audio (WMA) files in .NET applications. We'll explore how to record .NET WMA audio from microphones and other capture devices using the VideoCaptureCoreX class, and how to edit dotnet WMA files using the VideoEditCoreX class from the VisioForge .NET SDKs. Windows Media Audio is a popular audio format developed by Microsoft that offers excellent compression while maintaining good audio quality. The WMA format is widely used in Windows applications and supports various bitrates and sample rates, making it suitable for both voice records and high-quality music. The VisioForge library provides powerful classes for capturing audio data from system devices and processing audio video content. Whether you need to create a simple voice recorder console application or a complex WinForms audio editor, these SDKs deliver the functionality you need. This guide will show you how to capture dotnet WMA audio and record csharp WMA files with ease. ## Prerequisites and Installation Before you begin recording or editing WMA files in your dotnet application, ensure you have the following: - Visual Studio 2019 or later - .NET 6.0 or later (or .NET Framework 4.7.2+) - VisioForge Video Capture SDK .NET or Video Edit SDK .NET ### Installing the NuGet Packages Install the required packages using the NuGet Package Manager: ``` # For WMA recording with VideoCaptureCoreX Install-Package VisioForge.DotNet.VideoCapture # For WMA editing with VideoEditCoreX Install-Package VisioForge.DotNet.VideoEdit ``` For detailed installation instructions, please refer to the [installation guide](../../../install/). ## Recording WMA Files from Microphone Using VideoCaptureCoreX The VideoCaptureCoreX class provides a straightforward approach to capture csharp WMA audio from microphones and other audio input devices. This section demonstrates how to record csharp WMA audio files with proper device enumeration and encoder configuration. Learn how to capture csharp WMA content for various application scenarios. ### Core Components for WMA Recording 1. **VideoCaptureCoreX**: Main engine class for managing audio capture and WMA output in .NET. 2. **DeviceEnumerator**: Class for discovering available audio capture devices on the system. 3. **AudioCaptureDeviceSourceSettings**: Configuration settings for microphone or audio input device. 4. **WMAOutput**: Output format configuration specifically for Windows Media Audio file creation. 5. **WMAEncoderSettings**: Settings class for WMA encoder parameters like bitrate and sample rate. ### Basic WMA Recording Implementation Here's a complete csharp implementation to capture and record WMA files from a microphone: ``` using System; using System.IO; using System.Linq; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.VideoCaptureX; public class WmaRecorder { private VideoCaptureCoreX _videoCapture; // Call this method once during application startup or form load public async Task InitializeAsync() { // Initialize the VisioForge SDK await VisioForgeX.InitSDKAsync(); } public async Task StartRecordingAsync(string outputPath) { // Create VideoCaptureCoreX instance for audio capture _videoCapture = new VideoCaptureCoreX(); // Configure audio capture device (microphone) await ConfigureAudioSourceAsync(); // Disable video capture - we only need audio _videoCapture.Video_Source = null; _videoCapture.Video_Play = false; // Configure audio settings _videoCapture.Audio_Play = false; // Disable audio monitoring during recording _videoCapture.Audio_Record = true; // Enable audio recording to file // Configure WMA output format var wmaOutput = new WMAOutput(outputPath); // Configure WMA encoder settings wmaOutput.Audio.Bitrate = 192; // 192 Kbps bitrate wmaOutput.Audio.SampleRate = 48000; // 48 kHz sample rate wmaOutput.Audio.Channels = 2; // Stereo recording // Add WMA output to capture pipeline _videoCapture.Outputs_Add(wmaOutput, autostart: true); // Start the audio capture process await _videoCapture.StartAsync(); Console.WriteLine("Recording started. Press any key to stop..."); } private async Task ConfigureAudioSourceAsync() { // Get available audio capture devices using DirectSound API var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync( AudioCaptureDeviceAPI.DirectSound); if (audioDevices.Length == 0) { throw new Exception("No audio capture device found."); } // Get first available audio capture device (usually the default microphone) var audioDevice = audioDevices[0]; // Get supported format from the device var audioFormat = audioDevice.GetDefaultFormat(); // Create audio source settings with the selected device and format var audioSourceSettings = audioDevice.CreateSourceSettingsVC(audioFormat); // Configure audio capture device _videoCapture.Audio_Source = audioSourceSettings; } public async Task StopRecordingAsync() { if (_videoCapture != null) { // Stop all capture and encoding await _videoCapture.StopAsync(); // Clean up resources await _videoCapture.DisposeAsync(); _videoCapture = null; Console.WriteLine("Recording stopped and file saved."); } } } ``` ### Console Application Example for WMA Recording Here's a complete console application that records WMA audio from a microphone: ``` using System; using System.IO; using System.Linq; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.VideoCaptureX; class Program { static async Task Main(string[] args) { Console.WriteLine("WMA Audio Recorder - Console Application"); Console.WriteLine("========================================"); // Initialize SDK await VisioForgeX.InitSDKAsync(); // Create capture instance var videoCapture = new VideoCaptureCoreX(); try { // Enumerate and display available audio capture devices var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync( AudioCaptureDeviceAPI.DirectSound); Console.WriteLine("\nAvailable audio capture devices:"); for (int i = 0; i < audioDevices.Length; i++) { Console.WriteLine($" {i + 1}. {audioDevices[i].DisplayName}"); } if (audioDevices.Length == 0) { Console.WriteLine("No audio capture device found. Exiting."); return; } // Select first device for recording var selectedDevice = audioDevices[0]; var audioFormat = selectedDevice.GetDefaultFormat(); var audioSourceSettings = selectedDevice.CreateSourceSettingsVC(audioFormat); // Configure video capture for audio-only recording videoCapture.Audio_Source = audioSourceSettings; videoCapture.Video_Source = null; videoCapture.Video_Play = false; videoCapture.Audio_Play = false; videoCapture.Audio_Record = true; // Configure WMA output file string outputPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), $"recording_{DateTime.Now:yyyyMMdd_HHmmss}.wma"); var wmaOutput = new WMAOutput(outputPath); wmaOutput.Audio.Bitrate = 192; wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; videoCapture.Outputs_Add(wmaOutput, autostart: true); // Start recording Console.WriteLine($"\nRecording to: {outputPath}"); Console.WriteLine("Press ENTER to stop recording...\n"); await videoCapture.StartAsync(); // Wait for user input to stop Console.ReadLine(); // Stop recording await videoCapture.StopAsync(); Console.WriteLine($"\nRecording saved to: {outputPath}"); } finally { // Cleanup await videoCapture.DisposeAsync(); VisioForgeX.DestroySDK(); } } } ``` ### WinForms Application for WMA Recording For a Windows Forms application with visual controls, here's an implementation example: ``` using System; using System.IO; using System.Linq; using System.Windows.Forms; using VisioForge.Core; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.VideoCaptureX; public partial class WmaRecorderForm : Form { private VideoCaptureCoreX _videoCapture; private bool _isRecording = false; public WmaRecorderForm() { InitializeComponent(); } private async void Form_Load(object sender, EventArgs e) { // Initialize SDK await VisioForgeX.InitSDKAsync(); // Populate audio device dropdown var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync( AudioCaptureDeviceAPI.DirectSound); foreach (var device in audioDevices) { cmbAudioDevices.Items.Add(device.DisplayName); } if (cmbAudioDevices.Items.Count > 0) { cmbAudioDevices.SelectedIndex = 0; } // Set default output path txtOutputPath.Text = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), "recording.wma"); } private async void btnStartStop_Click(object sender, EventArgs e) { if (!_isRecording) { await StartRecordingAsync(); } else { await StopRecordingAsync(); } } private async Task StartRecordingAsync() { _videoCapture = new VideoCaptureCoreX(); // Get selected audio device var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync( AudioCaptureDeviceAPI.DirectSound); var selectedDevice = audioDevices.FirstOrDefault( d => d.DisplayName == cmbAudioDevices.SelectedItem.ToString()); if (selectedDevice == null) { MessageBox.Show("Please select an audio device."); return; } // Configure audio source var audioFormat = selectedDevice.GetDefaultFormat(); var audioSourceSettings = selectedDevice.CreateSourceSettingsVC(audioFormat); _videoCapture.Audio_Source = audioSourceSettings; // Configure for audio-only capture _videoCapture.Video_Source = null; _videoCapture.Video_Play = false; _videoCapture.Audio_Play = false; _videoCapture.Audio_Record = true; // Configure WMA output var wmaOutput = new WMAOutput(txtOutputPath.Text); wmaOutput.Audio.Bitrate = (int)numBitrate.Value; wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = rbStereo.Checked ? 2 : 1; _videoCapture.Outputs_Add(wmaOutput, autostart: true); // Start recording await _videoCapture.StartAsync(); _isRecording = true; btnStartStop.Text = "Stop Recording"; lblStatus.Text = "Recording..."; } private async Task StopRecordingAsync() { if (_videoCapture != null) { await _videoCapture.StopAsync(); await _videoCapture.DisposeAsync(); _videoCapture = null; } _isRecording = false; btnStartStop.Text = "Start Recording"; lblStatus.Text = "Recording saved."; } private void Form_FormClosing(object sender, FormClosingEventArgs e) { if (_isRecording) { StopRecordingAsync().Wait(); } VisioForgeX.DestroySDK(); } } ``` ### Advanced Audio Capture Settings The VideoCaptureCoreX class supports various audio capture configurations for different recording scenarios: ``` // Configure high-quality WMA recording var wmaOutput = new WMAOutput("high_quality.wma"); wmaOutput.Audio.Bitrate = 320; // Maximum quality bitrate wmaOutput.Audio.SampleRate = 48000; // Professional sample rate wmaOutput.Audio.Channels = 2; // Stereo // Configure voice recording (smaller file size) var voiceOutput = new WMAOutput("voice_memo.wma"); voiceOutput.Audio.Bitrate = 128; // Good for voice voiceOutput.Audio.SampleRate = 44100; // Standard sample rate voiceOutput.Audio.Channels = 1; // Mono is sufficient for voice // Check if WMA encoder is available on the system if (!WMAEncoderSettings.IsAvailable()) { Console.WriteLine("WMA encoder is not available on this system."); // Consider falling back to MP3 or other format } ``` ## Editing WMA Files Using VideoEditCoreX The VideoEditCoreX class provides powerful capabilities for editing WMA files and converting audio video content to Windows Media format. This section demonstrates how to edit dotnet WMA files with trimming, merging, and format conversion. ### Core Components for WMA Editing 1. **VideoEditCoreX**: Main engine class for managing audio and video editing operations. 2. **AudioFileSource**: Class for adding audio file sources to the editing timeline. 3. **WMAOutput**: Output format configuration for Windows Media Audio export. 4. **Audio\_Effects**: Collection for applying audio effects during editing. ### Basic WMA File Editing Here's how to edit WMA files using the VideoEditCoreX class: ``` using System; using System.IO; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.VideoEdit; using VisioForge.Core.VideoEditX; public class WmaEditor { private VideoEditCoreX _videoEdit; // Call this method once during application startup or form load public async Task InitializeAsync() { // Initialize the VisioForge SDK await VisioForgeX.InitSDKAsync(); } public async Task EditWmaFileAsync( string inputPath, string outputPath, TimeSpan? startTime = null, TimeSpan? endTime = null) { // Create VideoEditCoreX instance _videoEdit = new VideoEditCoreX(); // Set up event handlers _videoEdit.OnProgress += VideoEdit_OnProgress; _videoEdit.OnStop += VideoEdit_OnStop; _videoEdit.OnError += VideoEdit_OnError; // Add input WMA file with optional trimming var audioFile = new AudioFileSource( inputPath, startTime, // Start time for trimming (null for beginning) endTime); // End time for trimming (null for end) _videoEdit.Input_AddAudioFile(audioFile, insertTime: null); // Configure WMA output format var wmaOutput = new WMAOutput(outputPath); wmaOutput.Audio.Bitrate = 192; wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; _videoEdit.Output_Format = wmaOutput; // Start the editing process _videoEdit.Start(); Console.WriteLine("Editing in progress..."); } private void VideoEdit_OnProgress(object sender, ProgressEventArgs e) { Console.WriteLine($"Progress: {e.Progress}%"); } private void VideoEdit_OnStop(object sender, StopEventArgs e) { if (e.Successful) { Console.WriteLine("Editing completed successfully!"); } else { Console.WriteLine("Editing stopped with errors."); } // Cleanup _videoEdit?.Dispose(); _videoEdit = null; } private void VideoEdit_OnError(object sender, ErrorsEventArgs e) { Console.WriteLine($"Error: {e.Message}"); } } ``` ### Merging Multiple WMA Files The VideoEditCoreX class allows you to merge multiple audio files into a single WMA output: ``` using System; using System.Collections.Generic; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.VideoEdit; using VisioForge.Core.VideoEditX; public class WmaMerger { // Call this method once during application startup or form load public async Task InitializeAsync() { // Initialize SDK await VisioForgeX.InitSDKAsync(); } public async Task MergeWmaFilesAsync( List inputFiles, string outputPath) { var videoEdit = new VideoEditCoreX(); try { // Set up progress reporting videoEdit.OnProgress += (s, e) => Console.WriteLine($"Merging progress: {e.Progress}%"); videoEdit.OnError += (s, e) => Console.WriteLine($"Error: {e.Message}"); // Add each input file sequentially foreach (var inputFile in inputFiles) { var audioFile = new AudioFileSource(inputFile); // Adding with null insertTime appends to end of timeline videoEdit.Input_AddAudioFile(audioFile, insertTime: null); Console.WriteLine($"Added: {inputFile}"); } // Configure output format var wmaOutput = new WMAOutput(outputPath); wmaOutput.Audio.Bitrate = 192; wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; videoEdit.Output_Format = wmaOutput; // Create completion signal var completionSource = new TaskCompletionSource(); videoEdit.OnStop += (s, e) => completionSource.SetResult(e.Successful); // Start merging videoEdit.Start(); // Wait for completion bool success = await completionSource.Task; if (success) { Console.WriteLine($"Files merged successfully to: {outputPath}"); } else { Console.WriteLine("Merge operation failed."); } } finally { videoEdit.Dispose(); VisioForgeX.DestroySDK(); } } } ``` ### Trimming WMA Files Extract a specific portion of a WMA file: ``` // Note: Call VisioForgeX.InitSDKAsync() once during application startup or form load public async Task TrimWmaFileAsync( string inputPath, string outputPath, TimeSpan startTime, TimeSpan endTime) { var videoEdit = new VideoEditCoreX(); try { // Add input file with specific start and end times var audioFile = new AudioFileSource( inputPath, startTime, // e.g., TimeSpan.FromSeconds(10) endTime); // e.g., TimeSpan.FromSeconds(60) videoEdit.Input_AddAudioFile(audioFile, insertTime: null); // Configure WMA output var wmaOutput = new WMAOutput(outputPath); wmaOutput.Audio.Bitrate = 192; wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; videoEdit.Output_Format = wmaOutput; // Create completion signal var completionSource = new TaskCompletionSource(); videoEdit.OnStop += (s, e) => completionSource.SetResult(e.Successful); // Start trimming videoEdit.Start(); // Wait for completion bool success = await completionSource.Task; Console.WriteLine(success ? "Trim completed successfully!" : "Trim operation failed."); } finally { videoEdit.Dispose(); } } ``` ### Converting Video Files to WMA Audio Extract audio from video files and save as WMA: ``` // Note: Call VisioForgeX.InitSDKAsync() once during application startup or form load public async Task ExtractAudioToWmaAsync( string videoInputPath, string wmaOutputPath) { var videoEdit = new VideoEditCoreX(); try { // Add video file - audio will be extracted automatically var audioFile = new AudioFileSource(videoInputPath); videoEdit.Input_AddAudioFile(audioFile, insertTime: null); // Configure WMA output for audio extraction var wmaOutput = new WMAOutput(wmaOutputPath); wmaOutput.Audio.Bitrate = 256; // Higher quality for music wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; videoEdit.Output_Format = wmaOutput; var completionSource = new TaskCompletionSource(); videoEdit.OnProgress += (s, e) => Console.WriteLine($"Extraction progress: {e.Progress}%"); videoEdit.OnStop += (s, e) => completionSource.SetResult(e.Successful); videoEdit.Start(); bool success = await completionSource.Task; Console.WriteLine(success ? $"Audio extracted to: {wmaOutputPath}" : "Audio extraction failed."); } finally { videoEdit.Dispose(); } } ``` ### Applying Audio Effects During WMA Editing The VideoEditCoreX class supports various audio effects that can be applied during the editing process: ``` using VisioForge.Core.Types.X.AudioEffects; // Note: Call VisioForgeX.InitSDKAsync() once during application startup or form load public async Task EditWmaWithEffectsAsync( string inputPath, string outputPath) { var videoEdit = new VideoEditCoreX(); try { // Add input file var audioFile = new AudioFileSource(inputPath); videoEdit.Input_AddAudioFile(audioFile, insertTime: null); // Apply audio effects // Volume amplification effect var amplifyEffect = new AmplifyAudioEffect(1.5); // 150% volume videoEdit.Audio_Effects.Add(amplifyEffect); // 10-band equalizer effect var eqLevels = new double[] { 3.0, // 60 Hz 2.0, // 170 Hz 1.0, // 310 Hz 0.0, // 600 Hz 0.0, // 1 kHz 0.0, // 3 kHz 1.0, // 6 kHz 2.0, // 12 kHz 2.0, // 14 kHz 3.0 // 16 kHz }; var equalizerEffect = new Equalizer10AudioEffect(eqLevels); videoEdit.Audio_Effects.Add(equalizerEffect); // Configure WMA output var wmaOutput = new WMAOutput(outputPath); wmaOutput.Audio.Bitrate = 192; wmaOutput.Audio.SampleRate = 48000; wmaOutput.Audio.Channels = 2; videoEdit.Output_Format = wmaOutput; var completionSource = new TaskCompletionSource(); videoEdit.OnStop += (s, e) => completionSource.SetResult(e.Successful); videoEdit.Start(); await completionSource.Task; } finally { videoEdit.Dispose(); } } ``` ## WMA Encoder Configuration The WMAEncoderSettings class provides various configuration options for the Windows Media Audio encoder: ### Available Settings ``` var wmaSettings = new WMAEncoderSettings { // Bitrate in Kbps - supported values: 128, 192, 256, 320 Bitrate = 192, // Sample rate in Hz - supported values: 44100, 48000 SampleRate = 48000, // Number of channels - supported values: 1 (mono), 2 (stereo) Channels = 2 }; // Query supported configurations int[] supportedBitrates = wmaSettings.GetSupportedBitrates(); // Returns: [128, 192, 256, 320] int[] supportedSampleRates = wmaSettings.GetSupportedSampleRates(); // Returns: [44100, 48000] int[] supportedChannels = wmaSettings.GetSupportedChannelCounts(); // Returns: [1, 2] ``` ### Quality Presets Here are recommended presets for different use cases: ``` // High-quality music recording var musicPreset = new WMAEncoderSettings { Bitrate = 320, SampleRate = 48000, Channels = 2 }; // Voice recording / podcasts var voicePreset = new WMAEncoderSettings { Bitrate = 128, SampleRate = 44100, Channels = 1 }; // Balanced quality and file size var balancedPreset = new WMAEncoderSettings { Bitrate = 192, SampleRate = 48000, Channels = 2 }; ``` ## Working with Audio Packets and Buffers For advanced scenarios, you may need to work directly with audio data packets. The SDK provides mechanisms for accessing raw audio data during capturing and processing. ### Processing Audio Packets ``` // During capture, you can monitor audio levels and packets _videoCapture.OnAudioVUMeter += (sender, args) => { // args is VUMeterXEventArgs — channel levels come from MeterData (VUMeterXData) var meterData = args.MeterData; if (meterData == null || meterData.ChannelsCount == 0) return; double leftPeak = meterData.Peak[0]; double rightPeak = meterData.ChannelsCount > 1 ? meterData.Peak[1] : leftPeak; // Update UI with audio levels UpdateVUMeter(leftPeak, rightPeak); }; ``` ## Error Handling and Best Practices ### Proper Resource Management Always ensure proper cleanup of SDK resources: ``` public class WmaProcessor : IDisposable { private VideoCaptureCoreX _videoCapture; private bool _disposed = false; public async Task InitializeAsync() { await VisioForgeX.InitSDKAsync(); _videoCapture = new VideoCaptureCoreX(); } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _videoCapture?.Dispose(); VisioForgeX.DestroySDK(); } _disposed = true; } } } ``` ### Error Handling Implement comprehensive error handling for production applications: ``` try { await _videoCapture.StartAsync(); } catch (Exception ex) { // Log the error Console.WriteLine($"Failed to start recording: {ex.Message}"); // Clean up resources await _videoCapture.DisposeAsync(); // Notify user or retry throw; } ``` ### Checking Encoder Availability Before creating WMA files, verify the encoder is available: ``` if (!WMAEncoderSettings.IsAvailable()) { Console.WriteLine("WMA encoder is not available."); Console.WriteLine("Falling back to MP3 format..."); // Use MP3 as alternative var mp3Output = new MP3Output("output.mp3"); // ... continue with MP3 encoding } ``` ## Cross-Platform Considerations The WMA format and Windows Media components are primarily designed for Windows systems. When developing cross-platform applications: - **Windows**: Full WMA support with all encoding options - **Linux/macOS**: WMA encoding may require additional GStreamer plugins - **Mobile (Android/iOS)**: Consider using more universal formats like AAC or MP3 For cross-platform audio recording, consider these alternatives: ``` // Check platform and select appropriate format string outputFormat = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "output.wma" : "output.m4a"; // AAC container for non-Windows if (outputFormat.EndsWith(".wma")) { var wmaOutput = new WMAOutput(outputFormat); _videoCapture.Outputs_Add(wmaOutput, true); } else { var m4aOutput = new M4AOutput(outputFormat); _videoCapture.Outputs_Add(m4aOutput, true); } ``` ## Sample Applications and Resources Explore complete sample applications demonstrating WMA recording and editing: - [Video Capture SDK X Samples](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Video%20Capture%20SDK%20X) - [Video Edit SDK X Samples](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Video%20Edit%20SDK%20X) ### Additional Documentation - [Windows Media Audio Encoder Guide](../../audio-encoders/wma/) - [Windows Media Video Output Guide](../../output-formats/wmv/) - [Audio Sample Grabber](../../audio-effects/audio-sample-grabber/) - [API Documentation](https://api.visioforge.org/dotnet/api/index.html) ## Conclusion This comprehensive guide has demonstrated how to record and edit WMA files using the VisioForge .NET SDKs. You've learned how to record .NET WMA audio, capture dotnet WMA content, and create professional audio applications. The VideoCaptureCoreX class provides powerful capabilities for capturing audio from microphones and other devices, while the VideoEditCoreX class offers flexible options for editing and converting audio content to Windows Media format. Key takeaways: - **Record WMA files**: Use VideoCaptureCoreX with WMAOutput for capturing audio from system devices and reserve optimal quality settings for your output - **Edit WMA files**: Use VideoEditCoreX for trimming, merging, and applying effects to audio records - **Configuration**: The WMAEncoderSettings class allows fine-tuning of bitrate, sample rate, and channels - **Cross-platform**: Consider platform-specific requirements when working with Windows Media formats - **Windows application support**: Create WinForms, WPF, and console applications with ease Both classes integrate seamlessly with WinForms, WPF, and console applications, making it easy to create powerful audio recording and editing solutions in your .NET applications. The data processing capabilities and library features allow you to build professional-grade audio editor applications. ---END OF PAGE--- ## VisioForge .NET SDK General Guides and Documentation **URL:** https://www.visioforge.com/help/docs/dotnet/general/ **Description:** Comprehensive guides for VisioForge .NET SDKs covering video capture, media playback, editing, encoders, effects, and network streaming. **Tags:** .NET, Streaming # VisioForge .Net SDKs: Information, Manuals, and Usage This section provides essential information, detailed software manuals, and practical usage guides for the suite of VisioForge .Net SDKs. Whether you're working with video capture, media playback, or video editing, find the resources you need below. - **[MCP Server Usage Guide](mcp-server-usage/)** - Connect your AI coding assistant to the VisioForge MCP Server for instant access to API documentation, deployment guides, and code examples - **[Using VisioForge in Unity](unity/)** - Import the self-contained Unity package for video playback and RTSP camera streaming in Unity 6 on Windows - [Code samples](code-samples/) - [How to send logs?](sendlogs/) ## Guides - [Video capture to MPEG-TS in VisioForge SDKs](guides/video-capture-to-mpegts/) - [Record and Edit WMA Files in C# and .NET](guides/wma-recording-editing/) ## SDK Components Explore the core components of VisioForge .Net SDKs: ### Media Processing & Effects - **[Video Effects & Processing](video-effects/)**: Enhance your applications with powerful video effects, overlays, and processing capabilities. Learn how to implement professional-grade visual effects, text/image overlays, and custom video processing. - **[Audio Effects](audio-effects/audio-sample-grabber/)**: Explore options for applying various audio effects and enhancements within your .NET applications. ### Encoding & Formats - **[Video Encoders](video-encoders/)**: Detailed overview of video encoders (H.264, HEVC, AV1, etc.) - features, performance, and implementation for .NET developers. - **[Audio Encoders](audio-encoders/)**: Master audio encoding (AAC, FLAC, MP3, Opus) with guidance on optimal settings, performance tips, and best practices. - **[Output Formats](output-formats/)**: Learn about video and audio container formats (MP4, WebM, AVI, MKV) including examples, codec comparisons, and compatibility. ### Streaming & Connectivity - **[Network Streaming](network-streaming/)**: Implement RTMP, RTSP, HLS, and NDI streaming in .NET. Includes examples for live broadcasting, hardware acceleration, and platform integration. ---END OF PAGE--- ## Using the VisioForge MCP Server for AI-Assisted Development **URL:** https://www.visioforge.com/help/docs/dotnet/general/mcp-server-usage/ **Description:** Connect your AI coding assistant to the VisioForge MCP Server for instant access to API documentation, deployment guides, code examples, and SDK knowledge. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Streaming, Conversion, IP Camera, RTSP, C#, NuGet **API:** MediaBlocksPipeline, VideoRendererBlock, RTSPSourceBlock # Using the VisioForge MCP Server for AI-Assisted Development [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to the VisioForge MCP Server The VisioForge MCP (Model Context Protocol) Server provides AI-powered coding assistants with direct access to comprehensive VisioForge SDK documentation, deployment guides, code examples, and API references. This enables your AI assistant to provide accurate, context-aware help while you develop with VisioForge SDKs. ### What is Model Context Protocol (MCP)? Model Context Protocol (MCP) is an open standard developed by Anthropic that allows AI assistants to securely connect to external knowledge sources and tools. Think of it as a bridge between your AI coding assistant (like Claude Code, GitHub Copilot, or VS Code extensions) and specialized documentation servers. With MCP, your AI assistant can: - Query real-time API documentation - Fetch deployment guides for specific platforms - Retrieve code examples and snippets - Search through SDK documentation - Get platform-specific configuration details ## Why Use the VisioForge MCP Server? When developing with VisioForge SDKs, the MCP server provides several key benefits: ### 1. **Instant API Documentation Access** Your AI assistant can query the complete VisioForge SDK API, including: - All classes, methods, properties, and events - Detailed descriptions and usage notes - Parameter types and return values - Code examples and snippets - Cross-references to related APIs ### 2. **Platform-Specific Deployment Guidance** Get accurate deployment instructions for: - **Desktop**: Windows, Linux, macOS - **Mobile**: Android, iOS, Mac Catalyst - **Frameworks**: MAUI, Uno, Avalonia, WPF, WinForms, Blazor, Console - **Scenarios**: RTSP recording, cloud transcoding, HLS streaming ### 3. **Correct NuGet Package References** The MCP server generates ready-to-paste `.csproj` snippets with: - Platform-specific NuGet packages - Correct version numbers - Conditional package references - Required project references (like AndroidDependency) ### 4. **Platform-Specific Build Configuration** Retrieve MSBuild targets and configuration snippets for: - Mac Catalyst native library copying - Android permissions (manifest + runtime) - iOS Info.plist permissions - Platform-specific build settings ## Prerequisites Before connecting to the VisioForge MCP Server, ensure you have: - **An MCP-compatible AI assistant**: - [Claude Code](https://claude.ai/code) (recommended) - VS Code with MCP extension - GitHub Copilot with MCP support - Other MCP-compatible tools - **Internet connectivity** to access `https://mcp.visioforge.com` ## Connecting to the MCP Server ### Claude Code (Recommended) Claude Code has built-in MCP support. Connect with a single command: ``` claude mcp add --transport http visioforge-sdk https://mcp.visioforge.com/mcp ``` **Verify the connection:** ``` claude mcp list ``` You should see `visioforge-sdk` in the list of connected servers. ### VS Code with MCP Extension Add the VisioForge MCP Server to your workspace or user settings: 1. Open VS Code 2. Install the MCP extension (if not already installed) 3. Create or edit `.vscode/mcp.json` in your project: ``` { "servers": { "visioforge-sdk": { "type": "http", "url": "https://mcp.visioforge.com/mcp" } } } ``` ### Project-Level Configuration (Any MCP Client) For project-specific MCP configuration, create `.mcp.json` at your repository root: ``` { "servers": { "visioforge-sdk": { "type": "http", "url": "https://mcp.visioforge.com/mcp", "description": "VisioForge SDK documentation and deployment guides" } } } ``` ## Available MCP Tools The VisioForge MCP Server exposes 14 specialized tools your AI assistant can use. Names and descriptions match the live `tools/list` response from `https://mcp.visioforge.com/mcp` exactly. ### 1. **Media Blocks Tools** #### `list_media_blocks` List available VisioForge media blocks, optionally filtered by category. Media blocks are the building blocks of media processing pipelines. Categories include: Sources, Sinks, VideoEncoders, AudioEncoders, VideoDecoders, VideoProcessing, AudioProcessing, AudioRendering, VideoRendering, Demuxers, Parsers, OpenGL, OpenCV, Nvidia, Decklink, AWS, RTSPServer, Bridge, Special, Outputs. **Example queries:** - "List all video encoder blocks" - "Show MediaBlocks sources" - "What blocks are in the OpenCV category?" #### `get_media_block_info` Get detailed information about a specific media block including its properties, methods, events, input/output pads, constructor parameters, and documentation. Use this to understand how to configure and use a specific media block in a pipeline. **Example queries:** - "Get info on RTSPSourceBlock" - "Show pads and properties of H264EncoderBlock" - "What constructor parameters does VideoRendererBlock take?" #### `get_pipeline_template` Get a media block pipeline template for a specific use case. Returns the list of required blocks and how to connect them, along with C# code to build the pipeline. **Example queries:** - "Pipeline template for RTSP-to-MP4 recording" - "Template for screen capture with audio" - "Pipeline for HLS streaming" ### 2. **SDK Class & API Tools** #### `list_sdk_classes` List core VisioForge SDK classes. These are the main entry-point classes for building media applications: VideoCaptureCoreX (video capture/recording), VideoEditCoreX (video editing), MediaPlayerCoreX (media playback), MediaInfoReaderCoreX (media analysis), SimplePlayerCoreX (simple playback), and more. **Example queries:** - "List all core SDK classes" - "Show top-level entry-point classes" #### `get_class_info` Get detailed information about any VisioForge SDK class, including its full list of properties, methods, events, constructors, base class, interfaces, and documentation. Works for both core SDK classes and media blocks. **Example queries:** - "Show documentation for MediaBlocksPipeline class" - "Get details about VideoCaptureCoreX" - "What events does MediaPlayerCoreX expose?" #### `get_method_signature` Get the detailed signature and documentation for a specific method on a class. Useful when you need to understand a method's parameters, return type, and behavior. **Example queries:** - "Signature of StartAsync on MediaBlocksPipeline" - "What parameters does Connect take?" #### `search_api` Search across the entire VisioForge SDK API — class names, method names, property names, event names, and their documentation text. Returns ranked results. Use this when you don't know the exact class name, or to find all classes related to a concept (e.g., "RTSP streaming", "video overlay", "audio capture"). **Example queries:** - "Search for video capture classes" - "Find methods related to RTSP streaming" - "Show all MediaBlocks audio encoders" #### `get_enum_values` Get all values of a VisioForge SDK enum type with descriptions. Useful for understanding available options for configuration properties (e.g., MediaBlockType, video codecs, audio formats, pixel formats). **Example queries:** - "List values of VideoCodec enum" - "Show MediaBlockType enum values" #### `list_namespaces` Browse VisioForge SDK namespaces hierarchically. Shows child namespaces and classes within a given namespace. Start with `VisioForge.Core` or leave empty to see top-level namespaces. **Example queries:** - "List top-level namespaces" - "Show classes in VisioForge.Core.MediaBlocks" #### `get_code_example` Get a code example for a common VisioForge SDK scenario. Returns complete, working C# code snippets that demonstrate how to use the SDK for tasks like video capture, RTSP streaming, media playback, and more. **Example queries:** - "Code example for RTSP camera capture" - "Show MP4 recording snippet" - "Example of applying video effects" ### 3. **Deployment Guide Tools** #### `list_deployment_guides` List available deployment guides for VisioForge SDK. Filter by platform, project type, SDK type, or scenario. Returns a list of guides with titles, summaries, and tags. **Example queries:** - "List Android deployment guides" - "Show MAUI deployment guides" - "Find deployment guides for Linux" #### `get_deployment_guide` Get the complete deployment guide for a specific scenario. Returns detailed instructions, code snippets, NuGet packages, and platform-specific notes. **Example queries:** - "Get the Android deployment guide" - "Show deployment steps for Uno platform" - "How to deploy on macOS" #### `get_nuget_packages_snippet` Get .csproj snippet with required NuGet packages for a specific deployment scenario. Returns XML snippet ready to copy-paste into your project file. **Example queries:** - "Generate NuGet packages for Android MAUI project" - "Get package references for Avalonia on Windows" - "Show required packages for iOS" #### `get_platform_specific_config` Get platform-specific file copying/build configuration code. Returns MSBuild targets or post-build scripts for special deployment requirements. **Example queries:** - "Show Mac Catalyst file copying target" - "Get Android manifest permissions" - "iOS Info.plist permission keys" ## Usage Examples ### Example 1: Setting Up an Android MAUI Project **You ask your AI assistant:** > "I'm creating a video capture app with MAUI for Android. What NuGet packages do I need?" **Your AI assistant uses the MCP server to:** 1. Call `get_nuget_packages_snippet` with `platform: Android, projectType: MAUI, sdkType: MediaBlocks` 2. Retrieve the correct package references 3. Provide you with ready-to-paste XML: ``` ``` ### Example 2: Finding How to Use RTSP Streaming **You ask your AI assistant:** > "Show me how to capture from an RTSP camera using Media Blocks SDK" **Your AI assistant uses the MCP server to:** 1. Call `search_api` with query "RTSP camera capture" 2. Identify `RTSPSourceBlock` class 3. Call `get_code_example` for RTSP scenarios 4. Provide you with working code: ``` var pipeline = new MediaBlocksPipeline(); // RTSPSourceBlock takes RTSPSourceSettings (not a Uri directly). // Build the settings via the async factory — the ctor is private. var rtspSettings = await RTSPSourceSettings.CreateAsync( new Uri("rtsp://camera.example.com:554/stream"), login: null, password: null, audioEnabled: false); var rtspSource = new RTSPSourceBlock(rtspSettings); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(rtspSource.VideoOutput, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Example 3: Mac Catalyst Deployment **You ask your AI assistant:** > "How do I deploy my Uno app to Mac Catalyst?" **Your AI assistant uses the MCP server to:** 1. Call `get_deployment_guide` with `guideId: "uno-platform"` 2. Extract the Mac Catalyst section 3. Call `get_platform_specific_config` with `platform: "maccatalyst"` 4. Provide you with: - Build commands - MSBuild target for file copying - Deployment steps ### Example 4: Understanding a Specific API **You ask your AI assistant:** > "What parameters does UniversalSourceBlock accept?" **Your AI assistant uses the MCP server to:** 1. Call `search_api` with query "UniversalSourceBlock" 2. Find the class in the results 3. Call `get_class_info` with the class name 4. Parse the documentation and explain: - Constructor parameters - Supported file formats - Configuration options - Usage examples ## Best Practices ### 1. **Be Specific in Your Questions** Instead of generic questions, provide context: - ❌ "How do I capture video?" - ✅ "How do I capture video from an RTSP camera using Media Blocks SDK on Android?" ### 2. **Specify Your Platform and Framework** Always mention your target platform and UI framework: - "I'm using MAUI on iOS..." - "My Avalonia app targets Windows and Linux..." - "For my Uno Platform app on Android..." ### 3. **Ask About Deployment Early** Before diving deep into code, ask about deployment requirements: - "What NuGet packages do I need for Mac Catalyst?" - "Show me the deployment guide for Avalonia on Linux" - "What permissions are required for iOS camera access?" ### 4. **Request Code Examples** Don't hesitate to ask for working code: - "Show me a complete example of..." - "Generate code for..." - "Example implementation of..." ## Troubleshooting ### Connection Issues If your AI assistant can't connect to the MCP server: 1. **Check your internet connection** - The MCP server is hosted at `https://mcp.visioforge.com` 2. **Verify the URL** - Ensure you're using the correct endpoint: `https://mcp.visioforge.com/mcp` 3. **Restart your AI assistant** - Sometimes a restart resolves connection issues 4. **Check MCP client logs** - Look for connection errors in your client's logs ### Incorrect or Outdated Information The MCP server is updated regularly, but if you notice incorrect information: 1. **Check the SDK version** - Ensure you're using the latest SDK version 2. **Verify package versions** - Compare with [NuGet.org](https://www.nuget.org/packages?q=VisioForge) 3. **Report issues** - Contact our support team (see Additional Resources below) ### AI Assistant Not Using MCP Server If your AI assistant doesn't seem to use the MCP server: 1. **Explicitly mention it** - Say "Use the VisioForge MCP server to find..." 2. **Verify connection** - Run `claude mcp list` or check your MCP configuration 3. **Restart the session** - Start a new conversation with your AI assistant ## Security and Privacy ### Data Transmission - All communication with the MCP server uses **HTTPS encryption** - The server is read-only - it only provides documentation, no data collection - No personal information or code is sent to the server - API queries are processed in real-time and not stored ### Authentication - The VisioForge MCP Server is **publicly accessible** - no authentication required - Your AI assistant connects directly to `https://mcp.visioforge.com/mcp` - No API keys or credentials needed ## Technical Details ### MCP Server Endpoint ``` https://mcp.visioforge.com/mcp ``` ### Server Capabilities - **Protocol**: MCP (Model Context Protocol) - **Transport**: HTTP/HTTPS - **Tools**: 14 specialized documentation and deployment tools - **API Coverage**: Complete VisioForge .NET SDK API (all classes, methods, properties) - **Deployment Guides**: 15+ platform and project type guides - **Code Examples**: Hundreds of working code snippets - **Update Frequency**: Updated with each SDK release ### Server Architecture The MCP server features: - **High availability**: 99.9% uptime - **Fast response times**: < 200ms average - **SSL/TLS encryption**: All traffic encrypted - **Automatic updates**: Synchronized with SDK releases - **Rate limiting**: Fair use policy (no hard limits for developers) ## Additional Resources ### Documentation - [VisioForge SDK Documentation](https://www.visioforge.com/help/) - [MCP Protocol Specification](https://modelcontextprotocol.io/specification/2025-11-25) - [Claude Code Documentation](https://claude.ai/code) ### Support & Community Need help? Get in touch: - **[Support Portal](https://support.visioforge.com/)** - Technical support and issue reporting - **[Discord Community](https://discord.com/invite/yvXUG56WCH)** - Chat with developers and get quick answers - **[GitHub Samples](https://github.com/visioforge/.Net-SDK-s-samples)** - Complete example projects - **Email:** [support@visioforge.com](mailto:support@visioforge.com) ### Related Guides - [Installation Guide](../../install/) - [System Requirements](../../system-requirements/) - [Deployment Guides](../../deployment-x/) - [API Reference](https://api.visioforge.org/dotnet/api/index.html) ## Conclusion The VisioForge MCP Server transforms AI-assisted development by providing your coding assistant with direct access to comprehensive, up-to-date SDK documentation. Whether you're building a video capture app on Android, a media player on Windows, or a cross-platform editing tool with Avalonia, the MCP server ensures your AI assistant has the knowledge to help you succeed. Connect today and experience the future of AI-powered SDK development! ---END OF PAGE--- ## RTSP Reconnect & Fallback Switch in C# .NET — All SDKs **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-sources/reconnection-and-fallback/ **Description:** Handle IP camera disconnects in C# / .NET with reconnect events, DisconnectEventInterval, and FallbackSwitch (image/text/media) across all VisioForge SDKs. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, .NET, DirectShow, MediaPlayerCoreX, VideoCaptureCoreX, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Playback, Streaming, Decoding, IP Camera, RTSP, ONVIF, MP4, C# **API:** FallbackSwitchSettings, RTSPSourceSettings, MediaPlayerCore, VideoCaptureCoreX, MediaPlayerCoreX # RTSP Reconnection and Fallback Switch in C# / .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Cross-platform support Reconnection events work on every SDK. The declarative `FallbackSwitch` is GStreamer-backed and therefore runs on **Windows, macOS, Linux, Android, and iOS** in the modern `X` engines and Media Blocks — it's not available on classic DirectShow-only engines. See the [platform support matrix](../../../platform-matrix/) and the [Linux deployment guide](../../../deployment-x/Ubuntu/). IP cameras drop connections — network blips, power cycles, router reboots, keyframe starvation. VisioForge SDKs give you two ways to handle it: - **Reactive** — your code subscribes to a disconnect event, then stops and restarts the source. - **Declarative** — you configure a `FallbackSwitch` on the source, the pipeline swaps in a placeholder image / text card / alternate stream automatically, and your code never sees the hiccup. Pick based on which SDK you're using and the UX you want. This guide covers both approaches across every SDK in the family. ## Which approach is available where | SDK | Reactive (detect + restart) | Declarative (FallbackSwitch) | | --- | --- | --- | | VideoCaptureCore (classic, Windows) | ✅ `OnNetworkSourceDisconnect` + `DisconnectEventInterval` | ⛔ | | MediaPlayerCore (classic, Windows) | ✅ `OnNetworkSourceStop` (FFMPEG) / `OnError` | ⛔ | | VideoCaptureCoreX (cross-platform) | ✅ pipeline `OnNetworkSourceDisconnect` / `OnError` | ✅ via `RTSPSourceSettings.FallbackSwitch` | | MediaPlayerCoreX (cross-platform) | ✅ pipeline `OnNetworkSourceDisconnect` / `OnError` | ✅ | | Media Blocks SDK | ✅ pipeline event | ✅ `FallbackSwitchSourceBlock` | Rule of thumb: on the classic Windows engines you have reactive only. On any modern (cross-platform) engine, prefer declarative for the UX, add reactive on top for telemetry. ## Reactive — VideoCaptureCore (classic) `IPCameraSourceSettings.DisconnectEventInterval` defines how long the SDK waits without incoming frames before firing the disconnect event. Default is 10 seconds; drop it to 3–5 seconds for surveillance. ``` using VisioForge.Core.VideoCapture; using VisioForge.Core.Types.VideoCapture; videoCapture1.IP_Camera_Source = new IPCameraSourceSettings { URL = new Uri("rtsp://192.168.1.100:554/stream1"), Login = "admin", Password = "admin123", Type = IPSourceEngine.Auto_LAV, DisconnectEventInterval = TimeSpan.FromSeconds(5) }; videoCapture1.OnNetworkSourceDisconnect += async (s, e) => { // Exponential backoff: 1s, 2s, 4s, 8s... capped at 30s. int attempt = 0; int delayMs = 1000; while (attempt < 10) { await videoCapture1.StopAsync(); await Task.Delay(delayMs); if (await videoCapture1.StartAsync()) break; delayMs = Math.Min(delayMs * 2, 30_000); attempt++; } }; videoCapture1.Mode = VideoCaptureMode.IPPreview; await videoCapture1.StartAsync(); ``` `OnNetworkSourceDisconnect` fires from a timer thread — marshal to the UI thread (`Invoke` / `Dispatcher.Invoke`) before touching controls. ## Reactive — MediaPlayerCore (classic) Classic `MediaPlayerCore` exposes `OnNetworkSourceStop` on the FFMPEG engine; for other engines and any generic failure, subscribe `OnError`. ``` using VisioForge.Core.MediaPlayer; mediaPlayer1.OnNetworkSourceStop += async (s, e) => { await mediaPlayer1.StopAsync(); await Task.Delay(2000); await mediaPlayer1.StartAsync(); }; mediaPlayer1.OnError += (s, e) => { // Log but don't teardown — let the retry loop above handle real drops. Debug.WriteLine($"Player error: {e.Message}"); }; ``` ## Reactive — Media Blocks pipelines `MediaBlocksPipeline` exposes `OnNetworkSourceDisconnect` with rich `NetworkSourceDisconnectEventArgs` — useful when multiple RTSP sources share one app and you need to know *which* one dropped. ``` using VisioForge.Core.Types.Events; pipeline.OnNetworkSourceDisconnect += (s, e) => { // e.SourceElementName — the GStreamer element that faulted // e.ErrorMessage — short description // e.DebugInfo — GStreamer debug output (may be null) // e.Uri — the failing RTSP URL (may be null) // e.Timestamp — when the SDK detected the failure Log($"[{e.Timestamp:HH:mm:ss}] {e.SourceElementName} dropped: {e.ErrorMessage}"); }; pipeline.OnError += (s, e) => { Log($"Pipeline error: {e.Message}"); }; ``` ## Reactive — X engines (VideoCaptureCoreX / MediaPlayerCoreX) `VideoCaptureCoreX` and `MediaPlayerCoreX` do **not** publicly expose their internal `MediaBlocksPipeline`. To react to disconnects on these engines: 1. Subscribe to `OnError` on the engine — fires for all pipeline-level errors including lost RTSP sources. 2. Use the declarative `FallbackSwitch` (below) to keep the UI alive during transient drops. 3. If you need the granular `NetworkSourceDisconnectEventArgs` per-source, build the capture pipeline directly with `MediaBlocksPipeline` + `RTSPSourceBlock` and use the Media Blocks pattern above. ``` videoCaptureCoreX.OnError += (s, e) => { // e.Message carries the engine-level error; for RTSP drops the text includes // the source element name. Pair this handler with a retry loop or FallbackSwitch. Log($"VideoCaptureCoreX error: {e.Message}"); }; ``` ## Declarative — FallbackSwitch overview `FallbackSwitch` wraps a live source with automatic failover. When the main source stops producing frames for longer than `TimeoutMs`, the pipeline switches to a pre-configured fallback (text, image, or alternate media) and keeps your `VideoView` rendering. When the main source recovers, the pipeline switches back. ### The `FallbackSwitchSettings` container ``` public class FallbackSwitchSettings { public bool Enabled { get; set; } = false; public FallbackSwitchSettingsBase Fallback { get; set; } public bool EnableVideo { get; set; } = true; public bool EnableAudio { get; set; } = true; public int MinLatencyMs { get; set; } = 0; public string FallbackVideoCaps { get; set; } // e.g. "video/x-raw,width=1920,height=1080" public string FallbackAudioCaps { get; set; } // e.g. "audio/x-raw,rate=48000,channels=2" } ``` ### Base tunables (shared by all fallback types) ``` public abstract class FallbackSwitchSettingsBase { public int TimeoutMs { get; set; } = 5000; // silence before fallback kicks in public int RestartTimeoutMs { get; set; } = 5000; // wait between main-source restart attempts public int RetryTimeoutMs { get; set; } = 60000; // give-up window after repeated failures public bool ImmediateFallback{ get; set; } = false; // show fallback from the first frame gap public bool RestartOnEos { get; set; } = false; // treat EOS as a failure (for loops) public bool ManualUnblock { get; set; } = false; // require app to call Unblock() on recovery } ``` ### Three fallback types 1. **`StaticTextFallbackSettings`** — render a "Camera offline" text card. 2. **`StaticImageFallbackSettings`** — show a brand logo, last snapshot, or "reconnecting" slate. 3. **`MediaBlockFallbackSettings`** — play an alternate live stream or a looping file. ## Fallback — static text ``` using SkiaSharp; using VisioForge.Core.Types.X.Sources; var fallback = new FallbackSwitchSettings { Enabled = true, Fallback = new StaticTextFallbackSettings { Text = "Camera offline — reconnecting...", FontFamily = "Arial", FontSize = 32f, TextColor = SKColors.White, BackgroundColor = SKColors.Black, Position = new SKPoint(0.5f, 0.5f), // centre TimeoutMs = 3000, RestartTimeoutMs= 5000, }, }; ``` ## Fallback — static image ``` var fallback = new FallbackSwitchSettings { Enabled = true, Fallback = new StaticImageFallbackSettings { ImagePath = @"C:\assets\camera-offline.png", ScaleToFit = true, MaintainAspectRatio = true, BackgroundColor = SKColors.Black, TimeoutMs = 3000, }, }; ``` ## Fallback — alternate media source ``` var fallback = new FallbackSwitchSettings { Enabled = true, Fallback = new MediaBlockFallbackSettings { FallbackUri = "file:///C:/assets/standby-loop.mp4", IsLive = false, RestartOnEos = true, // restart the loop when the file ends TimeoutMs = 3000, }, }; ``` `FallbackUri` accepts any URI GStreamer can read — `file://`, another `rtsp://`, HLS, HTTP. `CustomPipeline` lets you inject a bespoke GStreamer launch line for advanced scenarios (e.g. `videotestsrc pattern=snow`). ## Using FallbackSwitch — high-level (`RTSPSourceSettings.FallbackSwitch`) The simplest path: attach the settings object directly to `RTSPSourceSettings` and pass it to `VideoCaptureCoreX` / `MediaPlayerCoreX` as usual. No extra pipeline plumbing. ``` var rtsp = await RTSPSourceSettings.CreateAsync( new Uri("rtsp://192.168.1.100:554/stream1"), "admin", "admin123", audioEnabled: false); rtsp.LowLatencyMode = true; rtsp.FallbackSwitch = new FallbackSwitchSettings { Enabled = true, Fallback = new StaticImageFallbackSettings { ImagePath = "offline.png", TimeoutMs = 3000, }, }; _videoCapture.Video_Source = rtsp; await _videoCapture.StartAsync(); ``` ## Using FallbackSwitch — low-level (`FallbackSwitchSourceBlock`) In the Media Blocks SDK you wire the fallback directly at the pipeline level via `FallbackSwitchSourceBlock`. This works with *any* source — RTSP, HTTP MJPEG, file, device — not just RTSP. ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; var fallbackSwitch = new FallbackSwitchSourceBlock( mainSourceSettings: rtspSettings, // IVideoSourceSettings fallbackSettings: new FallbackSwitchSettings { Enabled = true, Fallback = new StaticTextFallbackSettings { Text = "OFFLINE" }, }); // Telemetry — works alongside the declarative UI pipeline.OnNetworkSourceDisconnect += (s, e) => metrics.RecordDisconnect(e.SourceElementName, e.Uri, e.Timestamp); // FallbackSwitchSourceBlock exposes separate VideoOutput / AudioOutput pads — no single Output. pipeline.Connect(fallbackSwitch.VideoOutput, renderer.Input); await pipeline.StartAsync(); // Inspect runtime state: string status = fallbackSwitch.GetStatus(); var stats = fallbackSwitch.GetStatistics(); // If ManualUnblock is set, call Unblock() when you want playback to resume the main source. // fallbackSwitch.Unblock(); ``` ## Common patterns **Exponential backoff** — in the reactive loop, double the delay on each failed reconnect, cap at 30 s. Stops you from hammering a dead camera's ARP cache. **Declarative UX + reactive telemetry** — let `FallbackSwitch` keep the screen alive, and use `pipeline.OnNetworkSourceDisconnect` to feed your monitoring dashboard / Slack alert / NVR log. Neither approach precludes the other. **Multi-camera wall** — never tear down the whole grid on one fault. See the [multi-camera RTSP grid guide](../../../mediablocks/Guides/multi-camera-rtsp-grid/) for the one-pipeline-per-camera pattern; attach a `FallbackSwitch` to each engine independently. **Cross-platform note** — `FallbackSwitch` depends on the GStreamer `fallbackswitch` element, which ships with the X redist. Classic Windows-only `VideoCaptureCore` / `MediaPlayerCore` don't have it — use the reactive approach there. ## Troubleshooting **Fallback never activates** — `Enabled = true`? `TimeoutMs` lower than the gap you want to catch? First few frames need to succeed before the timeout starts counting — a camera that fails on first handshake is a pipeline-start error, not a timeout. **Fallback activates but never leaves** — the main source isn't recovering. Check `RestartTimeoutMs` (too high delays the next retry) and `RetryTimeoutMs` (after this window the block stops retrying). With `ManualUnblock = true` you must call `fallbackSwitch.Unblock()` yourself. **Image fallback shows black** — codec caps mismatch between the main pipeline and the fallback decoder. Set `FallbackVideoCaps` explicitly, e.g. `"video/x-raw,width=1920,height=1080,format=RGB"`, matching the renderer's expected format. **Text fallback — wrong font / position** — `FontFamily` must exist on the target platform (Arial is on Windows and macOS; prefer `DejaVuSans` on Linux). `Position` is 0.0–1.0 fractions of the video frame. **`OnNetworkSourceDisconnect` fires repeatedly** — the source block is retrying and failing in quick succession. Raise `RestartTimeoutMs` to 10–15 s on a known-flaky network, or wrap logging with a debounce. **UI thread exceptions** — `OnNetworkSourceDisconnect` fires from the GStreamer bus thread. Use `Dispatcher.Invoke` (WPF) / `Control.Invoke` (WinForms) / `MainThread.BeginInvokeOnMainThread` (MAUI) before touching controls. ## Related Documentation - [RTSP protocol deep-dive](../../network-streaming/rtsp/) — how RTSP works, transport options, and streaming architecture - [RTSP camera source configuration](../../../videocapture/video-sources/ip-cameras/rtsp/) — `IPCameraSourceSettings` / `RTSPSourceSettings` reference - [ONVIF IP camera integration](../../../videocapture/video-sources/ip-cameras/onvif/) — discovery + PTZ; pair ONVIF re-discovery with FallbackSwitch for hard-to-reach cameras - [Media Blocks RTSP player](../../../mediablocks/Guides/rtsp-player-csharp/) — single-camera pipeline - [Multi-camera RTSP grid (NVR wall)](../../../mediablocks/Guides/multi-camera-rtsp-grid/) — 4×4 wall with per-cell fallback - [Save RTSP stream without re-encoding](../../../mediablocks/Guides/rtsp-save-original-stream/) — archive alongside live preview - [RTSP server output](../../../mediablocks/RTSPServer/) — server-side resilience for your own stream - [Platform support matrix](../../../platform-matrix/) — codec and hardware-acceleration details across platforms --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page for code samples including RTSP preview, record, and MultiView demos. ---END OF PAGE--- ## Adobe Flash Media Server Video Streaming in .NET SDK **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/adobe-flash/ **Description:** Stream video to Adobe Flash Media Server in .NET with real-time effects, quality settings, and device switching for professional streaming. **Tags:** Video Capture SDK, Video Edit SDK, .NET, Windows, Streaming, Encoding # Streaming to Adobe Flash Media Server: Advanced Implementation Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) ## Introduction Adobe Flash Media Server (FMS) remains a powerful solution for streaming video content across various platforms. This guide demonstrates how to implement high-quality video streaming to Adobe Flash Media Server using VisioForge's .NET SDKs. The integration supports real-time video effects, quality adjustment, and seamless device switching during streaming sessions. ## Prerequisites Before implementing the streaming functionality, ensure you have: - VisioForge Video Capture SDK .NET or Video Edit SDK .NET installed - Adobe Flash Media Server (or a compatible service like Wowza with RTMP support) - Adobe Flash Media Live Encoder (FMLE) - .NET Framework 4.7.2 or later - Visual Studio 2022 or newer - Basic understanding of C# programming ## Demo Application Walkthrough The demo application provided with VisioForge SDKs offers a straightforward way to test streaming functionality. Here's a detailed walkthrough: 1. Start the Main Demo application 2. Navigate to the "Network Streaming" tab 3. Enable streaming by selecting the "Enabled" checkbox 4. Select the "External" radio button for external encoder compatibility 5. Start preview or capture to initialize the video stream 6. Open Adobe Flash Media Live Encoder 7. Configure FMLE to use "VisioForge Network Source" as the video source 8. Configure video parameters: 9. Resolution (e.g., 1280x720, 1920x1080) 10. Frame rate (typically 25-30 fps for smooth streaming) 11. Keyframe interval (recommend 2 seconds) 12. Video quality settings 13. Select "VisioForge Network Source Audio" as the audio source 14. Configure your connection to Adobe Flash Media Server 15. Press Start to initiate streaming The video from the SDK is now being streamed to your FMS instance. You can apply real-time effects, adjust settings, or even stop the SDK to switch input devices without terminating the streaming session on the server side. ## Implementation in Custom Applications ### Required Components To implement this functionality in your custom application, you'll need: - SDK redistributables (available in the SDK installation package) - References to the VisioForge SDK assemblies - Proper firewall and network configurations to allow streaming ## Required Redistributables Ensure the following components are included with your application: - VisioForge SDK redistributable packages - Microsoft Visual C++ Runtime (appropriate version for your SDK) - .NET Framework runtime (if not using self-contained deployment) ## Conclusion Streaming to Adobe Flash Media Server using VisioForge's Video Capture or Edit SDKs offers a flexible and powerful solution for implementing high-quality video streaming in .NET applications. The implementation supports real-time effects, quality adjustments, and seamless device switching, making it suitable for a wide range of streaming applications. By following this guide, developers can implement robust streaming solutions that leverage the powerful features of both the VisioForge SDKs and Adobe's streaming platform. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples and example projects. ---END OF PAGE--- ## Streaming Video and Audio to Amazon S3 in .NET SDK **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/aws-s3/ **Description:** Implement AWS S3 video and audio streaming in .NET with configuration, encoding settings, error handling, and best practices for media output. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, C# **API:** AWSS3Output, AWSS3SinkSettings, IVideoEncoder, IAudioEncoder, IMediaBlockSettings # AWS S3 Output [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The AWS S3 Output functionality in VisioForge SDKs enables direct video and audio output streaming to Amazon S3 storage. This guide will walk you through setting up and using AWS S3 output in your applications. ## Overview The `AWSS3Output` class is a specialized output handler within the VisioForge SDKs that facilitates video and audio output streaming to Amazon Web Services (AWS) S3 storage. This class implements multiple interfaces to support both video editing (`IVideoEditXBaseOutput`) and video capture (`IVideoCaptureXBaseOutput`) scenarios, along with processing capabilities for both video and audio content. ## Class Implementation ``` public class AWSS3Output : IVideoEditXBaseOutput, IVideoCaptureXBaseOutput, IOutputVideoProcessor, IOutputAudioProcessor ``` ## Key Features The `AWSS3Output` class provides a comprehensive solution for streaming media content to AWS S3 by managing: - Video encoding configuration - Audio encoding configuration - Custom media processing - AWS S3-specific settings ## Properties ### Video Encoder Settings ``` public IVideoEncoder Video { get; set; } ``` Controls the video encoding process. The selected video encoder must be compatible with the configured sink settings. This property allows you to specify compression methods, quality settings, and other video-specific parameters. ### Audio Encoder Settings ``` public IAudioEncoder Audio { get; set; } ``` Manages audio encoding configuration. Like the video encoder, the audio encoder must be compatible with the sink settings. This property enables control over audio quality, compression, and format settings. ### Sink Settings ``` public IMediaBlockSettings Sink { get; set; } ``` Defines the output destination configuration. In this context, it contains AWS S3-specific settings for the media output stream. ### Custom Processing Blocks ``` public MediaBlock CustomVideoProcessor { get; set; } ``` ``` public MediaBlock CustomAudioProcessor { get; set; } ``` Allow for additional processing of video and audio streams before they are encoded and uploaded to S3. These blocks can be used for implementing custom filters, transformations, or analysis of the media content. ### AWS S3 Configuration ``` public AWSS3SinkSettings Settings { get; set; } ``` Contains all AWS S3-specific configuration options, including: - Access credentials (Access Key, Secret Access Key) - Bucket and object key information - Region configuration - Upload behavior settings - Error handling preferences ## Constructor ``` public AWSS3Output(AWSS3SinkSettings settings, IVideoEncoder videoEnc, IAudioEncoder audioEnc, IMediaBlockSettings sink) ``` Creates a new instance of the `AWSS3Output` class with the specified configuration: - `settings`: AWS S3-specific configuration - `videoEnc`: Video encoder settings - `audioEnc`: Audio encoder settings - `sink`: Media sink configuration ## Methods ### File Management ``` public string GetFilename() ``` ``` public void SetFilename(string filename) ``` These methods manage the URI of the S3 object: - `GetFilename()`: Returns the current S3 URI - `SetFilename(string filename)`: Sets the S3 URI for the output ### Encoder Support All encoders are supported. Be sure that encoder settings are compatible with the sink settings. ## Usage Example ``` // Create AWS S3 sink settings var s3Settings = new AWSS3SinkSettings { AccessKey = "your-access-key", SecretAccessKey = "your-secret-key", Bucket = "your-bucket-name", Key = "output-file-key", Region = "us-west-1" }; // Configure encoders IVideoEncoder videoEncoder = /* your video encoder configuration */; IAudioEncoder audioEncoder = /* your audio encoder configuration */; IMediaBlockSettings sinkSettings = /* your sink settings */; // Create the AWS S3 output var s3Output = new AWSS3Output(s3Settings, videoEncoder, audioEncoder, sinkSettings); // Optional: Configure custom processors s3Output.CustomVideoProcessor = /* your custom video processor */; s3Output.CustomAudioProcessor = /* your custom audio processor */; ``` ## Best Practices 1. Always ensure your AWS credentials are properly secured and not hard-coded in the application. 2. Configure appropriate retry attempts and request timeouts based on your network conditions and file sizes. 3. Select compatible video and audio encoders for your target use case. 4. Consider implementing custom processors for specific requirements like watermarking or audio normalization. ## Error Handling The class works in conjunction with the `S3SinkOnError` enumeration defined in `AWSS3SinkSettings`, which provides three error handling strategies: - Abort: Stops the upload process on error - Complete: Attempts to complete the upload despite errors - DoNothing: Ignores errors during upload ## Related Components - AWSS3SinkSettings: Contains detailed configuration for AWS S3 connectivity - IVideoEncoder: Interface for video encoding configuration - IAudioEncoder: Interface for audio encoding configuration - IMediaBlockSettings: Interface for media output configuration ---END OF PAGE--- ## Facebook Live Streaming and Encoding in .NET Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/facebook/ **Description:** Stream to Facebook Live in .NET with hardware-accelerated encoding, RTMP broadcasting, and platform-specific optimizations for real-time video. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, Screen Capture, RTMP, H.264, H.265, AAC, C# **API:** VideoCaptureCoreX, VideoEditCoreX, FacebookLiveOutput, NVENCH264EncoderSettings, QSVH264EncoderSettings # Facebook Live Streaming with VisioForge SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Facebook Live Streaming Facebook Live provides a powerful platform for real-time video broadcasting to global audiences. Whether you're developing applications for live events, video conferencing, gaming streams, or social media integration, VisioForge SDKs offer robust solutions for implementing Facebook Live streaming in your .NET applications. This comprehensive guide explains how to implement Facebook Live streaming using VisioForge's suite of SDKs, with detailed code examples and configuration options for different platforms and hardware configurations. ## Core Components for Facebook Live Integration [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The cornerstone of Facebook Live integration in VisioForge is the `FacebookLiveOutput` class, which provides a complete implementation of the RTMP protocol required for Facebook streaming. This class implements multiple interfaces to ensure compatibility across various SDK components: - `IVideoEditXBaseOutput` - For Video Edit SDK integration - `IVideoCaptureXBaseOutput` - For Video Capture SDK integration - `IOutputVideoProcessor` - For video stream processing - `IOutputAudioProcessor` - For audio stream processing This multi-interface implementation ensures seamless operation across the entire VisioForge ecosystem, allowing developers to maintain consistent code while working with different SDK components. ## Setting Up Facebook Live Streaming ### Prerequisites Before implementing Facebook Live streaming in your application, you'll need: 1. A Facebook account with permissions to create Live streams 2. A valid Facebook streaming key (obtained from Facebook Live Producer) 3. VisioForge SDK installed in your .NET project 4. Sufficient bandwidth for the chosen quality settings ### Basic Implementation The most basic implementation of Facebook Live streaming requires just a few lines of code: ``` // Create Facebook Live output with your streaming key var facebookOutput = new FacebookLiveOutput("your_facebook_streaming_key_here"); // Add to your VideoCaptureCoreX instance captureCore.Outputs_Add(facebookOutput, true); // Or set as output format for VideoEditCoreX editCore.Output_Format = facebookOutput; ``` This minimal setup uses the default encoders, which VisioForge selects based on your platform for optimal performance. For most applications, these defaults provide excellent results with minimal configuration overhead. ## Optimizing Video Encoding for Facebook Live ### Supported Video Encoders Facebook Live requires H.264 or HEVC encoded video. VisioForge supports multiple encoder implementations to leverage different hardware capabilities: #### H.264 Encoders | Encoder | Platform Support | Hardware Acceleration | Performance Characteristics | | --- | --- | --- | --- | | OpenH264 | Cross-platform | Software-based | CPU-intensive, universal compatibility | | NVENC H264 | Windows, Linux | NVIDIA GPU | High performance, low CPU usage | | QSV H264 | Windows, Linux | Intel GPU | Efficient on Intel systems | | AMF H264 | Windows | AMD GPU | Optimized for AMD hardware | #### HEVC Encoders | Encoder | Platform Support | Hardware Acceleration | | --- | --- | --- | | MF HEVC | Windows only | DirectX Video Acceleration | | NVENC HEVC | Windows, Linux | NVIDIA GPU | | QSV HEVC | Windows, Linux | Intel GPU | | AMF H265 | Windows | AMD GPU | ### Selecting the Optimal Video Encoder VisioForge provides utility methods to check hardware encoder availability before attempting to use them: ``` // Video encoder selection with fallback options IVideoEncoderSettings GetOptimalVideoEncoder() { // Try NVIDIA GPU acceleration first if (NVENCH264EncoderSettings.IsAvailable()) { return new NVENCH264EncoderSettings(); } // Fall back to Intel Quick Sync if available if (QSVH264EncoderSettings.IsAvailable()) { return new QSVH264EncoderSettings(); } // Fall back to AMD acceleration if (AMFH264EncoderSettings.IsAvailable()) { return new AMFH264EncoderSettings(); } // Finally fall back to software encoding return new OpenH264EncoderSettings(); } // Apply the optimal encoder to Facebook output facebookOutput.Video = GetOptimalVideoEncoder(); ``` This cascading approach ensures your application uses the best available encoder on the user's system, maximizing performance while maintaining compatibility. ## Audio Encoding Configuration Audio quality significantly impacts the viewer experience. VisioForge supports multiple AAC encoder implementations to ensure optimal audio for Facebook streams: ### Supported Audio Encoders 1. **VO-AAC** - VisioForge's optimized AAC encoder (default for non-Windows platforms) 2. **AVENC AAC** - FFmpeg-based AAC encoder with wide platform support 3. **MF AAC** - Microsoft Media Foundation AAC encoder (Windows-only, hardware-accelerated) ``` // Platform-specific audio encoder selection IAudioEncoderSettings GetOptimalAudioEncoder() { IAudioEncoderSettings audioEncoder; #if NET_WINDOWS // Use Media Foundation on Windows audioEncoder = new MFAACEncoderSettings(); // MFAACEncoderSettings exposes Bitrate + SampleRate only; channel count follows the upstream source ((MFAACEncoderSettings)audioEncoder).SampleRate = 44100; #else // Use VisioForge optimized AAC on other platforms audioEncoder = new VOAACEncoderSettings(); // VOAACEncoderSettings exposes Bitrate + SampleRate only; channel count follows the upstream source ((VOAACEncoderSettings)audioEncoder).SampleRate = 44100; #endif return audioEncoder; } // Apply the optimal audio encoder facebookOutput.Audio = GetOptimalAudioEncoder(); ``` ## Advanced Facebook Live Features ### Custom Media Processing Pipeline For applications requiring advanced video or audio processing before streaming, VisioForge supports insertion of custom processors: ``` // Add text overlay to video stream var textOverlay = new TextOverlayBlock(new TextOverlaySettings("Live from VisioForge SDK")); // Add the video processor to Facebook output facebookOutput.CustomVideoProcessor = textOverlay; // Add audio volume boost var volume = new VolumeBlock(); volume.Level = 1.2; // Boost 20% volume // Add the audio processor to Facebook output facebookOutput.CustomAudioProcessor = volume; ``` ### Platform-Specific Optimizations VisioForge automatically applies platform-specific optimizations: - **Windows**: Leverages Media Foundation for AAC audio and DirectX Video Acceleration - **macOS**: Uses Apple Media frameworks for hardware-accelerated encoding - **Linux**: Employs VAAPI and other platform-specific acceleration when available These optimizations ensure your application achieves maximum performance regardless of the deployment platform. ## Complete Implementation Example Here's a comprehensive example showing how to set up a complete Facebook Live streaming pipeline with error handling and optimal encoder selection: ``` public FacebookLiveOutput ConfigureFacebookLiveStream(string streamKey, int videoBitrate = 4000000) { // Create the Facebook output with the provided stream key var facebookOutput = new FacebookLiveOutput(streamKey); try { // Configure optimal video encoder with fallback strategy if (NVENCH264EncoderSettings.IsAvailable()) { var nvencSettings = new NVENCH264EncoderSettings(); nvencSettings.Bitrate = videoBitrate; facebookOutput.Video = nvencSettings; } else if (QSVH264EncoderSettings.IsAvailable()) { var qsvSettings = new QSVH264EncoderSettings(); qsvSettings.Bitrate = videoBitrate; facebookOutput.Video = qsvSettings; } else { // Software fallback var openH264 = new OpenH264EncoderSettings(); openH264.Bitrate = videoBitrate; facebookOutput.Video = openH264; } // Configure platform-optimal audio encoder #if NET_WINDOWS facebookOutput.Audio = new MFAACEncoderSettings(); #else facebookOutput.Audio = new VOAACEncoderSettings(); #endif // Set additional stream parameters facebookOutput.Sink.Key = streamKey; return facebookOutput; } catch (Exception ex) { Console.WriteLine($"Error configuring Facebook Live output: {ex.Message}"); throw; } } // Usage with VideoCaptureCoreX var captureCore = new VideoCaptureCoreX(); var facebookOutput = ConfigureFacebookLiveStream("your_streaming_key_here"); captureCore.Outputs_Add(facebookOutput, true); await captureCore.StartAsync(); // Usage with VideoEditCoreX var editCore = new VideoEditCoreX(); // Add sources // ... // Set output format editCore.Output_Format = ConfigureFacebookLiveStream("your_streaming_key_here"); // Start await editCore.StartAsync(); ``` ## Media Blocks SDK Integration For developers requiring even more granular control, the Media Blocks SDK provides a modular approach to Facebook Live streaming: ``` // Create a pipeline var pipeline = new MediaBlocksPipeline(); // Add video source (camera, screen capture, etc.) var videoSource = new SomeVideoSourceBlock(); // Add audio source (microphone, system audio, etc.) var audioSource = new SomeAudioSourceBlock(); // Add video encoder (H.264) var h264Encoder = new H264EncoderBlock(videoEncoderSettings); // Add audio encoder (AAC) var aacEncoder = new AACEncoderBlock(audioEncoderSettings); // Create Facebook Live sink var facebookSink = new FacebookLiveSinkBlock( new FacebookLiveSinkSettings("your_streaming_key_here") ); // Connect blocks pipeline.Connect(videoSource.Output, h264Encoder.Input); pipeline.Connect(audioSource.Output, aacEncoder.Input); pipeline.Connect(h264Encoder.Output, facebookSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(aacEncoder.Output, facebookSink.CreateNewInput(MediaBlockPadMediaType.Audio)); // Start the pipeline pipeline.Start(); ``` ## Troubleshooting and Best Practices ### Common Issues and Solutions 1. **Stream Connection Failures** 2. Verify Facebook stream key validity and expiration status 3. Check network connectivity and firewall settings 4. Facebook requires port 80 (HTTP) and 443 (HTTPS) to be open 5. **Encoder Initialization Problems** 6. Always check hardware encoder availability before attempting to use them 7. Ensure GPU drivers are up-to-date for hardware acceleration 8. Fall back to software encoders when hardware acceleration is unavailable 9. **Performance Optimization** 10. Monitor CPU and GPU usage during streaming 11. Adjust video resolution and bitrate based on available bandwidth 12. Consider separate threads for video capture and encoding operations ### Quality and Security Best Practices 1. **Stream Key Security** 2. Never hardcode stream keys in your application 3. Store keys securely and consider runtime key retrieval from a secure API 4. Implement key rotation mechanisms for enhanced security 5. **Quality Settings Recommendations** 6. For HD streaming (1080p): 4-6 Mbps video bitrate, 128-192 Kbps audio 7. For SD streaming (720p): 2-4 Mbps video bitrate, 128 Kbps audio 8. Mobile-optimized: 1-2 Mbps video bitrate, 64-96 Kbps audio 9. **Resource Management** 10. Implement proper disposal of SDK resources 11. Monitor memory usage for long-running streams 12. Implement graceful error recovery mechanisms By implementing these best practices, your application will deliver reliable, high-quality Facebook Live streaming across a wide range of devices and network conditions. ---END OF PAGE--- ## HLS Live Streaming in C# .NET — m3u8 Playlist & Segments **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/hls-streaming/ **Description:** Generate .m3u8 playlists and .ts segments with built-in HTTP server. HLS.js, iOS AVPlayer, and Android ExoPlayer integration. VisioForge SDK examples. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, VideoCaptureCoreX, VideoEditCore, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, Conversion, HLS, TS, H.264, AAC, C# **API:** HLSOutput, HLSSinkSettings, MediaBlockPadMediaType, HLSPlaylistType, H264EncoderBlock # Complete Guide to HLS Network Streaming Implementation in .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) AI coding agents: use the VisioForge MCP server Building this with **Claude Code**, **Cursor**, or another AI coding agent? Connect to the public [VisioForge MCP server](../../mcp-server-usage/) at `https://mcp.visioforge.com/mcp` for structured API lookups, runnable code samples, and deployment guides — more accurate than grepping `llms.txt`. No authentication required. Claude Code: `claude mcp add --transport http visioforge-sdk https://mcp.visioforge.com/mcp` ## What is HTTP Live Streaming (HLS)? HTTP Live Streaming (HLS) is an adaptive bitrate streaming communications protocol designed and developed by Apple Inc. First introduced in 2009, it has since become one of the most widely adopted streaming protocols across various platforms and devices. HLS works by breaking the overall stream into a sequence of small HTTP-based file downloads, each containing a short segment of the overall content. ### Key Features of HLS Streaming - **Adaptive Bitrate Streaming**: HLS automatically adjusts video quality based on the viewer's network conditions, ensuring optimal playback quality without buffering. - **Cross-Platform Compatibility**: Works across iOS, macOS, Android, Windows, and most modern web browsers. - **HTTP-Based Delivery**: Leverages standard web server infrastructure, allowing content to pass through firewalls and proxy servers. - **Media Encryption and Authentication**: Supports content protection through encryption and various authentication methods. - **Live and On-Demand Content**: Can be used for both live broadcasting and pre-recorded media. ### HLS Technical Structure HLS content delivery relies on three key components: 1. **Manifest File (.m3u8)**: A playlist file that contains metadata about the various streams available 2. **Segment Files (.ts)**: The actual media content, divided into small chunks (typically 2-10 seconds each) 3. **HTTP Server**: Responsible for delivering both manifest and segment files Since HLS is entirely HTTP-based, you'll need either a dedicated HTTP server or can use the lightweight internal server provided by our SDKs. ## Implementing HLS Streaming with Media Blocks SDK The Media Blocks SDK offers a comprehensive approach to HLS streaming through its pipeline architecture, giving developers granular control over each aspect of the streaming process. ### Creating a Basic HLS Stream The following example demonstrates how to set up an HLS stream using Media Blocks SDK: ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AudioEncoders; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoEncoders; using VisioForge.Core.Types; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Sinks; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.Types.X.VideoEncoders; // Initialise the cross-platform engine once per process. VisioForgeX.InitSDK(); const string URL = "http://localhost:8088/"; // Pipeline (attach error handler before adding blocks). var pipeline = new MediaBlocksPipeline(); pipeline.OnError += (s, e) => Console.WriteLine($"ERROR: {e.Message}"); // Video source: first enumerated capture device. var videoDevices = await DeviceEnumerator.Shared.VideoSourcesAsync(); var videoSettings = new VideoCaptureDeviceSourceSettings(videoDevices[0]); var videoSource = new SystemVideoSourceBlock(videoSettings); // Audio source: first enumerated audio capture device. var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync(); var audioSettings = new AudioCaptureDeviceSourceSettings(audioDevices[0]); var audioSource = new SystemAudioSourceBlock(audioSettings); // H.264 and AAC encoders. var h264Encoder = new H264EncoderBlock(new OpenH264EncoderSettings()); var aacEncoder = new AACEncoderBlock(); // HLS sink. var settings = new HLSSinkSettings { Location = Path.Combine(AppContext.BaseDirectory, "segment_%05d.ts"), MaxFiles = 10, PlaylistLength = 5, PlaylistLocation = Path.Combine(AppContext.BaseDirectory, "playlist.m3u8"), PlaylistRoot = URL.TrimEnd('/'), SendKeyframeRequests = true, TargetDuration = TimeSpan.FromSeconds(5), // TimeSpan, not int Custom_HTTP_Server_Enabled = true, Custom_HTTP_Server_Port = 8088 }; var hlsSink = new HLSSinkBlock(settings); // Wire the graph: source → encoder → HLS sink (separate pads for video/audio). pipeline.Connect(videoSource.Output, h264Encoder.Input); pipeline.Connect(audioSource.Output, aacEncoder.Input); pipeline.Connect(h264Encoder.Output, hlsSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(aacEncoder.Output, hlsSink.CreateNewInput(MediaBlockPadMediaType.Audio)); // Start. Open http://localhost:8088/playlist.m3u8 in a player or browser. await pipeline.StartAsync(); ``` ### Advanced Configuration Options The Media Blocks SDK offers several advanced configuration options for HLS streaming: - **Multiple Bitrate Variants**: Create different quality levels for adaptive streaming - **Custom Segment Duration**: Optimize for different types of content and viewing environments - **Server-Side Options**: Configure cache control headers and other server behaviors - **Security Features**: Implement token-based authentication or encryption You can use this SDK to stream both live video capture and existing media files to HLS. The flexible pipeline architecture allows for extensive customization of the media processing workflow. ## HLS Streaming with Video Capture SDK .NET Video Capture SDK .NET provides a streamlined approach to HLS streaming specifically designed for live video sources like webcams, capture cards, and other input devices. ### VideoCaptureCoreX Implementation The VideoCaptureCoreX engine offers a modern, object-oriented approach to video capture and streaming: ``` // Create HLS sink settings var settings = new HLSSinkSettings { Location = Path.Combine(AppContext.BaseDirectory, "segment_%05d.ts"), MaxFiles = 10, PlaylistLength = 5, PlaylistLocation = Path.Combine(AppContext.BaseDirectory, "playlist.m3u8"), PlaylistRoot = edStreamingKey.Text, SendKeyframeRequests = true, TargetDuration = TimeSpan.FromSeconds(5), // TimeSpan, not int Custom_HTTP_Server_Enabled = true, Custom_HTTP_Server_Port = new Uri(edStreamingKey.Text).Port }; // Create HLS output var hlsOutput = new HLSOutput(settings); // Create video and audio encoders with default settings hlsOutput.Video = new OpenH264EncoderSettings(); hlsOutput.Audio = new VOAACEncoderSettings(); // Add HLS output to video capture object videoCapture.Outputs_Add(hlsOutput, true); ``` ### VideoCaptureCore Implementation For those working with the traditional VideoCaptureCore engine, the implementation is slightly different but equally straightforward: ``` VideoCapture1.Network_Streaming_Enabled = true; VideoCapture1.Network_Streaming_Audio_Enabled = true; VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.HLS; var hls = new HLSOutput { HLS = { SegmentDuration = 10, // Segment duration in seconds NumSegments = 5, // Number of segments in playlist OutputFolder = "c:\\hls\\", // Output folder PlaylistType = HLSPlaylistType.Live, // Playlist type Custom_HTTP_Server_Enabled = true, // Use internal HTTP server Custom_HTTP_Server_Port = 8088 // Port for internal HTTP server } }; VideoCapture1.Network_Streaming_Output = hls; ``` ### Performance Considerations When streaming with Video Capture SDK, consider these performance optimization techniques: - Keep segment durations between 2-10 seconds (10 seconds is optimal for most use cases) - Adjust the number of segments based on expected viewing patterns - Use hardware acceleration when available for encoding - Configure appropriate bitrates based on your target audience's connection speeds ## Converting Media Files to HLS with Video Edit SDK .NET The Video Edit SDK .NET enables developers to convert existing media files into HLS format for streaming, ideal for video-on-demand applications. ### VideoEditCore Implementation ``` VideoEdit1.Network_Streaming_Enabled = true; VideoEdit1.Network_Streaming_Audio_Enabled = true; VideoEdit1.Network_Streaming_Format = NetworkStreamingFormat.HLS; var hls = new HLSOutput { HLS = { SegmentDuration = 10, // Segment duration in seconds NumSegments = 5, // Number of segments in playlist OutputFolder = "c:\\hls\\", // Output folder PlaylistType = HLSPlaylistType.Live, // Playlist type Custom_HTTP_Server_Enabled = true, // Use internal HTTP server Custom_HTTP_Server_Port = 8088 // Port for internal HTTP server } }; VideoEdit1.Network_Streaming_Output = hls; ``` ### File Format Considerations When converting files to HLS, consider these factors: - Not all input formats are equally efficient for conversion - MP4, MOV, and MKV files typically provide the best results - Highly compressed formats may require more processing power - Consider pre-transcoding very large files to an intermediate format ## Playback and Integration ### HTML5 Player Integration All applications implementing HLS streaming should include an HTML file with a video player. Modern HTML5 players like HLS.js, Video.js, or JW Player provide excellent support for HLS streams. Here's a basic example using HLS.js: ``` HLS Player ``` For a complete example player, refer to our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples/blob/master/Media%20Blocks%20SDK/Console/HLS%20Streamer/index.htm). ### Mobile App Integration Our SDKs also support integration with mobile applications through: - Native iOS playback using AVPlayer - Android playback via ExoPlayer - Cross-platform options like Xamarin or MAUI ## Troubleshooting Common Issues ### CORS Configuration When serving HLS content to web browsers, you may encounter Cross-Origin Resource Sharing (CORS) issues. Ensure your server is configured to send the proper CORS headers: ``` Access-Control-Allow-Origin: * Access-Control-Allow-Methods: GET, HEAD, OPTIONS Access-Control-Allow-Headers: Range Access-Control-Expose-Headers: Accept-Ranges, Content-Encoding, Content-Length, Content-Range ``` ### Latency Optimization HLS inherently introduces some latency. To minimize this: - Use shorter segment durations (2-4 seconds) for lower latency - Consider enabling Low-Latency HLS (LL-HLS) if supported - Optimize your network infrastructure for minimal delays ## Conclusion HLS streaming provides a robust, cross-platform solution for delivering both live and on-demand video content to a wide range of devices. With VisioForge's .NET SDKs, implementing HLS in your applications becomes straightforward, allowing you to focus on creating compelling content rather than wrestling with technical details. For more code samples and advanced implementations, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). --- ## Additional Resources - [HLS Specification](https://developer.apple.com/streaming/) ---END OF PAGE--- ## HTTP MJPEG Streaming Server in C# .NET — Send Live Video **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/http-mjpeg/ **Description:** Stream live video as HTTP MJPEG from webcams, IP cameras, or files in C# / .NET. Browser-viewable endpoints, concurrent clients, GPU JPEG encoding. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Streaming, Editing, MJPEG, C# **API:** VideoCaptureCoreX, HTTPMJPEGLiveOutput, HTTPMJPEGLiveSinkBlock, IVideoCaptureXBaseOutput, IMediaBlockSink # HTTP MJPEG streaming [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Cross-platform support The `VideoCaptureCoreX` engine and the Media Blocks SDK run on **Windows, macOS, Linux, Android, and iOS** via GStreamer. See the [platform support matrix](../../../platform-matrix/) for codec and hardware-acceleration details, and the [Linux deployment guide](../../../deployment-x/Ubuntu/) for Ubuntu / NVIDIA Jetson / Raspberry Pi setup. The SDK's feature of streaming video encoded as Motion JPEG (MJPEG) over HTTP is advantageous for its simplicity and broad compatibility. MJPEG encodes each video frame individually as a JPEG image, which simplifies decoding and is ideal for applications like web streaming and surveillance. The use of HTTP ensures easy integration and high compatibility across different platforms and devices and is effective even in networks with strict configurations. This method is particularly suitable for real-time video feeds and applications requiring straightforward frame-by-frame analysis. With adjustable frame rates and resolutions, the SDK offers flexibility for various network conditions and quality requirements, making it a versatile choice for developers implementing video streaming in their applications. AI coding agents: use the VisioForge MCP server Building this with **Claude Code**, **Cursor**, or another AI coding agent? Connect to the public [VisioForge MCP server](../../mcp-server-usage/) at `https://mcp.visioforge.com/mcp` for structured API lookups, runnable code samples, and deployment guides — more accurate than grepping `llms.txt`. No authentication required. Claude Code: `claude mcp add --transport http visioforge-sdk https://mcp.visioforge.com/mcp` ## Cross-platform MJPEG output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The streaming functionality is implemented through two main classes: 1. `HTTPMJPEGLiveOutput`: The high-level configuration class that sets up the streaming output 2. `HTTPMJPEGLiveSinkBlock`: The underlying implementation block that handles the actual streaming process ### HTTPMJPEGLiveOutput Class This class serves as the configuration entry point for setting up an MJPEG HTTP stream. It implements the `IVideoCaptureXBaseOutput` interface, making it compatible with the video capture pipeline system. #### Key Properties - `Port`: Gets the network port number on which the MJPEG stream will be served #### Usage ``` // Create a new MJPEG streaming output on port 8080 var mjpegOutput = new HTTPMJPEGLiveOutput(8080); // Add the MJPEG output to the VideoCaptureCoreX engine core.Outputs_Add(mjpegOutput, true); ``` #### Implementation Details - The class is designed to be immutable, with the port being set only through the constructor - It does not support video or audio encoders, as MJPEG uses direct JPEG encoding - The filename-related methods return null or are no-ops, as this is a streaming-only implementation ### HTTPMJPEGLiveSinkBlock Class This class handles the actual implementation of the MJPEG streaming functionality. It's responsible for: - Setting up the pipeline for video processing - Managing the HTTP server for streaming - Handling input video data and converting it to MJPEG format - Managing client connections and stream delivery #### Key Features - Implements multiple interfaces for integration with the media pipeline: - `IMediaBlockInternals`: For pipeline integration - `IMediaBlockDynamicInputs`: For handling dynamic input connections - `IMediaBlockSink`: For sink functionality - `IDisposable`: For proper resource cleanup #### Input/Output Configuration - Accepts a single video input through the `Input` pad - No output pads (as it's a sink block) - Input pad configured for video media type only ### Implementation Notes #### Initialization ``` // The block must be initialized with a port number var mjpegSink = new HTTPMJPEGLiveSinkBlock(8080); pipeline.Connect(videoSource.Output, mjpegSink.Input); // "IMG tag URL is http://127.0.0.1:8090"; ``` #### Resource Management - The class implements proper resource cleanup through the `IDisposable` pattern - The `CleanUp` method ensures all resources are properly released - Event handlers are properly connected and disconnected during the pipeline lifecycle #### Pipeline Integration The `Build` method handles the critical setup process: 1. Creates the underlying HTTP MJPEG sink element 2. Initializes the sink with the specified port 3. Sets up the necessary GStreamer pad connections 4. Connects pipeline event handlers ### Error Handling - The implementation includes comprehensive error checking during the build process - Failed initialization is properly reported through the context error system - Resource cleanup is handled even in error cases ### Technical Considerations #### Performance - The implementation uses GStreamer's native elements for optimal performance - Direct pad connections minimize copying and overhead - The sink block is designed to handle multiple client connections efficiently #### Memory Management - Proper disposal patterns ensure no memory leaks - Resources are cleaned up when the pipeline stops or the block is disposed - The implementation handles GStreamer element lifecycle correctly #### Threading - The implementation is thread-safe for pipeline operations - Event handlers are properly synchronized with pipeline state changes - Client connections are handled asynchronously #### Client Usage To consume the MJPEG stream: 1. Initialize the streaming output with desired port 2. Connect it to your video pipeline 3. Access the stream through a web browser or HTTP client at: ``` http://[server-address]:[port] ``` #### Example Client HTML ``` ``` ### Limitations and Considerations 1. Bandwidth Usage 2. MJPEG streams can use significant bandwidth as each frame is a complete JPEG 3. Consider frame rate and resolution settings for optimal performance 4. Browser Support 5. While MJPEG is widely supported, some modern browsers may have limitations 6. Mobile devices may handle MJPEG streams differently 7. Latency 8. While MJPEG provides relatively low latency, it's not suitable for ultra-low-latency requirements 9. Network conditions can affect frame delivery timing ### Best Practices 1. Port Selection 2. Choose ports that don't conflict with other services 3. Consider firewall implications when selecting ports 4. Resource Management 5. Always dispose of the sink block properly 6. Monitor client connections and resource usage 7. Error Handling 8. Implement proper error handling for network and pipeline issues 9. Monitor the pipeline status for potential issues ### Security Considerations 1. Network Security 2. The MJPEG stream is unencrypted by default 3. Consider implementing additional security measures for sensitive content 4. Access Control 5. No built-in authentication mechanism 6. Consider implementing application-level access control if needed 7. Port Security 8. Ensure proper firewall rules are in place 9. Consider network isolation for internal streams ## Windows-only MJPEG output [VideoCaptureCore](#) [VideoEditCore](#) Set the `Network_Streaming_Enabled` property to true to enable network streaming. ``` VideoCapture1.Network_Streaming_Enabled = true; ``` Set the HTTP MJPEG output. ``` VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.HTTP_MJPEG; ``` Create the settings object and set the port. ``` VideoCapture1.Network_Streaming_Output = new MJPEGOutput(8080); ``` --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## IIS Smooth Streaming Setup Guide for .NET Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/iis-smooth-streaming/ **Description:** Configure Microsoft IIS Smooth Streaming in .NET with adaptive bitrate, mobile compatibility, and troubleshooting for quality video delivery. **Tags:** Video Capture SDK, Video Edit SDK, .NET, VideoCaptureCore, VideoEditCore, Windows, Capture, Streaming, Editing, HLS, MP4, C#, JavaScript, NuGet # Comprehensive Guide to IIS Smooth Streaming Implementation IIS Smooth Streaming is Microsoft's implementation of adaptive streaming technology that dynamically adjusts video quality based on network conditions and CPU capabilities. This guide provides detailed instructions on configuring and implementing IIS Smooth Streaming using VisioForge SDKs. ## Compatible VisioForge SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [VideoCaptureCore](#) [VideoEditCore](#) IIS Media Services and IIS Smooth Streaming are unmaintained Microsoft retired the **Web Platform Installer** feed on December 31, 2022 (see the [official announcement](https://blogs.iis.net/iisteam/web-platform-installer-end-of-support-feed)) and removed **IIS Media Services 4.1** — the component that delivers Smooth Streaming — from the IIS download portal. The Silverlight client that the Smooth Streaming Player uses was retired by Microsoft on October 12, 2021. For new projects, use **[HLS](../hls-streaming/)** instead: it is the modern adaptive-bitrate format supported natively by browsers and mobile devices, and VisioForge's `MP4Output` / `HLSOutput` produce HLS streams out of the box. The instructions below remain available for customers maintaining existing IIS Media Services 4.1 deployments only. ## Overview of IIS Smooth Streaming IIS Smooth Streaming provides several key advantages for developers and end-users: - **Adaptive bitrate streaming**: Automatically adjusts video quality based on available bandwidth - **Reduced buffering**: Minimizes playback interruptions during network fluctuations - **Broad device compatibility**: Works across desktops, mobile devices, smart TVs, and more - **Scalable delivery**: Handles large numbers of concurrent viewers efficiently This technology is particularly valuable for applications requiring high-quality video delivery across varied network conditions, such as live events, educational platforms, and media-rich applications. ## Prerequisites Before implementing IIS Smooth Streaming with VisioForge SDKs, ensure you have: 1. Windows Server with IIS installed 2. Administrative access to the server 3. Relevant VisioForge SDK (Video Capture SDK .Net or Video Edit SDK .Net) 4. Basic understanding of .NET development ## Step-by-Step IIS Configuration ### Installing Required Components 1. Install [Web Platform Installer](https://blogs.iis.net/iisteam/web-platform-installer-end-of-support-feed/) on your server. 2. Through the Web Platform Installer, search for and install IIS Media Services. This component package includes all necessary modules for Smooth Streaming functionality, including the Live Smooth Streaming Publishing service. ### Configuring IIS Manager 1. Open IIS Manager on your server through the Start menu or by running `inetmgr` in the Run dialog. 1. In the left navigation pane, locate and expand your server name, then select the site where you want to enable Smooth Streaming. ### Creating a Publishing Point 1. Within the selected site, find and open the "Live Smooth Streaming Publishing Points" feature. 2. Click "Add" to create a new publishing point. 1. Configure the basic settings for your publishing point: 2. **Name**: Provide a descriptive name for your publishing point (e.g., "MainStream") 3. **Path**: Specify the file path where the Smooth Streaming content will be stored 1. Configure additional parameters by enabling the "Allow clients to connect to this publishing point" checkbox. This ensures that clients can connect and receive the streamed content. ### Enabling Mobile Device Support To ensure your Smooth Streaming content is accessible on mobile devices: 1. In the publishing point configuration, navigate to the "Mobile Devices" tab. 2. Enable the checkbox for "Allow playback on mobile devices." This setting generates the necessary formats and manifests for mobile playback, significantly expanding your content's reach. ### Setting Up the Player To provide viewers with a way to watch your Smooth Streaming content: 1. Download the Smooth Streaming Player Silverlight control provided by Microsoft. 2. Extract the downloaded files and locate the `.xap` file. 3. Copy this `.xap` file to your website's directory. 4. Copy the included HTML file to the same directory and rename it to `index.html`. 5. Open `index.html` in a text editor and replace the "initparams" section with the following configuration: ``` ``` This configuration initializes the Silverlight player with optimal settings for Smooth Streaming playback. The `mediaurl` parameter should point to your publishing point's manifest. ### Starting the Publishing Point 1. Return to IIS Manager and select your configured publishing point. 2. Click the "Start" action in the right-hand panel. The publishing point will now be active and ready to receive content from your application. ## Implementing Smooth Streaming in VisioForge SDK Applications ### Basic Configuration Configure an existing `VideoCaptureCore` (or `VideoEditCore`) instance to push to your IIS publishing point using `NetworkStreamingFormat.SSF_H264_AAC_SW` (Smooth Streaming, H.264 + AAC, software encoding): ``` using VisioForge.Core.Types.Output; using VisioForge.Core.VideoCapture; // Assumes VideoCapture1 is a VideoCaptureCore already bound to a VideoView. VideoCapture1.Network_Streaming_Enabled = true; VideoCapture1.Network_Streaming_Audio_Enabled = true; // Pick the Smooth Streaming format. Use SSF_FFMPEG_EXE if you prefer FFMPEG-based encoding. VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.SSF_H264_AAC_SW; // URL of the IIS publishing point you created above. VideoCapture1.Network_Streaming_URL = "http://localhost/mainstream.isml"; // H.264 + AAC parameters via MP4Output (Smooth Streaming muxes H.264/AAC into the ISML container). var streamOutput = new MP4Output(); streamOutput.Video = new MP4OutputH264Settings { Bitrate = 2500, // kbps — target bitrate Profile = H264Profile.ProfileMain, Level = H264Level.Level4, RateControl = H264RateControl.VBR }; streamOutput.Audio_AAC.Bitrate = 128; streamOutput.Audio_AAC.Object = AACObject.Low; VideoCapture1.Network_Streaming_Output = streamOutput; await VideoCapture1.StartAsync(); ``` ### Verifying the Connection Once your application is configured: 1. Check the connection status in your application. You should see confirmation that the SDK has successfully connected to IIS. 1. Open a web browser and navigate to `http://localhost` (or your server address). 2. The Silverlight player should load and begin playing your stream. ### HTML5 Streaming for iOS Devices For broader device compatibility, particularly iOS devices that don't support Silverlight, create an HTML5 player: 1. Create a new HTML file in your website's directory. 2. Include the following code in the file: ``` Smooth Streaming HTML5 Player

HTML5 Smooth Streaming Player

``` This HTML5 player uses HLS (HTTP Live Streaming) format, which is automatically generated by IIS Media Services when you enable mobile device support. ## Required Redistributables To ensure your application functions correctly with IIS Smooth Streaming, include the following redistributables: - SDK redistributables for your specific VisioForge SDK - MP4 redistributables: - For x86 architectures: [VisioForge.DotNet.Core.Redist.MP4.x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.MP4.x86/) - For x64 architectures: [VisioForge.DotNet.Core.Redist.MP4.x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.MP4.x64/) You can add these packages through NuGet Package Manager in Visual Studio or via the command line: ``` Install-Package VisioForge.DotNet.Core.Redist.MP4.x64 ``` ## Advanced Configuration Options For production environments, consider these additional configurations: - **Multiple bitrate encoding**: Configure your VisioForge SDK to encode at multiple bitrates for optimal adaptive streaming - **Custom manifest settings**: Modify the Smooth Streaming manifest for specialized playback requirements - **Authentication**: Implement token-based authentication for secure streaming - **Content encryption**: Enable DRM protection for sensitive content - **Load balancing**: Configure multiple publishing points behind a load balancer for high-traffic scenarios ## Troubleshooting Common Issues - **Connection failures**: Verify firewall settings allow traffic on the streaming port (typically 80 or 443) - **Playback stuttering**: Check server resources and consider increasing buffer settings - **Mobile compatibility issues**: Ensure mobile format generation is enabled and test across multiple devices - **Quality issues**: Adjust encoding parameters and bitrate ladder configuration ## Conclusion IIS Smooth Streaming, when implemented with VisioForge SDKs, provides a robust solution for adaptive video delivery across diverse network conditions and devices. By following this comprehensive guide, you can configure, implement, and optimize Smooth Streaming for your .NET applications. For additional code samples and implementation examples, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). --- *This documentation is provided by VisioForge. For additional support or information about our SDKs, please visit [www.visioforge.com](https://www.visioforge.com).* ---END OF PAGE--- ## Network Streaming in .NET - RTMP, RTSP, HLS, NDI, SRT **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/ **Description:** Implement RTMP, RTSP, HLS, NDI, and other streaming protocols in .NET with hardware acceleration for live broadcasting and media platforms. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming # Comprehensive Network Streaming Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Network Streaming Network streaming enables real-time transmission of audio and video content across the internet or local networks. VisioForge's comprehensive SDKs provide powerful tools for implementing various streaming protocols in your .NET applications, allowing you to create professional-grade broadcasting solutions with minimal development effort. This guide covers all streaming options available in VisioForge SDKs, including implementation details, best practices, and code examples to help you select the most appropriate streaming technology for your specific requirements. ## Streaming Protocol Overview VisioForge SDKs support a wide range of streaming protocols, each with unique advantages for different use cases: ### Real-Time Protocols - **[RTMP (Real-Time Messaging Protocol)](rtmp/)**: Industry-standard protocol for low-latency live streaming, widely used for live broadcasting to CDNs and streaming platforms - **[RTSP (Real-Time Streaming Protocol)](rtsp/)**: Ideal for IP camera integration and surveillance applications, offering precise control over media sessions - **[SRT (Secure Reliable Transport)](srt/)**: Advanced protocol designed for high-quality, low-latency video delivery over unpredictable networks - **[NDI (Network Device Interface)](ndi/)**: Professional-grade protocol for high-quality, low-latency video transmission over local networks ### HTTP-Based Streaming - **[HLS (HTTP Live Streaming)](hls-streaming/)**: Apple-developed protocol that breaks streams into downloadable segments, offering excellent compatibility with browsers and mobile devices - **[HTTP MJPEG Streaming](http-mjpeg/)**: Simple implementation for streaming motion JPEG over HTTP connections - **[IIS Smooth Streaming](iis-smooth-streaming/)**: Microsoft's adaptive streaming technology for delivering media through IIS servers ### Platform-Specific Solutions - **[Windows Media Streaming (WMV)](wmv/)**: Microsoft's native streaming format, ideal for Windows-centric deployments - **[Adobe Flash Media Server](adobe-flash/)**: Legacy streaming solution for Flash-based applications ### Cloud & Social Media Integration - **[AWS S3](aws-s3/)**: Direct streaming to Amazon Web Services S3 storage - **[YouTube Live](youtube/)**: Simplified integration with YouTube's live streaming platform - **[Facebook Live](facebook/)**: Direct broadcasting to Facebook's streaming service ## Key Components of Network Streaming ### Video Encoders VisioForge SDKs provide multiple encoding options to balance quality, performance and compatibility: #### Software Encoders - **OpenH264**: Cross-platform software-based H.264 encoder - **AVENC H264**: FFmpeg-based software encoder #### Hardware-Accelerated Encoders - **NVENC H264/HEVC**: NVIDIA GPU-accelerated encoding - **QSV H264/HEVC**: Intel Quick Sync Video acceleration - **AMF H264/HEVC**: AMD GPU-accelerated encoding - **Apple Media H264**: macOS-specific hardware acceleration ## Best Practices for Network Streaming ### Performance Optimization 1. **Hardware acceleration**: Leverage GPU-based encoding where available for reduced CPU usage 2. **Resolution and framerate**: Match output to content type (60fps for gaming, 30fps for general content) 3. **Bitrate allocation**: Allocate 80-90% of bandwidth to video and 10-20% to audio ### Network Reliability 1. **Connection testing**: Verify upload speed before streaming 2. **Error handling**: Implement reconnection logic for disrupted streams 3. **Monitoring**: Track streaming metrics in real-time to identify issues ### Quality Assurance 1. **Pre-streaming checks**: Validate encoder settings and output parameters 2. **Quality monitoring**: Regularly check stream quality during broadcast 3. **Platform compliance**: Follow platform-specific requirements (YouTube, Facebook, etc.) ## Troubleshooting Common Issues 1. **Encoding overload**: If experiencing frame drops, reduce resolution or bitrate 2. **Connection failures**: Verify network stability and server addresses 3. **Audio/video sync**: Ensure proper timestamp synchronization between streams 4. **Platform rejection**: Confirm compliance with platform-specific requirements 5. **Hardware acceleration failures**: Verify driver installation and compatibility ## Conclusion Network streaming with VisioForge SDKs provides a comprehensive solution for implementing professional-grade media broadcasting in your .NET applications. By understanding the available protocols and following best practices, you can create high-quality streaming experiences for your users across multiple platforms. For protocol-specific implementation details, refer to the dedicated guides linked throughout this document. ---END OF PAGE--- ## NDI Video and Audio Streaming over IP Network in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/ndi/ **Description:** Stream video and audio to NDI from cameras, files, and capture devices in C# .NET. Setup guide with SDK output examples, audio resampling, and troubleshooting. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, GStreamer, Capture, Streaming, Editing, Webcam, NDI, MP4, C# **API:** NDISinkBlock, AudioResamplerBlock, NDIOutput, MediaBlockPadMediaType, MediaBlocksPipeline # Network Device Interface (NDI) Streaming Integration [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## What is NDI? Network Device Interface (NDI) is an industry standard for live video production over IP networks. It enables high-quality, low-latency video and audio streaming over standard Ethernet — replacing expensive SDI cabling with software-based workflows. Common use cases include: - Live broadcasting and streaming - Professional video conferencing - Multi-camera production setups - Remote production workflows - Playout server applications The VisioForge SDK provides NDI output support for desktop/server workflows, letting you stream cameras, capture devices, or media files to NDI receivers on your network. ## Installation Requirements To use NDI streaming, install one of the following official NDI packages: 1. **[NDI SDK](https://ndi.video/for-developers/ndi-sdk/download/)** - Recommended for developers 2. **[NDI Tools](https://ndi.video/tools/)** - Suitable for testing These provide the runtime components that enable NDI communication. You can verify NDI availability in code: ``` bool ndiAvailable = NDISinkBlock.IsAvailable(); ``` ## Cross-Platform NDI Output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ### NDIOutput Class The `NDIOutput` class provides NDI output for VideoCaptureCoreX and VideoEditCoreX engines: ``` public class NDIOutput : IVideoEditXBaseOutput, IVideoCaptureXBaseOutput, IOutputVideoProcessor, IOutputAudioProcessor ``` #### Configuration | Property | Type | Description | | --- | --- | --- | | `Sink` | `NDISinkSettings` | NDI output configuration (stream name, compression, network settings) | | `CustomVideoProcessor` | `MediaBlock` | Optional custom video processing before NDI transmission | | `CustomAudioProcessor` | `MediaBlock` | Optional custom audio processing before NDI transmission | #### Constructors ``` // Create with stream name var output = new NDIOutput("My Stream"); // Create with pre-configured settings var output = new NDIOutput(new NDISinkSettings("My Stream")); ``` ## Implementation Examples ### Media Blocks SDK ``` // Create an NDI output block with a descriptive stream name var ndiSink = new NDISinkBlock("VisioForge Production Stream"); // Connect video source to the NDI output pipeline.Connect(videoSource.Output, ndiSink.CreateNewInput(MediaBlockPadMediaType.Video)); // Connect audio source to the NDI output pipeline.Connect(audioSource.Output, ndiSink.CreateNewInput(MediaBlockPadMediaType.Audio)); ``` ### Video Capture SDK ``` // Initialize NDI output with a network-friendly stream name var ndiOutput = new NDIOutput("VisioForge_Studio_Output"); // Add the configured NDI output to the video capture pipeline core.Outputs_Add(ndiOutput); // core represents the VideoCaptureCoreX instance ``` ## Streaming a Camera to NDI [MediaBlocksPipeline](#) The most common use case is streaming a local webcam and microphone to NDI. This example uses the Media Blocks SDK to capture from system devices and send to NDI with proper audio resampling. ### Pipeline Architecture ``` SystemVideoSourceBlock → NDISinkBlock (video input) SystemAudioSourceBlock → AudioResamplerBlock (48kHz, F32LE, stereo) → NDISinkBlock (audio input) ``` ### Code Example ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.AudioProcessing; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.Types.X.AudioEncoders; // Initialize SDK once at startup await VisioForgeX.InitSDKAsync(); var pipeline = new MediaBlocksPipeline(); // Enumerate available devices var videoDevices = await DeviceEnumerator.Shared.VideoSourcesAsync(); var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync(); // Set up video source (first available camera) var videoSettings = new VideoCaptureDeviceSourceSettings(videoDevices[0]); var videoSource = new SystemVideoSourceBlock(videoSettings); // Set up audio source (first available microphone) var audioSettings = new AudioCaptureDeviceSourceSettings(audioDevices[0]); var audioSource = new SystemAudioSourceBlock(audioSettings); // Create NDI output var ndiSink = new NDISinkBlock("My Camera Stream"); // Connect video directly to NDI pipeline.Connect(videoSource.Output, ndiSink.CreateNewInput(MediaBlockPadMediaType.Video)); // Resample audio to 48kHz F32LE stereo (required by NDI) var audioResampler = new AudioResamplerBlock( new AudioResamplerSettings(AudioFormatX.F32LE, 48000, 2)); pipeline.Connect(audioSource.Output, audioResampler.Input); pipeline.Connect(audioResampler.Output, ndiSink.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## Windows-Specific NDI Implementation [VideoCaptureCore](#) [VideoEditCore](#) For Windows-specific implementations, the SDK provides additional configuration options through the VideoCaptureCore or VideoEditCore components. ### Step-by-Step Implementation Guide #### 1. Enable Network Streaming ``` VideoCapture1.Network_Streaming_Enabled = true; ``` #### 2. Configure Audio Streaming ``` VideoCapture1.Network_Streaming_Audio_Enabled = true; ``` #### 3. Select NDI Protocol ``` VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.NDI; ``` #### 4. Create and Configure NDI Output ``` var streamName = "VisioForge NDI Streamer"; var ndiOutput = new NDIOutput(streamName); ``` #### 5. Assign the Output ``` VideoCapture1.Network_Streaming_Output = ndiOutput; ``` #### 6. Generate the NDI URL (Optional) ``` string ndiUrl = $"ndi://{System.Net.Dns.GetHostName()}/{streamName}"; Debug.WriteLine(ndiUrl); ``` ## File Playback to NDI Output The Media Blocks SDK can stream local media files (MP4, MKV, AVI, etc.) directly to NDI without any local rendering — ideal for playout server applications. ### Recommended Pipeline ``` UniversalSourceBlock (file) VideoOutput → NDISinkBlock (video input) AudioOutput → AudioResamplerBlock (48kHz, F32LE, stereo) → NDISinkBlock (audio input) ``` ### Code Example ``` var pipeline = new MediaBlocksPipeline(); // File source with automatic format detection var fileSource = new UniversalSourceBlock( await UniversalSourceSettings.CreateAsync(new Uri("file:///path/to/video.mp4"))); // NDI output var ndiSink = new NDISinkBlock("My NDI Stream"); // Connect video directly to NDI pipeline.Connect(fileSource.VideoOutput, ndiSink.CreateNewInput(MediaBlockPadMediaType.Video)); // Resample audio to 48kHz F32LE stereo for NDI compatibility var audioResampler = new AudioResamplerBlock( new AudioResamplerSettings(AudioFormatX.F32LE, 48000, 2)); pipeline.Connect(fileSource.AudioOutput, audioResampler.Input); pipeline.Connect(audioResampler.Output, ndiSink.CreateNewInput(MediaBlockPadMediaType.Audio)); // Optional: enable loop playback pipeline.Loop = true; await pipeline.StartAsync(); ``` ## Audio Format Requirements NDI requires **48kHz, 32-bit float (F32LE), interleaved** audio. When streaming from sources that may contain audio at other sample rates (e.g., 44.1kHz AAC in MP4 files, or varying microphone rates), always include an `AudioResamplerBlock` to convert to 48kHz. Without resampling, audio may stutter, glitch, or lose synchronization with video. ``` var audioResampler = new AudioResamplerBlock( new AudioResamplerSettings(AudioFormatX.F32LE, 48000, 2)); ``` ## Receiving NDI Sources This guide focuses on sending video and audio to NDI. To discover, connect, preview, or capture NDI sources, including Android and MAUI NDI player applications, see the [NDI Video Source Reference](../../../videocapture/video-sources/ip-cameras/ndi/). ## Troubleshooting ### Audio Stuttering or Glitching on NDI Output **Symptom:** Audio is not smooth when streaming from file sources — stutters, glitches, or lip-sync issues. **Cause:** The source file contains audio at a sample rate other than 48kHz (e.g., 44.1kHz AAC in MP4 files). NDI expects 48kHz audio. **Solution:** Insert an `AudioResamplerBlock` configured for 48kHz F32LE stereo between the file source and the NDI sink, as shown in the file playback example above. ## Frequently Asked Questions ### How do I stream video from a camera to NDI in C#? Use the Media Blocks SDK to create a pipeline with `SystemVideoSourceBlock` for the camera, `SystemAudioSourceBlock` for the microphone, and `NDISinkBlock` as the output. Connect audio through an `AudioResamplerBlock` set to 48kHz F32LE stereo, which NDI requires. See the [Streaming a Camera to NDI](#streaming-a-camera-to-ndi) section for complete code. ### What audio format does NDI require? NDI requires 48kHz, 32-bit float (F32LE), interleaved stereo audio. Always include an `AudioResamplerBlock(new AudioResamplerSettings(AudioFormatX.F32LE, 48000, 2))` in your pipeline between the audio source and the NDI sink. Without proper resampling, you may experience audio stuttering, glitches, or A/V sync issues. ### Can I stream a video file to NDI for playout? Yes. Use `UniversalSourceBlock` to read the file, connect video directly to `NDISinkBlock`, and route audio through `AudioResamplerBlock` for 48kHz conversion. Enable `pipeline.Loop = true` for continuous playout. This pattern is ideal for broadcast playout servers with zero local rendering overhead. ### What are the system requirements for NDI streaming in .NET? You need the [NDI SDK](https://ndi.video/for-developers/ndi-sdk/download/) or [NDI Tools](https://ndi.video/tools/) installed for runtime NDI support. The VisioForge SDK supports Windows, macOS, and Linux. Check NDI availability at runtime with `NDISinkBlock.IsAvailable()`. Network bandwidth requirements depend on resolution and framerate — a typical HD NDI stream uses approximately 100-150 Mbps. ### How do I check if NDI is available on the system? Call `NDISinkBlock.IsAvailable()` before creating NDI pipeline components. This static method checks whether the NDI runtime libraries are installed and accessible. If it returns `false`, prompt the user to install the NDI SDK or NDI Tools package. ## See Also - [NDI Video Source Reference](../../../videocapture/video-sources/ip-cameras/ndi/) — receiving and capturing NDI sources in .NET - [RTSP Stream Viewer and IP Camera Player](../../../mediablocks/Guides/rtsp-player-csharp/) — similar IP streaming guide for RTSP cameras - [Deployment Guide](../../../deployment-x/) — platform-specific runtime packages for Windows, macOS, Linux - [Code Samples on GitHub](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK) — NDI streamer and source demos - [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) — product page and downloads ---END OF PAGE--- ## RTMP Live Streaming to YouTube and Facebook in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/rtmp/ **Description:** Go live with hardware-accelerated H.264 encoding. Automatic encoder fallback (NVENC, QSV, AMF, OpenH264). Cross-platform C# examples with VisioForge SDK. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, RTMP, H.264, H.265, AAC, C# **API:** RTMPOutput, NVENCH264EncoderSettings, RTMPSinkSettings, VideoCaptureCoreX, VideoEditCoreX # RTMP Streaming with VisioForge SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to RTMP Streaming RTMP (Real-Time Messaging Protocol) is a robust communication protocol designed for high-performance transmission of audio, video, and data between a server and a client. VisioForge SDKs provide comprehensive support for RTMP streaming, enabling developers to create powerful streaming applications with minimal effort. This guide covers implementation details for RTMP streaming across different VisioForge products, including cross-platform solutions and Windows-specific integrations. ## Cross-Platform RTMP Implementation [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The `RTMPOutput` class serves as the central configuration point for RTMP streaming in cross-platform scenarios. It implements multiple interfaces including `IVideoEditXBaseOutput` and `IVideoCaptureXBaseOutput`, making it versatile for both video editing and capture workflows. ### Setting Up RTMP Output To begin implementing RTMP streaming, you need to create and configure an `RTMPOutput` instance: ``` // Initialize with streaming URL var rtmpOutput = new RTMPOutput("rtmp://your-streaming-server/stream-key"); // Alternatively, set the URL after initialization var rtmpOutput = new RTMPOutput(); rtmpOutput.Sink.Location = "rtmp://your-streaming-server/stream-key"; ``` ### Integration with VisioForge SDKs #### Video Capture SDK Integration ``` // Add RTMP output to the Video Capture SDK engine core.Outputs_Add(rtmpOutput, true); // core is an instance of VideoCaptureCoreX ``` #### Video Edit SDK Integration ``` // Set RTMP as the output format for Video Edit SDK core.Output_Format = rtmpOutput; // core is an instance of VideoEditCoreX ``` #### Media Blocks SDK Integration ``` // Create an RTMP sink block var rtmpSink = new RTMPSinkBlock(new RTMPSinkSettings() { Location = "rtmp://streaming-server/stream" }); // Connect video and audio encoders to the RTMP sink pipeline.Connect(h264Encoder.Output, rtmpSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(aacEncoder.Output, rtmpSink.CreateNewInput(MediaBlockPadMediaType.Audio)); ``` ## Video Encoder Configuration ### Supported Video Encoders VisioForge provides extensive support for various video encoders, making it possible to optimize streaming based on available hardware: - **OpenH264**: Default software encoder for most platforms - **NVENC H264**: Hardware-accelerated encoding for NVIDIA GPUs - **QSV H264**: Intel Quick Sync Video acceleration - **AMF H264**: AMD GPU-based acceleration - **HEVC/H265**: Various implementations including MF HEVC, NVENC HEVC, QSV HEVC, and AMF H265 ### Implementing Hardware-Accelerated Encoding For optimal performance, it's recommended to utilize hardware acceleration when available: ``` // Check for NVIDIA encoder availability and use if present if (NVENCH264EncoderSettings.IsAvailable()) { rtmpOutput.Video = new NVENCH264EncoderSettings(); } // Fall back to OpenH264 if hardware acceleration isn't available else { rtmpOutput.Video = new OpenH264EncoderSettings(); } ``` ## Audio Encoder Configuration ### Supported Audio Encoders The SDK supports multiple AAC encoder implementations: - **VO-AAC**: Default for non-Windows platforms - **AVENC AAC**: Cross-platform implementation - **MF AAC**: Default for Windows platforms ``` // Configure MF AAC encoder on Windows platforms rtmpOutput.Audio = new MFAACEncoderSettings(); // For macOS or other platforms rtmpOutput.Audio = new VOAACEncoderSettings(); ``` ## Platform-Specific Considerations ### Windows Implementation On Windows platforms, the default configuration uses: - OpenH264 for video encoding - MF AAC for audio encoding Additionally, Windows supports Microsoft Media Foundation HEVC encoding for high-efficiency streaming. ### macOS Implementation For macOS applications, the system uses: - AppleMediaH264EncoderSettings for video encoding - VO-AAC for audio encoding ### Automatic Platform Detection The SDK handles platform differences automatically through conditional compilation: ``` #if __MACOS__ Video = new AppleMediaH264EncoderSettings(); #else Video = new OpenH264EncoderSettings(); #endif ``` ## Best Practices for RTMP Streaming ### 1. Encoder Selection Strategy Always verify encoder availability before attempting to use hardware acceleration: ``` // Check for Intel Quick Sync availability if (QSVH264EncoderSettings.IsAvailable()) { rtmpOutput.Video = new QSVH264EncoderSettings(); } // Check for NVIDIA acceleration else if (NVENCH264EncoderSettings.IsAvailable()) { rtmpOutput.Video = new NVENCH264EncoderSettings(); } // Fall back to software encoding else { rtmpOutput.Video = new OpenH264EncoderSettings(); } ``` ### 2. Error Handling Implement robust error handling to manage streaming failures gracefully: ``` try { var rtmpOutput = new RTMPOutput(streamUrl); // Configure and start streaming } catch (Exception ex) { logger.LogError($"RTMP streaming initialization failed: {ex.Message}"); // Implement appropriate error recovery } ``` ### 3. Resource Management Ensure proper disposal of resources when streaming is complete: ``` // RTMPOutput itself is a plain settings object and does not implement IDisposable. // Stop and dispose the pipeline/core that owns it instead. await core.StopAsync(); await core.DisposeAsync(); // VideoCaptureCoreX / MediaBlocksPipeline both DisposeAsync rtmpOutput = null; ``` ## Advanced RTMP Configuration ### Dynamic Encoder Selection For applications that need to adapt to different environments, you can enumerate available encoders: ``` var rtmpOutput = new RTMPOutput(); var availableVideoEncoders = rtmpOutput.GetVideoEncoders(); var availableAudioEncoders = rtmpOutput.GetAudioEncoders(); // Present options to users or select based on system capabilities ``` ### Custom Sink Configuration Fine-tune streaming parameters using the RTMPSinkSettings class: ``` rtmpOutput.Sink = new RTMPSinkSettings { Location = "rtmp://streaming-server/stream" }; ``` ## Windows-Specific RTMP Implementation [VideoCaptureCore](#) [VideoEditCore](#) For Windows-only applications, VisioForge provides an alternative implementation using FFmpeg: ``` // Enable network streaming VideoCapture1.Network_Streaming_Enabled = true; // Set streaming format to RTMP using FFmpeg VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.RTMP_FFMPEG_EXE; // Create and configure FFmpeg output var ffmpegOutput = new FFMPEGEXEOutput(); ffmpegOutput.FillDefaults(DefaultsProfile.MP4_H264_AAC, true); ffmpegOutput.OutputMuxer = OutputMuxer.FLV; // Assign output to the capture component VideoCapture1.Network_Streaming_Output = ffmpegOutput; // Enable audio streaming (required for many services) VideoCapture1.Network_Streaming_Audio_Enabled = true; ``` ## Streaming to Popular Platforms ### YouTube Live ``` // Format: rtmp://a.rtmp.youtube.com/live2/ + [YouTube stream key] VideoCapture1.Network_Streaming_URL = "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx"; ``` ### Facebook Live ``` // Format: rtmps://live-api-s.facebook.com:443/rtmp/ + [Facebook stream key] VideoCapture1.Network_Streaming_URL = "rtmps://live-api-s.facebook.com:443/rtmp/xxxx-xxxx-xxxx-xxxx"; ``` ### Custom RTMP Servers ``` // Connect to any RTMP server VideoCapture1.Network_Streaming_URL = "rtmp://your-streaming-server:1935/live/stream"; ``` ## Performance Optimization To achieve optimal streaming performance: 1. **Use hardware acceleration** when available to reduce CPU load 2. **Monitor resource usage** during streaming to identify bottlenecks 3. **Adjust resolution and bitrate** based on available bandwidth 4. **Implement adaptive bitrate** for varying network conditions 5. **Consider GOP size** and keyframe intervals for streaming quality ## Troubleshooting Common Issues - **Connection Failures**: Verify server URL format and network connectivity - **Encoder Errors**: Confirm hardware encoder availability and drivers - **Performance Issues**: Monitor CPU/GPU usage and adjust encoding parameters - **Audio/Video Sync**: Check timestamp synchronization settings ## Conclusion VisioForge's RTMP implementation provides developers with a powerful, flexible framework for creating robust streaming applications. By leveraging the appropriate SDK components and following the best practices outlined in this guide, you can create high-performance streaming solutions that work across platforms and integrate with popular streaming services. ## Related Resources - [Streaming to Adobe Flash Media Server](../adobe-flash/) - [YouTube Streaming Integration](../youtube/) - [Facebook Live Implementation](../facebook/) ---END OF PAGE--- ## Build RTSP Server in C# .NET — H.264/HEVC + GPU Encoding **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/rtsp/ **Description:** Build an RTSP server with H.264/AAC encoding, GPU acceleration (NVENC, QSV, AMF), authentication, and latency tuning. VisioForge SDK cross-platform examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, DirectShow, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Streaming, Encoding, Editing, IP Camera, RTSP, ONVIF, UDP, WebRTC, MP4, H.264, H.265, AAC, C# **API:** VideoCaptureCoreX, VideoEditCoreX, RTSPServerOutput, RTSPServerSettings, RTSPServerBlock # Mastering RTSP Streaming with VisioForge SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Cross-platform support The `VideoCaptureCoreX` engine and the Media Blocks SDK run on **Windows, macOS, Linux, Android, and iOS** via GStreamer. See the [platform support matrix](../../../platform-matrix/) for codec and hardware-acceleration details, and the [Linux deployment guide](../../../deployment-x/Ubuntu/) for Ubuntu / NVIDIA Jetson / Raspberry Pi setup. AI coding agents: use the VisioForge MCP server Building this with **Claude Code**, **Cursor**, or another AI coding agent? Connect to the public [VisioForge MCP server](../../mcp-server-usage/) at `https://mcp.visioforge.com/mcp` for structured API lookups, runnable code samples, and deployment guides — more accurate than grepping `llms.txt`. No authentication required. Claude Code: `claude mcp add --transport http visioforge-sdk https://mcp.visioforge.com/mcp` ## Introduction to RTSP The Real-Time Streaming Protocol (RTSP) is a network control protocol designed for use in entertainment and communications systems to control streaming media servers. It acts like a "network remote control," allowing users to play, pause, and stop media streams. VisioForge SDKs harness the power of RTSP to provide robust video and audio streaming capabilities. Our SDKs integrate RTSP with industry-standard codecs like **H.264 (AVC)** for video and **Advanced Audio Coding (AAC)** for audio. H.264 offers excellent video quality at relatively low bitrates, making it ideal for streaming over various network conditions. AAC provides efficient and high-fidelity audio compression. This powerful combination ensures reliable, high-definition audiovisual streaming suitable for demanding applications such as: - **Security and Surveillance:** Delivering clear, real-time video feeds from IP cameras. - **Live Broadcasting:** Streaming events, webinars, or performances to a wide audience. - **Video Conferencing:** Enabling smooth, high-quality communication. - **Remote Monitoring:** Observing industrial processes or environments remotely. This guide delves into the specifics of implementing RTSP streaming using VisioForge SDKs, covering both modern cross-platform approaches and legacy Windows-specific methods. ## Cross-Platform RTSP Output (Recommended) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The modern VisioForge SDKs (`CoreX` versions and Media Blocks) provide a flexible and powerful cross-platform RTSP server implementation built upon the robust GStreamer framework. This approach offers greater control, wider codec support, and compatibility across Windows, Linux, macOS, and other platforms. ### Core Component: `RTSPServerOutput` The `RTSPServerOutput` class is the central configuration point for establishing an RTSP stream within the Video Capture or Video Edit SDKs (`CoreX` versions). It acts as a bridge between your capture/edit pipeline and the underlying RTSP server logic. **Key Responsibilities:** - **Interface Implementation:** Implements `IVideoEditXBaseOutput` and `IVideoCaptureXBaseOutput`, allowing seamless integration as an output format in both editing and capture scenarios. - **Settings Management:** Holds the `RTSPServerSettings` object, which contains all the detailed configuration parameters for the server instance. - **Codec Specification:** Defines the video and audio encoders that will be used to compress the media before streaming. **Supported Encoders:** VisioForge provides access to a wide array of encoders, allowing optimization based on hardware capabilities and target platforms: - **Video Encoders:** - **Hardware-Accelerated (Recommended for performance):** - `NVENC` (NVIDIA): Leverages dedicated encoding hardware on NVIDIA GPUs. - `QSV` (Intel Quick Sync Video): Utilizes integrated GPU capabilities on Intel processors. - `AMF` (AMD Advanced Media Framework): Uses encoding hardware on AMD GPUs/APUs. - **Software-Based (Platform-independent, higher CPU usage):** - `OpenH264`: A widely compatible H.264 software encoder. - `VP8` / `VP9`: Royalty-free video codecs developed by Google, offering good compression (often used with WebRTC, but available here). - **Platform-Specific:** - `MF HEVC` (Media Foundation HEVC): Windows-specific H.265/HEVC encoder for higher efficiency compression. - **Audio Encoders:** - **AAC Variants:** - `VO-AAC`: A versatile, cross-platform AAC encoder. - `AVENC AAC`: Utilizes FFmpeg's AAC encoder. - `MF AAC`: Windows Media Foundation AAC encoder. - **Other Formats:** - `MP3`: Widely compatible but less efficient than AAC. - `OPUS`: Excellent low-latency codec, ideal for interactive applications. ### Configuring the Stream: `RTSPServerSettings` This class encapsulates all the parameters needed to define the behavior and properties of your RTSP server. **Detailed Properties:** - **Network Configuration:** - `Port` (int): The TCP port the server listens on for incoming RTSP connections. The default is `8554`, a common alternative to the standard (often restricted) port 554. Ensure this port is open in firewalls. - `Address` (string): The IP address the server binds to. - `"127.0.0.1"` (Default): Listens only for connections from the local machine. - `"0.0.0.0"`: Listens on all available network interfaces (use for public access). - Specific IP (e.g., `"192.168.1.100"`): Binds only to that specific network interface. - `Point` (string): The path component of the RTSP URL (e.g., `/live`, `/stream1`). Clients will connect to `rtsp://
:`. Default is `"/live"`. - **Stream Configuration:** - `VideoEncoder` (IVideoEncoder): An `IVideoEncoder` instance — typically an encoder-settings object (e.g., `OpenH264EncoderSettings`) or the result of `H264EncoderBlock.GetDefaultSettings()`. Defines codec, bitrate (Kbit/s), quality, etc. - `AudioEncoder` (IAudioEncoder): An `IAudioEncoder` instance (e.g., `VOAACEncoderSettings`). Defines audio codec parameters. - `Latency` (TimeSpan): Controls the buffering delay introduced by the server to smooth out network jitter. Default is 250 milliseconds. Higher values increase stability but also delay. - **Authentication:** - `Username` (string): If set, clients must provide this username for basic authentication. - `Password` (string): If set, clients must provide this password along with the username. - **Server Identity:** - `Name` (string): A friendly name for the server, sometimes displayed by client applications. - `Description` (string): A more detailed description of the stream content or server purpose. - **Convenience Property:** - `URL` (string, read-only): Automatically composes the full RTSP connection URL from `Address`, `Port`, and `Point`. With `RTSPServerSettings` defaults (`Port = 8554`), the composed URL is `rtsp://127.0.0.1:8554/live`. ### The Engine: `RTSPServerBlock` (Media Blocks SDK) When using the Media Blocks SDK, the `RTSPServerBlock` represents the actual GStreamer-based element that performs the streaming. **Functionality:** - **Media Sink:** Acts as a terminal point (sink) in a media pipeline, receiving encoded video and audio data. - **Input Pads:** Provides distinct `VideoInput` and `AudioInput` pads for connecting upstream video and audio sources/encoders. - **GStreamer Integration:** Manages the underlying GStreamer `rtspserver` and related elements necessary for handling client connections and streaming RTP packets. - **Availability Check:** The static `IsAvailable()` method allows checking if the necessary GStreamer plugins for RTSP streaming are present on the system. - **Resource Management:** Implements `IDisposable` for proper cleanup of network sockets and GStreamer resources when the block is no longer needed. ### Practical Usage Examples #### Example 1: Basic Server Setup (VideoCaptureCoreX / VideoEditCoreX) ``` // 1. Choose and configure encoders // Use hardware acceleration if available, otherwise fallback to software var videoEncoder = H264EncoderBlock.GetDefaultSettings(); var audioEncoder = new VOAACEncoderSettings(); // Reliable cross-platform AAC // 2. Configure server network settings var settings = new RTSPServerSettings(videoEncoder, audioEncoder) { Port = 8554, Address = "0.0.0.0", // Accessible from other machines on the network Point = "/livefeed" }; // 3. Create the output object var rtspOutput = new RTSPServerOutput(settings); // 4. Integrate with the SDK engine // For VideoCaptureCoreX: // videoCapture is an initialized instance of VideoCaptureCoreX videoCapture.Outputs_Add(rtspOutput); // For VideoEditCoreX: // videoEdit is an initialized instance of VideoEditCoreX // videoEdit.Output_Format = rtspOutput; // Set before starting editing/playback ``` #### Example 2: Media Blocks Pipeline ``` // Assume 'pipeline' is an initialized MediaBlocksPipeline // Assume 'videoSource' and 'audioSource' provide unencoded media streams // 1. Create video and audio encoder settings var videoEncoder = H264EncoderBlock.GetDefaultSettings(); var audioEncoder = new VOAACEncoderSettings(); // 2. Create RTSP server settings with a specific URL var serverUri = new Uri("rtsp://192.168.1.50:8554/cam1"); var rtspSettings = new RTSPServerSettings(serverUri, videoEncoder, audioEncoder) { Description = "Camera Feed 1 - Warehouse" }; // 3. Create the RTSP Server Block if (!RTSPServerBlock.IsAvailable()) { Console.WriteLine("RTSP Server components not available. Check GStreamer installation."); return; } var rtspSink = new RTSPServerBlock(rtspSettings); // Connect source directly to RTSP server block, because server block will use its own encoders pipeline.Connect(videoSource.Output, rtspSink.VideoInput); // Connect source directly to video input of RTSP server block pipeline.Connect(audioSource.Output, rtspSink.AudioInput); // Connect source directly to audio input of RTSP server block // Start the pipeline await pipeline.StartAsync(); ``` #### Example 3: Advanced Configuration with Authentication ``` // Using settings from Example 1... var secureSettings = new RTSPServerSettings(videoEncoder, audioEncoder) { Port = 8555, // Use a different port Address = "192.168.1.100", // Bind to a specific internal IP Point = "/secure", Username = "viewer", Password = "VerySecretPassword!", Latency = TimeSpan.FromMilliseconds(400), // Slightly higher latency Name = "SecureStream", Description = "Authorized access only" }; var secureRtspOutput = new RTSPServerOutput(secureSettings); // Add to VideoCaptureCoreX or set for VideoEditCoreX as before // videoCapture.Outputs_Add(secureRtspOutput); ``` ### Streaming Best Practices 1. **Encoder Selection Strategy:** - **Prioritize Hardware:** Always prefer hardware encoders (NVENC, QSV, AMF) when available on the target system. They drastically reduce CPU load, allowing for higher resolutions, frame rates, or more simultaneous streams. - **Software Fallback:** Use `OpenH264` as a reliable software fallback for broad compatibility when hardware acceleration isn't present or suitable. - **Codec Choice:** H.264 remains the most widely compatible codec for RTSP clients. HEVC offers better compression but client support might be less universal. 2. **Latency Tuning:** - **Interactivity vs. Stability:** Lower latency (e.g., 100-200ms) is crucial for applications like video conferencing but makes the stream more susceptible to network hiccups. - **Broadcast/Surveillance:** Higher latency (e.g., 500ms-1000ms+) provides larger buffers, improving stream resilience over unstable networks (like Wi-Fi or the internet) at the cost of increased delay. Start with the default (250ms) and adjust based on observed stream quality and requirements. 3. **Network Configuration:** - **Security First:** Implement `Username` and `Password` authentication for any stream not intended for public anonymous access. - **Binding Address:** Use `"0.0.0.0"` cautiously. For enhanced security, bind explicitly to the network interface (`Address`) intended for client connections if possible. - **Firewall Rules:** Meticulously configure system and network firewalls to allow incoming TCP connections on the chosen RTSP `Port`. Also, remember that RTP/RTCP (used for the actual media data) often use dynamic UDP ports; firewalls might need helper modules (like `nf_conntrack_rtsp` on Linux) or broad UDP port ranges opened (less secure). 4. **Resource Management:** - **Dispose Pattern:** RTSP server instances hold network resources (sockets) and potentially complex GStreamer pipelines. *Always* ensure they are disposed of correctly using `using` statements or explicit `.Dispose()` calls in `finally` blocks to prevent resource leaks. - **Graceful Shutdown:** When stopping the capture or edit process, ensure the output is properly removed or the pipeline is stopped cleanly to allow the RTSP server to shut down gracefully. ### Performance Considerations Optimizing RTSP streaming involves balancing quality, latency, and resource usage: 1. **Encoder Impact:** This is often the biggest factor. - **Hardware:** Significantly lower CPU usage, higher potential throughput. Requires compatible hardware and drivers. - **Software:** High CPU load, especially at higher resolutions/framerates. Limits the number of concurrent streams on a single machine but works universally. 2. **Latency vs. Bandwidth:** Lower latency settings can sometimes lead to increased peak bandwidth usage as the system has less time to smooth out data transmission. 3. **Resource Monitoring:** - **CPU:** Keep a close eye on CPU usage, particularly with software encoders. Overload leads to dropped frames and stuttering. - **Memory:** Monitor RAM usage, especially if handling multiple streams or complex Media Blocks pipelines. - **Network:** Ensure the server's network interface has sufficient bandwidth for the configured bitrate, resolution, and number of connected clients. Calculate required bandwidth (Video Bitrate + Audio Bitrate) \* Number of Clients. ## Windows-Only RTSP Output (Legacy) [VideoCaptureCore](#) [VideoEditCore](#) The implementation includes several error handling mechanisms: Older versions of the SDK (`VideoCaptureCore`, `VideoEditCore`) included a simpler, Windows-specific RTSP output mechanism. While functional, it offers less flexibility and codec support compared to the cross-platform `RTSPServerOutput`. **It is generally recommended to use the `CoreX` / Media Blocks approach for new projects.** ### How it Works This method leverages built-in Windows components or specific bundled filters. Configuration is done directly via properties on the `VideoCaptureCore` or `VideoEditCore` object. ### Sample Configuration Code ``` using VisioForge.Core.Types.Output; // MP4Output, NetworkStreamingFormat, H264Profile using VisioForge.Core.Types.VideoCapture; using VisioForge.Core.VideoCapture; // VideoCaptureCore // Assuming VideoCapture1 is an instance of VideoCaptureCore already bound to a VideoView. // 1. Enable network streaming globally for the component VideoCapture1.Network_Streaming_Enabled = true; // 2. Enable audio streaming (optional) VideoCapture1.Network_Streaming_Audio_Enabled = true; // 3. Select the RTSP format. // RTSP_H264_AAC_SW = software H.264 + AAC (DirectShow-based Windows RTSP). VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.RTSP_H264_AAC_SW; // 4. Configure encoder settings. MP4Output holds the H.264 and AAC parameters // even though the stream is sent over RTSP rather than written to a file. var mp4Output = new MP4Output(); // H.264 settings live on MP4Output.Video (MP4OutputH264Settings). mp4Output.Video = new MP4OutputH264Settings { Bitrate = 2000, // kbps Profile = H264Profile.ProfileMain, Level = H264Level.Level4, RateControl = H264RateControl.VBR }; // AAC settings live on MP4Output.Audio_AAC (M4AOutput — already initialised in the constructor). mp4Output.Audio_AAC.Bitrate = 128; // kbps mp4Output.Audio_AAC.Object = AACObject.Low; mp4Output.Audio_AAC.Version = AACVersion.MPEG4; // 5. Assign the settings container to the network streaming output VideoCapture1.Network_Streaming_Output = mp4Output; // 6. Define the RTSP URL clients will use. // The server listens on the port specified in the URL (5554 here). VideoCapture1.Network_Streaming_URL = "rtsp://localhost:5554/vfstream"; // Use the machine's actual IP instead of localhost for external access. // 7. Start as usual (OnError fires if the port is busy or encoders are unavailable). await VideoCapture1.StartAsync(); ``` **Note:** This legacy method often relies on DirectShow filters or Media Foundation transforms available on the specific Windows system, making it less predictable and portable than the GStreamer-based cross-platform solution. ## See also - [RTSP reconnection and fallback switch](../../network-sources/reconnection-and-fallback/) — handle camera disconnects with reconnect events, `DisconnectEventInterval`, and the declarative `FallbackSwitch` (image / text / media fallback) across all VisioForge SDKs - [RTSP camera source configuration in C#](../../../videocapture/video-sources/ip-cameras/rtsp/) — `IPCameraSourceSettings` and `RTSPSourceSettings` reference with UDP/TCP transport and buffer tuning - [ONVIF IP camera integration](../../../videocapture/video-sources/ip-cameras/onvif/) — WS-Discovery, profile selection, and PTZ control for standards-based cameras - [IP camera live preview tutorial](../../../videocapture/video-tutorials/ip-camera-preview/) — video walkthrough for a minimal preview implementation - [Record RTSP stream to MP4](../../../videocapture/video-tutorials/ip-camera-capture-mp4/) — capture any IP camera to MP4 file in .NET - [Media Blocks RTSP player](../../../mediablocks/Guides/rtsp-player-csharp/) — pipeline-based RTSP playback with the Media Blocks SDK - [RTSP server output block](../../../mediablocks/RTSPServer/) — broadcast your own video and audio stream over RTSP - [Multi-camera RTSP grid (NVR wall)](../../../mediablocks/Guides/multi-camera-rtsp-grid/) — build a 4×4 live preview wall with WPF or MAUI, with synchronized start - [Pre-Event Recording with IP Camera](../../../mediablocks/Guides/pre-event-recording/) — record RTSP streams with circular buffer and motion detection triggers - [Save Original RTSP Stream](../../../mediablocks/Guides/rtsp-save-original-stream/) — save RTSP video without re-encoding - [Barcode & QR Code Scanner](../../../mediablocks/Guides/barcode-qr-reader-guide/) — scan barcodes from RTSP IP camera streams in real time --- For more detailed examples and advanced use cases, explore the code samples provided in our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). For brand-specific RTSP URLs, see our [IP camera brands directory](../../../camera-brands/). ---END OF PAGE--- ## SRT Streaming in C# .NET - Send and Receive Video over IP **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/srt/ **Description:** Stream and receive video over SRT protocol in C# .NET with caller/listener modes, AES encryption, and MPEG-TS multiplexing. Includes SDK code examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, Webcam, IP Camera, NDI, SRT, TS, H.264, H.265, AAC, C# **API:** SRTSinkSettings, SRTMPEGTSSinkBlock, MediaBlocksPipeline, SRTSourceSettings, SRTSourceBlock # SRT Streaming Implementation Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## What is SRT? SRT (Secure Reliable Transport) is a streaming protocol designed for low-latency, high-quality video delivery across unreliable networks. It provides built-in error recovery, AES encryption, and firewall traversal — making it ideal for: - Live broadcasting over the internet - Contribution feeds between production facilities - Remote camera backhaul over cellular or satellite links - Secure point-to-point video transport - Cloud-based video ingest and distribution The VisioForge .NET SDKs support both sending and receiving SRT streams across Windows, macOS, and Linux. SRT streams use MPEG-TS multiplexing to carry video and audio together. You can check SRT availability at runtime: ``` bool srtAvailable = SRTSinkBlock.IsAvailable(); // for sending bool srtSourceAvailable = SRTSourceBlock.IsAvailable(); // for receiving ``` ## SRT Connection Modes [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) SRT supports three connection modes via the `SRTConnectionMode` enum: | Mode | Description | Use Case | | --- | --- | --- | | **Caller** | Connects to a remote listener | Client connecting to a server | | **Listener** | Waits for incoming connections on a port | Server accepting connections | | **Rendezvous** | Both sides connect simultaneously | Peer-to-peer, firewall traversal | ### Listener (Server) Mode The listener waits for incoming SRT connections on a specified port: ``` var sinkSettings = new SRTSinkSettings { Uri = "srt://:8888", Mode = SRTConnectionMode.Listener }; ``` ### Caller (Client) Mode The caller connects to a remote SRT listener: ``` // SRTSourceSettings has a private ctor — use the CreateAsync factory. Uri is System.Uri, not string. var sourceSettings = await SRTSourceSettings.CreateAsync(new Uri("srt://192.168.1.100:8888")); sourceSettings.Mode = SRTConnectionMode.Caller; ``` ### Rendezvous Mode Both endpoints connect simultaneously — useful when both sides are behind firewalls: ``` var settings = new SRTSinkSettings { Uri = "srt://remote-host:8888", Mode = SRTConnectionMode.Rendezvous, LocalPort = 8888 }; ``` ## Basic SRT Output ### Video Capture SDK ``` // Initialize SRT output with destination URL var srtOutput = new SRTOutput("srt://streaming-server:1234"); // Add the configured SRT output to your capture engine videoCapture.Outputs_Add(srtOutput, true); // videoCapture is a VideoCaptureCoreX instance ``` ### Media Blocks SDK The `SRTMPEGTSSinkBlock` multiplexes video and audio into an MPEG-TS container and sends over SRT: ``` // Create an SRT MPEG-TS sink in listener mode var srtSink = new SRTMPEGTSSinkBlock(new SRTSinkSettings { Uri = "srt://:8888" }); // Connect video encoder output to the SRT sink pipeline.Connect(h264Encoder.Output, srtSink.CreateNewInput(MediaBlockPadMediaType.Video)); // Connect audio encoder output to the SRT sink pipeline.Connect(aacEncoder.Output, srtSink.CreateNewInput(MediaBlockPadMediaType.Audio)); ``` ## Streaming a Camera to SRT [MediaBlocksPipeline](#) This complete example captures from a webcam and microphone, encodes to H.264/AAC, and streams over SRT: ### Pipeline Architecture ``` SystemVideoSourceBlock → H264EncoderBlock → SRTMPEGTSSinkBlock (video input) SystemAudioSourceBlock → AACEncoderBlock → SRTMPEGTSSinkBlock (audio input) ``` ### Code Example ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoEncoders; using VisioForge.Core.MediaBlocks.AudioEncoders; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.Types.X.VideoEncoders; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Sinks; using VisioForge.Core.Types.X.Sources; // Initialize SDK once at startup await VisioForgeX.InitSDKAsync(); var pipeline = new MediaBlocksPipeline(); // Enumerate devices var videoDevices = await DeviceEnumerator.Shared.VideoSourcesAsync(); var audioDevices = await DeviceEnumerator.Shared.AudioSourcesAsync(); // Video source (first camera) var videoSource = new SystemVideoSourceBlock( new VideoCaptureDeviceSourceSettings(videoDevices[0])); // Audio source (first microphone) var audioSource = new SystemAudioSourceBlock( new AudioCaptureDeviceSourceSettings(audioDevices[0])); // Video encoder — H.264 with hardware fallback var h264Encoder = new H264EncoderBlock(new OpenH264EncoderSettings()); // Audio encoder — AAC var aacEncoder = new AACEncoderBlock(new VOAACEncoderSettings()); // SRT output in listener mode on port 8888 var srtSink = new SRTMPEGTSSinkBlock(new SRTSinkSettings { Uri = "srt://:8888", Mode = SRTConnectionMode.Listener, Latency = TimeSpan.FromMilliseconds(125) }); // Build pipeline: camera → encoder → SRT pipeline.Connect(videoSource.Output, h264Encoder.Input); pipeline.Connect(h264Encoder.Output, srtSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(audioSource.Output, aacEncoder.Input); pipeline.Connect(aacEncoder.Output, srtSink.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` Receivers can connect using `ffplay srt://your-ip:8888` or any SRT-compatible player. ## Receiving an SRT Stream [MediaBlocksPipeline](#) Use `SRTSourceBlock` to receive and play an SRT stream with automatic decoding: ``` var pipeline = new MediaBlocksPipeline(); // Connect to an SRT sender (caller mode by default) var sourceSettings = await SRTSourceSettings.CreateAsync(new Uri("srt://192.168.1.100:8888")); var srtSource = new SRTSourceBlock(sourceSettings); // Video renderer var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(srtSource.VideoOutput, videoRenderer.Input); // Audio renderer var audioRenderer = new AudioRendererBlock(); pipeline.Connect(srtSource.AudioOutput, audioRenderer.Input); await pipeline.StartAsync(); ``` For passthrough recording without decoding (e.g., saving the raw MPEG-TS stream), use `SRTRAWSourceBlock` instead. ## Encryption SRT supports AES encryption with 128, 192, or 256-bit keys. Both sender and receiver must use the same passphrase and key length. ### Sender (Encrypted) ``` var sinkSettings = new SRTSinkSettings { Uri = "srt://:8888", Mode = SRTConnectionMode.Listener, Passphrase = "my-secret-passphrase", // minimum 10 characters PbKeyLen = SRTKeyLength.Length32 // 256-bit AES }; ``` ### Receiver (Encrypted) ``` // Use the async factory — SRTSourceSettings has a private ctor; Uri is System.Uri, not string. var sourceSettings = await SRTSourceSettings.CreateAsync(new Uri("srt://192.168.1.100:8888")); sourceSettings.Mode = SRTConnectionMode.Caller; sourceSettings.Passphrase = "my-secret-passphrase"; sourceSettings.PbKeyLen = SRTKeyLength.Length32; ``` Available key lengths: `SRTKeyLength.NoKey` (disabled), `Length16` (128-bit), `Length24` (192-bit), `Length32` (256-bit). ## Latency Configuration The `Latency` property controls the SRT receiver buffer size (default: 125ms). Lower values reduce delay but increase sensitivity to network jitter: ``` // Low-latency for local network var settings = new SRTSinkSettings { Uri = "srt://:8888", Latency = TimeSpan.FromMilliseconds(50) }; // Higher latency for unreliable networks (internet streaming) var settings = new SRTSinkSettings { Uri = "srt://:8888", Latency = TimeSpan.FromMilliseconds(500) }; ``` | Network | Recommended Latency | Notes | | --- | --- | --- | | Local LAN | 20–80ms | Minimal jitter | | Reliable internet | 125ms (default) | Good balance | | Unreliable/long-distance | 250–1000ms | Prevents drops | ## Video Encoding Options ### Software Encoders - **OpenH264** — Default cross-platform H.264 encoder ### Hardware-Accelerated Encoders - **NVIDIA NVENC** (H.264/HEVC) — GPU-accelerated encoding on NVIDIA cards - **Intel Quick Sync** (H.264/HEVC) — Intel integrated GPU acceleration - **AMD AMF** (H.264/HEVC) — AMD GPU acceleration - **Microsoft Media Foundation HEVC** — Windows-only hardware encoder ### Encoder Selection with Fallback ``` if (NVENCH264EncoderSettings.IsAvailable()) { srtOutput.Video = new NVENCH264EncoderSettings(); } else { srtOutput.Video = new OpenH264EncoderSettings(); } ``` ## Audio Encoding SRT streams typically use AAC audio. The SDK provides multiple encoders: - **VO-AAC** — Cross-platform, consistent performance - **AVENC AAC** — FFmpeg-based with extensive options - **MF AAC** — Windows-only, Microsoft Media Foundation The SDK auto-selects the best available encoder per platform (MF AAC on Windows, VO AAC elsewhere). ## Troubleshooting ### Unable to Establish SRT Connection **Symptom:** Connection times out or is refused. **Solutions:** - Verify the SRT URL format: `srt://host:port` for caller, `srt://:port` for listener - Ensure the port is open in firewalls on both sides - Confirm both sides use matching connection modes (one caller, one listener) - Check that passphrases match if encryption is enabled ### High CPU Usage or Dropped Frames **Symptom:** Performance degrades during streaming. **Solutions:** - Switch to hardware-accelerated encoders (NVENC, QSV, AMF) - Reduce resolution or bitrate - Increase the `Latency` value to give more buffer room ### Encoder Fails to Initialize **Symptom:** Exception when starting the pipeline. **Solutions:** - Use `IsAvailable()` to check encoder support before creating it - Verify GPU drivers are up to date for hardware encoders - Fall back to OpenH264 as a universal software encoder ## Frequently Asked Questions ### What is the difference between SRT caller and listener mode? The **listener** binds to a port and waits for incoming connections — it acts as the server. The **caller** initiates the connection to a listener's address and port — it acts as the client. For firewall traversal where both sides are behind NAT, use **rendezvous** mode where both endpoints connect simultaneously. ### How do I encrypt an SRT stream? Set the `Passphrase` property (minimum 10 characters) and `PbKeyLen` on both `SRTSinkSettings` and `SRTSourceSettings`. Both sender and receiver must use identical values. Available key lengths are 128-bit (`Length16`), 192-bit (`Length24`), and 256-bit (`Length32`). See the [Encryption](#encryption) section for code examples. ### How do I receive and play an SRT stream in C#? Create `SRTSourceSettings` with the sender's URL, then pass it to `SRTSourceBlock`. Connect `VideoOutput` to a `VideoRendererBlock` and `AudioOutput` to an `AudioRendererBlock`. The source block handles MPEG-TS demuxing and decoding automatically. See the [Receiving an SRT Stream](#receiving-an-srt-stream) section for the complete example. ### What video codecs does SRT support? SRT itself is codec-agnostic — it transports any data over the wire. When using `SRTMPEGTSSinkBlock`, the stream is multiplexed as MPEG-TS, which supports H.264, HEVC (H.265), MPEG-2, and AV1 video codecs. H.264 is the most widely compatible choice for SRT streaming. ### How do I reduce SRT streaming latency? Lower the `Latency` property on both sender and receiver settings (default is 125ms). For local networks, values as low as 20–50ms work well. For internet streaming, keep at least 125ms to handle jitter. Also ensure your encoder is configured for low-latency mode and that you're using hardware acceleration to minimize encoding delay. ## See Also - [NDI Streaming Integration](../ndi/) — NDI video-over-IP streaming - [RTSP Stream Viewer and IP Camera Player](../../../mediablocks/Guides/rtsp-player-csharp/) — RTSP camera streaming guide - [MPEG-TS Output Format](../../output-formats/mpegts/) — MPEG-TS container configuration - [Deployment Guide](../../../deployment-x/) — platform-specific runtime packages - [Code Samples on GitHub](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK) — SRT source demo - [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) — product page and downloads ---END OF PAGE--- ## UDP Video Streaming with MPEG-TS Container in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/udp/ **Description:** Stream H.264/HEVC video over UDP in C# / .NET — multicast, point-to-point, low-latency configs. Full send/receive code samples with bitrate tuning. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCore, VideoEditCore, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Streaming, Encoding, Editing, UDP, MP4, TS, H.264, H.265, AAC, C# **API:** FFMPEGEXEOutput, BasicVideoSettings, MediaBlockPadMediaType, MediaBlocksPipeline, UDPMPEGTSSinkBlock, UDPSinkSettings, MultiUDPMPEGTSSinkBlock # UDP Streaming with VisioForge SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) AI coding agents: use the VisioForge MCP server Building this with **Claude Code**, **Cursor**, or another AI coding agent? Connect to the public [VisioForge MCP server](../../mcp-server-usage/) at `https://mcp.visioforge.com/mcp` for structured API lookups, runnable code samples, and deployment guides — more accurate than grepping `llms.txt`. No authentication required. Claude Code: `claude mcp add --transport http visioforge-sdk https://mcp.visioforge.com/mcp` ## Introduction to UDP Streaming The User Datagram Protocol (UDP) is a lightweight, connectionless transport protocol that provides a simple interface between network applications and the underlying IP network. Unlike TCP, UDP offers minimal overhead and doesn't guarantee packet delivery, making it ideal for real-time applications where speed is crucial and occasional packet loss is acceptable. VisioForge SDKs offer robust support for UDP streaming, enabling developers to implement high-performance, low-latency streaming solutions for various applications, including live broadcasts, video surveillance, and real-time communication systems. ## Key Features and Capabilities The VisioForge SDK suite provides comprehensive UDP streaming functionality with the following key features: ### Video and Audio Codec Support - **Video Codecs**: Full support for H.264 (AVC) and H.265 (HEVC), offering excellent compression efficiency while maintaining high video quality. - **Audio Codec**: Advanced Audio Coding (AAC) support, providing superior audio quality at lower bitrates compared to older audio codecs. ### MPEG Transport Stream (MPEG-TS) The SDK utilizes MPEG-TS as the container format for UDP streaming. MPEG-TS offers several advantages: - Designed specifically for transmission over potentially unreliable networks - Built-in error correction capabilities - Support for multiplexing multiple audio and video streams - Low latency characteristics ideal for live streaming ### FFMPEG Integration VisioForge SDKs leverage the power of FFMPEG for UDP streaming, ensuring: - High performance encoding and streaming - Wide compatibility with various networks and receiving clients - Reliable packet handling and stream management ### Unicast and Multicast Support - **Unicast**: Point-to-point transmission from a single sender to a single receiver - **Multicast**: Efficient distribution of the same content to multiple recipients simultaneously without duplicating bandwidth at the source ## Technical Implementation Details UDP streaming in VisioForge SDKs involves several key technical components: 1. **Video Encoding**: Source video is compressed using H.264 or HEVC encoders with configurable parameters for bitrate, resolution, and frame rate. 2. **Audio Encoding**: Audio streams are processed through AAC encoders with adjustable quality settings. 3. **Multiplexing**: Video and audio streams are combined into a single MPEG-TS container. 4. **Packetization**: The MPEG-TS stream is divided into UDP packets of appropriate size for network transmission. 5. **Transmission**: Packets are sent over the network to specified unicast or multicast addresses. The implementation prioritizes low latency while maintaining sufficient quality for professional applications. Advanced buffering mechanisms help manage network jitter and ensure smooth playback at the receiving end. ## Windows-only UDP Output Implementation [VideoCaptureCore](#) [VideoEditCore](#) ### Step 1: Enable Network Streaming The first step is to enable network streaming functionality in your application. This is done by setting the `Network_Streaming_Enabled` property to true: ``` VideoCapture1.Network_Streaming_Enabled = true; ``` ### Step 2: Configure Audio Streaming (Optional) If your application requires audio streaming alongside video, enable it with: ``` VideoCapture1.Network_Streaming_Audio_Enabled = true; ``` ### Step 3: Set the Streaming Format Specify UDP as the streaming format by setting the `Network_Streaming_Format` property to `UDP_FFMPEG_EXE`: ``` VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.UDP_FFMPEG_EXE; ``` ### Step 4: Configure the UDP Stream URL Set the destination URL for your UDP stream. For a basic unicast stream to localhost: ``` VideoCapture1.Network_Streaming_URL = "udp://127.0.0.1:10000?pkt_size=1316"; ``` The `pkt_size` parameter defines the UDP packet size. The value 1316 is optimized for most network environments, allowing for efficient transmission while minimizing fragmentation. ### Step 5: Multicast Configuration (Optional) For multicast streaming to multiple receivers, use a multicast address (typically in the range 224.0.0.0 to 239.255.255.255): ``` VideoCapture1.Network_Streaming_URL = "udp://239.101.101.1:1234?ttl=1&pkt_size=1316"; ``` The additional parameters include: - **ttl**: Time-to-live value that determines how many network hops the packets can traverse - **pkt\_size**: Packet size as explained above ### Step 6: Configure Output Settings Finally, configure the streaming output parameters using the `FFMPEGEXEOutput` class: ``` var ffmpegOutput = new FFMPEGEXEOutput(); ffmpegOutput.FillDefaults(DefaultsProfile.MP4_H264_AAC, true); ffmpegOutput.OutputMuxer = OutputMuxer.MPEGTS; VideoCapture1.Network_Streaming_Output = ffmpegOutput; ``` This code: 1. Creates a new FFMPEG output configuration 2. Applies default settings for H.264 video and AAC audio 3. Specifies MPEG-TS as the container format 4. Assigns this configuration to the streaming output ## Cross-platform UDP Output with Media Blocks [MediaBlocksPipeline](#) The Media Blocks SDK provides cross-platform UDP streaming support using GStreamer-based blocks. These blocks work on Windows, macOS, Linux, iOS, and Android. ### Single-destination MPEG-TS Streaming Use `UDPMPEGTSSinkBlock` to multiplex audio and video into MPEG-TS and send over UDP to a single destination: ``` var pipeline = new MediaBlocksPipeline(); var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("input.mp4")); var videoEncoder = new H264EncoderBlock(new OpenH264EncoderSettings()); var audioEncoder = new AACEncoderBlock(new AVENCAACEncoderSettings() { Bitrate = 192 }); pipeline.Connect(fileSource.VideoOutput, videoEncoder.Input); pipeline.Connect(fileSource.AudioOutput, audioEncoder.Input); var udpSettings = new UDPSinkSettings { Host = "192.168.1.100", Port = 5004, TTL = 64 }; var udpSink = new UDPMPEGTSSinkBlock(udpSettings); pipeline.Connect(videoEncoder.Output, udpSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(audioEncoder.Output, udpSink.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ### Multi-destination MPEG-TS Streaming Use `MultiUDPMPEGTSSinkBlock` to send the same MPEG-TS stream to multiple receivers simultaneously: ``` var multiUdpSettings = new MultiUDPSinkSettings(); multiUdpSettings.AddClient("192.168.1.100", 5004); multiUdpSettings.AddClient("192.168.1.101", 5004); var multiUdpSink = new MultiUDPMPEGTSSinkBlock(multiUdpSettings); pipeline.Connect(videoEncoder.Output, multiUdpSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(audioEncoder.Output, multiUdpSink.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ### Multicast Streaming For multicast delivery, set the `Host` to a multicast address (224.0.0.0 – 239.255.255.255): ``` var udpSettings = new UDPSinkSettings { Host = "239.101.101.1", Port = 5004, MulticastTTL = 4, AutoMulticast = true }; ``` ### Receiving UDP Streams You can verify the stream using GStreamer command-line tools: ``` gst-launch-1.0 udpsrc port=5004 ! tsdemux ! decodebin ! autovideosink ``` Or receive with VLC: ``` vlc udp://@:5004 ``` ## Advanced Configuration Options ### Bitrate Management For optimal streaming performance, adjust the video and audio bitrates to match your network capacity. `FFMPEGEXEOutput` exposes the encoder knobs via `.Video` and `.Audio` (not `VideoSettings`/`AudioSettings`), and the underlying `BasicVideoSettings` / `BasicAudioSettings` store bitrate in **kbps**: ``` ffmpegOutput.Video.Bitrate = 2500; // 2.5 Mbps for video (kbps) ffmpegOutput.Audio.Bitrate = 128; // 128 kbps for audio ``` ### Resolution and Frame Rate Lower resolutions reduce bandwidth. Set the target size inside `VideoCapture1.Video_Resize` (the classic engine exposes it as an `IVideoResizeSettings` object, not flat properties on the core), and enable the resize stage with `Video_ResizeOrCrop_Enabled`: ``` VideoCapture1.Video_ResizeOrCrop_Enabled = true; VideoCapture1.Video_Resize = new VideoResizeSettings { Width = 1280, // 720p resolution Height = 720, Mode = VideoResizeMode.Letterbox, }; // Frame rate is configured on the capture device format, not the core — pick // a 30 fps device format via Video_CaptureDevice_Format / _FrameRate. ``` ### Buffer Size Configuration Latency vs. stability for FFMPEG-based streaming is controlled on the output object, not on the core. Milliseconds: ``` ffmpegOutput.VideoBufferSize = 5000; // 5 s buffer for smoother streaming ``` ## Best Practices for UDP Streaming ### Network Considerations 1. **Bandwidth Assessment**: Ensure sufficient bandwidth for your target quality. As a guideline: 2. SD quality (480p): 1-2 Mbps 3. HD quality (720p): 2.5-4 Mbps 4. Full HD (1080p): 4-8 Mbps 5. **Network Stability**: UDP doesn't guarantee packet delivery. In unstable networks, consider: 6. Reducing resolution or bitrate 7. Implementing application-level error recovery 8. Using forward error correction when available 9. **Firewall Configuration**: Ensure that UDP ports are open on both sender and receiver firewalls. ### Performance Optimization 1. **Hardware Acceleration / Keyframes / Preset**: `FFMPEGEXEOutput` does not expose first-class properties for HW accel, keyframe interval, or x264 presets — instead inject them as FFMPEG CLI flags via `Custom_AdditionalVideoArgs`. FFMPEG then applies them to the video encoder invocation. ``` // NVENC hardware encoder + 2-second keyframe interval (60 frames @ 30 fps) // + ultrafast preset (lowest latency). ffmpegOutput.Custom_AdditionalVideoArgs = "-c:v h264_nvenc -g 60 -preset p1"; // Intel QuickSync instead: // ffmpegOutput.Custom_AdditionalVideoArgs = "-c:v h264_qsv -g 60"; // Software x264 with a quality/speed trade-off: // ffmpegOutput.Custom_AdditionalVideoArgs = "-c:v libx264 -g 60 -preset ultrafast"; ``` 1. **Pipe-based transport** (avoids a temp file between SDK and FFMPEG) generally reduces latency: ``` ffmpegOutput.UsePipe = true; ``` ## Troubleshooting Common Issues 1. **Stream Not Receiving**: Verify network connectivity, port availability, and firewall settings. 2. **High Latency**: Check network congestion, reduce bitrate, or adjust buffer sizes. 3. **Poor Quality**: Increase bitrate, adjust encoding settings, or check for network packet loss. 4. **Audio/Video Sync Issues**: Ensure proper timestamp synchronization in your application. ## Conclusion UDP streaming with VisioForge SDKs provides a powerful solution for real-time video and audio transmission with minimal latency. By leveraging H.264/HEVC video codecs, AAC audio, and MPEG-TS packaging, developers can create robust streaming applications suitable for a wide range of use cases. The flexibility of the SDK allows for fine-tuning of all streaming parameters, enabling optimization for specific network conditions and quality requirements. Whether implementing a simple point-to-point stream or a complex multicast distribution system, VisioForge's UDP streaming capabilities provide the necessary tools for success. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples and working demonstrations of UDP streaming implementations. ---END OF PAGE--- ## WMV Network Streaming Implementation in .NET Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/wmv/ **Description:** Implement Windows Media Video streaming in .NET with compression algorithms, adaptive bitrates, and bandwidth optimization for network delivery. **Tags:** Video Capture SDK, .NET, VideoCaptureCore, Windows, WinForms, Capture, Streaming, WMV, C#, NuGet **API:** VideoCaptureCore, WMVOutput, WMVMode, NetworkStreamingFormat # Windows Media Video (WMV) Network Streaming Implementation Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [VideoCaptureCore](#) ## Introduction to WMV Streaming Technology Windows Media Video (WMV) represents a versatile and powerful streaming technology developed by Microsoft. As an integral component of the Windows Media framework, WMV has established itself as a reliable solution for efficiently delivering video content across networks. This format utilizes sophisticated compression algorithms that substantially reduce file sizes while maintaining acceptable visual quality, making it particularly well-suited for streaming applications where bandwidth optimization is critical. The WMV format supports an extensive range of video resolutions and bitrates, allowing developers to tailor their streaming implementations to accommodate varying network conditions and end-user requirements. This adaptability makes WMV an excellent choice for applications that need to serve diverse client environments with different connectivity constraints. ## Technical Overview of WMV Format ### Key Features and Capabilities WMV implements the Advanced Systems Format (ASF) container, which provides several technical advantages for streaming applications: - **Efficient compression**: Employs codec technology that balances quality with file size - **Scalable bitrate adjustment**: Adapts to available bandwidth conditions - **Error resilience**: Built-in mechanisms for packet loss recovery - **Content protection**: Supports Digital Rights Management (DRM) when required - **Metadata support**: Allows embedding of descriptive information about the stream ### Technical Specifications | Feature | Specification | | --- | --- | | Codec | VC-1 (primarily) | | Container | ASF (Advanced Systems Format) | | Supported resolutions | Up to 4K UHD (depending on profile) | | Bitrate range | 10 Kbps to 20+ Mbps | | Audio support | WMA (Windows Media Audio) | | Streaming protocols | HTTP, RTSP, MMS | ## Windows-Only WMV Streaming Implementation [VideoCaptureCore](#) The VisioForge SDK provides a robust framework for implementing WMV streaming in Windows environments. This implementation allows applications to broadcast video over networks while simultaneously capturing to a file if desired. ### Implementation Prerequisites Before implementing WMV streaming in your application, ensure the following requirements are met: 1. Your development environment includes the VisioForge Video Capture SDK 2. Required redistributables are installed (details provided in the Deployment section) 3. Your application targets Windows operating systems 4. Network ports are properly configured and accessible ### Step-by-Step Implementation Guide #### 1. Initialize the Video Capture Component Begin by setting up the core video capture component in your application: ``` using VisioForge.Core.VideoCapture; using VisioForge.Core.Types.Output; using VisioForge.Core.Types.VideoCapture; // Initialize VideoCaptureCore with the VideoView that hosts the preview var VideoCapture1 = new VideoCaptureCore(VideoView1 as IVideoView); // Configure basic capture settings (device selection, mode, etc.) // ... ``` #### 2. Enable Network Streaming To activate network streaming functionality, you need to enable it explicitly and set the format to WMV: ``` // Enable network streaming VideoCapture1.Network_Streaming_Enabled = true; // Set the streaming format to WMV VideoCapture1.Network_Streaming_Format = NetworkStreamingFormat.WMV; ``` #### 3. Configure WMV Output Settings Create and configure a WMV output object with appropriate settings: ``` // Create WMV output. Default ctor picks the "Windows Media Video 9 for Local Network // (768 kbps)" internal profile with Mode = WMVMode.InternalProfile. var wmvOutput = new WMVOutput(); // Option A: pick a different built-in profile wmvOutput.Mode = WMVMode.InternalProfile; wmvOutput.Internal_Profile_Name = "Windows Media Video 9 for Broadband (NTSC, 1400 Kbps)"; // Option B: drive the encoder from custom settings instead of a profile. // Note the flat "Custom_*" naming — WMVOutput has no nested Profile object. // Bitrate is bits/sec; KeyFrameInterval is seconds between keyframes; // Quality is a 0..100 byte. wmvOutput.Mode = WMVMode.CustomSettings; wmvOutput.Custom_Video_StreamPresent = true; wmvOutput.Custom_Video_Bitrate = 2_000_000; // 2 Mbps wmvOutput.Custom_Video_KeyFrameInterval = 3; // seconds wmvOutput.Custom_Video_Quality = 85; // 0..100 wmvOutput.Custom_Video_SizeSameAsInput = true; wmvOutput.Custom_Audio_StreamPresent = true; // Cap the number of simultaneous clients (lives on WMVOutput, not on VideoCaptureCore) wmvOutput.Network_Streaming_WMV_Maximum_Clients = 25; // Wire the WMV output into the network-streaming pipeline VideoCapture1.Network_Streaming_Output = wmvOutput; // The port that the Windows Media server binds to VideoCapture1.Network_Streaming_Network_Port = 12345; ``` #### 4. Start the Streaming Process Once everything is configured, you can start the streaming process: ``` // Start the streaming process try { await VideoCapture1.StartAsync(); // The streaming URL is now available for clients string streamingUrl = VideoCapture1.Network_Streaming_URL; // Display or log the streaming URL for client connections Console.WriteLine($"Streaming available at: {streamingUrl}"); } catch (Exception ex) { // Handle any exceptions during streaming initialization Console.WriteLine($"Streaming error: {ex.Message}"); } ``` ### Advanced Configuration Options #### External .prx Profile Files For fine control beyond the built-in profiles, point WMVOutput at a profile file authored with Windows Media Profile Editor: ``` wmvOutput.Mode = WMVMode.ExternalProfile; wmvOutput.External_Profile_FileName = @"C:\profiles\my-stream.prx"; // Or paste the profile XML inline: // wmvOutput.Mode = WMVMode.ExternalProfileFromText; // wmvOutput.External_Profile_Text = "..."; VideoCapture1.Network_Streaming_Output = wmvOutput; ``` ## Client-Side Connection Implementation Clients can connect to the WMV stream using Windows Media Player or any application that supports the Windows Media streaming protocol. The connection URL follows this format: ``` http://[server_ip]:[port]/ ``` For example: ``` http://192.168.1.100:12345/ ``` ### Sample Client Connection Code For programmatic connections to the WMV stream in client applications: ``` // Client-side WMV stream connection using Windows Media Player control using System.Windows.Forms; public partial class StreamViewerForm : Form { public StreamViewerForm(string streamUrl) { InitializeComponent(); // Assuming you have a Windows Media Player control named 'wmPlayer' on your form wmPlayer.URL = streamUrl; wmPlayer.Ctlcontrols.play(); } } ``` ## Performance Optimization When implementing WMV network streaming, consider these optimization strategies: 1. **Adjust bitrate based on network conditions**: Lower bitrates for constrained networks 2. **Balance keyframe intervals**: Frequent keyframes improve seek performance but increase bandwidth 3. **Monitor CPU usage**: WMV encoding can be CPU-intensive; adjust quality settings accordingly 4. **Implement network quality detection**: Adapt streaming parameters dynamically 5. **Consider buffer settings**: Larger buffers improve stability but increase latency ## Troubleshooting Common Issues | Issue | Possible Solution | | --- | --- | | Connection failures | Verify network port is open in firewall settings | | Poor video quality | Increase bitrate or adjust compression settings | | High CPU usage | Reduce resolution or frame rate | | Client buffering | Adjust buffer window settings or reduce bitrate | | Authentication errors | Verify credentials on both server and client | ## Deployment Requirements ### Required Redistributables To successfully deploy applications using WMV streaming functionality, include the following redistributable packages: - Video capture redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x64/) ### Installation Commands Using NuGet Package Manager: ``` Install-Package VisioForge.DotNet.Core.Redist.VideoCapture.x64 ``` Or for 32-bit systems: ``` Install-Package VisioForge.DotNet.Core.Redist.VideoCapture.x86 ``` ## Conclusion WMV network streaming provides a reliable way to broadcast video content across networks in Windows environments. The VisioForge SDK simplifies implementation with its comprehensive API while giving developers fine-grained control over streaming parameters. By following the guidelines in this document, you can create robust streaming applications that deliver high-quality video content to multiple clients simultaneously. For more advanced implementations and additional code samples, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## YouTube Live Streaming in C# .NET with RTMP Output **URL:** https://www.visioforge.com/help/docs/dotnet/general/network-streaming/youtube/ **Description:** Stream to YouTube Live with RTMP in .NET applications using optimized video encoders, audio configuration, and cross-platform support. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, RTMP, H.264, H.265, AAC, C# **API:** VideoCaptureCoreX, VideoEditCoreX, YouTubeOutput, NVENCH264EncoderSettings, MediaBlockPadMediaType # YouTube Live Streaming with VisioForge SDKs ## Introduction to YouTube Streaming Integration The YouTube RTMP output functionality in VisioForge SDKs enables developers to create robust .NET applications that stream high-quality video content directly to YouTube. This implementation leverages various video and audio encoders to optimize streaming performance across different hardware configurations and platforms. This comprehensive guide provides detailed instructions on setting up, configuring, and troubleshooting YouTube streaming in your applications. ## Supported SDK Platforms [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) All major VisioForge SDK platforms provide cross-platform capabilities for YouTube streaming, ensuring consistent functionality across Windows, macOS, and other operating systems. ## Understanding the YouTubeOutput Class The `YouTubeOutput` class serves as the primary interface for YouTube streaming configuration, offering extensive customization options including: - **Video encoder selection and configuration**: Choose from multiple hardware-accelerated and software-based encoders - **Audio encoder selection and configuration**: Configure AAC audio encoders with custom parameters - **Custom video and audio processing**: Apply filters and transformations before streaming - **YouTube-specific sink settings**: Fine-tune streaming parameters specific to YouTube's requirements ## Getting Started: Basic Setup Process ### Stream Key Configuration The foundation of any YouTube streaming implementation begins with your YouTube stream key. This authentication token connects your application to your YouTube channel: ``` // Initialize YouTube output with your stream key var youtubeOutput = new YouTubeOutput("your-youtube-stream-key"); ``` ## Video Encoder Configuration Options ### Comprehensive Video Encoder Support The SDK provides support for multiple video encoders, each optimized for different hardware environments and performance requirements: | Encoder Type | Platform/Hardware | Performance Characteristics | | --- | --- | --- | | OpenH264 | Cross-platform (software) | CPU-intensive, widely compatible | | NVENC H264 | NVIDIA GPUs | Hardware-accelerated, reduced CPU usage | | QSV H264 | Intel CPUs with Quick Sync | Hardware-accelerated, efficient | | AMF H264 | AMD GPUs | Hardware-accelerated for AMD hardware | | HEVC/H265 | Various (where supported) | Higher compression efficiency | ### Dynamic Encoder Selection The system intelligently selects default encoders based on the platform (OpenH264 on most platforms, Apple Media H264 on macOS). Developers can override these defaults to leverage specific hardware capabilities: ``` // Example: Using NVIDIA NVENC encoder if available if (NVENCH264EncoderSettings.IsAvailable()) { youtubeOutput.Video = new NVENCH264EncoderSettings(); } ``` ### Configuring Video Encoding Parameters Each encoder supports customization of various parameters to optimize streaming quality and performance: ``` var videoSettings = new OpenH264EncoderSettings { Bitrate = 4500, // Kbit/s — 4.5 Mbps GOPSize = 60, // Keyframe every 2 seconds at 30 fps (real property name; no KeyframeInterval) // Add other encoder-specific settings as needed }; youtubeOutput.Video = videoSettings; ``` ## Audio Encoder Configuration ### Supported AAC Audio Encoders The SDK supports multiple AAC audio encoders to ensure optimal audio quality across different platforms: - **VO-AAC**: Default for non-Windows platforms, providing consistent audio encoding - **AVENC AAC**: Alternative cross-platform option with different performance characteristics - **MF AAC**: Windows-specific encoder leveraging Media Foundation ### Audio Encoder Configuration Example ``` // Example: Configure audio encoder settings. // VOAACEncoderSettings exposes only Bitrate (Kbit/s); sample rate follows the upstream source. var audioSettings = new VOAACEncoderSettings { Bitrate = 128, // Kbit/s — 128 kbps }; youtubeOutput.Audio = audioSettings; ``` ## Platform-Specific Optimization Strategies ### Windows-Specific Features - Leverages Media Foundation (MF) encoders for optimal Windows performance - Provides extended HEVC/H265 encoding capabilities - Defaults to MF AAC for audio encoding, optimized for the Windows platform ### macOS Implementation Considerations - Automatically utilizes Apple Media H264 encoder for native performance - Implements VO-AAC for audio encoding with macOS optimization ### Cross-Platform Compatibility Layer - Falls back to OpenH264 for video on platforms without specific optimizations - Utilizes VO-AAC for consistent audio encoding across diverse environments ## Best Practices for Optimal Streaming ### Hardware-Aware Encoder Selection - Always verify encoder availability before implementing hardware-accelerated options - Implement fallback mechanisms to OpenH264 when specialized hardware is unavailable - Consider platform-specific encoder capabilities when designing cross-platform applications ### YouTube-Optimized Stream Settings - Adhere to YouTube's recommended bitrates for your target resolution - Implement the standard 2-second keyframe interval (60 frames at 30fps) - Configure 48 kHz audio sample rate to meet YouTube's audio specifications ### Robust Error Management - Develop comprehensive error handling for connection issues - Implement continuous monitoring of encoder performance - Create diagnostic tools to evaluate stream health during operation ## Complete Implementation Examples ### VideoCaptureCoreX/VideoEditCoreX Integration This example demonstrates a complete YouTube streaming implementation with error handling for VideoCaptureCoreX/VideoEditCoreX: ``` try { var youtubeOutput = new YouTubeOutput("your-stream-key"); // Configure video encoding (Bitrate in Kbit/s; GOPSize controls keyframe cadence) if (NVENCH264EncoderSettings.IsAvailable()) { youtubeOutput.Video = new NVENCH264EncoderSettings { Bitrate = 4500, GOPSize = 60, }; } // Configure audio encoding (Bitrate in Kbit/s) youtubeOutput.Audio = new MFAACEncoderSettings { Bitrate = 128, }; // Rotate the YouTube stream key or swap the sink destination by replacing the Sink object. // YouTubeSinkSettings exposes only the stream Key (other properties are internal). // youtubeOutput.Sink = new YouTubeSinkSettings("new-stream-key"); // Add the output to the video capture instance core.Outputs_Add(youtubeOutput, true); // core is an instance of VideoCaptureCoreX // Or set the output for the video edit instance videoEdit.Output_Format = youtubeOutput; // videoEdit is an instance of VideoEditCoreX } catch (Exception ex) { // Handle initialization errors Console.WriteLine($"Failed to initialize YouTube output: {ex.Message}"); } ``` ### Media Blocks SDK Implementation For developers using the Media Blocks SDK, this example shows how to connect encoder components with the YouTube sink: ``` // Create the YouTube sink block (using RTMP) var youtubeSinkBlock = new YouTubeSinkBlock(new YouTubeSinkSettings("streaming key")); // Connect the video encoder to the sink block pipeline.Connect(h264Encoder.Output, youtubeSinkBlock.CreateNewInput(MediaBlockPadMediaType.Video)); // Connect the audio encoder to the sink block pipeline.Connect(aacEncoder.Output, youtubeSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio)); ``` ## Troubleshooting Common Issues ### Encoder Initialization Problems - Verify hardware encoder availability through system diagnostics - Ensure system meets all requirements for your chosen encoder - Confirm proper installation of hardware-specific drivers for GPU acceleration ### Stream Connection Failures - Validate stream key format and expiration status - Test network connectivity to YouTube's streaming servers - Verify YouTube service status through official channels ### Performance Optimization - Monitor system resource utilization during streaming sessions - Adjust encoding bitrates and settings based on available resources - Consider switching to hardware acceleration when CPU usage is excessive ## Additional Resources and Documentation - [Official YouTube Live Streaming Documentation](https://support.google.com/youtube/topic/9257891) - [YouTube Technical Stream Requirements](https://support.google.com/youtube/answer/2853702) By leveraging these detailed configuration options and best practices, developers can create robust YouTube streaming applications using VisioForge SDKs that deliver high-quality content while optimizing system resource utilization across multiple platforms. ---END OF PAGE--- ## AVI File Output Guide for .NET Video and Audio Encoding **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/avi/ **Description:** Implement AVI file output in .NET with video and audio encoding, hardware acceleration, and cross-platform multimedia container support. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Recording, Encoding, Editing, AVI, H.264, H.265, MJPEG, AAC, MP3, C#, NuGet **API:** AVIOutput, VideoCaptureCoreX, VOAACEncoderSettings, VideoEditCoreX, NVENCH264EncoderSettings # AVI File Output in VisioForge .NET SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) AVI (Audio Video Interleave) is a Microsoft-developed multimedia container format that stores both audio and video data in a single file with synchronized playback. It supports both compressed and uncompressed data, offering flexibility while sometimes resulting in larger file sizes. ## Technical Overview of AVI Format AVI files use a RIFF (Resource Interchange File Format) structure to organize data. This format divides content into chunks, with each chunk containing either audio or video frames. Key technical aspects include: - Container format supporting multiple audio and video codecs - Interleaved audio and video data for synchronized playback - Maximum file size of 4GB in standard AVI (extended to 16EB in OpenDML AVI) - Support for multiple audio tracks and subtitles - Widely supported across platforms and media players Despite newer container formats like MP4 and MKV offering more features, AVI remains valuable for certain workflows due to its simplicity and compatibility with legacy systems. ## Cross-Platform AVI Implementation [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The [AVIOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.AVIOutput.html) class provides a robust way to configure and generate AVI files with various encoding options. ### Setting Up AVI Output Create an `AVIOutput` instance by specifying a target filename: ``` var aviOutput = new AVIOutput("output_video.avi"); ``` This constructor automatically initializes default encoders: - Video: OpenH264 encoder - Audio: MP3 encoder ### Video Encoder Options Configure video encoding through the `Video` property with several available encoders. For detailed configuration options, see the [H.264 encoder documentation](../../video-encoders/h264/), [HEVC encoder documentation](../../video-encoders/hevc/), and [MJPEG encoder documentation](../../video-encoders/mjpeg/): #### Standard Encoder ``` // Open-source H.264 encoder for general use aviOutput.Video = new OpenH264EncoderSettings(); ``` #### Hardware-Accelerated Encoders ``` // NVIDIA GPU acceleration aviOutput.Video = new NVENCH264EncoderSettings(); // H.264 aviOutput.Video = new NVENCHEVCEncoderSettings(); // HEVC // Intel Quick Sync acceleration aviOutput.Video = new QSVH264EncoderSettings(); // H.264 aviOutput.Video = new QSVHEVCEncoderSettings(); // HEVC // AMD GPU acceleration aviOutput.Video = new AMFH264EncoderSettings(); // H.264 aviOutput.Video = new AMFHEVCEncoderSettings(); // HEVC ``` #### Special Purpose Encoder ``` // Motion JPEG for high-quality frame-by-frame encoding aviOutput.Video = new MJPEGEncoderSettings(); ``` ### Audio Encoder Options The `Audio` property lets you configure audio encoding settings. For detailed configuration options, see the [MP3 encoder documentation](../../audio-encoders/mp3/) and [AAC encoder documentation](../../audio-encoders/aac/): ``` // Standard MP3 encoding aviOutput.Audio = new MP3EncoderSettings(); // AAC encoding options aviOutput.Audio = new VOAACEncoderSettings(); aviOutput.Audio = new AVENCAACEncoderSettings(); aviOutput.Audio = new MFAACEncoderSettings(); // Windows only ``` ### Integration with SDK Components #### Video Capture SDK ``` var core = new VideoCaptureCoreX(); core.Outputs_Add(aviOutput, true); ``` #### Video Edit SDK ``` var core = new VideoEditCoreX(); core.Output_Format = aviOutput; ``` #### Media Blocks SDK ``` var aac = new VOAACEncoderSettings(); var h264 = new OpenH264EncoderSettings(); var aviSinkSettings = new AVISinkSettings("output.avi"); var aviOutput = new AVIOutputBlock(aviSinkSettings, h264, aac); ``` ### File Management You can get or change the output filename after initialization: ``` // Get current filename string currentFile = aviOutput.GetFilename(); // Set new filename aviOutput.SetFilename("new_output.avi"); ``` ### Complete Example Here's a full example showing how to configure AVI output with hardware acceleration: ``` // Create AVI output with specified filename var aviOutput = new AVIOutput("high_quality_output.avi"); // Configure hardware-accelerated NVIDIA H.264 encoding aviOutput.Video = new NVENCH264EncoderSettings(); // Configure AAC audio encoding aviOutput.Audio = new VOAACEncoderSettings(); ``` ## Windows-Specific AVI Implementation [VideoCaptureCore](#) [VideoEditCore](#) The Windows-only components provide additional options for AVI output configuration. ### Basic Setup Create the AVIOutput object: ``` var aviOutput = new AVIOutput(); ``` ### Configuration Methods #### Method 1: Using Settings Dialog ``` var aviSettingsDialog = new AVISettingsDialog( VideoCapture1.Video_Codecs.ToArray(), VideoCapture1.Audio_Codecs.ToArray()); aviSettingsDialog.ShowDialog(this); aviSettingsDialog.SaveSettings(ref aviOutput); ``` #### Method 2: Programmatic Configuration First, get available codecs: ``` // Populate codec lists foreach (string codec in VideoCapture1.Video_Codecs) { cbVideoCodecs.Items.Add(codec); } foreach (string codec in VideoCapture1.Audio_Codecs) { cbAudioCodecs.Items.Add(codec); } ``` Then set video and audio settings: ``` // Configure video aviOutput.Video_Codec = cbVideoCodecs.Text; // Configure audio aviOutput.ACM.Name = cbAudioCodecs.Text; aviOutput.ACM.Channels = 2; aviOutput.ACM.BPS = 16; aviOutput.ACM.SampleRate = 44100; aviOutput.ACM.UseCompression = true; ``` ### Implementation Apply settings and start capture: ``` // Set output format VideoCapture1.Output_Format = aviOutput; // Set capture mode VideoCapture1.Mode = VideoCaptureMode.VideoCapture; // Set output file path VideoCapture1.Output_Filename = "output.avi"; // Start capture await VideoCapture1.StartAsync(); ``` ## Best Practices for AVI Output ### Encoder Selection Guidelines 1. **General-Purpose Applications** 2. OpenH264 provides good compatibility and quality 3. Suitable for most standard development scenarios 4. **Performance-Critical Applications** 5. Use hardware-accelerated encoders (NVENC, QSV, AMF) when available 6. Offers significant performance advantages with minimal quality loss 7. **Quality-Focused Applications** 8. HEVC encoders provide better compression at similar quality 9. MJPEG for scenarios requiring frame-by-frame accuracy ### Audio Encoding Recommendations - MP3: Good compatibility with reasonable quality - AAC: Better quality-to-size ratio, preferred for newer applications - Choose based on your target platform and quality requirements ### Platform Considerations - Some encoders are platform-specific: - MF HEVC and MF AAC encoders are Windows-only - Hardware-accelerated encoders require appropriate GPU support - Check encoder availability with `GetVideoEncoders()` and `GetAudioEncoders()` when developing cross-platform applications ### Error Handling Tips - Always verify encoder availability before use - Implement fallback encoders for platform-specific scenarios - Check file write permissions before setting output paths ## Troubleshooting Common Issues ### Codec Not Found If you encounter "Codec not found" errors: ``` // Check if codec is available before using if (!VideoCapture1.Video_Codecs.Contains("H264")) { // Fall back to another codec or show error MessageBox.Show("H264 codec not available. Please install required codecs."); return; } ``` ### File Write Permission Issues Handle permission-related errors: ``` try { // Test write permissions using (var fs = File.Create(outputPath, 1, FileOptions.DeleteOnClose)) { } // If successful, proceed with AVI output aviOutput.SetFilename(outputPath); } catch (UnauthorizedAccessException) { // Handle permission error MessageBox.Show("Cannot write to the specified location. Please select another folder."); } ``` ### 4 GB AVI container limit The AVI container has a hard 4 GB cap, and `AVIOutput` exposes no built-in split API. For long recordings, either: - Stop the pipeline before you approach 4 GB and start a new one with a fresh `AVIOutput(nextFilename)`, or - Switch container: [MP4](../mp4/) or [MKV](../mkv/) both handle multi-hour recordings without this limit. Watch free disk space and rotate at the application layer when you need multi-file capture. ## Required Dependencies ### Video Capture SDK .Net - [x86 Redist](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x86/) - [x64 Redist](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x64/) ### Video Edit SDK .Net - [x86 Redist](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x86/) - [x64 Redist](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x64/) ## Additional Resources - [VisioForge API Documentation](https://api.visioforge.org/dotnet/) - [Sample Projects Repository](https://github.com/visioforge/.Net-SDK-s-samples) - [Support and Community Forums](https://support.visioforge.com/) ---END OF PAGE--- ## DirectShow Custom Video Format Integration in .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/custom/ **Description:** Implement custom video output formats with DirectShow filters for specialized processing pipelines and codec configuration in .NET applications. **Tags:** Video Capture SDK, Video Edit SDK, .NET, DirectShow, VideoCaptureCore, VideoEditCore, Windows, Capture, Streaming, Encoding, Editing, MP4, C#, NuGet **API:** CustomOutput, VideoCaptureCore, VideoEditCore, VideoCaptureMode # Creating Custom Video Output Formats with DirectShow Filters [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [VideoCaptureCore](#) [VideoEditCore](#) ## Overview Working with video in .NET applications often requires custom output formats to meet specific project requirements. The VisioForge SDKs provide powerful capabilities to implement custom format outputs using DirectShow filters, giving developers precise control over audio and video processing pipelines. This guide demonstrates practical techniques for implementing custom output formats that work seamlessly with both the Video Capture SDK .NET and Video Edit SDK .NET, allowing you to tailor your video applications to exact specifications. ## Why Use Custom Output Formats? Custom output formats offer several advantages for .NET developers: - Support for specialized video codecs not available in standard formats - Fine-grained control over video and audio compression settings - Integration with third-party DirectShow filters - Ability to create proprietary or industry-specific output formats - Optimization for specific use cases (streaming, archiving, editing) ## Getting Started with CustomOutput The `CustomOutput` class is the cornerstone for configuring custom output settings in VisioForge SDKs. This class enables you to define and configure the filters used in your video processing pipeline. Start by initializing a new instance: ``` var customOutput = new CustomOutput(); ``` While our examples use the `VideoCaptureCore` class, developers using Video Edit SDK .NET can apply the same techniques with `VideoEditCore`. ## Implementation Strategies There are two primary approaches to implementing custom format output with DirectShow filters: ### Strategy 1: Three-Component Pipeline This modular approach divides the processing pipeline into three distinct components: 1. Audio codec 2. Video codec 3. Multiplexer (file format container) This separation provides maximum flexibility and control over each stage of the process. You can use either standard DirectShow filters or specialized codecs for audio and video components. #### Retrieving Available Codecs Begin by populating your UI with available codecs and filters: ``` // Populate video codec options foreach (string codec in VideoCapture1.Video_Codecs) { videoCodecDropdown.Items.Add(codec); } // Populate audio codec options foreach (string codec in VideoCapture1.Audio_Codecs) { audioCodecDropdown.Items.Add(codec); } // Get all available DirectShow filters foreach (string filter in VideoCapture1.DirectShow_Filters) { directShowAudioFilters.Items.Add(filter); directShowVideoFilters.Items.Add(filter); multiplexerFilters.Items.Add(filter); fileWriterFilters.Items.Add(filter); } ``` #### Configuring the Pipeline Components Next, set up your video and audio processing components based on user selections: ``` // Set up video codec if (useStandardVideoCodec.Checked) { customOutput.Video_Codec = videoCodecDropdown.Text; customOutput.Video_Codec_UseFiltersCategory = false; } else { customOutput.Video_Codec = directShowVideoFilters.Text; customOutput.Video_Codec_UseFiltersCategory = true; } // Set up audio codec if (useStandardAudioCodec.Checked) { customOutput.Audio_Codec = audioCodecDropdown.Text; customOutput.Audio_Codec_UseFiltersCategory = false; } else { customOutput.Audio_Codec = directShowAudioFilters.Text; customOutput.Audio_Codec_UseFiltersCategory = true; } // Configure the multiplexer customOutput.MuxFilter_Name = multiplexerFilters.Text; customOutput.MuxFilter_IsEncoder = false; ``` #### Custom File Writer Configuration For specialized outputs that require a dedicated file writer: ``` // Enable special file writer if needed customOutput.SpecialFileWriter_Needed = useCustomFileWriter.Checked; customOutput.SpecialFileWriter_FilterName = fileWriterFilters.Text; ``` This approach gives you granular control over each stage of the encoding process, making it ideal for complex output requirements. ### Strategy 2: All-in-One Filter This streamlined approach uses a single DirectShow filter that combines the functionality of the multiplexer, video codec, and audio codec. The SDK intelligently handles detection of the filter's capabilities, determining whether it: - Can directly write files without assistance - Requires the standard DirectShow File Writer filter - Needs a specialized file writer filter Implementation is straightforward: ``` // Populate filter options from available DirectShow filters foreach (string filter in VideoCapture1.DirectShow_Filters) { filterDropdown.Items.Add(filter); } // Configure the all-in-one filter customOutput.MuxFilter_Name = selectedFilter.Text; customOutput.MuxFilter_IsEncoder = true; // Set up specialized file writer if required customOutput.SpecialFileWriter_Needed = requiresCustomWriter.Checked; customOutput.SpecialFileWriter_FilterName = fileWriterFilter.Text; ``` This approach is simpler to implement but offers less granular control over individual components of the encoding process. ## Simplifying Configuration with Dialog UI For a more user-friendly implementation, VisioForge provides a built-in settings dialog that handles the configuration of custom formats: ``` // Create and configure the settings dialog CustomFormatSettingsDialog settingsDialog = new CustomFormatSettingsDialog( VideoCapture1.Video_Codecs.ToArray(), VideoCapture1.Audio_Codecs.ToArray(), VideoCapture1.DirectShow_Filters.ToArray()); // Apply settings to your CustomOutput instance settingsDialog.SaveSettings(ref customOutput); ``` This dialog provides a complete UI for configuring all aspects of custom output formats, saving development time while still offering full flexibility. ## Implementing the Output Process After configuring your custom format settings, you need to apply them to your capture or edit process: ``` // Apply the custom format configuration VideoCapture1.Output_Format = customOutput; // Set the capture mode VideoCapture1.Mode = VideoCaptureMode.VideoCapture; // Specify output file path VideoCapture1.Output_Filename = "output_video.mp4"; // Start the capture or encoding process await VideoCapture1.StartAsync(); ``` ## Performance Considerations When implementing custom output formats, keep these performance tips in mind: - DirectShow filters vary in efficiency and resource usage - Test your filter combinations with typical input media - Some third-party filters may introduce additional latency - Consider memory usage when processing high-resolution video - Filter compatibility may vary across different Windows versions ## Required Packages To use custom DirectShow filters, ensure you have the appropriate redistributable packages installed: ### Video Capture SDK .Net - [x86 Package](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x86/) - [x64 Package](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x64/) ### Video Edit SDK .Net - [x86 Package](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x86/) - [x64 Package](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x64/) ## Troubleshooting Common issues when working with custom DirectShow filters include: - Filter compatibility conflicts - Missing codecs or dependencies - Registration issues with COM components - Memory leaks in third-party filters - Performance bottlenecks with complex filter graphs If you encounter problems, verify that all required filters are properly registered on your system and that you have the latest versions of both the filters and the VisioForge SDK. ## Conclusion Custom output formats using DirectShow filters provide powerful capabilities for .NET developers working with video applications. Whether you choose the flexibility of a three-component pipeline or the simplicity of an all-in-one filter approach, VisioForge's SDKs give you the tools you need to create exactly the output format your application requires. --- For more code samples and implementation examples, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## FFMPEG.exe Output Format Configuration in .NET Video SDKs **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/ffmpeg-exe/ **Description:** Configure FFMPEG.exe output in .NET for video capture and editing with hardware acceleration, custom codecs, and professional encoding options. **Tags:** Video Capture SDK, Video Edit SDK, .NET, VideoCaptureCore, VideoEditCore, Windows, Capture, Encoding, Editing, MP4, WebM, AVI, MOV, TS, H.264, H.265, ProRes, C#, NuGet **API:** VideoCaptureCore, VideoEditCore, FFMPEGEXEOutput, H264MFSettings, H264NVENCSettings # FFMPEG.exe Integration with VisioForge .Net SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [VideoCaptureCore](#) [VideoEditCore](#) ## Introduction to FFMPEG Output in .NET This guide provides detailed instructions for implementing FFMPEG.exe output in Windows applications using VisioForge's .NET SDKs. The integration works with both [Video Capture SDK .NET](https://www.visioforge.com/video-capture-sdk-net) and [Video Edit SDK .NET](https://www.visioforge.com/video-edit-sdk-net), utilizing the `VideoCaptureCore` and `VideoEditCore` engines. FFMPEG functions as a powerful multimedia framework that enables developers to output to a wide variety of video and audio formats. Its flexibility stems from extensive codec support and granular control over encoding parameters for both video and audio streams. ## Why Use FFMPEG with VisioForge SDKs? Integrating FFMPEG into your VisioForge-powered applications provides several technical advantages: - **Format versatility**: Support for virtually all modern container formats - **Codec flexibility**: Access to both open-source and proprietary codecs - **Performance optimization**: Options for CPU and GPU acceleration - **Customization depth**: Fine-grained control over encoding parameters - **Cross-platform compatibility**: Consistent output on different systems ## Key Features and Capabilities ### Supported Output Formats FFMPEG supports numerous container formats, including but not limited to: - MP4 (MPEG-4 Part 14) - WebM (VP8/VP9 with Vorbis/Opus) - MKV (Matroska) - AVI (Audio Video Interleave) - MOV (QuickTime) - WMV (Windows Media Video) - FLV (Flash Video) - TS (MPEG Transport Stream) ### Hardware Acceleration Options Modern video encoding benefits from hardware acceleration technologies that significantly improve encoding speed and efficiency: - **Intel QuickSync**: Leverages Intel integrated graphics for H.264 and HEVC encoding - **NVIDIA NVENC**: Utilizes NVIDIA GPUs for accelerated encoding (requires compatible NVIDIA graphics card) - **AMD AMF/VCE**: Employs AMD graphics processors for encoding acceleration ### Video Codec Support The integration offers access to multiple video codecs with customizable parameters: - **H.264/AVC**: Industry standard with excellent quality-to-size ratio - **H.265/HEVC**: Higher efficiency codec for 4K+ content - **VP9**: Google's open video codec used in WebM - **AV1**: Next-generation open codec (where supported) - **MPEG-2**: Legacy codec for DVD and broadcast compatibility - **ProRes**: Professional codec for editing workflows ## Implementation Process ### 1. Setting Up Your Development Environment Before implementing FFMPEG output, ensure your development environment is properly configured: 1. Create a new or open an existing .NET project 2. Install the appropriate VisioForge SDK NuGet packages 3. Add FFMPEG dependency packages (detailed in the Dependencies section) 4. Import the necessary namespaces in your code: ``` using VisioForge.Core.Types; using VisioForge.Core.Types.VideoCapture; using VisioForge.Core.Types.VideoEdit; using VisioForge.Core.Types.Output; // FFMPEGEXEOutput using VisioForge.Core.Types.FFMPEGEXE; // H264MFSettings, H264NVENCSettings, H264QSVSettings, HEVCQSVSettings, OutputMuxer, BasicAudioSettings, ... ``` ### 2. Initializing FFMPEG Output Start by creating an instance of `FFMPEGEXEOutput` to handle your output configuration: ``` var ffmpegOutput = new FFMPEGEXEOutput(); ``` This object will serve as the container for all your encoding settings and preferences. ### 3. Configuring Output Container Format Set your desired output container format using the `OutputMuxer` property: ``` ffmpegOutput.OutputMuxer = OutputMuxer.MP4; ``` Other common container options include: - `OutputMuxer.Matroska` - For Matroska container (.mkv) - `OutputMuxer.WebM` - For WebM format - `OutputMuxer.AVI` - For AVI format - `OutputMuxer.MOV` - For QuickTime container ### 4. Video Encoder Configuration FFMPEG provides multiple video encoder options. Select and configure the appropriate encoder based on your requirements and available hardware: #### Standard CPU-Based H.264 Encoding ``` var videoEncoder = new H264MFSettings { Bitrate = 5000, // Kbit/s — 5000 = 5 Mbps RateControl = H264MFRateControl.CBR, }; ffmpegOutput.Video = videoEncoder; ``` #### Hardware-Accelerated NVIDIA Encoding ``` var nvidiaEncoder = new H264NVENCSettings { Bitrate = 8000000, // 8 Mbps }; ffmpegOutput.Video = nvidiaEncoder; ``` #### Hardware-Accelerated Intel QuickSync Encoding ``` var intelEncoder = new H264QSVSettings { Bitrate = 6000000 }; ffmpegOutput.Video = intelEncoder; ``` #### HEVC/H.265 Encoding for Higher Efficiency ``` var hevcEncoder = new HEVCQSVSettings { Bitrate = 3000000, }; ffmpegOutput.Video = hevcEncoder; ``` ### 5. Audio Encoder Configuration Configure your audio encoding settings based on quality requirements and target platform compatibility: ``` var audioEncoder = new BasicAudioSettings { Bitrate = 192000, // 192 kbps Channels = 2, // Stereo SampleRate = 48000, // 48 kHz - professional standard Encoder = AudioEncoder.AAC, Mode = AudioMode.CBR }; ffmpegOutput.Audio = audioEncoder; ``` ### 6. Final Configuration and Execution Apply all settings and start the encoding process: ``` // Apply format settings core.Output_Format = ffmpegOutput; // Set operation mode core.Mode = VideoCaptureMode.VideoCapture; // For Video Capture SDK // core.Mode = VideoEditMode.Convert; // For Video Edit SDK // Set output path core.Output_Filename = "output.mp4"; // Begin processing await core.StartAsync(); ``` ## Required Dependencies Install the following NuGet packages based on your target architecture to ensure proper functionality: ### Video Capture SDK Dependencies ``` Install-Package VisioForge.DotNet.Core.Redist.VideoCapture.x64 Install-Package VisioForge.DotNet.Core.Redist.FFMPEGEXE.x64 ``` For x86 targets: ``` Install-Package VisioForge.DotNet.Core.Redist.VideoCapture.x86 Install-Package VisioForge.DotNet.Core.Redist.FFMPEGEXE.x86 ``` ### Video Edit SDK Dependencies ``` Install-Package VisioForge.DotNet.Core.Redist.VideoEdit.x64 Install-Package VisioForge.DotNet.Core.Redist.FFMPEGEXE.x64 ``` For x86 targets: ``` Install-Package VisioForge.DotNet.Core.Redist.VideoEdit.x86 Install-Package VisioForge.DotNet.Core.Redist.FFMPEGEXE.x86 ``` ## Troubleshooting and Optimization ### Common Issues and Solutions - **Codec not found errors**: Ensure you've installed the correct FFMPEG package with proper codec support - **Hardware acceleration failures**: Verify GPU compatibility and driver versions - **Performance issues**: Adjust thread count and encoding preset based on available CPU resources - **Output quality problems**: Fine-tune bitrate, profile, and encoding parameters ### Performance Optimization Tips - Use hardware acceleration when available - Choose appropriate presets based on your quality/speed requirements - Set reasonable bitrates based on content type and resolution - Consider two-pass encoding for non-realtime scenarios requiring highest quality ## Additional Resources For more code samples and implementation examples, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). To learn more about FFMPEG parameters and capabilities, refer to the [official FFMPEG documentation](https://ffmpeg.org/documentation.html). ---END OF PAGE--- ## Video to Animated GIF Encoding in .NET Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/gif/ **Description:** Create GIF animations from video in .NET with frame rate control, resolution settings, and optimization for cross-platform applications. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Encoding, Editing, GIF, C# **API:** AnimatedGIFOutput, GIFEncoderSettings, VideoCaptureCoreX, VideoEditCoreX, VideoCaptureCore # GIF Encoder [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The GIF encoder is a component of the VisioForge SDK that enables video encoding to the GIF format. This document provides detailed information about the GIF encoder settings and implementation guidelines. ## Cross-platform GIF output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The GIF encoder settings are managed through the `GIFEncoderSettings` class, which provides configuration options for controlling the encoding process. ### Properties 1. **Repeat** 2. Type: `uint` 3. Description: Controls the number of times the GIF animation will repeat 4. Values: - `-1`: Loop forever - `0..n`: Finite number of repetitions 5. **Speed** 6. Type: `int` 7. Description: Controls the encoding speed 8. Range: 1 to 30 (higher values result in faster encoding) 9. Default: 10 ## Implementation Guide ### Basic Usage Here's a basic example of how to configure and use the GIF encoder: ``` using VisioForge.Core.Types.X.VideoEncoders; // Create and configure GIF encoder settings var settings = new GIFEncoderSettings { Repeat = 0, // Play once Speed = 15 // Set encoding speed to 15 }; ``` ### Advanced Configuration For more controlled GIF encoding, you can adjust the settings based on your specific needs: ``` // Configure for an infinitely looping GIF with maximum encoding speed var settings = new GIFEncoderSettings { Repeat = uint.MaxValue, // Loop forever Speed = 30 // Maximum encoding speed }; // Configure for optimal quality var qualitySettings = new GIFEncoderSettings { Repeat = 1, // Play twice Speed = 1 // Slowest encoding speed for best quality }; ``` ## Best Practices 1. **Speed Selection** 2. For best quality, use lower speed values (1-5) 3. For balanced quality and performance, use medium speed values (6-15) 4. For fastest encoding, use higher speed values (16-30) 5. **Memory Considerations** 6. Higher speed values consume more memory during encoding 7. For large videos, consider using lower speed values to manage memory usage 8. **Loop Configuration** (`Repeat` is a `uint`) 9. Use `Repeat = uint.MaxValue` for infinite loops (the docstring reads "-1 = loop forever" but the property type is `uint`, so `-1` won't compile) 10. Set specific repeat counts for presentation-style GIFs 11. Use `Repeat = 0` for single-play GIFs ## Performance Optimization When encoding videos to GIF format, consider these optimization strategies: ``` // Optimize for web delivery var webOptimizedSettings = new GIFEncoderSettings { Repeat = uint.MaxValue, // Infinite loop for web playback Speed = 20 // Fast encoding for web content }; // Optimize for quality var qualityOptimizedSettings = new GIFEncoderSettings { Repeat = 1, // Single repeat Speed = 3 // Slower encoding for better quality }; ``` ### Example Implementation Here's a complete example showing how to set up GIF output: First build the `GIFOutput` (X engines) with the encoder settings: ``` var gifOutput = new GIFOutput("output.gif"); gifOutput.Settings = new GIFEncoderSettings { Repeat = uint.MaxValue, // Infinite loop Speed = 4, }; ``` Add the GIF output to the Video Capture SDK core instance: ``` var core = new VideoCaptureCoreX(); core.Outputs_Add(gifOutput, true); ``` Or assign it as the `Output_Format` of a `VideoEditCoreX` timeline: ``` var editor = new VideoEditCoreX(); editor.Input_AddVideoFile("input.mp4"); editor.Output_Format = gifOutput; editor.Start(); ``` GIF output is video-only `GIFOutput` implements both `IVideoCaptureXBaseOutput` and `IVideoEditXBaseOutput`, so it works with `VideoCaptureCoreX` and `VideoEditCoreX`. There is no muxer — `gifenc` writes the final `.gif` directly. Audio tracks on the timeline are dropped, and `SmartRender = true` is incompatible with GIF output (no source clip is already in `image/gif`). For pipelines that need finer control over the encoder placement, the Media Blocks `GIFEncoderBlock` snippet below remains available. Create a Media Blocks GIF output instance: ``` var gifSettings = new GIFEncoderSettings(); var gifEncoderBlock = new GIFEncoderBlock(gifSettings, "output.gif"); ``` ## Windows-only GIF output [VideoCaptureCore](#) [VideoEditCore](#) The `AnimatedGIFOutput` class is a specialized configuration class within the `VisioForge.Core.Types.Output` namespace that handles settings for generating animated GIF files. This class is designed to work with both video capture and video editing operations, implementing both `IVideoEditBaseOutput` and `IVideoCaptureBaseOutput` interfaces. The primary purpose of this class is to provide a configuration container for controlling how video content is converted into animated GIF format. It allows users to specify key parameters such as frame rate and output dimensions, which are crucial for creating optimized animated GIFs from video sources. ### Properties #### ForcedVideoHeight - Type: `int` - Purpose: Specifies a forced height for the output GIF - Usage: Set this property when you need to resize the output GIF to a specific height, regardless of the input video dimensions - Example: `gifOutput.ForcedVideoHeight = 480;` #### ForcedVideoWidth - Type: `int` - Purpose: Specifies a forced width for the output GIF - Usage: Set this property when you need to resize the output GIF to a specific width, regardless of the input video dimensions - Example: `gifOutput.ForcedVideoWidth = 640;` #### FrameRate - Type: `VideoFrameRate` - Default Value: 2 frames per second - Purpose: Controls how many frames per second the output GIF will contain - Note: The default value of 2 fps is chosen to balance file size and animation smoothness for typical GIF usage ### Constructor ``` public AnimatedGIFOutput() ``` The constructor initializes a new instance with default settings: - Sets the frame rate to 2 fps using `new VideoFrameRate(2)` - All other properties are initialized to their default values ### Serialization Methods #### Save() - Returns: `string` - Purpose: Serializes the current configuration to JSON format - Usage: Use this method when you need to save or transfer the configuration - Example: ``` var gifOutput = new AnimatedGIFOutput(); gifOutput.ForcedVideoWidth = 800; string jsonConfig = gifOutput.Save(); ``` #### Load(string json) - Parameters: `json` - A JSON string containing serialized configuration - Returns: `AnimatedGIFOutput` - Purpose: Creates a new instance from a JSON configuration string - Usage: Use this method to restore a previously saved configuration - Example: ``` string jsonConfig = "..."; // Your saved JSON configuration var gifOutput = AnimatedGIFOutput.Load(jsonConfig); ``` ### Best Practices and Usage Guidelines 1. Frame Rate Considerations 2. The default 2 fps is suitable for most basic animations 3. Increase the frame rate for smoother animations, but be aware of file size implications 4. Consider using higher frame rates (e.g., 10-15 fps) for complex motion 5. Resolution Settings 6. Only set ForcedVideoWidth/Height when you specifically need to resize 7. Maintain aspect ratio by setting width and height proportionally 8. Consider target platform limitations when choosing dimensions 9. Performance Optimization 10. Lower frame rates result in smaller file sizes 11. Consider the balance between quality and file size based on your use case 12. Test different configurations to find the optimal settings for your needs ### Example Usage Here's a complete example of configuring and using the AnimatedGIFOutput class: ``` // Create a new instance with default settings var gifOutput = new AnimatedGIFOutput(); // Configure the output settings gifOutput.ForcedVideoWidth = 800; gifOutput.ForcedVideoHeight = 600; gifOutput.FrameRate = new VideoFrameRate(5); // 5 fps // Apply the settings to the core core.Output_Format = gifOutput; // core is an instance of VideoCaptureCore or VideoEditCore core.Output_Filename = "output.gif"; ``` ### Common Scenarios and Solutions #### Creating Web-Optimized GIFs ``` var webGifOutput = new AnimatedGIFOutput { ForcedVideoWidth = 480, ForcedVideoHeight = 270, FrameRate = new VideoFrameRate(5) }; ``` #### High-Quality Animation Settings ``` var highQualityGif = new AnimatedGIFOutput { FrameRate = new VideoFrameRate(15) }; ``` ---END OF PAGE--- ## Video and Audio Output Formats for .NET Development **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/ **Description:** Comprehensive guide to video and audio formats for .NET including MP4, WebM, AVI, MKV with codec comparisons and compatibility matrices. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, DirectShow, Windows, macOS, Linux, Android, iOS, Streaming # Output Formats for .NET Media SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction The VisioForge .NET SDKs support a wide range of output formats for video, audio, and media projects. Selecting the right format is crucial for ensuring compatibility, optimizing file size, and maintaining quality appropriate for your target platform. This guide covers all available formats, their technical specifications, use cases, and implementation details to help developers make informed decisions. ## Choosing the Right Format When selecting an output format, consider these key factors: - **Target platform** - Some formats work better on specific devices or browsers - **Quality requirements** - Different codecs provide varying levels of quality at different bitrates - **File size constraints** - Some formats offer better compression than others - **Processing overhead** - Encoding complexity varies between formats - **Streaming requirements** - Certain formats are optimized for streaming scenarios ## Video Container Formats ### AVI (Audio Video Interleave) [AVI](avi/) is a classic container format developed by Microsoft that supports various video and audio codecs. **Key features:** - Wide compatibility with Windows applications - Supports virtually any DirectShow-compatible video and audio codec - Simple structure makes it reliable for video editing workflows - Better suited for archiving than streaming ### MP4 (MPEG-4 Part 14) [MP4](mp4/) is one of the most versatile and widely used container formats in modern applications. **Key features:** - Excellent compatibility across devices and platforms - Supports advanced codecs including H.264, H.265/HEVC, and AAC - Optimized for streaming and progressive download - Efficient storage with good quality-to-size ratio **Supported video codecs:** - H.264 (AVC) - Balance of quality and compatibility - H.265 (HEVC) - Better compression but higher encoding overhead - MPEG-4 Part 2 - Older codec with wider compatibility **Supported audio codecs:** - AAC - Industry standard for digital audio compression - MP3 - Widely supported legacy format ### WebM [WebM](webm/) is an open-source container format designed specifically for web use. **Key features:** - Royalty-free format ideal for web applications - Native support in most modern browsers - Excellent for streaming video content - Supports VP8, VP9, and AV1 video codecs **Technical considerations:** - VP9 offers ~50% bitrate reduction compared to H.264 at similar quality - AV1 provides even better compression but with significantly higher encoding complexity - Works well with HTML5 video elements without plugins ### MKV (Matroska) [MKV](mkv/) is a flexible container format that can hold virtually any type of audio or video. **Key features:** - Supports multiple audio, video, and subtitle tracks - Can contain almost any codec - Great for archiving and high-quality storage - Supports chapters and attachments **Best uses:** - Media archives requiring multiple tracks - High-quality video storage - Projects requiring complex chapter structures ### Additional Container Formats - [MOV](mov/) - Apple's QuickTime container format - [MPEG-TS](mpegts/) - Transport Stream format optimized for broadcasting - [MXF](mxf/) - Material Exchange Format used in professional video production - [Windows Media Video](wmv/) - Microsoft's proprietary format ## Audio-Only Formats ### MP3 (MPEG-1 Audio Layer III) [MP3](../audio-encoders/mp3/) remains one of the most widely supported audio formats. **Key features:** - Near-universal compatibility - Configurable bitrate for quality vs. size tradeoffs - VBR (Variable Bit Rate) option for optimized file sizes ### AAC in M4A Container [M4A](../audio-encoders/aac/) provides better audio quality than MP3 at the same bitrate. **Key features:** - Better compression efficiency than MP3 - Good compatibility with modern devices - Supports advanced audio features like multichannel audio ### Other Audio Formats - [FLAC](../audio-encoders/flac/) - Lossless audio format for high-quality archiving - [OGG Vorbis](../audio-encoders/vorbis/) - Open-source alternative to MP3 with better quality at lower bitrates ## Specialized Formats ### GIF (Graphics Interchange Format) [GIF](gif/) is useful for creating short, silent animations. **Key features:** - Wide web compatibility - Limited to 256 colors per frame - Support for transparency - Ideal for short, looping animations ### Custom Output Format [Custom output format](custom/) allows integration with third-party DirectShow filters. **Key features:** - Maximum flexibility for specialized requirements - Integration with commercial or custom codecs - Support for proprietary formats ## Advanced Output Options ### FFMPEG Integration [FFMPEG EXE](ffmpeg-exe/) integration provides access to FFMPEG's extensive codec library. **Key features:** - Support for virtually any format FFMPEG can handle - Advanced encoding options - Custom command line arguments for fine-tuned control ## Performance Optimization Tips When working with video output formats, consider these optimization strategies: 1. **Match format to use case** - Use streaming-optimized formats for web delivery 2. **Consider hardware acceleration** - Many modern codecs support GPU acceleration 3. **Use appropriate bitrates** - Higher isn't always better; find the sweet spot for your content 4. **Test on target devices** - Ensure compatibility before finalizing format choice 5. **Enable multi-threading** - Take advantage of multiple CPU cores for faster encoding ## Implementation Best Practices - Configure proper keyframe intervals for streaming formats - Set appropriate bitrate constraints for target platforms - Use two-pass encoding for highest quality output when time permits - Consider audio quality requirements alongside video format decisions ## Format Compatibility Matrix | Format | Windows | macOS | iOS | Android | Web Browsers | | --- | --- | --- | --- | --- | --- | | MP4 (H.264) | ✓ | ✓ | ✓ | ✓ | ✓ | | WebM (VP9) | ✓ | ✓ | Partial | ✓ | ✓ | | MKV | ✓ | With players | With players | With players | ✗ | | AVI | ✓ | With players | Limited | Limited | ✗ | | MP3 | ✓ | ✓ | ✓ | ✓ | ✓ | --- Visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for more code samples and implementation examples. Our documentation is continuously updated to reflect new features and optimizations available in the latest SDK releases. ---END OF PAGE--- ## MKV Container Format - .NET Video Encoding and Recording **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/mkv/ **Description:** Implement MKV output in .NET with hardware-accelerated encoding, multiple audio tracks, and flexible Matroska container support for video apps. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Recording, Encoding, Editing, MKV, H.264, H.265, AAC, C# **API:** MKVOutput, VideoCaptureCoreX, VideoEditCoreX, MediaBlocksPipeline, NVENCH264EncoderSettings # MKV Output in VisioForge .NET SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ## Introduction to MKV Format MKV (Matroska Video) is a flexible, open-standard container format that can hold an unlimited number of video, audio, and subtitle tracks in one file. The VisioForge SDKs provide robust support for MKV output with various encoding options to meet diverse development requirements. This format is particularly valuable for developers working on applications that require: - Multiple audio tracks or languages - High-quality video with multiple codec options - Cross-platform compatibility - Support for metadata and chapters ## Getting Started with MKV Output The `MKVOutput` class serves as the primary interface for generating MKV files in VisioForge SDKs. You can initialize it with default settings or specify custom encoders to match your application's needs. ### Basic Implementation ``` // Create MKV output with default encoders var mkvOutput = new MKVOutput("output.mkv"); ``` Or specify custom encoders during initialization (the second and third constructor parameters are `IVideoEncoder` / `IAudioEncoder`, both nullable): ``` var videoEncoder = new NVENCH264EncoderSettings(); var audioEncoder = new MFAACEncoderSettings(); var mkvOutput = new MKVOutput("output.mkv", videoEncoder, audioEncoder); ``` ## Video Encoding Options The MKV format supports multiple video codecs, giving developers flexibility in balancing quality, performance, and compatibility. VisioForge SDKs offer both software and hardware-accelerated encoders. ### H.264 Encoder Options H.264 remains one of the most widely supported video codecs, providing excellent compression and quality. For detailed configuration options, see the [H.264 encoder documentation](../../video-encoders/h264/). - **OpenH264**: Software-based encoder, used as default when hardware acceleration isn't available - **NVENC H.264**: NVIDIA GPU-accelerated encoding for superior performance - **QSV H.264**: Intel Quick Sync Video technology for hardware acceleration - **AMF H.264**: AMD GPU-accelerated encoding option ### HEVC (H.265) Encoder Options For applications requiring higher compression efficiency or 4K content, see the [HEVC encoder documentation](../../video-encoders/hevc/) for detailed settings: - **MF HEVC**: Windows Media Foundation implementation (Windows-only) - **NVENC HEVC**: NVIDIA GPU acceleration for H.265 - **QSV HEVC**: Intel Quick Sync implementation for H.265 - **AMF HEVC**: AMD GPU acceleration for H.265 encoding ### Setting a Video Encoder ``` mkvOutput.Video = new NVENCH264EncoderSettings(); ``` ## Audio Encoding Options Audio quality is equally important for most applications. VisioForge SDKs provide several audio encoder options for MKV output: ### Supported Audio Codecs - **AAC Encoders** - See [AAC encoder documentation](../../audio-encoders/aac/): - **VO AAC**: Default choice for non-Windows platforms - **AVENC AAC**: FFMPEG AAC implementation - **MF AAC**: Windows Media Foundation implementation (default on Windows) - **Alternative Audio Formats**: - **[MP3](../../audio-encoders/mp3/)**: Common format with wide compatibility - **[Vorbis](../../audio-encoders/vorbis/)**: Open source audio codec - **[OPUS](../../audio-encoders/opus/)**: Modern codec with excellent quality-to-size ratio ### Configuring Audio Encoding ``` // Platform-specific audio encoder selection #if NET_WINDOWS var aacSettings = new MFAACEncoderSettings { Bitrate = 192, SampleRate = 48000 }; mkvOutput.Audio = aacSettings; #else var aacSettings = new VOAACEncoderSettings { Bitrate = 192, SampleRate = 44100 }; mkvOutput.Audio = aacSettings; #endif // Or use OPUS for better quality at lower bitrates (Bitrate is in Kbit/s; channel count // is inferred from the input caps, so there is no Channels property on OPUSEncoderSettings) var opusSettings = new OPUSEncoderSettings { Bitrate = 128 }; mkvOutput.Audio = opusSettings; ``` ## Advanced MKV Configuration ### Custom Video and Audio Processing For applications that require special processing, you can integrate custom MediaBlock processors: ``` // Add a video processor for effects or transformations var textOverlayBlock = new TextOverlayBlock(new TextOverlaySettings("Hello world!")); mkvOutput.CustomVideoProcessor = textOverlayBlock; // Add audio processing var volumeBlock = new VolumeBlock() { Level = 1.2 }; // Boost volume by 20% mkvOutput.CustomAudioProcessor = volumeBlock; ``` ### Sink Settings Management Control output file properties through the sink settings: ``` // Change output filename mkvOutput.Sink.Filename = "processed_output.mkv"; // Get current filename string currentFile = mkvOutput.GetFilename(); // Update filename with timestamp string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss"); mkvOutput.SetFilename($"recording_{timestamp}.mkv"); ``` ## Integration with VisioForge SDK Components ### With Video Capture SDK ``` // Initialize capture core var captureCore = new VideoCaptureCoreX(); // Configure video and audio source // ... // Add MKV output to recording pipeline var mkvOutput = new MKVOutput("capture.mkv"); captureCore.Outputs_Add(mkvOutput, true); // Start recording await captureCore.StartAsync(); ``` ### With Video Edit SDK ``` // Initialize editing core var editCore = new VideoEditCoreX(); // Add input sources // ... // Configure MKV output with hardware acceleration var h265Encoder = new NVENCHEVCEncoderSettings { Bitrate = 10000 }; var mkvOutput = new MKVOutput("edited.mkv", h265Encoder); editCore.Output_Format = mkvOutput; // Process the file await editCore.StartAsync(); ``` ### With Media Blocks SDK `MKVOutputBlock` takes encoder **settings** (not encoder blocks) in its constructor and builds the encoder chain internally. Connect source audio/video directly to its input pads. ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Outputs; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Sinks; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.Types.X.VideoEncoders; using VisioForge.Core.Types; // Pipeline. var pipeline = new MediaBlocksPipeline(); // Source (any file — will be decoded into separate video and audio outputs). var sourceSettings = await UniversalSourceSettings.CreateAsync("input.mp4"); var sourceBlock = new UniversalSourceBlock(sourceSettings); // MKV sink — the constructor accepts encoder settings, not encoder blocks. var mkvSinkSettings = new MKVSinkSettings("processed.mkv"); var mkvOutput = new MKVOutputBlock( mkvSinkSettings, videoSettings: new OpenH264EncoderSettings(), audioSettings: new VOAACEncoderSettings()); // Wire source pads directly to the MKV output — it handles encoding internally. pipeline.Connect(sourceBlock.VideoOutput, mkvOutput.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(sourceBlock.AudioOutput, mkvOutput.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## Hardware Acceleration Benefits Hardware-accelerated encoding offers significant advantages for developers building real-time or batch processing applications: 1. **Reduced CPU Load**: Offloads encoding to dedicated hardware 2. **Faster Processing**: Up to 5-10x performance improvement 3. **Power Efficiency**: Lower energy consumption, important for mobile apps 4. **Higher Quality**: Some hardware encoders provide better quality-per-bitrate ## Best Practices for Developers When implementing MKV output in your applications, consider these recommendations: 1. **Always check hardware availability** before using GPU-accelerated encoders 2. **Select appropriate bitrates** based on content type and resolution 3. **Use platform-specific encoders** where possible for optimal performance 4. **Test on target platforms** to ensure compatibility 5. **Consider quality-size trade-offs** based on your application's needs ## Conclusion The MKV format provides developers with a flexible, robust container for video content in .NET applications. With VisioForge SDKs, you can leverage hardware acceleration, advanced encoding options, and custom processing to create high-performance video applications. By understanding the available encoders and configuration options, you can optimize your implementation for specific hardware platforms while maintaining cross-platform compatibility where needed. ---END OF PAGE--- ## MOV File Encoding and Output in .NET Video Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/mov/ **Description:** Generate MOV files in .NET with hardware-accelerated encoding, cross-platform support, and professional audio/video configuration options. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Encoding, Editing, MP4, MOV, H.264, H.265, AAC, MP3, C# **API:** MOVOutput, NVENCH264EncoderSettings, VOAACEncoderSettings, VideoCaptureCoreX, VideoEditCoreX # MOV File Output for .NET Video Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ## Introduction to MOV Output in VisioForge The MOV container format is widely used for video storage in professional environments and Apple ecosystems. VisioForge's .NET SDKs provide robust cross-platform support for generating MOV files with customizable encoding options. The `MOVOutput` class serves as the primary interface for configuring and generating these files across Windows, macOS, and Linux environments. MOV files created with VisioForge SDKs can leverage hardware acceleration through NVIDIA, Intel, and AMD encoders, making them ideal for performance-critical applications. This guide walks through the essential steps for implementing MOV output in .NET video applications. ### When to Use MOV Format MOV is particularly well-suited for: - Video editing workflows - Projects requiring Apple ecosystem compatibility - Professional video production pipelines - Applications needing metadata preservation - High-quality archival purposes ## Getting Started with MOV Output The `MOVOutput` class ([API reference](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MOVOutput.html)) provides the foundation for MOV file generation with VisioForge SDKs. It encapsulates the configuration of video and audio encoders, processing parameters, and sink settings. ### Basic Implementation Creating a MOV output requires minimal code: ``` // Create a MOV output targeting the specified filename var movOutput = new MOVOutput("output.mov"); ``` This simple implementation automatically: - Selects NVENC H264 encoder if available (falls back to OpenH264) - Chooses the appropriate AAC encoder for your platform (MF AAC on Windows, VO-AAC elsewhere) - Configures MOV container settings for broad compatibility ### Default Configuration Behavior The default configuration delivers balanced performance and compatibility across platforms. However, for specialized use cases, you'll likely need to customize encoder settings, which we'll cover in the following sections. ## Video Encoder Options for MOV Files MOV output supports a variety of video encoders to accommodate different performance, quality, and compatibility requirements. The choice of encoder significantly impacts processing speed, resource consumption, and output quality. ### Supported Video Encoders The MOV output supports these video encoders. For detailed configuration options, see the [H.264 encoder documentation](../../video-encoders/h264/) and [HEVC encoder documentation](../../video-encoders/hevc/): | Encoder | Technology | Platform | Best For | | --- | --- | --- | --- | | OpenH264 | Software | Cross-platform | Compatibility | | NVENC H264 | NVIDIA GPU | Cross-platform | Performance | | QSV H264 | Intel GPU | Cross-platform | Efficiency | | AMF H264 | AMD GPU | Cross-platform | Performance | | MF HEVC | Software | Windows only | Quality | | NVENC HEVC | NVIDIA GPU | Cross-platform | Quality/Performance | | QSV HEVC | Intel GPU | Cross-platform | Efficiency | | AMF H265 | AMD GPU | Cross-platform | Quality/Performance | ### Configuring Video Encoders Set a specific video encoder with code like this: ``` // For NVIDIA hardware-accelerated encoding. Bitrate is Kbit/s on X-namespace encoders. movOutput.Video = new NVENCH264EncoderSettings() { Bitrate = 5000, // Kbit/s — 5 Mbps }; // For software-based encoding with OpenH264. RateControl is OpenH264RCMode (not RateControlMode). movOutput.Video = new OpenH264EncoderSettings() { RateControl = OpenH264RCMode.Bitrate, Bitrate = 2500, // Kbit/s — 2.5 Mbps }; ``` ### Encoder Selection Strategy When implementing MOV output, consider these factors for encoder selection: 1. **Hardware availability** - Check if GPU acceleration is available 2. **Quality requirements** - HEVC offers better quality at lower bitrates 3. **Processing speed** - Hardware encoders provide significant speed advantages 4. **Platform compatibility** - Some encoders are Windows-specific A multi-tier approach often works best, checking for the fastest available encoder and falling back as needed: ``` // Try NVIDIA, then Intel, then software encoding if (NVENCH264EncoderSettings.IsAvailable()) { movOutput.Video = new NVENCH264EncoderSettings(); } else if (QSVH264EncoderSettings.IsAvailable()) { movOutput.Video = new QSVH264EncoderSettings(); } else { movOutput.Video = new OpenH264EncoderSettings(); } ``` ## Audio Encoder Options Audio quality is critical for most video applications. The SDK provides several audio encoders optimized for different use cases. ### Supported Audio Encoders For audio codec configuration details, see the [AAC encoder documentation](../../audio-encoders/aac/) and [MP3 encoder documentation](../../audio-encoders/mp3/): | Encoder | Type | Platform | Quality | Use Case | | --- | --- | --- | --- | --- | | MP3 | Software | Cross-platform | Good | Web distribution | | VO-AAC | Software | Cross-platform | Excellent | Professional use | | AVENC AAC | Software | Cross-platform | Very good | General purpose | | MF AAC | Hardware-accelerated | Windows only | Excellent | Windows apps | ### Audio Encoder Configuration Implementing audio encoding requires minimal code: ``` // MP3 configuration. Bitrate is Kbit/s (one of 8/16/.../320). MP3EncoderSettings exposes // only Bitrate and ForceMono — channel count follows the upstream source. movOutput.Audio = new MP3EncoderSettings() { Bitrate = 320, // Kbit/s — 320 kbps high quality ForceMono = false, // Leave false (default) to keep stereo from the source }; // Or AAC for better quality (Windows) movOutput.Audio = new MFAACEncoderSettings() { Bitrate = 192, // Kbit/s — 192 kbps }; // Cross-platform AAC implementation. Sample rate follows the source. movOutput.Audio = new VOAACEncoderSettings() { Bitrate = 192, }; ``` ### Platform-Specific Audio Considerations To handle platform differences elegantly, use conditional compilation: ``` // Select appropriate encoder based on platform #if NET_WINDOWS movOutput.Audio = new MFAACEncoderSettings(); #else movOutput.Audio = new VOAACEncoderSettings(); #endif ``` ## Advanced MOV Output Customization Beyond basic configuration, VisioForge SDKs enable powerful customization of MOV output through media processing blocks and sink settings. ### Custom Processing Pipeline For specialized video processing needs, the SDK provides media block integration: ``` // Add custom video processing movOutput.CustomVideoProcessor = new SomeMediaBlock(); // Add custom audio processing movOutput.CustomAudioProcessor = new SomeMediaBlock(); ``` ### MOV Sink Configuration Fine-tune the MOV container settings for specialized requirements: ``` // Configure sink settings movOutput.Sink.Filename = "new_output.mov"; ``` ### Dynamic Encoder Detection Your application can intelligently select encoders based on system capabilities: ``` // Get available video encoders var videoEncoders = movOutput.GetVideoEncoders(); // Get available audio encoders var audioEncoders = movOutput.GetAudioEncoders(); // Display available options to users or auto-select foreach (var encoder in videoEncoders) { Console.WriteLine($"Available encoder: {encoder.Name}"); } ``` ## Integration with VisioForge SDK Core Components The MOV output integrates seamlessly with the core SDK components for video capture, editing, and processing. ### Video Capture Integration Add MOV output to a capture workflow: ``` // Create and configure capture core var core = new VideoCaptureCoreX(); // Add capture devices // .. // Add configured MOV output core.Outputs_Add(movOutput, true); // Start capture await core.StartAsync(); ``` ### Video Edit SDK Integration Incorporate MOV output in video editing: ``` // Create edit core and configure project var core = new VideoEditCoreX(); // Add input file // ... // Set MOV as output format core.Output_Format = movOutput; // Process the video await core.StartAsync(); ``` ### Media Blocks SDK Implementation For direct media pipeline control: ``` // Create encoder blocks (not raw settings — the pipeline consumes blocks). var aacEncoder = new AACEncoderBlock(new VOAACEncoderSettings { Bitrate = 192 }); var h264Encoder = new H264EncoderBlock(new OpenH264EncoderSettings { Bitrate = 5000 }); // Configure the MOV sink — MOV and MP4 are different muxers (qtmux vs mp4mux), so use MOVSinkBlock. var movSinkSettings = new MOVSinkSettings("output.mov"); var movSink = new MOVSinkBlock(movSinkSettings); // Wire encoders into the sink via dynamic inputs. pipeline.Connect(h264Encoder.Output, movSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(aacEncoder.Output, movSink.CreateNewInput(MediaBlockPadMediaType.Audio)); ``` ## Platform Compatibility Notes While VisioForge's MOV implementation is cross-platform, some features are platform-specific: ### Windows-Specific Features - MF HEVC video encoder provides optimized encoding on Windows - MF AAC audio encoder offers hardware acceleration on compatible systems ### Cross-Platform Features - OpenH264, NVENC, QSV, and AMF encoders work across operating systems - VO-AAC and AVENC AAC provide consistent audio encoding everywhere ## Conclusion The MOV output capability in VisioForge .NET SDKs provides a powerful and flexible solution for creating high-quality video files. By leveraging hardware acceleration where available and falling back to optimized software implementations when needed, the SDK ensures excellent performance across platforms. For more information, refer to the [VisioForge API documentation](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MOVOutput.html) or explore other output formats in our documentation. ---END OF PAGE--- ## MP4 Video Output in C# .NET — H.264, HEVC, AAC Muxing **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/mp4/ **Description:** Encoder auto-selection with NVENC/QSV/AMF fallback. File splitting by size, duration, or timecode. Rolling buffer recording and stream muxing. VisioForge SDK. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Recording, Encoding, Editing, Webcam, MP4, H.264, H.265, MPEG-2, AAC, MP3, C#, NuGet **API:** MP4Output, MP4SplitSinkSettings, NVENCH264EncoderSettings, VOAACEncoderSettings, MP4OutputBlock # MP4 file output [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) MP4 (MPEG-4 Part 14), introduced in 2001, is a digital multimedia container format most commonly used to store video and audio. It also supports subtitles and images. MP4 is known for its high compression and compatibility across various devices and platforms, making it a popular choice for streaming and sharing. Capturing videos from a webcam and saving them to a file is a common requirement in many applications. One way to achieve this is by using a software development kit (SDK) like VisioForge Video Capture SDK .Net, which provides an easy-to-use API for capturing and processing videos in C#. To capture video in MP4 format using Video Capture SDK, you need to configure video output format using one of the classes for MP4 output. You can use several available software and hardware video encoders, including Intel QuickSync, Nvidia NVENC, and AMD/ATI APU. ## Cross-platform MP4 output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The [MP4Output](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MP4Output.html?q=MP4Output) class provides a flexible and powerful way to configure MP4 video output settings for video capture and editing operations. This guide will walk you through how to use the MP4Output class effectively, covering its key features and common usage patterns. MP4Output implements several important interfaces: - IVideoEditXBaseOutput - IVideoCaptureXBaseOutput - Media Block creation This makes it suitable for both video editing and capture scenarios while providing extensive control over video and audio processing. ### Basic Usage The simplest way to create an MP4Output instance is using the constructor with a filename: ``` var output = new MP4Output("output.mp4"); ``` This creates an MP4Output with default video and audio encoder settings. On Windows, it will use OpenH264 for video encoding and Media Foundation AAC for audio encoding by default. ### Video Encoder Configuration The MP4Output class supports multiple video encoders through its `Video` property. Here are the supported video encoders: **[H.264 Encoders](../../video-encoders/h264/)** - OpenH264EncoderSettings (Default, CPU) - AMFH264EncoderSettings (AMD) - NVENCH264EncoderSettings (NVIDIA) - QSVH264EncoderSettings (Intel Quick Sync) **[HEVC (H.265) Encoders](../../video-encoders/hevc/)** - MFHEVCEncoderSettings (Windows only) - AMFHEVCEncoderSettings (AMD) - NVENCHEVCEncoderSettings (NVIDIA) - QSVHEVCEncoderSettings (Intel Quick Sync) You can check the availability of specific encoders using the `IsAvailable` method: ``` if (NVENCH264EncoderSettings.IsAvailable()) { output.Video = new NVENCH264EncoderSettings(); } ``` Example of configuring a specific video encoder: ``` var output = new MP4Output("output.mp4"); output.Video = new NVENCH264EncoderSettings(); // Use NVIDIA encoder ``` ### Audio Encoder Configuration The `Audio` property allows you to specify the audio encoder. Supported audio encoders include: - [VOAACEncoderSettings](../../audio-encoders/aac/) - [AVENCAACEncoderSettings](../../audio-encoders/aac/) - [MFAACEncoderSettings](../../audio-encoders/aac/) (Windows only) - [MP3EncoderSettings](../../audio-encoders/mp3/) Example of setting a custom audio encoder: ``` var output = new MP4Output("output.mp4"); output.Audio = new MP3EncoderSettings(); ``` The MP4Output class automatically selects appropriate default encoders based on the platform. ### Sample code Add the MP4 output to the Video Capture SDK core instance: ``` var core = new VideoCaptureCoreX(); core.Outputs_Add(output, true); ``` Set the output format for the Video Edit SDK core instance: ``` var core = new VideoEditCoreX(); core.Output_Format = output; ``` Create a Media Blocks MP4 output instance: ``` var aac = new VOAACEncoderSettings(); var h264 = new OpenH264EncoderSettings(); var mp4SinkSettings = new MP4SinkSettings("output.mp4"); var mp4Output = new MP4OutputBlock(mp4SinkSettings, h264, aac); ``` ### File Splitting The [MP4SplitSinkSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Sinks.MP4SplitSinkSettings.html) class provides automatic file splitting capabilities, allowing you to split MP4 output into multiple files based on size, duration, or timecode. This class can be used with both `MP4OutputBlock` (which includes encoding) and `MP4SinkBlock` (muxing only). This is particularly useful for: - Long recording sessions that need to be broken into manageable file sizes - Creating time-based segments for easier archival or distribution - Managing disk space by limiting the number of files kept on storage - Implementing rolling buffer recording where only recent files are retained **Split by File Size** Split the output when a file reaches a specific size in bytes: ``` var h264 = new OpenH264EncoderSettings(); var aac = new VOAACEncoderSettings(); // Create split sink settings with filename pattern var splitSettings = new MP4SplitSinkSettings("recording_%05d.mp4"); // Split when file reaches 100 MB (104857600 bytes) splitSettings.SplitFileSize = 104857600; // Disable duration-based splitting (default is 1 minute) splitSettings.SplitDuration = TimeSpan.Zero; // Create output block var mp4Output = new MP4OutputBlock(splitSettings, h264, aac); ``` **Split by Duration** Split the output when a file reaches a specific duration: ``` var h264 = new OpenH264EncoderSettings(); var aac = new VOAACEncoderSettings(); // Create split sink settings with filename pattern var splitSettings = new MP4SplitSinkSettings("recording_%05d.mp4"); // Split every 5 minutes splitSettings.SplitDuration = TimeSpan.FromMinutes(5); // Create output block var mp4Output = new MP4OutputBlock(splitSettings, h264, aac); ``` **Limit Maximum Files** Control the maximum number of files to keep on disk. Once the limit is reached, the oldest files are automatically deleted: ``` var h264 = new OpenH264EncoderSettings(); var aac = new VOAACEncoderSettings(); // Create split sink settings var splitSettings = new MP4SplitSinkSettings("recording_%05d.mp4"); // Split every 10 minutes splitSettings.SplitDuration = TimeSpan.FromMinutes(10); // Keep only the last 6 files (1 hour of recordings) splitSettings.SplitMaxFiles = 6; // Create output block var mp4Output = new MP4OutputBlock(splitSettings, h264, aac); ``` **Split by Timecode** Split the output based on timecode difference between first and last frame: ``` var h264 = new OpenH264EncoderSettings(); var aac = new VOAACEncoderSettings(); // Create split sink settings var splitSettings = new MP4SplitSinkSettings("recording_%05d.mp4"); // Split when timecode difference reaches 1 hour // Format: "HH:MM:SS:FF" where FF is frames splitSettings.SplitMaxSizeTimecode = "01:00:00:00"; // Disable other splitting methods splitSettings.SplitFileSize = 0; splitSettings.SplitDuration = TimeSpan.Zero; // Create output block var mp4Output = new MP4OutputBlock(splitSettings, h264, aac); ``` **Combined Settings** You can combine splitting criteria. The file will split when any of the enabled criteria is met: ``` var h264 = new OpenH264EncoderSettings(); var aac = new VOAACEncoderSettings(); // Create split sink settings var splitSettings = new MP4SplitSinkSettings("recording_%05d.mp4"); // Split at 200 MB OR 10 minutes, whichever comes first splitSettings.SplitFileSize = 209715200; // 200 MB splitSettings.SplitDuration = TimeSpan.FromMinutes(10); // Keep only last 12 files splitSettings.SplitMaxFiles = 12; // Start numbering from 1 instead of 0 splitSettings.StartIndex = 1; // Create output block var mp4Output = new MP4OutputBlock(splitSettings, h264, aac); ``` **Using with MP4SinkBlock** For scenarios where you already have encoded streams and only need muxing (container creation), use `MP4SinkBlock` with `MP4SplitSinkSettings`: ``` // Create split sink settings var splitSettings = new MP4SplitSinkSettings("output_%05d.mp4"); splitSettings.SplitDuration = TimeSpan.FromMinutes(5); // Create MP4 sink block (muxing only, no encoding) var mp4Sink = new MP4SinkBlock(splitSettings); // Connect your pre-encoded streams to the sink block // (connection logic depends on your pipeline structure) ``` **Important Notes:** - The filename parameter must include a format specifier (like `%05d`) for the file index - Set `SplitFileSize` to 0 to disable size-based splitting (default is 0) - The default `SplitDuration` is 1 minute; set to `TimeSpan.Zero` to disable duration-based splitting - Set `SplitMaxFiles` to 0 to keep all files (default is 0, no deletion) - When combining criteria, splitting occurs when ANY criterion is met - The `StartIndex` property controls the initial file number (default is 0) ### Segment events When recording with `MP4SplitSinkSettings`, both `MP4OutputBlock` and `MP4SinkBlock` raise events around each segment file, so you can name the files yourself and be notified when a segment is finished: - `OnSegmentFileNameRequested` — raised just before a new segment file is created. Set the event's `FileName` to a custom path (for example, one that embeds the segment start time). Leave it unset to keep the default name built from the location pattern. - `OnSegmentCreated` — raised when a new segment file has been opened. - `OnSegmentClosed` — raised when a segment file has been finished and closed. This is the moment to rename the file (for example, to append its end time). The same events are available on `MPEGTSSinkBlock` — see the [MPEG-TS output](../mpegts/) page. [`SegmentSinkFileEventArgs`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Sinks.SegmentSinkFileEventArgs.html) (passed to `OnSegmentCreated` / `OnSegmentClosed`) properties: | Property | Type | Description | | --- | --- | --- | | `FileName` | string | Full path of the segment file. | | `FragmentIndex` | uint | Zero-based index of the segment. | | `RunningTime` | TimeSpan | Pipeline running time at the event (relative to the pipeline start, not wall-clock time). | | `FragmentOffset` | TimeSpan? | Running time of the segment start. Reported on `OnSegmentClosed` only; otherwise `null`. | | `FragmentDuration` | TimeSpan? | Duration of the segment. Reported on `OnSegmentClosed` only; otherwise `null`. | [`SegmentSinkFileNameEventArgs`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Sinks.SegmentSinkFileNameEventArgs.html) (passed to `OnSegmentFileNameRequested`) properties: | Property | Type | Description | | --- | --- | --- | | `FragmentIndex` | uint | Zero-based index of the segment about to be created. | | `FileName` | string | Full path to use for the new segment. Set it to override the default name; leave `null`/empty to use the location pattern. | The following example names each segment from its start time and appends the end time when the segment closes: ``` var splitSettings = new MP4SplitSinkSettings("recording_%05d.mp4") { SplitDuration = TimeSpan.FromMinutes(5) }; var mp4Sink = new MP4SinkBlock(splitSettings); // Build a custom name from the segment start time. mp4Sink.OnSegmentFileNameRequested += (sender, e) => { e.FileName = Path.Combine(@"c:\recordings", $"rec_{DateTime.Now:yyyyMMdd_HHmmss}_{e.FragmentIndex:D5}.mp4"); }; // Rename the finished file to append the end time. mp4Sink.OnSegmentClosed += (sender, e) => { var dir = Path.GetDirectoryName(e.FileName); var name = Path.GetFileNameWithoutExtension(e.FileName); var ext = Path.GetExtension(e.FileName); File.Move(e.FileName, Path.Combine(dir, $"{name}__end_{DateTime.Now:HHmmss}{ext}")); }; ``` Threading These events fire on a GStreamer streaming thread, so a handler must not touch UI controls directly — marshal to the UI thread (for example, `Dispatcher.Invoke` in WPF). The file rename inside `OnSegmentClosed` is plain file I/O and is safe to do there. ### Best Practices **Hardware Acceleration**: When possible, use hardware-accelerated encoders (NVENC, AMF, QSV) for better performance: ``` var output = new MP4Output("output.mp4"); if (NVENCH264EncoderSettings.IsAvailable()) { output.Video = new NVENCH264EncoderSettings(); } ``` **Encoder Selection**: Use the provided methods to enumerate available encoders: ``` var output = new MP4Output("output.mp4"); var availableVideoEncoders = output.GetVideoEncoders(); var availableAudioEncoders = output.GetAudioEncoders(); ``` ### Common Issues and Solutions 1. **File Access**: The MP4Output constructor attempts to verify write access by creating and immediately deleting a test file. Ensure the application has proper permissions to the output directory. 2. **Encoder Availability**: Hardware encoders might not be available on all systems. Always provide a fallback: ``` var output = new MP4Output("output.mp4"); if (!NVENCH264EncoderSettings.IsAvailable()) { output.Video = new OpenH264EncoderSettings(); // Fallback to software encoder } ``` 1. **Platform Compatibility**: Some encoders are platform-specific. Use conditional compilation or runtime checks when targeting multiple platforms: ``` #if NET_WINDOWS output.Audio = new MFAACEncoderSettings(); #else output.Audio = new MP3EncoderSettings(); #endif ``` ## Windows-only MP4 output [VideoCaptureCore](#) [VideoEditCore](#) `The same sample code can be used for Video Edit SDK .Net. Use the VideoEditCore class instead of VideoCaptureCore.` ### CPU encoder or Intel QuickSync GPU encoder Create an `MP4Output` object for MP4 output. ``` var mp4Output = new MP4Output(); ``` Set MP4 mode to `CPU_QSV`. ``` mp4Output.MP4Mode = MP4Mode.CPU_QSV; ``` Set video settings. ``` mp4Output.Video.Profile = H264Profile.ProfileMain; // H264 profile mp4Output.Video.Level = H264Level.Level4; // H264 level mp4Output.Video.Bitrate = 2000; // bitrate // optional parameters mp4Output.Video.MBEncoding = H264MBEncoding.CABAC; //CABAC / CAVLC mp4Output.Video.BitrateAuto = false; // true to use auto bitrate mp4Output.Video.RateControl = H264RateControl.VBR; // rate control - CBR or VBR ``` Set AAC audio settings. ``` mp4Output.Audio_AAC.Bitrate = 192; mp4Output.Audio_AAC.Version = AACVersion.MPEG4; // MPEG-4 / MPEG-2 mp4Output.Audio_AAC.Output = AACOutput.RAW; // RAW or ADTS mp4Output.Audio_AAC.Object = AACObject.Low; // type of AAC ``` ### Nvidia NVENC encoder Create the `MP4Output` object for MP4 output. ``` var mp4Output = new MP4Output(); ``` Set MP4 mode to `NVENC`. ``` mp4Output.MP4Mode = MP4Mode.NVENC; ``` Set the video settings. ``` mp4Output.Video_NVENC.Profile = NVENCVideoEncoderProfile.H264_Main; // H264 profile mp4Output.Video_NVENC.Level = NVENCEncoderLevel.H264_4; // H264 level mp4Output.Video_NVENC.Bitrate = 2000; // bitrate // optional parameters mp4Output.Video_NVENC.RateControl = NVENCRateControlMode.VBR; // rate control - CBR or VBR ``` Set the audio settings. ``` mp4Output.Audio_AAC.Bitrate = 192; mp4Output.Audio_AAC.Version = AACVersion.MPEG4; // MPEG-4 / MPEG-2 mp4Output.Audio_AAC.Output = AACOutput.RAW; // RAW or ADTS mp4Output.Audio_AAC.Object = AACObject.Low; // type of AAC ``` ### CPU/GPU encoders Using MP4 HW output, you can use hardware-accelerated encoders by Intel (QuickSync), Nvidia (NVENC), and AMD/ATI. Create `MP4HWOutput` object for MP4 HW output. ``` var mp4Output = new MP4HWOutput(); ``` Get available encoders. ``` var availableEncoders = VideoCaptureCore.HWEncodersAvailable(); // or var availableEncoders = VideoEditCore.HWEncodersAvailable(); ``` Depending on available encoders, select video codec. ``` mp4Output.Video.Codec = MFVideoEncoder.MS_H264; // Microsoft H264 mp4Output.Video.Profile = MFH264Profile.Main; // H264 profile mp4Output.Video.Level = MFH264Level.Level4; // H264 level mp4Output.Video.AvgBitrate = 2000; // bitrate // optional parameters mp4Output.Video.CABAC = true; // CABAC / CAVLC mp4Output.Video.RateControl = MFCommonRateControlMode.CBR; // rate control // many other parameters are available ``` Set audio settings. ``` mp4Output.Audio.Bitrate = 192; mp4Output.Audio.Version = AACVersion.MPEG4; // MPEG-4 / MPEG-2 mp4Output.Audio.Output = AACOutput.RAW; // RAW or ADTS mp4Output.Audio.Object = AACObject.Low; // type of AAC ``` Now, we can apply MP4 output settings to the core class (VideoCaptureCore or VideoEditCore) and start video capture or editing. ### Apply video capture settings Set MP4 format settings for output. ``` core.Output_Format = mp4Output; ``` Set a video capture mode (or video convert mode if you use Video Edit SDK). ``` core.Mode = VideoCaptureMode.VideoCapture; ``` Set a file name (ensure you have to write access rights). ``` core.Output_Filename = "output.mp4"; ``` Start video capture (convert) to a file. ``` await VideoCapture1.StartAsync(); ``` Finally, when we're done capturing the video, stop the pipeline and release the resources. `StopAsync()` flushes the muxer and finalises the output file — don't skip it or the MP4 will be unplayable: ``` await VideoCapture1.StopAsync(); VideoCapture1.Dispose(); ``` ### Required redists - Video Capture SDK redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x64/) - Video Edit SDK redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x64/) - MP4 redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.MP4.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.MP4.x64/) --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## MPEG-TS Video Output with File Splitting in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/mpegts/ **Description:** File splitting by duration, size, or timecode. Rolling buffer with max file limit. H.264/HEVC GPU encoding and Blu-ray M2TS mode. VisioForge SDK examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Recording, Encoding, Editing, MP4, TS, H.264, H.265, AAC, MP3, C#, NuGet **API:** MPEGTSOutput, NVENCH264EncoderSettings, MPEGTSSplitSinkSettings, MFBaseOutput, QSVH264EncoderSettings # MPEG-TS Output [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The MPEG-TS (Transport Stream) output module in VisioForge SDK functionality for creating MPEG transport stream files with various video and audio encoding options. This guide explains how to configure and use the `MPEGTSOutput` class effectively. ## Cross-platform MPEG-TS output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) To create a new MPEG-TS output, use the following constructor: ``` // Initialize with AAC audio (recommended) var output = new MPEGTSOutput("output.ts", useAAC: true); ``` You can also use MP3 audio instead of AAC: ``` // Initialize with MP3 audio instead of AAC var output = new MPEGTSOutput("output.ts", useAAC: false); ``` ### Video Encoding Options The [MPEGTSOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MPEGTSOutput.html) supports multiple video encoders through the `Video` property. Available encoders include: **[H.264 Encoders](../../video-encoders/h264/)** - OpenH264 (Software-based) - NVENC H.264 (NVIDIA GPU acceleration) - QSV H.264 (Intel Quick Sync) - AMF H.264 (AMD GPU acceleration) **[H.265/HEVC Encoders](../../video-encoders/hevc/)** - MF HEVC (Windows Media Foundation, Windows only) - NVENC HEVC (NVIDIA GPU acceleration) - QSV HEVC (Intel Quick Sync) - AMF H.265 (AMD GPU acceleration) Example of setting a specific video encoder: ``` // Check if NVIDIA encoder is available if (NVENCH264EncoderSettings.IsAvailable()) { output.Video = new NVENCH264EncoderSettings(); } else { // Fall back to OpenH264 output.Video = new OpenH264EncoderSettings(); } ``` ### Audio Encoding Options The following audio encoders are supported through the `Audio` property: **[AAC Encoders](../../audio-encoders/aac/)** - VO-AAC (Cross-platform) - AVENC AAC - MF AAC (Windows only) **[MP3 Encoder](../../audio-encoders/mp3/)**: - MP3EncoderSettings Example of setting an audio encoder: ``` // For Windows platforms output.Audio = new MFAACEncoderSettings(); ``` ``` // For cross-platform compatibility output.Audio = new VOAACEncoderSettings(); ``` ``` // Using MP3 instead of AAC output.Audio = new MP3EncoderSettings(); ``` ### File Management You can get or set the output filename after initialization: ``` // Get current filename string currentFile = output.GetFilename(); // Change output filename output.SetFilename("new_output.ts"); ``` ### File Splitting The `MPEGTSSplitSinkSettings` class enables automatic splitting of MPEG-TS output into multiple files based on size, duration, or timecode. This is useful for: - Creating segmented files for HLS streaming - Managing storage by limiting file sizes - Recording time-lapse videos - Implementing rolling buffer recording #### Configuration Options ``` using VisioForge.Core.Types.X.Sinks; // Create split settings with filename pattern // %05d will be replaced with segment number (00000, 00001, etc.) var splitSettings = new MPEGTSSplitSinkSettings("video_%05d.ts") { // Split by duration (e.g., every 5 minutes) SplitDuration = TimeSpan.FromMinutes(5), // Split by file size (e.g., 100 MB, 0 = disabled) SplitFileSize = 100 * 1024 * 1024, // Maximum number of files to keep (older files deleted, 0 = unlimited) SplitMaxFiles = 10, // Split by timecode difference (optional) SplitMaxSizeTimecode = "01:00:00:00", // 1 hour // Starting index for segment numbering StartIndex = 0, // M2TS mode (Blu-ray format with 192-byte packets) M2TSMode = false }; // Apply to output output.Sink = splitSettings; ``` #### Split Triggers Files will be split when any of these conditions are met: 1. **Duration-based**: `SplitDuration` - New file created after specified time 2. **Size-based**: `SplitFileSize` - New file created when size limit reached 3. **Timecode-based**: `SplitMaxSizeTimecode` - New file when timecode difference reached #### Filename Pattern The filename pattern uses printf-style formatting for segment numbers: ``` // Examples of filename patterns "recording_%02d.ts" // recording_00.ts, recording_01.ts, ... "stream_%05d.ts" // stream_00000.ts, stream_00001.ts, ... "output_%d.ts" // output_0.ts, output_1.ts, ... ``` #### Rolling Buffer Recording To implement a rolling buffer that keeps only the last N segments: ``` var settings = new MPEGTSSplitSinkSettings("buffer_%03d.ts") { SplitDuration = TimeSpan.FromMinutes(1), // 1 minute segments SplitMaxFiles = 60 // Keep last 60 minutes }; ``` #### Usage Example ``` // Complete example with split settings var output = new MPEGTSOutput("video_%05d.ts", useAAC: true); // Configure split settings output.Sink = new MPEGTSSplitSinkSettings("video_%05d.ts") { SplitDuration = TimeSpan.FromMinutes(5), SplitMaxFiles = 12, // Keep last hour (12 x 5 minutes) M2TSMode = false }; // Configure encoders if (NVENCH264EncoderSettings.IsAvailable()) { output.Video = new NVENCH264EncoderSettings(); } // Use with VideoCaptureCoreX or MediaBlocksPipeline // The filename pattern will be used automatically ``` ### Segment events When recording with `MPEGTSSplitSinkSettings`, the Media Blocks `MPEGTSSinkBlock` raises events around each segment file, so you can name the files yourself and be notified when a segment is finished: - `OnSegmentFileNameRequested` — raised just before a new segment file is created. Set the event's `FileName` to a custom path (for example, one that embeds the segment start time). Leave it unset to keep the default name built from the location pattern. - `OnSegmentCreated` — raised when a new segment file has been opened. - `OnSegmentClosed` — raised when a segment file has been finished and closed — the moment to rename the file (for example, to append its end time). ``` var splitSettings = new MPEGTSSplitSinkSettings("video_%05d.ts") { SplitDuration = TimeSpan.FromMinutes(5) }; var tsSink = new MPEGTSSinkBlock(splitSettings); tsSink.OnSegmentClosed += (sender, e) => { // e.FileName, e.FragmentIndex and e.FragmentDuration are available here. Console.WriteLine($"Segment {e.FragmentIndex} finished: {e.FileName}"); }; ``` `OnSegmentCreated` / `OnSegmentClosed` receive a [`SegmentSinkFileEventArgs`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Sinks.SegmentSinkFileEventArgs.html) carrying `FileName` (string), `FragmentIndex` (uint), `RunningTime` (TimeSpan), and — on `OnSegmentClosed` only — `FragmentOffset` and `FragmentDuration` (TimeSpan?). `OnSegmentFileNameRequested` receives a [`SegmentSinkFileNameEventArgs`](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Sinks.SegmentSinkFileNameEventArgs.html) whose settable `FileName` overrides the segment name. The same events are available on `MP4SinkBlock` / `MP4OutputBlock` — see the [MP4 output](../mp4/) page for a full custom-naming and rename-on-close example. Threading These events fire on a GStreamer streaming thread, so a handler must not touch UI controls directly — marshal to the UI thread. The file rename inside `OnSegmentClosed` is plain file I/O and is safe to do there. ### Advanced Features #### Custom Processing The MPEGTSOutput supports custom video and audio processing through MediaBlocks: ``` // Add custom video processing output.CustomVideoProcessor = new YourCustomVideoProcessor(); // Add custom audio processing output.CustomAudioProcessor = new YourCustomAudioProcessor(); ``` #### Sink Settings The output uses `MPEGTSSinkSettings` (or the derived `MPEGTSSplitSinkSettings` for segmented output) for configuration: ``` // Access sink settings output.Sink.Filename = "modified_output.ts"; ``` ### Platform Considerations - Some encoders (MF AAC, MF HEVC) are only available on Windows platforms - Cross-platform applications should use platform-agnostic encoders like VO-AAC for audio ### Best Practices 1. **Hardware Acceleration**: When available, prefer hardware-accelerated encoders (NVENC, QSV, AMF) over software encoders for better performance. 2. **Audio Codec Selection**: Use AAC for better compatibility and quality unless you have specific requirements for MP3. 3. **Error Handling**: Always check for encoder availability before using hardware-accelerated options: ``` if (NVENCH264EncoderSettings.IsAvailable()) { // Use NVIDIA encoder } else if (QSVH264EncoderSettings.IsAvailable()) { // Fall back to Intel Quick Sync } else { // Fall back to software encoding } ``` **Cross-Platform Compatibility**: For cross-platform applications, ensure you're using encoders available on all target platforms or implement appropriate fallbacks. ### Implementation Example Here's a complete example showing how to create and configure an MPEG-TS output: ``` var output = new MPEGTSOutput("output.ts", useAAC: true); // Configure video encoder if (NVENCH264EncoderSettings.IsAvailable()) { output.Video = new NVENCH264EncoderSettings(); } else if (QSVH264EncoderSettings.IsAvailable()) { output.Video = new QSVH264EncoderSettings(); } else { output.Video = new OpenH264EncoderSettings(); } // Configure audio encoder based on platform #if NET_WINDOWS output.Audio = new MFAACEncoderSettings(); #else output.Audio = new VOAACEncoderSettings(); #endif // Optional: Add custom processing output.CustomVideoProcessor = new YourCustomVideoProcessor(); output.CustomAudioProcessor = new YourCustomAudioProcessor(); ``` ## Windows-only MPEG-TS output [VideoCaptureCore](#) The `MPEGTSOutput` class provides configuration settings for MPEG Transport Stream (MPEG-TS) output in the VisioForge video processing framework. This class inherits from `MFBaseOutput` and implements the `IVideoCaptureBaseOutput` interface, so the classic Windows engine exposes it through `VideoCaptureCore` only — classic `VideoEditCore` has no MPEG-TS output path (use `VideoEditCoreX` for cross-platform MPEG-TS instead). ### Class Hierarchy ``` MFBaseOutput └── MPEGTSOutput ``` ### Inherited Video Settings The [MPEGTSOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.MPEGTSOutput.html) class inherits video encoding capabilities from MFBaseOutput, which includes: **Video Encoding Configuration**: Through the `Video` property, supporting: - Multiple codec options (H.264/H.265) with hardware acceleration support - Bitrate control (CBR/VBR) - Quality settings - Frame type and GOP structure configuration - Interlacing options - Resolution and aspect ratio controls ### Inherited Audio Settings Audio configuration is handled through the inherited `Audio` property of type M4AOutput, which includes: AAC audio encoding with configurable: - Version (default: MPEG-4) - Object type (default: AAC-LC) - Bitrate (default: 128 kbps) - Output format (default: RAW) ### Usage #### Basic Implementation ``` // Create VideoCaptureCore instance var core = new VideoCaptureCore(); // Set output filename core.Output_Filename = "output.ts"; // Create MPEG-TS output var mpegtsOutput = new MPEGTSOutput(); // Configure video settings mpegtsOutput.Video.Codec = MFVideoEncoder.MS_H264; mpegtsOutput.Video.AvgBitrate = 2000; // 2 Mbps mpegtsOutput.Video.RateControl = MFCommonRateControlMode.CBR; // Configure audio settings mpegtsOutput.Audio.Bitrate = 128; // 128 kbps mpegtsOutput.Audio.Version = AACVersion.MPEG4; core.Output_Format = mpegtsOutput; ``` #### Serialization Support The class provides built-in JSON serialization support for saving and loading configurations: ``` // Save configuration string jsonConfig = mpegtsOutput.Save(); // Load configuration MPEGTSOutput loadedConfig = MPEGTSOutput.Load(jsonConfig); ``` ### Default Configuration The `MPEGTSOutput` class initializes with these default settings: #### Video Defaults (inherited from MFBaseOutput) - Average Bitrate: 2000 kbps - Codec: Microsoft H.264 - Profile: Main - Level: 4.2 - Rate Control: CBR - Quality vs Speed: 85 - Maximum Reference Frames: 2 - MaxKeyFrameSpacing (GOP size): 125 frames - B-Picture Count: 0 - Low Latency Mode: Disabled - CABAC: Disabled - Interlace Mode: Progressive #### Audio Defaults - Bitrate: 128 kbps - AAC Version: MPEG-4 - AAC Object Type: Low Complexity (LC) - Output Format: RAW ### Best Practices 1. **Bitrate Configuration**: 2. For streaming applications, ensure the combined video and audio bitrates are within your target bandwidth 3. Consider using VBR for storage scenarios and CBR for streaming 4. **Hardware Acceleration**: 5. When available, use hardware-accelerated encoders (QSV, NVENC, AMD) for better performance 6. Fall back to MS\_H264/MS\_H265 when hardware acceleration is unavailable 7. **Quality Optimization**: 8. For higher quality at the cost of performance, increase the `QualityVsSpeed` value 9. Enable CABAC for better compression efficiency in non-low-latency scenarios 10. Adjust `MaxKeyFrameSpacing` based on your specific use case (lower values for better seeking, higher values for better compression) ### Technical Notes 1. **MPEG-TS Characteristics**: 2. Suitable for streaming and broadcasting applications 3. Provides error resilience through packet-based structure 4. Supports multiple programs and elementary streams 5. **Performance Considerations**: 6. Low latency mode trades quality for reduced encoding delay 7. B-frames improve compression but increase latency 8. Hardware acceleration can significantly reduce CPU usage ### Required redists - Video Capture SDK redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoCapture.x64/) - Video Edit SDK redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.VideoEdit.x64/) - MP4 redist [x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.MP4.x86/) [x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.MP4.x64/) --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Professional MXF Integration for .NET Applications **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/mxf/ **Description:** Generate broadcast MXF files in .NET with hardware acceleration, codec optimization, and professional workflows for broadcast production. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Encoding, Editing, MXF, H.264, H.265, AAC, MP3, C# **API:** QSVH264EncoderSettings, MXFOutput, NVENCH264EncoderSettings, AMFH264EncoderSettings, MFAACEncoderSettings # MXF Output in VisioForge .NET SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) Material Exchange Format (MXF) is an industry-standard container format designed for professional video applications. It's widely adopted in broadcast environments, post-production workflows, and archival systems. VisioForge SDKs provide robust cross-platform MXF output capabilities that allow developers to integrate this professional format into their applications. ## Understanding MXF Format MXF serves as a wrapper that can contain various types of video and audio data along with metadata. The format was designed to address interoperability issues in professional video workflows: - **Industry Standard**: Adopted by major broadcasters worldwide - **Professional Metadata**: Supports extensive technical and descriptive metadata - **Versatile Container**: Compatible with numerous audio and video codecs - **Cross-Platform**: Supported across Windows, macOS, and Linux ## Getting Started with MXF Output Two code paths cover 99% of uses: - **`MXFOutput`** (class in `VisioForge.Core.Types.X.Output`) is a settings object consumed by `VideoCaptureCoreX.Outputs_Add(...)` or set as `VideoEditCoreX.Output_Format`. - **`MXFSinkBlock`** + **`MXFSinkSettings`** are the Media Blocks path when you drive the pipeline by hand. ### Basic implementation Here's the foundational code to create an MXF output: ``` var mxfOutput = new MXFOutput( filename: "output.mxf", videoStreamType: MXFVideoStreamType.H264, audioStreamType: MXFAudioStreamType.MPEG ); ``` This creates a valid MXF output with default encoding settings. For professional applications, you'll typically want to customize the encoding parameters. ## Video Encoding Options for MXF The quality and compatibility of your MXF output largely depends on your choice of video encoder. VisioForge SDKs support multiple encoder options to balance performance, quality, and compatibility. For detailed configuration options, see the [H.264 encoder documentation](../../video-encoders/h264/) and [HEVC encoder documentation](../../video-encoders/hevc/). > Video encoder `Bitrate` properties on the X namespace are in **Kbps** (so 8000 = 8 Mbps). Don't pass raw bits per second. ### Hardware-Accelerated Encoders For optimal performance in real-time applications, hardware-accelerated encoders are recommended: #### NVIDIA NVENC Encoders ``` // Check availability first if (NVENCH264EncoderSettings.IsAvailable()) { var nvencSettings = new NVENCH264EncoderSettings { Bitrate = 8000, // 8 Mbps (Kbps) }; mxfOutput.Video = nvencSettings; } ``` #### Intel Quick Sync Video (QSV) Encoders ``` if (QSVH264EncoderSettings.IsAvailable()) { var qsvSettings = new QSVH264EncoderSettings { Bitrate = 8000, }; mxfOutput.Video = qsvSettings; } ``` #### AMD Advanced Media Framework (AMF) Encoders ``` if (AMFH264EncoderSettings.IsAvailable()) { var amfSettings = new AMFH264EncoderSettings { Bitrate = 8000, }; mxfOutput.Video = amfSettings; } ``` ### Software-Based Encoders When hardware acceleration isn't available, software encoders provide reliable alternatives: #### OpenH264 Encoder ``` var openH264Settings = new OpenH264EncoderSettings { Bitrate = 8000, }; mxfOutput.Video = openH264Settings; ``` ### High-Efficiency Video Coding (HEVC/H.265) For applications requiring higher compression efficiency: ``` // NVIDIA HEVC encoder if (NVENCHEVCEncoderSettings.IsAvailable()) { var nvencHevcSettings = new NVENCHEVCEncoderSettings { Bitrate = 5000, // Lower bitrate possible with HEVC }; mxfOutput.Video = nvencHevcSettings; } ``` ## Audio Encoding for MXF Files While video often gets the most attention, proper audio encoding is crucial for professional MXF outputs. VisioForge SDKs offer multiple audio encoder options. For detailed configuration options, see the [AAC encoder documentation](../../audio-encoders/aac/) and [MP3 encoder documentation](../../audio-encoders/mp3/). > Audio encoder `Bitrate` on the X namespace is also in **Kbps** (so 192 = 192 kbps). `MFAACEncoderSettings` and `VOAACEncoderSettings` do expose a `SampleRate` property (default 48000); only `MP3EncoderSettings` has no sample-rate setter and follows the upstream source's audio format. Channel layout on all three follows the upstream audio unless reshaped upstream (e.g., via `AudioResamplerBlock`). ### AAC Encoders AAC is the preferred codec for most professional applications: ``` // Media Foundation AAC (Windows-only) #if NET_WINDOWS var mfAacSettings = new MFAACEncoderSettings { Bitrate = 192, // kbps }; mxfOutput.Audio = mfAacSettings; #else // Cross-platform AAC alternative var voAacSettings = new VOAACEncoderSettings { Bitrate = 192, }; mxfOutput.Audio = voAacSettings; #endif ``` ### MP3 Encoder For maximum compatibility: ``` var mp3Settings = new MP3EncoderSettings { Bitrate = 320, // Kbps — must be one of 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 ForceMono = false // Default; set true to downmix to mono }; mxfOutput.Audio = mp3Settings; ``` ## Advanced MXF Configuration ### Custom Processing Pipelines One of the powerful features of VisioForge SDKs is the ability to add custom processing to your MXF output chain: ``` // Add custom video processing mxfOutput.CustomVideoProcessor = yourVideoProcessingBlock; // Add custom audio processing mxfOutput.CustomAudioProcessor = yourAudioProcessingBlock; ``` ### Sink Configuration Fine-tune your MXF output with sink settings: ``` // Access sink settings (MXFSinkSettings) mxfOutput.Sink.Filename = "new_output.mxf"; ``` ## Cross-Platform Considerations Building applications that work across different platforms requires careful planning: ``` // Platform-specific encoder selection var mxfOutput = new MXFOutput( filename: "output.mxf", videoStreamType: MXFVideoStreamType.H264, audioStreamType: MXFAudioStreamType.MPEG ); #if NET_WINDOWS if (QSVH264EncoderSettings.IsAvailable()) { mxfOutput.Video = new QSVH264EncoderSettings { Bitrate = 8000 }; mxfOutput.Audio = new MFAACEncoderSettings { Bitrate = 192 }; } #elif NET_MACOS mxfOutput.Video = new OpenH264EncoderSettings { Bitrate = 8000 }; mxfOutput.Audio = new VOAACEncoderSettings { Bitrate = 192 }; #else mxfOutput.Video = new OpenH264EncoderSettings { Bitrate = 8000 }; mxfOutput.Audio = new MP3EncoderSettings { Bitrate = 320 }; #endif ``` ## Error Handling and Validation Robust MXF implementations require proper error handling: ``` try { // Create MXF output var mxfOutput = new MXFOutput( filename: Path.Combine(outputDirectory, "output.mxf"), videoStreamType: MXFVideoStreamType.H264, audioStreamType: MXFAudioStreamType.MPEG ); // Validate encoder availability if (!OpenH264EncoderSettings.IsAvailable()) { throw new ApplicationException("No compatible H.264 encoder found"); } // Validate output directory var directoryInfo = new DirectoryInfo(Path.GetDirectoryName(mxfOutput.Sink.Filename)); if (!directoryInfo.Exists) { Directory.CreateDirectory(directoryInfo.FullName); } // Attach MXFOutput as a VideoCaptureCoreX output videoCapture.Outputs_Add(mxfOutput, autostart: true); await videoCapture.StartAsync(); } catch (Exception ex) { logger.LogError($"MXF output error: {ex.Message}"); // Implement fallback strategy } ``` ## Performance Optimization For optimal MXF output performance: 1. **Prioritize Hardware Acceleration**: Always check for and use hardware encoders first 2. **Buffer Management**: Adjust buffer sizes based on system capabilities 3. **Parallel Processing**: Utilize multi-threading where appropriate 4. **Preset Selection**: Choose encoder presets based on quality vs. speed requirements ## Complete Implementation Example — VideoCaptureCoreX Here's a full example demonstrating MXF implementation with fallback options: ``` // Create MXF output with specific stream types var mxfOutput = new MXFOutput( filename: "output.mxf", videoStreamType: MXFVideoStreamType.H264, audioStreamType: MXFAudioStreamType.MPEG ); // Configure video encoder with prioritized fallback chain (bitrate in Kbps) if (NVENCH264EncoderSettings.IsAvailable()) { mxfOutput.Video = new NVENCH264EncoderSettings { Bitrate = 8000 }; } else if (QSVH264EncoderSettings.IsAvailable()) { mxfOutput.Video = new QSVH264EncoderSettings { Bitrate = 8000 }; } else if (AMFH264EncoderSettings.IsAvailable()) { mxfOutput.Video = new AMFH264EncoderSettings { Bitrate = 8000 }; } else { mxfOutput.Video = new OpenH264EncoderSettings { Bitrate = 8000 }; } // Configure platform-optimized audio (Kbps) #if NET_WINDOWS mxfOutput.Audio = new MFAACEncoderSettings { Bitrate = 192 }; #else mxfOutput.Audio = new VOAACEncoderSettings { Bitrate = 192 }; #endif // Attach to VideoCaptureCoreX (or VideoEditCoreX: videoEdit.Output_Format = mxfOutput;) videoCapture.Outputs_Add(mxfOutput, autostart: true); await videoCapture.StartAsync(); ``` ## Complete Implementation Example — MediaBlocksPipeline When you're driving the pipeline by hand, use `MXFSinkBlock` + `MXFSinkSettings` instead of `MXFOutput`: ``` var pipeline = new MediaBlocksPipeline(); var mxfSettings = new MXFSinkSettings("output.mxf", videoStreamType: MXFVideoStreamType.H264, audioStreamType: MXFAudioStreamType.MPEG); var mxfSink = new MXFSinkBlock(mxfSettings); // videoEncoder / audioEncoder are existing H264EncoderBlock / AACEncoderBlock instances pipeline.Connect(videoEncoder.Output, mxfSink.CreateNewInput(MediaBlockPadMediaType.Video)); pipeline.Connect(audioEncoder.Output, mxfSink.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` By following this guide, you can implement professional-grade MXF output in your applications using VisioForge .NET SDKs, ensuring compatibility with broadcast workflows and post-production systems. ---END OF PAGE--- ## WebM Video Output with VP8, VP9, AV1 Codecs in .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/webm/ **Description:** Create WebM videos in .NET with VP8, VP9, and AV1 codecs for efficient web-ready video streaming and HTML5 content delivery. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Recording, Encoding, Editing, WebM, VP8, VP9, AV1, Opus, Vorbis, C#, NuGet **API:** WebMOutput, VideoCaptureCore, VideoEditCore, VideoCaptureCoreX, VideoEditCoreX # WebM Video Output in VisioForge .NET SDKs [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## What is WebM? WebM is an open-source, royalty-free media file format optimized for web delivery. Developed to provide efficient video streaming with minimal processing requirements, WebM has become a standard for HTML5 video content. The format supports modern codecs including VP8 and VP9 for video compression, along with Vorbis and Opus for audio encoding. The key advantages of WebM include: - **Web-optimized performance** with fast loading times - **Broad browser support** across major platforms - **High-quality video** at smaller file sizes - **Open-source licensing** without royalty costs - **Efficient streaming** capabilities for media applications ## Windows Implementation [VideoCaptureCore](#) [VideoEditCore](#) On Windows platforms, VisioForge's implementation leverages the [WebMOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.WebMOutput.html) class from the `VisioForge.Core.Types.X.Output` namespace. ### Basic Configuration To quickly implement WebM output in your Windows application: ``` using VisioForge.Core.Types.Output; // Initialize WebM output settings var webmOutput = new WebMOutput(); // Configure essential parameters webmOutput.Video_Mode = VP8QualityMode.Realtime; webmOutput.Video_EndUsage = VP8EndUsageMode.VBR; webmOutput.Video_Encoder = WebMVideoEncoder.VP8; webmOutput.Video_Bitrate = 2000; webmOutput.Audio_Quality = 80; // Apply to your core instance var core = new VideoCaptureCore(); // or VideoEditCore core.Output_Format = webmOutput; core.Output_Filename = "output.webm"; ``` ### Video Quality Settings Fine-tuning your WebM video quality involves balancing several parameters: ``` var webmOutput = new WebMOutput(); // Quality parameters webmOutput.Video_MinQuantizer = 4; // Lower values = higher quality (range: 0-63) webmOutput.Video_MaxQuantizer = 48; // Upper quality bound (range: 0-63) webmOutput.Video_Bitrate = 2000; // Target bitrate in kbps // Encode with multiple threads for better performance webmOutput.Video_ThreadCount = 4; // Adjust based on available CPU cores ``` ### Keyframe Control Proper keyframe configuration is crucial for efficient streaming and seeking: ``` // Keyframe settings webmOutput.Video_Keyframe_MinInterval = 30; // Minimum frames between keyframes webmOutput.Video_Keyframe_MaxInterval = 300; // Maximum frames between keyframes webmOutput.Video_Keyframe_Mode = VP8KeyframeMode.Auto; ``` ### Performance Optimization Balance encoding speed and quality with these parameters: ``` // Performance settings webmOutput.Video_CPUUsed = 0; // Range: -16 to 16 (higher = faster encoding, lower quality) webmOutput.Video_LagInFrames = 25; // Frame look-ahead buffer (higher = better quality) webmOutput.Video_ErrorResilient = true; // Enable for streaming applications ``` ### Buffer Management For streaming applications, proper buffer configuration improves playback stability: ``` // Buffer settings webmOutput.Video_Decoder_Buffer_Size = 6000; // Buffer size in milliseconds webmOutput.Video_Decoder_Buffer_InitialSize = 4000; // Initial buffer fill level webmOutput.Video_Decoder_Buffer_OptimalSize = 5000; // Target buffer level // Rate control fine-tuning webmOutput.Video_UndershootPct = 50; // Allows bitrate to drop below target webmOutput.Video_OvershootPct = 50; // Allows bitrate to exceed target temporarily ``` ## Cross-Platform Implementation [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) For cross-platform applications, VisioForge provides the [WebMOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.WebMOutput.html) class from the `VisioForge.Core.Types.X.Output` namespace, offering enhanced codec flexibility. ### Basic Setup ``` using VisioForge.Core.Types.X.Output; using VisioForge.Core.Types.X.VideoEncoders; using VisioForge.Core.Types.X.AudioEncoders; // Create WebM output var webmOutput = new WebMOutput("output.webm"); // Configure video encoder (VP8) webmOutput.Video = new VP8EncoderSettings(); // Configure audio encoder (Vorbis) webmOutput.Audio = new VorbisEncoderSettings(); ``` ### Integration with Video Capture SDK ``` // Add WebM output to Video Capture SDK var core = new VideoCaptureCoreX(); core.Outputs_Add(webmOutput, true); ``` ### Integration with Video Edit SDK ``` // Set WebM as output format for Video Edit SDK var core = new VideoEditCoreX(); core.Output_Format = webmOutput; ``` ### Integration with Media Blocks SDK ``` // Create encoders var vorbis = new VorbisEncoderSettings(); var vp9 = new VP9EncoderSettings(); // Configure WebM output block var webmSettings = new WebMSinkSettings("output.webm"); var webmOutput = new WebMOutputBlock(webmSettings, vp9, vorbis); // Add to your pipeline // pipeline.AddBlock(webmOutput); ``` ## Codec Selection Guide ### Video Codecs VisioForge SDKs support multiple video codecs for WebM: 1. **VP8** 2. Faster encoding speed 3. Lower computational requirements 4. Wider compatibility with older browsers 5. Good quality for standard video 6. **VP9** 7. Better compression efficiency (30-50% smaller files vs. VP8) 8. Higher quality at the same bitrate 9. Slower encoding performance 10. Ideal for high-resolution content 11. **AV1** 12. Next-generation codec with superior compression 13. Highest quality per bit 14. Significantly higher encoding complexity 15. Best for situations where encoding time isn't critical For codec-specific settings, refer to our dedicated documentation pages: - [VP8/VP9 Configuration](../../video-encoders/vp8-vp9/) - [AV1 Configuration](../../video-encoders/av1/) ### Audio Codecs Two primary audio codec options are available: 1. **Vorbis** 2. Established codec with good overall quality 3. Compatible with all WebM-supporting browsers 4. Default choice for most applications 5. **Opus** 6. Superior audio quality, especially at low bitrates 7. Better for voice content and music 8. Lower latency for streaming applications 9. More efficient for bandwidth-constrained scenarios For detailed audio settings, see: - [Vorbis Configuration](../../audio-encoders/vorbis/) - [Opus Configuration](../../audio-encoders/opus/) ## Optimization Strategies ### For Video Quality To achieve the highest possible video quality: - Use VP9 or AV1 for video encoding - Set lower quantizer values (higher quality) - Increase `LagInFrames` for better lookahead analysis - Use 2-pass encoding for offline video processing - Set higher bitrates for complex visual content ``` // Quality-focused VP9 configuration (properties live on the shared VPXEncoderSettings base). var vp9 = new VP9EncoderSettings { TargetBitrate = 3000, // kbps — higher bitrate for better quality CPUUsed = 0, // 0 = slowest/highest-quality; raise toward 5 for speed Deadline = 0, // 0 = best, 1 = realtime (microseconds per frame) RateControl = VPXRateControl.VBR, // variable bitrate for quality work MultipassMode = VPXMultipassMode.OnePass // switch to FirstPass/LastPass for 2-pass workflows }; ``` ### For Real-time Applications When low latency is critical: - Choose VP8 for faster encoding - Use single-pass encoding - Set `CPUUsed` to higher values - Use smaller frame lookahead buffers - Configure shorter keyframe intervals ``` // Low-latency VP8 configuration var vp8 = new VP8EncoderSettings { RateControl = VPXRateControl.CBR, // constant bitrate for predictable streaming CPUUsed = 8, // 0..16 on VP8 — higher = faster/worse quality Deadline = 1, // 1 = realtime (microseconds per frame; 0 = best quality) ErrorResilient = VPXErrorResilientFlags.Default // enable resilience bitflags for packet-loss recovery }; ``` ### For File Size Efficiency To minimize storage requirements: - Use VP9 or AV1 for maximum compression - Enable two-pass encoding - Set appropriate target bitrates - Use Variable Bit Rate (VBR) encoding - Avoid unnecessary keyframes ``` // Storage-optimized configuration using the AOM reference AV1 encoder. // Other AV1 variants: SVTAV1EncoderSettings, NVENCAV1EncoderSettings, AMFAV1EncoderSettings, QSVAV1EncoderSettings. var av1 = new AOMAV1EncoderSettings { RateControl = AOMAV1EncoderEndUsageMode.VBR, // variable bitrate for efficiency CPUUsed = 2 // balance between speed and compression (0 = slowest/best) }; ``` ## Dependencies To implement WebM output, add the appropriate NuGet packages to your project: - For x86 platforms: [VisioForge.DotNet.Core.Redist.WebM.x86](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.WebM.x86) - For x64 platforms: [VisioForge.DotNet.Core.Redist.WebM.x64](https://www.nuget.org/packages/VisioForge.DotNet.Core.Redist.WebM.x64) ## Learning Resources For additional implementation examples and more advanced scenarios, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) containing sample code for all VisioForge SDKs. ---END OF PAGE--- ## WMV Encoding in .NET — Windows Media Video Output Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/output-formats/wmv/ **Description:** Implement Windows Media Video encoding in .NET with audio/video configuration, streaming options, and cross-platform profile management. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, GStreamer, Capture, Streaming, Encoding, Editing, Screen Capture, MP4, WMV, WMA, C# **API:** WMVOutput, WMVMode, WMVStreamMode, VideoCaptureCore # Windows Media Video encoders [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) This documentation covers the Windows Media Video (WMV) encoding capabilities available in VisioForge, including both Windows-specific and cross-platform solutions. ## Windows-only output [VideoCaptureCore](#) [VideoEditCore](#) The [WMVOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.WMVOutput.html) class provides comprehensive Windows Media encoding capabilities for both audio and video on Windows platforms. ### Quick Start Guide #### Simple Video Capture with Default Settings ``` using VisioForge.Core.VideoCapture; using VisioForge.Core.Types.Output; var captureCore = new VideoCaptureCore(); // Use default WMV settings (Internal Profile mode) captureCore.Output_Format = new WMVOutput(); captureCore.Output_Filename = "output.wmv"; await captureCore.StartAsync(); ``` #### Simple Video Editing with Default Settings ``` using VisioForge.Core.VideoEdit; using VisioForge.Core.Types.Output; var editCore = new VideoEditCore(); // Use default WMV settings editCore.Output_Format = new WMVOutput(); editCore.Output_Filename = "edited_output.wmv"; // Add input files and configure editing... await editCore.StartAsync(); ``` #### Custom Settings Example ``` using VisioForge.Core.VideoCapture; using VisioForge.Core.Types.Output; var wmvOutput = new WMVOutput { Mode = WMVMode.CustomSettings, // Video configuration Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.VBRQuality, Custom_Video_Quality = 90, Custom_Video_Width = 1280, Custom_Video_Height = 720, Custom_Video_FrameRate = 30.0, // Audio configuration Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 90, Custom_Audio_Format = "48kHz 16bit Stereo" }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = wmvOutput; captureCore.Output_Filename = "custom_output.wmv"; await captureCore.StartAsync(); ``` ### Audio Encoding Features The `WMVOutput` class offers several audio-specific configuration options: - Custom audio codec selection - Audio format customization - Multiple stream modes - Bitrate control - Quality settings - Language support - Buffer size management ### Rate Control Modes WMV encoding supports four rate control modes through the `WMVStreamMode` enum: 1. CBR (Constant Bitrate) 2. VBRQuality (Variable Bitrate based on quality) 3. VBRBitrate (Variable Bitrate with target bitrate) 4. VBRPeakBitrate (Variable Bitrate with peak bitrate constraint) ### Configuration Modes The encoder can be configured in several ways using the `WMVMode` enum: - ExternalProfile: Load settings from a profile file - ExternalProfileFromText: Load settings from a text string - InternalProfile: Use built-in profiles - CustomSettings: Manual configuration - V8SystemProfile: Use Windows Media 8 system profiles ### Sample Code Create new WMV custom output configuration: ``` var wmvOutput = new WMVOutput { // Basic configuration Mode = WMVMode.CustomSettings, // Audio settings Custom_Audio_StreamPresent = true, Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 98, Custom_Audio_PeakBitrate = 192000, Custom_Audio_PeakBufferSize = 3, // Optional language setting Custom_Audio_LanguageID = "en-US" }; ``` Using an internal profile: ``` var profileWmvOutput = new WMVOutput { Mode = WMVMode.InternalProfile, Internal_Profile_Name = "Windows Media Video 9 for Local Network (768 kbps)" }; ``` Network streaming configuration: ``` var streamingWmvOutput = new WMVOutput { Mode = WMVMode.CustomSettings, Network_Streaming_WMV_Maximum_Clients = 20, Custom_Audio_Mode = WMVStreamMode.CBR }; ``` ### Custom Profile Configuration Custom profiles give you the most flexibility by allowing you to configure every aspect of the encoding process. Here are several examples for different scenarios: #### Understanding WMV Custom Settings Properties Before diving into examples, it's important to understand the key properties available in the `WMVOutput` class for custom configuration: **Video Properties:** - `Custom_Video_StreamPresent` (bool): Enables video stream in the output - `Custom_Video_Codec` (string): Specifies the video codec (e.g., "Windows Media Video 9") - `Custom_Video_Mode` (WMVStreamMode): Rate control mode (CBR, VBRQuality, VBRBitrate, VBRPeakBitrate) - `Custom_Video_Bitrate` (int): Target bitrate in bits per second - `Custom_Video_Quality` (byte): Quality level (0-100) for VBR quality mode - `Custom_Video_Width` (int): Output video width in pixels - `Custom_Video_Height` (int): Output video height in pixels - `Custom_Video_SizeSameAsInput` (bool): Use input video dimensions - `Custom_Video_FrameRate` (double): Output frame rate - `Custom_Video_KeyFrameInterval` (byte): Number of frames between keyframes - `Custom_Video_Smoothness` (byte): Smoothness level (0-100) - `Custom_Video_Peak_BitRate` (int): Peak bitrate for VBR peak mode - `Custom_Video_Peak_BufferSizeSeconds` (byte): Peak buffer window in seconds - `Custom_Video_Buffer_Size` (int): Buffer size in milliseconds - `Custom_Video_Buffer_UseDefault` (bool): Use default buffer settings - `Custom_Video_TVSystem` (WMVTVSystem): TV system standard (NTSC, PAL) **Audio Properties:** - `Custom_Audio_StreamPresent` (bool): Enables audio stream in the output - `Custom_Audio_Codec` (string): Specifies the audio codec (e.g., "Windows Media Audio 9.2") - `Custom_Audio_Format` (string): Format specification (e.g., "48kHz 16bit Stereo") - `Custom_Audio_Mode` (WMVStreamMode): Rate control mode - `Custom_Audio_Quality` (byte): Quality level (0-100) for VBR quality mode - `Custom_Audio_PeakBitrate` (int): Peak bitrate in bits per second - `Custom_Audio_PeakBufferSize` (byte): Peak buffer window in seconds - `Custom_Audio_LanguageID` (string): Language identifier (e.g., "en-US") **Profile Metadata:** - `Custom_Profile_Name` (string): Profile name for identification - `Custom_Profile_Description` (string): Detailed description of profile purpose - `Custom_Profile_Language` (string): Profile language identifier #### High-Quality Video Streaming Configuration Perfect for professional streaming applications requiring excellent visual quality: ``` var highQualityConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings - High quality 1080p Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.VBRQuality, Custom_Video_Quality = 95, Custom_Video_Width = 1920, Custom_Video_Height = 1080, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 4, Custom_Video_Smoothness = 80, Custom_Video_Buffer_UseDefault = false, Custom_Video_Buffer_Size = 4000, // Audio settings - High quality stereo Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 98, Custom_Audio_Format = "48kHz 16bit Stereo", Custom_Audio_PeakBitrate = 320000, Custom_Audio_PeakBufferSize = 3, // Profile metadata Custom_Profile_Name = "High Quality Streaming", Custom_Profile_Description = "1080p streaming profile with high quality audio", Custom_Profile_Language = "en-US" }; // Apply to VideoCaptureCore var captureCore = new VideoCaptureCore(); captureCore.Output_Format = highQualityConfig; captureCore.Output_Filename = "output_hq.wmv"; // Or apply to VideoEditCore var editCore = new VideoEditCore(); editCore.Output_Format = highQualityConfig; editCore.Output_Filename = "output_hq.wmv"; ``` #### Low Bandwidth Configuration for Mobile Streaming Optimized for mobile devices with limited bandwidth: ``` var mobileLowBandwidthConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings optimized for mobile Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.CBR, Custom_Video_Bitrate = 800000, // 800 kbps Custom_Video_Width = 854, Custom_Video_Height = 480, Custom_Video_FrameRate = 24.0, Custom_Video_KeyFrameInterval = 5, Custom_Video_Smoothness = 60, Custom_Video_Buffer_UseDefault = true, // Audio settings for low bandwidth Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.CBR, Custom_Audio_PeakBitrate = 64000, // 64 kbps Custom_Audio_Format = "44kHz 16bit Mono", Custom_Audio_LanguageID = "en-US", Custom_Profile_Name = "Mobile Low Bandwidth", Custom_Profile_Description = "480p optimized for mobile devices" }; // Apply to VideoCaptureCore var captureCore = new VideoCaptureCore(); captureCore.Output_Format = mobileLowBandwidthConfig; captureCore.Output_Filename = "output_mobile.wmv"; ``` #### Audio-Focused Configuration for Music Content High-quality audio with minimal video processing: ``` var audioFocusedConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // High quality audio settings Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2 Professional", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 99, Custom_Audio_Format = "96kHz 24bit Stereo", Custom_Audio_PeakBitrate = 512000, Custom_Audio_PeakBufferSize = 4, Custom_Audio_LanguageID = "en-US", // Minimal video settings Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.VBRBitrate, Custom_Video_Bitrate = 500000, Custom_Video_Width = 1280, Custom_Video_Height = 720, Custom_Video_FrameRate = 25.0, Custom_Video_KeyFrameInterval = 10, Custom_Video_Buffer_UseDefault = true, Custom_Profile_Name = "Audio Focus", Custom_Profile_Description = "High quality audio configuration for music content" }; // Apply to VideoEditCore for processing audio files with video var editCore = new VideoEditCore(); editCore.Output_Format = audioFocusedConfig; editCore.Output_Filename = "output_audio_focus.wmv"; ``` #### Constant Bitrate (CBR) for Streaming CBR mode is ideal for network streaming where consistent bandwidth is required: ``` var cbrStreamingConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings with CBR Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.CBR, Custom_Video_Bitrate = 2000000, // 2 Mbps constant Custom_Video_Width = 1280, Custom_Video_Height = 720, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 3, Custom_Video_Buffer_Size = 3000, Custom_Video_Buffer_UseDefault = false, // Audio settings with CBR Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.CBR, Custom_Audio_PeakBitrate = 128000, // 128 kbps constant Custom_Audio_Format = "48kHz 16bit Stereo", // Network streaming configuration Network_Streaming_WMV_Maximum_Clients = 50, Custom_Profile_Name = "CBR Streaming", Custom_Profile_Description = "Constant bitrate for reliable network streaming" }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = cbrStreamingConfig; captureCore.Output_Filename = "output_cbr_stream.wmv"; ``` #### Variable Bitrate with Peak Control VBR with peak bitrate constraint provides quality optimization while limiting maximum bandwidth: ``` var vbrPeakConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings with peak bitrate control Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9 Advanced Profile", Custom_Video_Mode = WMVStreamMode.VBRPeakBitrate, Custom_Video_Bitrate = 3000000, // 3 Mbps average Custom_Video_Peak_BitRate = 5000000, // 5 Mbps peak Custom_Video_Peak_BufferSizeSeconds = 3, Custom_Video_Width = 1920, Custom_Video_Height = 1080, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 4, Custom_Video_Smoothness = 75, // Audio settings with peak control Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.VBRPeakBitrate, Custom_Audio_PeakBitrate = 256000, Custom_Audio_PeakBufferSize = 2, Custom_Audio_Format = "48kHz 16bit Stereo", Custom_Profile_Name = "VBR Peak Control", Custom_Profile_Description = "Variable bitrate with peak constraints for quality and bandwidth balance" }; var editCore = new VideoEditCore(); editCore.Output_Format = vbrPeakConfig; editCore.Output_Filename = "output_vbr_peak.wmv"; ``` #### Screen Recording Optimized Configuration Optimized for screen capture with efficient encoding of static content: ``` var screenRecordingConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings optimized for screen content Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9 Screen", Custom_Video_Mode = WMVStreamMode.VBRQuality, Custom_Video_Quality = 90, Custom_Video_SizeSameAsInput = true, // Use screen resolution Custom_Video_FrameRate = 15.0, // Lower frame rate for screen recording Custom_Video_KeyFrameInterval = 10, Custom_Video_Smoothness = 50, Custom_Video_Buffer_UseDefault = true, // Audio settings for voice narration Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 85, Custom_Audio_Format = "44kHz 16bit Mono", // Mono for voice Custom_Audio_LanguageID = "en-US", Custom_Profile_Name = "Screen Recording", Custom_Profile_Description = "Optimized for screen capture with efficient compression" }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = screenRecordingConfig; captureCore.Output_Filename = "screen_recording.wmv"; ``` #### Archival Quality Configuration Maximum quality for archival purposes: ``` var archivalConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings for maximum quality Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9 Advanced Profile", Custom_Video_Mode = WMVStreamMode.VBRQuality, Custom_Video_Quality = 100, Custom_Video_Width = 1920, Custom_Video_Height = 1080, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 1, // Every frame is a keyframe Custom_Video_Smoothness = 100, Custom_Video_Buffer_Size = 8000, Custom_Video_Buffer_UseDefault = false, // Audio settings for maximum quality Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2 Lossless", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 100, Custom_Audio_Format = "96kHz 24bit Stereo", Custom_Audio_LanguageID = "en-US", Custom_Profile_Name = "Archival Quality", Custom_Profile_Description = "Maximum quality for long-term storage", Custom_Profile_Language = "en-US" }; var editCore = new VideoEditCore(); editCore.Output_Format = archivalConfig; editCore.Output_Filename = "archival_quality.wmv"; ``` ### Internal Profile Usage Internal profiles provide pre-configured settings optimized for common scenarios. Here are examples of using different internal profiles: #### Available Codecs and Formats Before configuring custom settings, it's useful to understand the available codecs and formats: **Video Codecs:** - "Windows Media Video 9" - Standard WMV9 codec - "Windows Media Video 9 Advanced Profile" - Advanced features support - "Windows Media Video 9 Screen" - Optimized for screen content - "Windows Media Video 8" - Legacy WMV8 codec **Audio Codecs:** - "Windows Media Audio 9.2" - Standard WMA codec - "Windows Media Audio 9.2 Professional" - High-quality audio - "Windows Media Audio 9.2 Lossless" - Lossless compression - "Windows Media Audio Voice 9" - Optimized for speech **Audio Formats:** Common format strings for `Custom_Audio_Format` property: - "48kHz 16bit Stereo" - CD quality stereo - "44kHz 16bit Stereo" - Standard quality stereo - "44kHz 16bit Mono" - Standard quality mono - "96kHz 24bit Stereo" - High-resolution audio - "22kHz 16bit Mono" - Voice recording quality Standard broadcast quality profile: ``` var broadcastProfile = new WMVOutput { Mode = WMVMode.InternalProfile, Internal_Profile_Name = "Windows Media Video 9 Advanced Profile", Custom_Video_TVSystem = WMVTVSystem.NTSC // Optional TV system override }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = broadcastProfile; captureCore.Output_Filename = "broadcast_output.wmv"; ``` Web streaming profile: ``` var webStreamingProfile = new WMVOutput { Mode = WMVMode.InternalProfile, Internal_Profile_Name = "Windows Media Video 9 for Broadband (2 Mbps)", Network_Streaming_WMV_Maximum_Clients = 100 // Optional streaming override }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = webStreamingProfile; captureCore.Output_Filename = "web_stream.wmv"; ``` Low latency profile for live streaming: ``` var liveStreamingProfile = new WMVOutput { Mode = WMVMode.InternalProfile, Internal_Profile_Name = "Windows Media Video 9 Screen (Low Rate)", Network_Streaming_WMV_Maximum_Clients = 50 }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = liveStreamingProfile; captureCore.Output_Filename = "live_stream.wmv"; ``` ### External Profile Configuration External profiles allow you to load encoding settings from files or text. This is useful for sharing configurations across different projects or storing multiple configurations: Loading profile from a file: ``` var fileBasedProfile = new WMVOutput { Mode = WMVMode.ExternalProfile, External_Profile_FileName = @"C:\Profiles\HighQualityStreaming.prx" }; ``` Loading profile from text configuration: ``` var textBasedProfile = new WMVOutput { Mode = WMVMode.ExternalProfileFromText, External_Profile_Text = @" " }; ``` Saving and loading profiles programmatically: ``` async Task SaveAndLoadProfile(WMVOutput profile, string filename) { // Save profile configuration to JSON string jsonConfig = profile.Save(); await File.WriteAllTextAsync(filename, jsonConfig); // Load profile configuration from JSON string loadedJson = await File.ReadAllTextAsync(filename); WMVOutput loadedProfile = WMVOutput.Load(loadedJson); } ``` Example usage of profile saving/loading: ``` var profile = new WMVOutput { Mode = WMVMode.CustomSettings, // ... configure settings ... }; await SaveAndLoadProfile(profile, "encoding_profile.json"); ``` ### Working with Legacy Windows Media 8 Profiles For compatibility with older systems, you can use Windows Media 8 system profiles: Using Windows Media 8 profile: ``` var wmv8Profile = new WMVOutput { Mode = WMVMode.V8SystemProfile, V8ProfileName = "Windows Media Video 8 for Dial-up Access (28.8 Kbps)", }; ``` Customizing streaming settings for Windows Media 8 profiles: ``` var wmv8StreamingProfile = new WMVOutput { Mode = WMVMode.V8SystemProfile, V8ProfileName = "Windows Media Video 8 for Local Area Network (384 Kbps)", Network_Streaming_WMV_Maximum_Clients = 25, Custom_Video_TVSystem = WMVTVSystem.PAL // Optional TV system override }; ``` ### Apply settings to your core object ``` var core = new VideoCaptureCore(); // or VideoEditCore core.Output_Format = wmvOutput; core.Output_Filename = "output.wmv"; ``` ### Complete Working Example Here's a complete example showing video capture with custom WMV settings, including proper initialization and error handling: ``` using System; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.VideoCapture; using VisioForge.Core.Types; using VisioForge.Core.Types.Output; using VisioForge.Core.Types.VideoCapture; namespace WMVCaptureExample { class Program { static async Task Main(string[] args) { // Initialize VisioForge SDK VisioForgeX.InitSDK(); // Create VideoCaptureCore instance var captureCore = new VideoCaptureCore(); try { // Configure video source (first available camera) var videoDevices = captureCore.Video_CaptureDevices(); if (videoDevices.Length > 0) { captureCore.Video_CaptureDevice = new VideoCaptureSource(videoDevices[0].Name); } // Configure audio source (first available microphone) var audioDevices = captureCore.Audio_CaptureDevices(); if (audioDevices.Length > 0) { captureCore.Audio_CaptureDevice = new AudioCaptureSource(audioDevices[0].Name); } // Configure WMV output with custom settings var wmvOutput = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.VBRQuality, Custom_Video_Quality = 85, Custom_Video_Width = 1280, Custom_Video_Height = 720, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 5, // Audio settings Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 90, Custom_Audio_Format = "48kHz 16bit Stereo", Custom_Profile_Name = "Standard Capture", Custom_Profile_Description = "Standard quality capture profile" }; // Apply output settings captureCore.Output_Format = wmvOutput; captureCore.Output_Filename = "capture_output.wmv"; captureCore.Mode = VideoCaptureMode.VideoCapture; // Start capture Console.WriteLine("Starting video capture..."); await captureCore.StartAsync(); Console.WriteLine("Recording... Press any key to stop."); Console.ReadKey(); // Stop capture Console.WriteLine("Stopping video capture..."); await captureCore.StopAsync(); Console.WriteLine($"Video saved to: capture_output.wmv"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Console.WriteLine($"Stack trace: {ex.StackTrace}"); } finally { // Clean up captureCore?.Dispose(); VisioForgeX.DestroySDK(); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } } ``` ### Complete Video Editing Example Here's a complete example for video editing with custom WMV settings: ``` using System; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.VideoEdit; using VisioForge.Core.Types.Output; using VisioForge.Core.Types.VideoEdit; namespace WMVEditExample { class Program { static async Task Main(string[] args) { // Initialize VisioForge SDK VisioForgeX.InitSDK(); var editCore = new VideoEditCore(); try { // Add input video files editCore.Input_AddVideoFile("input_video1.mp4", false); editCore.Input_AddVideoFile("input_video2.mp4", false); // Configure WMV output var wmvOutput = new WMVOutput { Mode = WMVMode.CustomSettings, // High-quality video settings Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9 Advanced Profile", Custom_Video_Mode = WMVStreamMode.VBRPeakBitrate, Custom_Video_Bitrate = 4000000, // 4 Mbps average Custom_Video_Peak_BitRate = 6000000, // 6 Mbps peak Custom_Video_Peak_BufferSizeSeconds = 3, Custom_Video_Width = 1920, Custom_Video_Height = 1080, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 4, Custom_Video_Smoothness = 80, // High-quality audio settings Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2 Professional", Custom_Audio_Mode = WMVStreamMode.VBRQuality, Custom_Audio_Quality = 95, Custom_Audio_Format = "48kHz 16bit Stereo", Custom_Profile_Name = "High Quality Edit", Custom_Profile_Description = "High quality output for edited videos" }; // Apply output settings editCore.Output_Format = wmvOutput; editCore.Output_Filename = "edited_output.wmv"; // Configure edit mode editCore.Mode = VideoEditMode.Convert; // Start editing Console.WriteLine("Starting video editing..."); await editCore.StartAsync(); // Monitor progress while (editCore.State == VideoEditCoreState.Working) { var progress = editCore.Progress(); Console.WriteLine($"Progress: {progress}%"); await Task.Delay(500); } Console.WriteLine($"Video editing complete! Output saved to: edited_output.wmv"); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); Console.WriteLine($"Stack trace: {ex.StackTrace}"); } finally { // Clean up editCore?.Dispose(); VisioForgeX.DestroySDK(); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } } } ``` ## Cross-platform WMV output [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) The `WMVEncoderSettings` class provides a cross-platform solution for WMV encoding using GStreamer technology. ### Features - Platform-independent implementation - Integration with GStreamer backend - Simple configuration interface - Availability checking ### Sample Code #### VideoCaptureCoreX Configuration Add the WMV output to the Video Capture SDK core instance: ``` // Basic configuration with default settings var wmvOutput = new WMVOutput("output.wmv"); var core = new VideoCaptureCoreX(); core.Outputs_Add(wmvOutput, true); // With custom encoder settings var wmvOutput2 = new WMVOutput("output_custom.wmv"); wmvOutput2.Video = new WMVEncoderSettings(); wmvOutput2.Audio = new WMAEncoderSettings { Bitrate = 192, // Bitrate in Kbps SampleRate = 48000, // Sample rate in Hz Channels = 2 // Stereo }; var core2 = new VideoCaptureCoreX(); core2.Outputs_Add(wmvOutput2, true); ``` #### VideoEditCoreX Configuration Set the output format for the Video Edit SDK core instance: ``` // Basic configuration var wmvOutput = new WMVOutput("output.wmv"); var core = new VideoEditCoreX(); core.Output_Format = wmvOutput; // With custom audio settings var wmvOutput2 = new WMVOutput("output_high_quality.wmv"); wmvOutput2.Audio = new WMAEncoderSettings { Bitrate = 256, // High-quality audio SampleRate = 48000, Channels = 2 }; var core2 = new VideoEditCoreX(); core2.Output_Format = wmvOutput2; ``` #### Media Blocks Pipeline Configuration Create a Media Blocks WMV output instance: ``` // Configure audio encoder var wma = new WMAEncoderSettings { Bitrate = 128, // Bitrate in Kbps SampleRate = 48000, // 48 kHz Channels = 2 // Stereo }; // Configure video encoder var wmv = new WMVEncoderSettings(); // Configure ASF sink (container) var sinkSettings = new ASFSinkSettings("output.wmv"); // Create output block var wmvOutput = new WMVOutputBlock(sinkSettings, wmv, wma); // Add to pipeline var pipeline = new MediaBlocksPipeline(); // ... configure sources and connect to wmvOutput ``` #### Checking Encoder Availability Always check if encoders are available before use: ``` // Check WMV encoder availability if (WMVEncoderSettings.IsAvailable()) { Console.WriteLine("WMV encoder is available"); var wmvOutput = new WMVOutput("output.wmv"); // ... use encoder } else { Console.WriteLine("WMV encoder is not available on this system"); // Fall back to alternative encoder } // Check WMA encoder availability if (WMAEncoderSettings.IsAvailable()) { Console.WriteLine("WMA encoder is available"); } ``` #### Advanced Cross-Platform Configuration ``` // Create a high-quality cross-platform WMV output var wmvOutput = new WMVOutput("output_hq.wmv"); // Configure high-quality audio wmvOutput.Audio = new WMAEncoderSettings { Bitrate = 320, // Maximum quality SampleRate = 48000, Channels = 2 }; // Video encoder settings (uses default WMV1 encoder) wmvOutput.Video = new WMVEncoderSettings(); // Check if custom video processor is needed // wmvOutput.CustomVideoProcessor = myCustomProcessor; // Apply to core var core = new VideoCaptureCoreX(); core.Outputs_Add(wmvOutput, true); // Start capture await core.StartAsync(); ``` #### Available Audio Settings The `WMAEncoderSettings` class provides the following configuration options: ``` var audioSettings = new WMAEncoderSettings { // Bitrate in Kbps - supported values: 128, 192, 256, 320 Bitrate = 192, // Sample rate in Hz - supported values: 44100, 48000 SampleRate = 48000, // Number of channels - supported values: 1 (mono), 2 (stereo) Channels = 2 }; // Get supported bitrates int[] supportedBitrates = audioSettings.GetSupportedBitrates(); // Returns: [128, 192, 256, 320] // Get supported sample rates int[] supportedSampleRates = audioSettings.GetSupportedSampleRates(); // Returns: [44100, 48000] // Get supported channel counts int[] supportedChannels = audioSettings.GetSupportedChannelCounts(); // Returns: [1, 2] ``` ### Choosing Between Encoders Consider the following factors when choosing between Windows-specific `WMVOutput` and cross-platform `WMVEncoderSettings`: #### Windows-Specific WMVOutput - Pros: - Full access to Windows Media format features - Advanced rate control options - Network streaming support - Profile-based configuration - Cons: - Windows-only compatibility - Requires Windows Media components #### Cross-Platform WMV - Pros: - Platform independence - Simpler implementation - Cons: - More limited feature set - Basic configuration options only ## Best Practices ### MSDN References For detailed information about Windows Media technologies, refer to these official Microsoft resources: - [Windows Media Format SDK](https://learn.microsoft.com/es-es/windows/win32/wmformat/windows-media-format-11-sdk) - Complete Windows Media Format documentation - [Working with Profiles](https://learn.microsoft.com/en-us/windows/win32/wmformat/working-with-profiles) - Profile management and configuration - [Windows Media Codecs](https://learn.microsoft.com/en-us/windows/win32/medfound/windows-media-codecs) - Audio and video codec information - [ASF File Structure](https://learn.microsoft.com/en-us/windows/win32/medfound/asf-file-structure) - Advanced Systems Format container details - [Configuring Video Streams](https://learn.microsoft.com/en-us/windows/win32/wmformat/configuring-video-streams) - Video encoding parameters - [Configuring Audio Streams](https://learn.microsoft.com/en-us/windows/win32/wmformat/configuring-audio-streams) - Audio encoding parameters ### Choosing Rate Control Modes Select the appropriate rate control mode based on your use case: 1. **CBR (Constant Bitrate)** 2. Use for: Network streaming, broadcasting 3. Advantages: Predictable bandwidth, consistent quality 4. Disadvantages: Less efficient compression, may not adapt to content complexity 5. Example: Live streaming to ensure smooth playback 6. **VBRQuality (Variable Bitrate - Quality)** 7. Use for: File-based output, archival, high-quality video 8. Advantages: Best quality-to-size ratio, adapts to content complexity 9. Disadvantages: Unpredictable file size and bitrate 10. Example: Recording tutorials or presentations for later playback 11. **VBRBitrate (Variable Bitrate - Target Bitrate)** 12. Use for: When you need quality optimization with size constraints 13. Advantages: Balances quality and target file size 14. Disadvantages: Quality may vary between scenes 15. Example: Creating videos for upload with size limits 16. **VBRPeakBitrate (Variable Bitrate - Peak Constrained)** 17. Use for: Streaming with bandwidth constraints 18. Advantages: Quality optimization with bandwidth ceiling 19. Disadvantages: More complex configuration 20. Example: Adaptive streaming scenarios ### Performance Optimization 1. **Buffer Configuration** 2. Set `Custom_Video_Buffer_UseDefault = false` for fine-tuned control 3. Increase `Custom_Video_Buffer_Size` for smoother streaming (default: 3000ms) 4. Balance buffer size with latency requirements 5. **KeyFrame Interval** 6. Lower values (1-3): Better seek performance, larger file size 7. Higher values (5-10): Smaller file size, less seek precision 8. Recommended: 3-5 for streaming, 10+ for screen recording 9. **Smoothness Settings** 10. 0-50: Prioritize compression efficiency 11. 50-75: Balanced quality and efficiency 12. 75-100: Prioritize visual quality ### Resolution and Frame Rate Guidelines ``` // 4K/UHD Configuration var uhd4KConfig = new WMVOutput { Mode = WMVMode.CustomSettings, Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9 Advanced Profile", Custom_Video_Mode = WMVStreamMode.VBRQuality, Custom_Video_Quality = 95, Custom_Video_Width = 3840, Custom_Video_Height = 2160, Custom_Video_FrameRate = 30.0, // ... other settings }; // Full HD Configuration var fullHDConfig = new WMVOutput { Mode = WMVMode.CustomSettings, Custom_Video_StreamPresent = true, Custom_Video_Width = 1920, Custom_Video_Height = 1080, Custom_Video_FrameRate = 30.0, // ... other settings }; // HD Ready Configuration var hdReadyConfig = new WMVOutput { Mode = WMVMode.CustomSettings, Custom_Video_StreamPresent = true, Custom_Video_Width = 1280, Custom_Video_Height = 720, Custom_Video_FrameRate = 30.0, // ... other settings }; // SD Configuration var sdConfig = new WMVOutput { Mode = WMVMode.CustomSettings, Custom_Video_StreamPresent = true, Custom_Video_Width = 720, Custom_Video_Height = 480, Custom_Video_FrameRate = 29.97, Custom_Video_TVSystem = WMVTVSystem.NTSC, // ... other settings }; ``` ### Error Handling and Validation Always validate your configuration before starting capture or editing: ``` var wmvOutput = new WMVOutput { Mode = WMVMode.CustomSettings, // ... configuration }; try { var captureCore = new VideoCaptureCore(); captureCore.Output_Format = wmvOutput; captureCore.Output_Filename = "output.wmv"; // Validate configuration if (captureCore.Output_Filename == null || captureCore.Output_Filename.Length == 0) { throw new InvalidOperationException("Output filename is required"); } await captureCore.StartAsync(); } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); // Handle error appropriately } ``` ### Network Streaming Configuration For network streaming scenarios, configure both encoder and streaming settings: ``` var streamingConfig = new WMVOutput { Mode = WMVMode.CustomSettings, // Video settings optimized for streaming Custom_Video_StreamPresent = true, Custom_Video_Codec = "Windows Media Video 9", Custom_Video_Mode = WMVStreamMode.CBR, Custom_Video_Bitrate = 1500000, // 1.5 Mbps Custom_Video_Width = 1280, Custom_Video_Height = 720, Custom_Video_FrameRate = 30.0, Custom_Video_KeyFrameInterval = 3, Custom_Video_Buffer_Size = 2000, // Lower buffer for reduced latency Custom_Video_Buffer_UseDefault = false, // Audio settings Custom_Audio_StreamPresent = true, Custom_Audio_Codec = "Windows Media Audio 9.2", Custom_Audio_Mode = WMVStreamMode.CBR, Custom_Audio_PeakBitrate = 128000, Custom_Audio_Format = "48kHz 16bit Stereo", // Network streaming settings Network_Streaming_WMV_Maximum_Clients = 100, Custom_Profile_Name = "Network Streaming", Custom_Profile_Description = "Optimized for network streaming with low latency" }; var captureCore = new VideoCaptureCore(); captureCore.Output_Format = streamingConfig; captureCore.Output_Filename = "http://localhost:8080/stream"; // Or file path ``` ### Testing and Validation 1. **Always test your configuration** with sample content before production use 2. **Monitor encoding performance** to ensure real-time encoding capability 3. **Check file compatibility** with your target playback devices 4. **Validate audio sync** especially with custom frame rates 5. **Test network streaming** under various bandwidth conditions ### Profile Management Save and reuse configurations for consistency: ``` // Save configuration to JSON var wmvOutput = new WMVOutput { Mode = WMVMode.CustomSettings, // ... configuration }; string jsonConfig = wmvOutput.Save(); File.WriteAllText("profile_high_quality.json", jsonConfig); // Load configuration from JSON string loadedJson = File.ReadAllText("profile_high_quality.json"); var loadedProfile = WMVOutput.Load(loadedJson); var captureCore = new VideoCaptureCore(); captureCore.Output_Format = loadedProfile; ``` ### Common Issues and Solutions 1. **Large File Sizes** 2. Use VBRBitrate mode instead of VBRQuality 3. Reduce video quality or resolution 4. Increase KeyFrameInterval 5. Consider using screen codec for screen recordings 6. **Poor Quality** 7. Increase video quality setting 8. Use higher bitrate 9. Switch to VBRQuality mode 10. Ensure sufficient buffer size 11. **Streaming Issues** 12. Use CBR mode for consistent bandwidth 13. Reduce buffer size for lower latency 14. Test with appropriate client count 15. Monitor network bandwidth 16. **Codec Not Available** 17. Ensure Windows Media components are installed 18. Check codec enumeration programmatically 19. Fall back to default internal profiles 20. Consider cross-platform alternatives (WMVEncoderSettings) --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Enable Debug Logs for .NET SDK Troubleshooting Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/sendlogs/ **Description:** Enable and capture debug logs for .NET SDK troubleshooting with step-by-step instructions for demo and production environments. **Tags:** Video Capture SDK, Media Player SDK, Video Edit SDK, .NET # Troubleshooting with Logs for .NET SDK Products [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Why Logs Matter in SDK Troubleshooting When developing applications that utilize media SDKs, you may encounter technical issues that require detailed investigation. Debug logs provide critical information that helps identify the root cause of problems quickly and efficiently. These logs capture everything from initialization sequences to detailed operation steps, error conditions, and system information. Properly collected logs offer several key benefits: - **Faster Issue Resolution**: Technical support can quickly identify the source of problems - **Complete Context**: Logs provide a full picture of what happened before, during, and after an issue - **System Information**: Details about your environment help reproduce and solve problems - **Development Insights**: Understanding logs can help you optimize your implementation ## Log Collection in Demo Applications Our demo applications include built-in debugging capabilities that make it easy to collect logs for troubleshooting. Follow these steps to enable and share logs: ### Step-by-Step Guide for Demo Application Logging 1. **Launch the Demo Application** 2. Open the relevant demo application for your SDK 3. Locate the main interface where settings can be configured 4. **Enable Debug Mode** 5. Find and check the "Debug" checkbox in the application interface 6. This activates detailed logging of all SDK operations 7. **Reproduce the Issue** 8. Configure any other required settings for your specific scenario 9. Press the Start or Play button (depending on which SDK you're using) 10. Allow the application to run until the issue occurs 11. After sufficient time to capture the problem, press the Stop button 12. **Collect Log Files** 13. Navigate to "My Documents\VisioForge" on your system 14. This folder contains all generated log files 15. **Important**: Exclude any audio/video recordings from your collection to reduce file size 16. **Share Logs Securely** 17. Compress the log files into a ZIP archive 18. Upload to a secure file sharing service like Dropbox, Google Drive, or OneDrive 19. Share the access link with technical support ## Implementing Logging in Your Custom Applications When you're developing your own applications with our SDKs, you'll need to explicitly enable and configure logging. This section explains how to implement logging with different SDK components. ### Enabling Debug Logs in Your Code Regardless of which SDK you're using, the basic approach to enabling logs follows a similar pattern: ``` // Example for MediaPlayer SDK mediaPlayer.Debug_Mode = true; mediaPlayer.Debug_Dir = "C:\\Logs\\MyApplication"; // Example for Video Capture SDK videoCapture.Debug_Mode = true; videoCapture.Debug_Dir = "C:\\Logs\\MyApplication"; // Example for Video Edit SDK videoEdit.Debug_Mode = true; videoEdit.Debug_Dir = "C:\\Logs\\MyApplication"; ``` ### Detailed Implementation Guide 1. **Set Debug Mode Property** 2. For any SDK component you're using, set the `Debug_Mode` property to `true` 3. This must be done before calling initialization or playback methods 4. Example: `MediaPlayer1.Debug_Mode = true;` 5. **Specify Log Directory** 6. Set the `Debug_Dir` property to a valid directory path 7. Ensure the specified directory exists and your application has write permissions 8. Example: `MediaPlayer1.Debug_Dir = "C:\\LogFiles\\MyApp";` 9. **Configure Additional Parameters** 10. Set up any other required parameters for your specific use case 11. These could include video sources, codecs, output settings, etc. 12. **Initialize and Run the Component** 13. Call the appropriate method to start the component (e.g., `Start()` or `Play()`) 14. Let the application run until you've reproduced the issue you're troubleshooting 15. **Collect and Share Logs** 16. Locate the log files in both your specified directory and "My Documents\VisioForge" 17. Compress all log files into a ZIP archive 18. Share via secure file sharing service ## Advanced Logging Techniques For more complex applications or difficult-to-reproduce issues, consider these advanced logging approaches: ### Conditional Debug Activation You might want to enable debug logging only in certain scenarios or based on user actions: ``` // Enable debug mode only when troubleshooting if (troubleshootingMode) { mediaPlayer.Debug_Mode = true; mediaPlayer.Debug_Dir = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AppLogs" ); } ``` ### Environment-Specific Logging Different deployment environments may require different logging approaches: ``` #if DEBUG // Development environment logging videoCapture.Debug_Mode = true; videoCapture.Debug_Dir = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "DevLogs" ); #else // Production environment logging (if permitted by your privacy policy) string appDataPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "YourCompany", "YourApp", "Logs" ); Directory.CreateDirectory(appDataPath); videoCapture.Debug_Mode = true; videoCapture.Debug_Dir = appDataPath; #endif ``` ## Best Practices for Effective Logging To ensure you get the most valuable information from your logs, follow these best practices: ### 1. Clear Initial State Before starting a logging session, consider resetting your application state: - Close and restart the application - Clear any cached data if relevant - Ensure you're capturing from a known starting point ### 2. Capture Complete Sessions When possible, capture the entire session from start to finish: - Enable logging before initializing SDK components - Let logging run through the entire operation - Continue logging until after the issue occurs ### 3. Document Reproduction Steps Along with your logs, provide clear steps to reproduce the issue: - Note specific settings used - Document the exact sequence of operations - Include timing information if relevant (e.g., "crash occurs after 30 seconds of playback") ### 4. Manage Log Size Debug logs can grow large, especially for long sessions: - For extended tests, consider breaking logging into multiple sessions - Focus on capturing just the problematic scenario - Always exclude large media files when sharing logs ### 5. Secure Sensitive Information Before sharing logs, be aware of potential sensitive data: - Review logs for any personal or sensitive information - Consider using sanitized test content when possible - Use secure methods to transfer log files ## Interpreting Common Log Messages While advanced log analysis is best left to technical support, understanding some common log patterns can help you identify issues: - **Initialization Errors**: Look for messages containing "Init" or "Initialize" - **Format Issues**: Watch for "format" or "codec" related messages - **Resource Problems**: Messages about "memory", "handles", or "resources" - **Performance Warnings**: Notes about "frame drops", "processing time", or "buffers" ## Conclusion Proper logging is essential for efficient troubleshooting of SDK-based applications. By following the guidelines in this document, you can provide the detailed information needed to quickly resolve any issues you encounter. Remember that detailed logs significantly reduce resolution time and help improve the quality of both your application and our SDKs. For additional code samples and implementation guides, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## Build a Unity App with Video Playback for Android arm64 **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/android/ **Description:** Build settings, IL2CPP, AndroidManifest permissions and troubleshooting for the VisioForge Media Blocks SDK .NET in Unity 6 on Android. **Tags:** Media Blocks SDK, .NET, Unity, Android, IL2CPP, RTSP, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline, RTSPSourceBlock # Build for Android [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) The Android flavor ships as a monolithic `libgstreamer_android.so` with every GStreamer plugin statically linked in, plus the package's managed assemblies built against `netstandard2.1`. This page covers the Build Profile settings, the manifest permissions, and the Android-specific gotchas. For the bring-up sequence shared across platforms, see [Bootstrap and lifecycle](../bootstrap/). The Android flavor is bundled into the `.unitypackage` when the build pipeline is run with `-IncludeAndroid`. The result is one cumulative package that holds the Windows, Android, and any opt-in Apple runtimes together — Unity then picks the correct one at build time from the per-file `PluginImporter` metadata. ## Player Settings | Setting | Value | Where | | --- | --- | --- | | Target Platform | **Android** | File → Build Profiles → Android | | Texture Compression | **ASTC** *(recommended; default in Unity 6)* | File → Build Profiles → Android | | Api Compatibility Level | **.NET Standard 2.1** | Project Settings → Player → Other Settings → Configuration | | Scripting Backend | **IL2CPP** *(mandatory — Mono is not supported on Android by Unity itself)* | Project Settings → Player → Other Settings → Configuration | | Target Architectures | **ARM64** *(ARMv7 not shipped — uncheck it)* | Project Settings → Player → Other Settings → Configuration | | Internet Access | **Require** *(needed for RTSP / HTTPS sources)* | Project Settings → Player → Other Settings → Configuration | | Write Permission | **External (SDCard)** if you write or record media to external storage | Project Settings → Player → Other Settings → Configuration | | Minimum API Level | **24 (Android 7.0)** or later | Project Settings → Player → Other Settings → Identification | Mono cannot load `libgstreamer_android.so` correctly through Unity's Android runtime — only IL2CPP is exercised in CI and supported in production. ## Required AndroidManifest entries Unity generates `AndroidManifest.xml` for you. The settings above translate into the standard entries; if you need a custom manifest, make sure it contains: ``` ``` `READ_MEDIA_VIDEO` / `READ_MEDIA_AUDIO` replace the legacy `READ_EXTERNAL_STORAGE` on Android 13+ (API 33+); declare both forms so older devices keep working. ## What the package adds for Android The `deploy-unity-natives.ps1` step stages the Android runtime into your project as follows: | Path | Contents | | --- | --- | | `Assets/Plugins/Android/libs/arm64-v8a/libgstreamer_android.so` | Monolithic GStreamer runtime — all plugins statically linked. | | `Assets/Plugins/Android/libs/arm64-v8a/libVisioForge_Core.so` | The SDK's Android-flavor native shim. | | `Assets/Plugins/Android/visioforge-gstreamer.aar` | The Java archive that exposes `org.freedesktop.gstreamer.GStreamer.init(Context)`. | | `Assets/VisioForge/link.xml` | Type / member preservation rules for IL2CPP. | | `Assets/Plugins/Android/` | Managed assemblies built against `netstandard2.1` with `UNITY_NS21_ANDROID` defined. | The `link.xml` is mandatory. Without it, IL2CPP's managed-code stripping removes types the SDK references through reflection — `GLib.SignalArgs` subclasses, `SignalClosure.MarshalCallback` — and the first delegate firing throws `MissingMethodException`. The package ships a tested `link.xml`; do not remove it from `Assets/`. ## Build size The Android flavor adds roughly **35 MB** to the APK / AAB: - `libgstreamer_android.so` — ~30 MB (arm64-v8a, stripped) - `libVisioForge_Core.so` — ~2 MB - Managed assemblies — ~3 MB If you ship ARMv7 too (not currently included by the package, but if you stage it manually), expect to double the native libraries. ## Standalone build **File → Build Profiles → Android → Build** (or **Build And Run**) produces an APK / AAB. Tested on: - Unity 6 (`6000.x`) with the Android Build Support module installed - Android 9 through Android 15 devices - Pixel 6 / 7 / 8 / 9, Galaxy S22 / S23 / S24 ## Troubleshooting | Symptom | Cause | Fix | | --- | --- | --- | | `DllNotFoundException: libgstreamer_android` at scene start | Scripting Backend is Mono, not IL2CPP. | Switch to IL2CPP under Project Settings → Player → Other Settings. | | `MissingMethodException` from `GLib.SignalArgs` or `SignalClosure.MarshalCallback` | `link.xml` is missing or was stripped. | Confirm `Assets/VisioForge/link.xml` exists. Re-import the package if it is not there. | | `InvalidOperationException: Unity Android bootstrap requires com.unity3d.player.UnityPlayer.currentActivity to be available` | Wear OS / Android TV / Unity-as-a-library host where the field is null at `BeforeSceneLoad`. | Defer `VisioForgeEnvironment.Configure()` to the first Activity event you can observe and call it manually from there. | | Java init fails with `failed to find getFilesDir` | Activity is not a `UnityPlayerActivity` and does not expose the standard Android Context API. | Confirm the host Activity inherits from a real Android `Activity`. | | RTSPS / HTTPS streams fail with a TLS error | CA bundle extraction failed silently. | Look in the Logcat for `[VisioForge] CA cert extraction failed`. Re-import the package if the embedded resource is missing. | | App crashes on the second `Awake` after returning from background | `VisioForgeX.DestroySDK()` was called in `OnDestroy`. | Don't call it — see [Bootstrap and lifecycle](../bootstrap/#the-editor-lifecycle). | ## Frequently Asked Questions ### Why is ARMv7 not shipped? Modern Android devices (API 24 / Android 7.0 baseline) are predominantly arm64. Shipping the ~30 MB monolithic GStreamer for both ABIs would double the package size for a vanishingly small device share. If you have a hard ARMv7 requirement, contact support. ### Can I use the SDK in a non-Unity Android project? Yes — the underlying SDK ships as a standalone `VisioForge.CrossPlatform.Core.Android` NuGet package for raw .NET Android apps. The Unity package wraps that runtime plus the Java bootstrap and `link.xml`; the wrapper is Unity-specific. ### Does the SDK work in the Android Editor (Project Player → Run In Editor) mode? Run-in-Editor for Android targets is not exercised; build and deploy to a real device. The Editor itself runs the **Windows** flavor of the SDK on a Windows host — switching the Build Target to Android in Build Profiles does not change which native runtime the Editor loads. ### Which sources work over RTSP on Android? The same `RTSPSourceBlock` used on Windows. Auto-reconnect, optional credentials, video-only and video+audio streams, and the standard RTSP transports (TCP, UDP, UDP multicast) are all supported. The Android flavor uses the GStreamer `rtspsrc` element internally — the same one as the Windows and macOS flavors. ## See also - [Install the Media Blocks SDK in Unity](../../../install/unity/) — package setup - [Bootstrap and lifecycle](../bootstrap/) — the Android Java bootstrap explained - [View an RTSP camera in Unity](../rtsp-viewer/) — the `RTSPViewer` sample - [Troubleshooting](../troubleshooting/) — cross-platform error reference - [Platform matrix](../platform-matrix/) — feature support by Unity platform ---END OF PAGE--- ## Unity SDK Bootstrap — Configure the Native Runtime **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/bootstrap/ **Description:** How VisioForgeEnvironment.Configure starts the native GStreamer runtime in Unity 6 on Windows, Android, macOS and iOS plus the Editor lifecycle. **Tags:** Media Blocks SDK, Media Player SDK, Video Capture SDK, Video Edit SDK, .NET, Unity, Bootstrap, Windows, Android, macOS, iOS, C# **API:** VisioForgeEnvironment, VisioForgeX # Bootstrap and lifecycle [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) The Unity package ships a static helper, `VisioForgeEnvironment`, that brings up the bundled native runtime before the first scene loads. You do not call it from your scripts — Unity invokes it automatically through `RuntimeInitializeOnLoadMethod`. This page explains what it does on each platform and the lifecycle rules your scripts have to follow. The same two-step bring-up applies to **every** engine in the package: the low-level `MediaBlocksPipeline` and the high-level `MediaPlayerCoreX`, `VideoCaptureCoreX`, and `VideoEditCoreX` engines all run on the one bundled GStreamer runtime that `Configure()` and `InitializeSdk()` start. Bootstrap is engine-agnostic — nothing on this page is specific to a single engine. If you only need to ship the SDK, you can skip this page: drop `MediaBlocksPlayer` or `RTSPViewerPlayer` into a scene and press **Play**. Come back here when you build your own scripts, hit a runtime error, or want to understand why the Editor settings are mandatory. ## The two entry points `VisioForgeEnvironment` has exactly two public methods your code interacts with: | Method | When it runs | What it does | | --- | --- | --- | | `Configure()` | Automatically, **before the first scene loads** (`[RuntimeInitializeOnLoadMethod(BeforeSceneLoad)]`). | Prepares the native runtime for the current platform — DLL search path, environment variables, CA bundle, Java bootstrap. Idempotent. | | `InitializeSdk()` | You call it once before building a pipeline. The sample players do this in `Start()`. | Calls `VisioForgeX.InitSDK()` and scans the bundled plugin registry. Idempotent. | Both methods are static. Both flag themselves complete only after every step succeeds — so a recoverable failure (for example, the Android Java bootstrap firing before `currentActivity` is ready) leaves the flag unset and a later call retries instead of silently no-op-ing into a broken state. ## What `Configure()` does on each platform `Configure()` dispatches on compile-time symbols (`UNITY_STANDALONE_WIN`, `UNITY_STANDALONE_OSX`, `UNITY_ANDROID`, `UNITY_IOS`) — Unity defines exactly one of these per build target. The body of each branch is the minimum the platform needs for GStreamer to find its plugins, locate its TLS roots, and resolve the rest of the bundled runtime via its native loader. WindowsmacOSAndroidiOSOther 1. Validate the bundled natives directory exists (`StreamingAssets/VisioForge/x64`). Refuse to mutate any process state if not — a missing folder must not poison the process `PATH`. 2. Strip any system GStreamer entry from the **process** `PATH` (a homebrew / system install on `PATH` would load a second physical copy of `gstreamer-1.0-0.dll`, double-register GLib types and hang the pipeline). 3. Point the Win32 DLL loader at the bundled natives via `SetDllDirectoryW`. 4. Prepend the natives folder to the process `PATH` so each plugin's transitive core-lib dependencies resolve (`SetDllDirectory` alone is not enough for those). 5. Set `GST_PLUGIN_PATH` / `GST_PLUGIN_SYSTEM_PATH` to the same flat folder. 6. Set `SSL_CERT_FILE` and `CA_CERTIFICATES` to the bundled `ca-certificates.crt` so RTSPS and HTTPS verify peers. The user / system `PATH` is never touched — only the live process copy. 1. Resolve the natives path by probing the Unity-known layouts: `Plugins/macOS` (Editor and some Standalone Player versions), then `Contents/PlugIns`, `Contents/PlugIns/macOS`, `Contents/Frameworks`, and `Contents/Resources/Data/Plugins/macOS` for a Standalone `.app`. The first folder that contains `libgstreamer-1.0.0.dylib` wins. The result is cached. 2. Prune any system / homebrew GStreamer from `DYLD_LIBRARY_PATH` (`/opt/homebrew/lib`, `/usr/local/lib`) — same double-init failure mode as the Windows `PATH` prune. 3. Set `GST_PLUGIN_PATH` / `GST_PLUGIN_SYSTEM_PATH` to the natives folder so GStreamer can enumerate the bundled plugins. 4. Set `GIO_MODULE_DIR` so GIO finds `libgioopenssl.so` (the TLS backend that RTSPS / HTTPS verify peers through). 5. Set `SSL_CERT_FILE` and `CA_CERTIFICATES` to the bundled CA bundle. Each bundled `.dylib` has its `@rpath` / `@loader_path` baked in by the NuGet pack, so once dyld has loaded one through the first `[DllImport]`, the others resolve siblings automatically — no `SetDllDirectory` equivalent is needed. 1. Acquire `com.unity3d.player.UnityPlayer.currentActivity` through JNI. If the field is null — Wear OS / Android TV variants, Unity-as-a-library hosts that have not assigned it yet, very early `BeforeSceneLoad` on some Unity 6 startup paths — fail fast with a descriptive exception so the customer sees something better than an opaque `NullReferenceException` from deep inside JNI. 2. Resolve `getFilesDir()` and `getCacheDir()` from the Activity. 3. Capture the previous values of `TMP`, `TEMP`, `TMPDIR`, `XDG_RUNTIME_DIR`, `XDG_CACHE_HOME`, `HOME`, `GST_REGISTRY`, `SSL_CERT_FILE`, `CA_CERTIFICATES` so a later failure can roll them back. 4. Point GLib at the app-private writable dirs by setting the variables above (only the app-private dirs are writable on Android). 5. Extract the embedded `ca-certificates.crt` resource into `filesDir/ssl/certs/` and point `SSL_CERT_FILE` / `CA_CERTIFICATES` at it. 6. Call `org.freedesktop.gstreamer.GStreamer.init(activity)` — this loads `libgstreamer_android.so`, captures the JavaVM in `JNI_OnLoad`, runs `gst_init`, and registers every plugin statically linked into the monolith. 7. If any of those throws, restore the captured environment and rethrow. 1. Extract the embedded `ca-certificates.crt` resource into `Application.persistentDataPath/ssl/certs/`. 2. Set `SSL_CERT_FILE` / `CA_CERTIFICATES` to that path so GIO's OpenSSL backend can verify RTSPS / HTTPS peers. 3. Prime the `NativesPath` cache on the main thread (`s_cachedNativesPath = Application.dataPath.Replace('\\', '/')`). Without this prime, a background-thread reader — the GStreamer bus, an async log callback, a pad-added callback — would later hit the lazy getter and call `Application.dataPath` off the main thread, which throws `UnityException`. The compute formula matches the lazy getter byte-for-byte. iOS does not need a plugin scan: every GStreamer plugin is statically registered inside `GStreamerX.framework` at `gst_plugin_register_static()` time, and dyld resolves `@rpath/GStreamerX.framework/GStreamerX` automatically when the first `[DllImport]` fires. `Configure()` sets the success flag and logs a warning. No native runtime exists for the current platform, so any later `[DllImport]` would throw `DllNotFoundException`. Build for one of the four supported platforms instead. ## What `InitializeSdk()` does After `Configure()` has prepared the runtime, `InitializeSdk()` finishes the bring-up: 1. Refuse to run if `Configure()` never succeeded — failing fast here surfaces an actionable error instead of a `DllNotFoundException` deep inside the SDK. 2. Refuse to run on an unsupported `Application.platform` value at runtime (Windows / Android / macOS / iOS are admitted; everything else short-circuits with a warning). 3. On Windows and macOS, before calling the native SDK, double-check that the resolved natives folder exists on disk. This catches the cross-flavor mismatch (Windows-only `.unitypackage` imported into a macOS host, or the opposite) with a clear message instead of an opaque `DllNotFoundException`. Android and iOS skip this check (no folder to probe). 4. Call `VisioForgeX.InitSDK()`. Catch and log on failure; leave the flag unset so a later retry can succeed. 5. On Windows and macOS, explicitly scan the bundled plugin folder with `Gst.Registry.Get().ScanPath(NativesPath)`. Unity's in-process plugin scan does not reliably honour `GST_PLUGIN_PATH` on either platform; the explicit scan is what makes blocks like `BufferSinkBlock` (which depends on `appsink`) load. Android registers plugins statically in `GStreamer.init`; iOS registers them statically in the framework — both skip the scan. 6. Set the success flag. Every sample script — the low-level `MediaBlocksPlayer` / `RTSPViewerPlayer` and the high-level `MediaPlayerXPlayer` / `VideoCaptureXRecorder` / `IPCameraXViewer` / `VideoEditXRenderer` — calls `InitializeSdk()` from its `Start()` method, before it builds a pipeline or constructs an engine. Your scripts should follow the same pattern. ## The Editor lifecycle The SDK initializes once per Editor process and is reused across **Play → Stop → Play** sessions. Two consequences: - **Disable Domain Reload is mandatory.** With it enabled, leaving Play mode triggers a domain reload while the SDK's background GLib main-loop thread is still running, which can hang the Editor. The Editor settings dialog the package shows on first import configures this for you; set it manually under **Edit → Project Settings → Editor → Enter Play Mode Settings** if you skipped that dialog. - **Do not call `VisioForgeX.DestroySDK()` on Stop or in `OnDestroy`.** GStreamer's `gst_deinit` cannot be re-initialized in the same process — destroying the SDK on Stop and trying to use it again on the next Play crashes inside the native registry. The sample players follow this rule: their `OnDestroy` disposes only the per-play pipeline. The SDK stays alive for the rest of the process lifetime. There is one Editor-only guard the package installs automatically: a `VisioForgeEditorReloadGuard` that calls `VisioForgeX.StopMainLoop()` on `beforeAssemblyReload` and `EditorApplication.quitting`. The GLib main-loop runs on a dedicated background thread, blocked inside a native call Unity cannot abort — without this guard, the domain reload that follows a script recompile would hang. The guard does **not** call `DestroySDK` (see above); it stops only the loop thread, and the next Play rebuilds the loop. This guard is internal — your scripts should ignore it. ## Frequently Asked Questions ### Do I have to call `Configure()` manually? No. Unity's `[RuntimeInitializeOnLoadMethod(BeforeSceneLoad)]` attribute runs it for you before the first scene loads. The only time you would call it again is from a custom recovery path when an earlier attempt failed — and `Configure()` is idempotent, so a redundant call is harmless. ### Why does `Configure()` mutate environment variables instead of passing arguments? GLib reads `GST_PLUGIN_PATH`, `GIO_MODULE_DIR`, `SSL_CERT_FILE`, `HOME`, etc. from the C `environ` directly during `gst_init` and again at first TLS use. The SDK has no API to override them — the only correct way to point the runtime at the bundled assets is to set the variables before any pipeline is built. The mutations are scoped to the process; the user and system environments are untouched. ### What happens if I call `InitializeSdk()` before `Configure()` has succeeded? It logs an error and returns. The success flag stays unset so a later retry can succeed once `Configure()` works. This guard exists because `InitSDK()` will otherwise crash deep inside native code with a far less actionable error. ### Can I run two pipelines side by side? Yes. `InitializeSdk()` brings the SDK up once per process; after that you can construct as many `MediaBlocksPipeline` instances — or `MediaPlayerCoreX` / `VideoCaptureCoreX` / `VideoEditCoreX` engines — as you want. Each is independent — the sample multi-camera RTSP pattern is to attach one `RTSPViewerPlayer` per `RawImage`, and each builds and tears down its own pipeline. ## See also - [Using VisioForge in Unity](../) — package overview and how rendering works - [Build for Windows](../windows/) — Windows Editor and Standalone build settings - [Build for Android](../android/) — Android IL2CPP build settings - [Build for macOS](../macos/) — macOS Standalone build settings - [Build for iOS](../ios/) — iOS device build settings - [Troubleshooting](../troubleshooting/) — common bootstrap and runtime errors ---END OF PAGE--- ## Get Started with Media Blocks SDK in Unity 6 — Quickstart **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/getting-started/ **Description:** Five-step quickstart from a fresh Unity 6 project to a playing video — import the VisioForge .unitypackage, apply Player Settings, run the sample. **Tags:** Media Blocks SDK, .NET, Unity, Quickstart, Windows, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline, BufferSinkBlock # Getting started [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) This page is the five-step path from a fresh Unity 6 project to a playing video. For installation details, deep platform notes, and the bootstrap explanation, follow the links at the end. ## What you need - **Unity 6 LTS** (`6000.x`) — verified on `6000.4.6f1`. Older Unity LTS (2022 / 2023) may also work (untested), provided they offer `.NET Standard 2.1` as an Api Compatibility Level option. - **A short NTFS project path** on Windows — for example, `C:\unity\MyApp`. Avoid Dev Drive (ReFS) and very long paths; Unity's package cache can overflow Windows' 260-character `MAX_PATH`. - For the mobile / Apple targets, the matching Unity module installed via Unity Hub (Android Build Support, iOS Build Support, macOS Build Support). ## Step 1 — Download the cumulative `.unitypackage` [**VisioForge.MediaBlocks.Unity.unitypackage**](https://files.visioforge.com/unity/VisioForge.MediaBlocks.Unity.unitypackage) ``` https://files.visioforge.com/unity/VisioForge.MediaBlocks.Unity.unitypackage ``` The package is self-contained — managed assemblies, every supported native runtime, sample scenes, and the one-time setup helper are all inside it. No NuGet restore, no external GStreamer install, no per-platform downloads. ## Step 2 — Import the package In Unity: **Assets → Import Package → Custom Package…**, select the downloaded `.unitypackage`, and click **Import** with all items checked. The published cumulative package adds all four platform runtimes (a custom private build only includes the platforms its `-Include*` switches opted into): - `Assets/StreamingAssets/VisioForge/x64/` — Windows native runtime - `Assets/Plugins/Android/` — Android native runtime - `Assets/Plugins/macOS/` — macOS native runtime - `Assets/Plugins/iOS/GStreamerX.framework/` — iOS native runtime - `Assets/Plugins/` — managed SDK assemblies - `Assets/Scripts/` — the shared `VisioForgeEnvironment`, `VisioForgeVideoView`, and two sample player components - `Assets/Scenes/SimplePlayer.unity` and `Assets/Scenes/RTSPViewer.unity` — sample scenes - `Assets/VisioForge/` — the one-time setup helper and (on mobile / macOS builds) `link.xml` ## Step 3 — Apply the project settings On first import the setup helper offers to apply the mandatory settings. Click **Apply** and both are configured for you: | Setting | Value | Why | | --- | --- | --- | | Api Compatibility Level | `.NET Standard 2.1` | The SDK ships as `netstandard2.1` assemblies. The legacy `.NET Framework` setting cannot load them. | | Enter Play Mode → Reload Domain | **Disabled** | The SDK initializes once per process; a domain reload between Play sessions can hang the Editor while the GLib main loop is mid-call. | If you click **Skip**, set both manually under **Edit → Project Settings**: - Player → Other Settings → Configuration → Api Compatibility Level - Editor → Enter Play Mode Settings → When entering Play Mode (any option that does **not** reload the domain — `Reload Scene only` matches what **Apply** does) For mobile targets (Android, iOS), set **Scripting Backend = IL2CPP** in the same Configuration section. Mono is not supported on Android or iOS by Unity itself. ## Step 4 — Run the sample scene 1. In the **Project** window open `Assets/Scenes/SimplePlayer.unity` (double-click — do not stay on the empty default scene). 2. Select the **RawImage** GameObject in the **Hierarchy**. 3. In the **Inspector** set **File Path** to an absolute path to a local media file. 4. Press **▶ Play**. Video renders in the Game view; audio plays through the system default device. If you have a local RTSP camera, open `Assets/Scenes/RTSPViewer.unity` instead, set **Rtsp Url** (plus **Login** / **Password** if the camera requires authentication), and press **Play**. ## Step 5 — Adapt to your own scene You do not have to use the sample scenes. To play a video into your own UI: 1. Add a **Canvas → Raw Image** (*GameObject → UI → Raw Image*). 2. Select the **Raw Image** and **Add Component →** `MediaBlocksPlayer` (or `RTSPViewerPlayer` for RTSP). 3. Set the **File Path** (or **Rtsp Url**) field and press **▶ Play**. The aspect handling, vertical flip, and `Texture2D` upload are handled by the bundled `VisioForgeVideoView`. Your script is just the pipeline — see [Play a media file in Unity](../simple-player/) for the C# breakdown. ## Build for a target platform When you are ready to ship: - [Windows x64](../windows/) — Editor and Standalone Player baseline. - [Android](../android/) — IL2CPP arm64, AndroidManifest permissions, build size notes. - [macOS](../macos/) — Universal arm64+x86\_64, code-signing and notarization. - [iOS](../ios/) — Xcode export, Info.plist permissions, IL2CPP arm64 device only. The cumulative `.unitypackage` contains every platform you opted into when it was built; Unity picks the right runtime per Build Target via the per-file `PluginImporter` metadata. ## See also - [Install the Media Blocks SDK in Unity](../../../install/unity/) — installation reference - [Using VisioForge in Unity](../) — architecture and rendering overview - [Bootstrap and lifecycle](../bootstrap/) — what `Configure()` and `InitializeSdk()` do - [Platform matrix](../platform-matrix/) — feature availability by platform - [Troubleshooting](../troubleshooting/) — common errors and fixes ---END OF PAGE--- ## Video Playback & RTSP in Unity with Media Blocks SDK .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/ **Description:** Add video playback and live RTSP to Unity 6 with the VisioForge Media Blocks SDK .NET — cross-platform .unitypackage for Windows, Android, macOS, iOS. **Tags:** Media Blocks SDK, .NET, Unity, Windows, Android, macOS, iOS, RTSP, C# **API:** MediaBlocksPipeline, BufferSinkBlock, UniversalSourceBlock, RTSPSourceBlock, AudioRendererBlock, VisioForgeEnvironment # Video playback and RTSP streaming in Unity [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) The **Media Blocks SDK .NET** ships a cross-platform, ready-to-import **`.unitypackage`** that brings video-file playback, live RTSP / IP-camera streaming, and the rest of the Media Blocks pipeline into **Unity 6**. The same package targets four platforms — **Windows x64**, **Android (IL2CPP arm64)**, **macOS Standalone (Universal arm64+x86\_64)**, and **iOS Standalone (device arm64)**. Import once, switch Build Target, build. To install the package, see **[Install the Media Blocks SDK in Unity](../../install/unity/)**. For the five-step shortcut, see **[Quickstart](getting-started/)**. AI coding agents: use the VisioForge MCP server Building this with **Claude Code**, **Cursor**, or another AI coding agent? Connect to the public [VisioForge MCP server](../mcp-server-usage/) at `https://mcp.visioforge.com/mcp` for structured API lookups and verified code examples. The full SDK is available — the samples are just a starting point The package bundles the **complete Media Blocks SDK .NET**. The included sample scenes are examples to get you running quickly — your scripts have access to the **entire Media Blocks API**: capture and multiple source types, decoders and encoders, audio/video processing and effects, mixing and compositing, recording to file, and network streaming output. Build whatever pipeline your app needs. See the [Media Blocks SDK .NET documentation](../../mediablocks/) for the full block catalog. ## Cumulative platform packaging The shipped `.unitypackage` is **cumulative** — one file carries the managed assemblies plus every native runtime, and Unity's per-file `PluginImporter` metadata picks the right copy when you switch Build Target. There is no per-platform download. | Platform | Native runtime | Architecture | Build profile | | --- | --- | --- | --- | | Windows | flat GStreamer install in `StreamingAssets/VisioForge/x64/` | x86\_64 | [Build for Windows](windows/) | | Android | monolithic `libgstreamer_android.so` + Java AAR | arm64-v8a | [Build for Android](android/) | | macOS | ~300 separate dylibs in `Plugins/macOS/` | Universal arm64 + x86\_64 | [Build for macOS](macos/) | | iOS | embedded `GStreamerX.framework` (statically registered plugins) | device arm64 | [Build for iOS](ios/) | All four flavors share the same managed surface — `MediaBlocksPipeline`, `BufferSinkBlock`, `RTSPSourceBlock`, `UniversalSourceBlock`, every effect, every encoder, every sink. The only per-platform thing your script ever sees is the `Application.platform` value at runtime. ## Samples The package ships ready scenes under `Assets/Scenes/`. Open one in the **Project** window (double-click it — do not stay on the empty default scene) and press **▶ Play**: - **[Play a media file](simple-player/)** — two scenes: the low-level `SimplePlayer` (`MediaBlocksPipeline`) and the high-level `MediaPlayerX` (`MediaPlayerCoreX`, with seek/pause/volume). - **[View an RTSP camera](rtsp-viewer/)** — two scenes: the low-level `RTSPViewer` (`MediaBlocksPipeline`) and the high-level `IPCameraX` (`VideoCaptureCoreX`, with optional recording). - **[Capture a webcam](video-capture-x/)** — the `VideoCaptureX` scene: local webcam + microphone with MP4 recording (`VideoCaptureCoreX`, Windows / macOS). - **[Edit and render](video-edit-x/)** — the `VideoEditX` scene: a multi-clip timeline previewed live, then rendered to MP4 (`VideoEditCoreX`). The low-level scenes use the `MediaBlocksPipeline` API; the high-level CoreX scenes render into a `RawImage` through the Unity-only `OnVideoFrameUnity` event (tightly packed RGBA32, `Texture2D`-ready). The RawImage looks empty until you press Play The video texture is created at runtime, so the `RawImage` is blank (white) in edit mode. That is expected — nothing is drawn until the pipeline starts. ## How rendering works Two shared helpers handle setup and rendering for you, so each player script is just the Media Blocks pipeline: 1. **`VisioForgeEnvironment.Configure()`** runs automatically before the first scene loads and prepares the bundled native runtime for the current platform — Windows DLL search path, macOS dylib loader hints, Android Java bootstrap, or iOS framework bring-up. You don't manage any native dependencies or paths. The full story is in [Bootstrap and lifecycle](bootstrap/). 2. **`VisioForgeEnvironment.InitializeSdk()`** initializes the SDK once. Call it before you build a pipeline (the sample players call it in `Start()`). 3. Each player builds a pipeline ending in a **`BufferSinkBlock(VideoFormatX.RGBA)`**; its `OnVideoFrameBuffer` event hands video frames to **`VisioForgeVideoView`**. 4. **`VisioForgeVideoView`** uploads each frame into a Unity `Texture2D` on the main thread and applies the aspect mode, so the video shows up in your `RawImage`. You don't write any texture code — just attach it (the sample players do this for you). ### Editor lifecycle The SDK initializes once per process and is reused across Play/Stop sessions in the Editor. Two points follow from that: - **Keep Disable Domain Reload on** so re-entering Play mode reuses the initialized SDK. With it off, the Editor can hang when leaving Play mode. - The sample players dispose only the per-play pipeline on Stop (`StopAsync`) and intentionally **do not** shut the whole SDK down — keep that pattern in your own scripts. If you hit instability after a script recompile, restart the Editor. See [Bootstrap and lifecycle](bootstrap/#the-editor-lifecycle) for the rationale. ## Frequently Asked Questions ### Do I get the full Media Blocks SDK, or only playback? The full SDK. The sample scenes are starting points; your scripts have access to the entire Media Blocks SDK .NET API — capture, multiple source types, decoders and encoders, audio/video processing and effects, mixing and compositing, recording to file, and network streaming. ### Can I render video into my own UI instead of the sample scenes? Yes. Add a `RawImage`, attach `MediaBlocksPlayer` (file) or `RTSPViewerPlayer` (RTSP), or build your own pipeline and feed a `BufferSinkBlock` into `VisioForgeVideoView`. The texture upload, aspect handling, and flip are handled for you. ### Is the same package used for every platform? Yes — one cumulative `.unitypackage` contains the Windows, Android, macOS, and iOS native runtimes plus a single set of `netstandard2.1` managed assemblies. Unity picks the matching slot at build time from per-file `PluginImporter` metadata; you do not import a separate package per platform. ### Can I see which platform code path is running? Yes. `VisioForgeEnvironment.Configure()` logs one of `[VisioForge] Environment configured. Natives: ` (Windows / macOS), `[VisioForge] Android GStreamer bootstrap complete.`, or `[VisioForge] iOS environment configured (GStreamerX.framework via @rpath).` in the Console. Use that line to confirm which branch ran. ## See Also - [Install the Media Blocks SDK in Unity](../../install/unity/) — full setup, step by step - [Quickstart](getting-started/) — the five-step path to a playing video - [Bootstrap and lifecycle](bootstrap/) — what `Configure()` and `InitializeSdk()` do - [Play a media file in Unity](simple-player/) — the file-playback sample - [View an RTSP camera in Unity](rtsp-viewer/) — the live RTSP / IP camera sample - [Capture a webcam with VideoCaptureCoreX](video-capture-x/) · [Edit and render with VideoEditCoreX](video-edit-x/) — the standalone CoreX engine samples - [Build for Windows](windows/) · [Android](android/) · [macOS](macos/) · [iOS](ios/) - [Platform matrix](platform-matrix/) — feature support by Unity platform - [Troubleshooting](troubleshooting/) — common errors and fixes - [Media Blocks SDK .NET overview](../../mediablocks/) — the full block catalog - [IP camera brands directory](../../camera-brands/) — tested camera URLs and settings ---END OF PAGE--- ## Build a Unity App with Video Playback for iOS (device arm64) **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/ios/ **Description:** Build settings, Xcode workflow, Info.plist permissions, and troubleshooting for the VisioForge Media Blocks SDK .NET in Unity 6 on iOS Standalone. **Tags:** Media Blocks SDK, .NET, Unity, iOS, IL2CPP, RTSP, Xcode, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline, RTSPSourceBlock # Build for iOS [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) The iOS flavor ships as a single `GStreamerX.framework` (~68 MB on disk, arm64 device only) with every GStreamer plugin statically registered inside the framework, plus the package's managed assemblies built against `netstandard2.1`. There are no separate plugin files and no plugin scan at runtime — dyld loads the framework via `@rpath` when the first `[DllImport]` fires. This page covers the Xcode export workflow, the Info.plist entries, and the iOS-specific gotchas; for the bring-up sequence see [Bootstrap and lifecycle](../bootstrap/). The iOS flavor is bundled into the `.unitypackage` when the build pipeline is run with both `-IncludeMacOS` and `-IncludeIOS`. iOS development happens on a Mac host, so the macOS flavor is required alongside iOS — without it, the Editor on the Mac would have no native runtime to load when opening the package. The result is one cumulative package that holds Windows, Android, macOS, and iOS together. ## Player Settings | Setting | Value | Where | | --- | --- | --- | | Target Platform | **iOS** | File → Build Profiles → iOS | | Target SDK | **Device SDK** | File → Build Profiles → iOS | | Target minimum iOS Version | **15.0** or later | Project Settings → Player → Other Settings → Configuration | | Architecture | **ARM64** | Project Settings → Player → Other Settings → Configuration | | Api Compatibility Level | **.NET Standard 2.1** | Project Settings → Player → Other Settings → Configuration | | Scripting Backend | **IL2CPP** *(mandatory — Mono is not supported on iOS by Unity itself)* | Project Settings → Player → Other Settings → Configuration | | Target Device | **iPhone + iPad** | Project Settings → Player → Other Settings → Configuration | | Enable Bitcode | **Off** *(removed from Xcode 14+)* | Project Settings → Player → Other Settings → Configuration | The Editor automatically applies `Api Compatibility Level = .NET Standard 2.1` for iOS when the package's one-time setup dialog runs. If you skipped that dialog, set it manually. ## Required Info.plist entries These are appended to the generated Xcode project's `Info.plist`. Edit them either through Unity's **Player Settings** UI or via a post-process script in your Editor scripts: | Key | Value | Required for | | --- | --- | --- | | `NSCameraUsageDescription` | Reason you need camera access | Camera capture sources | | `NSMicrophoneUsageDescription` | Reason you need microphone access | Microphone capture sources | | `NSLocalNetworkUsageDescription` | Reason you need LAN access | RTSP streams on the local network (`192.168.*`, mDNS discovery) | | `NSAppTransportSecurity` → `NSAllowsArbitraryLoads` = `YES` | (optional) | Plain `http://` URLs and self-signed `https://` / `rtsps://` certificates | Without `NSLocalNetworkUsageDescription`, iOS 14+ silently blocks the first connection attempt to any local-network address — `RTSPSourceBlock` then surfaces a connect timeout that looks like a camera-side error. Set the string to something the App Store reviewers will accept (for example, "This app streams video from local IP cameras on your network."). If you stream only public `https://` / `rtsps://` URLs from internet hosts with valid CA-signed certificates, you can skip the ATS exception entirely — App Transport Security accepts those by default. ## On-disk layout The `deploy-unity-natives.ps1 -Platform iOS` step stages the iOS runtime as: | Path | Contents | | --- | --- | | `Assets/Plugins/iOS/GStreamerX.framework/GStreamerX` | The Mach-O arm64 binary — every GStreamer plugin statically registered. | | `Assets/Plugins/iOS/GStreamerX.framework/Info.plist` | Framework metadata. | | `Assets/Plugins/iOS/GStreamerX.framework/Modules/module.modulemap` | Swift / Objective-C module map. | | `Assets/Plugins/iOS/libVisioForge_Core.a` | The SDK's iOS-flavor static archive. | | `Assets/VisioForge/link.xml` | IL2CPP preservation rules (shared across mobile flavors). | | `Assets/Plugins/iOS/Managed/` | Managed assemblies built against `netstandard2.1` with `UNITY_NS21_IOS` defined. | `PluginImporter` metadata on the framework folder marks it `Add To Embedded Binaries = YES`, so Unity embeds it into the generated Xcode project automatically. Dyld resolves `@rpath/GStreamerX.framework/GStreamerX` when the first `[DllImport]` from the SDK fires — no search path setup is required. The CA bundle is **not** a separate file on iOS — it is an embedded managed resource inside `VisioForge.Core.dll` (`VisioForge.Core.ResourcesData.ca-certificates.crt`). `VisioForgeEnvironment.Configure()` extracts it to `Application.persistentDataPath/ssl/certs/` at startup and points `SSL_CERT_FILE` there. ## Xcode workflow 1. **File → Build Profiles → iOS → Build** — Unity produces an Xcode project, not a final `.ipa`. 2. Open the generated `.xcworkspace` (or `.xcodeproj`) in Xcode on the same Mac. 3. **Signing & Capabilities** tab on the Unity-iPhone target — set your Apple Developer team and a bundle identifier you own. 4. Connect the iPhone (or simulator stub — see the Simulator note below), pick it as the Run target, and press **▶ Run**. The first build takes a few minutes — Xcode is compiling IL2CPP-generated C++ into device arm64. Incremental builds are seconds. Simulator is not supported `GStreamerX.framework` ships device-arm64 only. The iOS Simulator (x86\_64 on Intel Macs, arm64-sim on Apple silicon) cannot load it — Xcode aborts the build with `Could not find module 'GStreamerX' for target 'arm64-apple-ios-simulator'`. Test on a real iPhone or iPad. If you have a hard Simulator requirement, contact support. ## Build size The iOS flavor adds roughly **40 MB** to the final `.ipa`: - `GStreamerX.framework/GStreamerX` — ~38 MB device-arm64 binary after link-time thinning (from the ~68 MB on-disk framework) - `libVisioForge_Core.a` — linked into the IL2CPP binary, ~2 MB delta - Managed assemblies — ~3 MB The compressed `.ipa` is typically smaller after App Store thinning. ## Troubleshooting | Symptom | Cause | Fix | | --- | --- | --- | | Xcode aborts: `dyld: Library not loaded: @rpath/GStreamerX.framework/GStreamerX` | `Add To Embedded Binaries` was not applied to the framework PluginImporter slot. | Confirm `Assets/Plugins/iOS/GStreamerX.framework`'s `.meta` has `AddToEmbeddedBinaries: 1`. If you replaced it manually, re-import the package. | | `UnityException: get_dataPath can only be called from the main thread` from a GStreamer callback | The first reader of `NativesPath` ran on a background thread before `Configure()`'s main-thread prime. | Confirm `Configure()` completed — it prints `[VisioForge] iOS environment configured (GStreamerX.framework via @rpath).` in the Console. If absent, the bootstrap failed before priming. | | `MissingMethodException` from `GLib.SignalArgs` or `SignalClosure.MarshalCallback` | `link.xml` was removed or IL2CPP managed stripping is on without it. | Confirm `Assets/VisioForge/link.xml` exists. Re-import the package if missing. | | RTSP stream times out before connecting on iOS 14+ | `NSLocalNetworkUsageDescription` is missing — iOS blocks the first LAN connection. | Add the key to `Info.plist` with a user-facing reason. | | RTSPS / HTTPS fails with TLS error on first request | CA bundle extraction failed silently. | Check Console for `[VisioForge] CA cert extraction failed`. The embedded resource ships in `VisioForge.Core.dll` — confirm the DLL was not stripped. | | App rejected from App Store review for "missing privacy reason" | A capture source needs `NSCameraUsageDescription` or `NSMicrophoneUsageDescription`. | Add the matching keys with user-facing reasons. | | Crash on the second `Play` in Xcode | `VisioForgeX.DestroySDK()` was called in `OnDestroy`. | Don't call it — see [Bootstrap and lifecycle](../bootstrap/#the-editor-lifecycle). | ## Frequently Asked Questions ### Can I use Mono on iOS? No. Unity itself does not support Mono on iOS — IL2CPP is the only backend for iOS Standalone builds. The SDK matches that constraint. ### Does the iOS flavor work in the iOS Simulator? No. `GStreamerX.framework` is device-arm64 only — see the note above. Test on real hardware. ### Why is the Xcode build the slow step? IL2CPP transpiles every managed assembly (your scripts + Unity engine + the SDK) into C++, then Xcode compiles that C++ for device arm64. The first cold build is ~3 — 5 minutes; incremental builds are seconds because Xcode caches almost everything. ### Does the SDK upload data to VisioForge servers? No. The SDK runs entirely in-process — no telemetry, no licensing call-home, no usage analytics. The `NSLocalNetworkUsageDescription` requirement is purely about your app's outgoing RTSP / HTTP connections, which iOS treats as user-visible. ## See also - [Install the Media Blocks SDK in Unity](../../../install/unity/) — package setup - [Bootstrap and lifecycle](../bootstrap/) — how `Configure()` brings up the iOS runtime - [Build for macOS](../macos/) — the matching macOS host you need to build iOS - [View an RTSP camera in Unity](../rtsp-viewer/) — the `RTSPViewer` sample - [Troubleshooting](../troubleshooting/) — cross-platform error reference ---END OF PAGE--- ## Build a Unity Game with Video Playback for macOS (Universal) **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/macos/ **Description:** Build settings, dylib layout, code-signing, and troubleshooting for the VisioForge Media Blocks SDK .NET in Unity 6 on macOS Standalone. **Tags:** Media Blocks SDK, .NET, Unity, macOS, Standalone Player, RTSP, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline, RTSPSourceBlock # Build for macOS [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) The macOS flavor ships a Universal (arm64 + x86\_64) GStreamer runtime plus the package's managed assemblies built against `netstandard2.1`. The native runtime is a set of ~300 separate dylibs — core GStreamer libs, plugins, GIO modules, OpenSSL TLS backend, CA bundle — flat in `Assets/Plugins/macOS/`. This page covers the Build Profile settings, the dylib layout, and the macOS-specific issues; for the bring-up sequence see [Bootstrap and lifecycle](../bootstrap/). The macOS flavor is bundled into the `.unitypackage` when the build pipeline is run with `-IncludeMacOS`. The result is one cumulative package that holds Windows-x64, Android, and macOS together — Unity picks the right files per Build Target through the per-file `PluginImporter` metadata. ## Player Settings | Setting | Value | Where | | --- | --- | --- | | Target Platform | **macOS** | File → Build Profiles → macOS | | Architecture | **Intel 64-bit + Apple silicon** (Universal) | File → Build Profiles → macOS | | Api Compatibility Level | **.NET Standard 2.1** | Project Settings → Player → Other Settings → Configuration | | Scripting Backend | **Mono** *or* **IL2CPP** *(both are tested)* | Project Settings → Player → Other Settings → Configuration | | Mac App Store Validation | **Off** *(or sign the GStreamer dylibs first, see below)* | Project Settings → Player → Other Settings | | Enter Play Mode → Reload Domain | **Off** | Project Settings → Editor → Enter Play Mode Settings | Both scripting backends are tested. Mono is the default and is faster to iterate on; switch to IL2CPP only if you have a project-wide reason. The same `link.xml` that the package ships preserves the SDK's managed types on either backend. ## On-disk layout The `deploy-unity-natives.ps1 -Platform macOS` step stages the macOS runtime as: | Path | Contents | | --- | --- | | `Assets/Plugins/macOS/libgstreamer-1.0.0.dylib` | Core GStreamer library. | | `Assets/Plugins/macOS/libgio-2.0.0.dylib`, `libglib-2.0.0.dylib`, `libgobject-2.0.0.dylib` | GLib core. | | `Assets/Plugins/macOS/libgst*.dylib` | Every GStreamer plugin (decoders, encoders, sources, sinks, base elements). | | `Assets/Plugins/macOS/libgioopenssl.so` | GIO TLS backend that RTSPS / HTTPS verify peers through. | | `Assets/Plugins/macOS/ca-certificates.crt` | CA bundle for OpenSSL. | | `Assets/Plugins/macOS/libVisioForge_Core.dylib` | The SDK's native shim. | | `Assets/VisioForge/link.xml` | IL2CPP preservation rules (shared with Android). | | `Assets/Plugins/macOS/` | Managed assemblies built against `netstandard2.1` with `UNITY_NS21_MACOS` defined. | The layout is flat — every dylib's `@rpath` / `@loader_path` is baked in by the NuGet pack, so once dyld has loaded one via the first `[DllImport]`, the siblings resolve automatically. ## Standalone build **File → Build Profiles → macOS → Build** produces a `.app` bundle. Where the natives end up in the bundle depends on the Unity version: | Layout | Used by | `VisioForgeEnvironment.NativesPath` resolves to | | --- | --- | --- | | `.app/Contents/PlugIns/` | Unity 6 default | `…/Contents/PlugIns` | | `.app/Contents/PlugIns/macOS/` | some Unity 6 patch releases | `…/Contents/PlugIns/macOS` | | `.app/Contents/Frameworks/` | older Unity layouts | `…/Contents/Frameworks` | | `.app/Contents/Resources/Data/Plugins/macOS/` | very old layouts | `…/Contents/Resources/Data/Plugins/macOS` | `NativesPath` probes all four locations at startup, looking for the sentinel `libgstreamer-1.0.0.dylib`. The first folder that contains it wins, and the result is cached for the rest of the process — there is no setting you adjust per Unity version. ## Build size The macOS flavor adds roughly **100 MB** to the `.app` bundle (Universal arm64 + x86\_64). It is the largest of the cumulative-package flavors because every plugin ships as its own dylib and both architectures are included. If you target Apple silicon only, you can post-process the bundle to strip the x86\_64 slices with `lipo`, but the package itself does not split them by default. ## Code-signing and notarization For distribution outside the Mac App Store you typically want to sign and notarize the bundle: 1. **Hardened Runtime** enabled (Project Settings → Player → Other Settings or your signing workflow). 2. **Codesign every dylib in `Contents/PlugIns/`** with your Developer ID Application certificate before signing the `.app` itself. Unity does not sign third-party plugins for you. 3. **Notarize** the final `.app` (or its `.zip` / `.dmg`) with `xcrun notarytool submit … --wait`. 4. **Staple** the notarization ticket with `xcrun stapler staple `. The GStreamer dylibs do not require any Apple entitlements beyond the Hardened Runtime default; they do not access protected resources from inside their native code. Your own app determines which entitlements (camera, microphone, network, etc.) are required. For Mac App Store submission, the bundled `libgioopenssl.so` and `libgmp.10.dylib` are statically linked and ship under permissive licenses, but the App Store review may flag the file extension `.so` for a macOS bundle. If you need App Store distribution, contact support — that path is not exercised by the package CI. ## Troubleshooting | Symptom | Cause | Fix | | --- | --- | --- | | `DllNotFoundException: libgstreamer-1.0.0` on Play | `Plugins/macOS/` is empty or the sentinel `libgstreamer-1.0.0.dylib` is missing. | Re-import the `.unitypackage` with all items checked. The Console shows the resolved `NativesPath` — confirm the sentinel is there. | | `[VisioForge] Native runtime folder not found at '…/Contents/PlugIns'` on a Standalone build | Plugins were not staged into the `.app` because the macOS flavor was not in the package. | Re-build the package with `-IncludeMacOS` (or import the cumulative `.unitypackage` that includes macOS). | | Pipeline hangs at startup, log shows two `gst_init` calls | A homebrew or system GStreamer install is on `DYLD_LIBRARY_PATH`. | `Configure()` prunes it — confirm the stripped count is non-zero in the Console. Hardened Runtime strips `DYLD_*` before the process starts, so this is mostly a Mono-Editor concern. | | RTSPS / HTTPS fails with `Peer certificate cannot be authenticated with given CA certificates` | `ca-certificates.crt` not found at the expected path. | `Configure()` logs a warning if the bundle is missing. Re-import the package or re-run `deploy-unity-natives.ps1 -Platform macOS`. | | Bundle launched from Finder shows `Damaged app` dialog | The `.app` is unsigned and downloaded with the quarantine flag set. | Sign + notarize for distribution, or for local testing run `xattr -d com.apple.quarantine ` once. | | Bundle launched from a Mac App Store TestFlight build crashes | `.so` files in the bundle violate App Store layout rules. | Contact support — App Store submission needs an alternate native packaging. | ## Frequently Asked Questions ### Does the macOS flavor work in the Editor on a Mac? Yes — both `OSXEditor` (the Editor itself) and `OSXPlayer` (a Standalone build) are admitted runtime targets. `Configure()` resolves `Plugins/macOS/` from the project root in the Editor and probes the bundle layout in the player. ### Do I need the macOS flavor to open the package in a Mac-host Editor? Yes. The `.unitypackage` you import must contain the macOS flavor (`-IncludeMacOS`) for the Mac-host Editor to find a native runtime to load. A Windows-only package, opened in a Mac Editor, will surface the cross-flavor mismatch as `[VisioForge] Native runtime folder not found at '…' for runtime platform OSXEditor` — see [Bootstrap and lifecycle](../bootstrap/). ### Can I ship Apple silicon only and skip x86\_64? Yes. After the build, run `lipo -thin arm64 -output ` on each `.dylib` in `Contents/PlugIns/` to strip the Intel slices. The package does not do this by default because both architectures are still useful for compatibility testing. ### Does the same package work on iOS too? The iOS flavor is shipped as a separate platform inside the same `.unitypackage` when built with `-IncludeIOS`. See [Build for iOS](../ios/). ## See also - [Install the Media Blocks SDK in Unity](../../../install/unity/) — package setup - [Bootstrap and lifecycle](../bootstrap/) — how `Configure()` finds the macOS runtime - [Build for iOS](../ios/) — the matching iOS flavor (requires a Mac host) - [View an RTSP camera in Unity](../rtsp-viewer/) — the `RTSPViewer` sample - [Troubleshooting](../troubleshooting/) — cross-platform error reference ---END OF PAGE--- ## Unity Media Blocks SDK .NET — platform feature matrix **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/platform-matrix/ **Description:** Feature support by Unity build target — sources, sinks, encoders, capture, and effects across Windows x64, Android, macOS Standalone, and iOS device. **Tags:** Media Blocks SDK, .NET, Unity, Platform Matrix, Windows, Android, macOS, iOS, C# **API:** MediaBlocksPipeline, UniversalSourceBlock, RTSPSourceBlock, BufferSinkBlock # Platform matrix [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) This page lists what works on which Unity build target — the matrix is filtered to the runtime that ships in the cumulative `.unitypackage`. For the SDK-wide feature matrix that covers all .NET project types (not just Unity), see [Platform matrix (.NET)](../../../platform-matrix/). Legend: ✅ supported · ⚠️ partial · ❌ not supported ## Build targets | Build target | Architecture | Scripting backend | Min. version | | --- | --- | --- | --- | | Windows Editor + Standalone Player | x86\_64 | Mono *(default)* or IL2CPP | Windows 10 1809 / Server 2019 | | macOS Editor + Standalone Player | Universal arm64 + x86\_64 | Mono *(default)* or IL2CPP | macOS 11 Big Sur | | Android Standalone Player | arm64-v8a | IL2CPP *(mandatory)* | Android 7.0 / API 24 | | iOS Standalone Player | device arm64 | IL2CPP *(mandatory)* | iOS 15 | Other build targets (Linux, WebGL, UWP, tvOS, visionOS, console SDKs) are not part of the package today. ## Source blocks | Source | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | `UniversalSourceBlock` (file / URL via decodebin) | ✅ | ✅ | ✅ | ✅ | | `RTSPSourceBlock` (live RTSP / RTSPS) | ✅ | ✅ | ✅ | ✅ | | `VirtualVideoSourceBlock` (test pattern) | ✅ | ✅ | ✅ | ✅ | | `HTTPMJPEGSourceBlock` | ✅ | ✅ | ✅ | ✅ | | `NDISourceBlock` | ✅ | ❌ | ✅ | ❌ | | `DecklinkVideoSourceBlock` | ✅ | ❌ | ✅ | ❌ | | `SystemVideoSourceBlock` (camera) | ✅ DirectShow / MediaFoundation | ✅ Camera2 | ✅ AVFoundation | ✅ AVFoundation | | `SystemAudioSourceBlock` (microphone) | ✅ WASAPI | ✅ OpenSL | ✅ CoreAudio | ✅ AVAudio | | `ScreenSourceBlock` (desktop capture) | ✅ | ❌ | ✅ | ❌ | ## Sink blocks | Sink | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | `BufferSinkBlock` (raw frame callback into `RawImage`) | ✅ | ✅ | ✅ | ✅ | | `AudioRendererBlock` (system default device) | ✅ WASAPI | ✅ OpenSL | ✅ CoreAudio | ✅ AVAudio | | `MP4SinkBlock` (file mux) | ✅ | ✅ | ✅ | ✅ | | `MKVSinkBlock` (file mux) | ✅ | ✅ | ✅ | ✅ | | `WebMSinkBlock` (file mux) | ✅ | ✅ | ✅ | ✅ | | `RTSPServerBlock` (egress) | ✅ | ⚠️ no auto port-forward | ✅ | ⚠️ no auto port-forward | | `RTMPSinkBlock` (egress) | ✅ | ✅ | ✅ | ✅ | | `SRTSinkBlock` (egress) | ✅ | ✅ | ✅ | ✅ | | `HLSSinkBlock` (egress) | ✅ | ✅ | ✅ | ✅ | Unity's built-in renderer is not exposed via `VideoRendererBlock` — render through `BufferSinkBlock` + `VisioForgeVideoView`, which uploads each frame into a `Texture2D` you attach to a `RawImage` (or any material). ## Codecs ### Video decode | Codec | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | H.264 | ✅ | ✅ HW | ✅ HW (VideoToolbox) | ✅ HW (VideoToolbox) | | H.265 / HEVC | ✅ | ✅ HW | ✅ HW (VideoToolbox) | ✅ HW (VideoToolbox) | | AV1 | ✅ SW (libdav1d) | ✅ HW where available | ✅ HW where available | ✅ HW where available | | VP8 / VP9 | ✅ | ✅ | ✅ | ✅ | | MPEG-4 part 2 | ✅ | ✅ | ✅ | ✅ | | MPEG-2 | ✅ | ✅ | ✅ | ✅ | | MJPEG | ✅ | ✅ | ✅ | ✅ | | ProRes | ✅ | ⚠️ SW only | ✅ HW | ⚠️ SW only | ### Video encode | Codec | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | H.264 | ✅ NVENC / QSV / SW | ✅ HW (MediaCodec) | ✅ HW (VideoToolbox) | ✅ HW (VideoToolbox) | | H.265 / HEVC | ✅ NVENC / QSV / SW | ✅ HW (MediaCodec) | ✅ HW (VideoToolbox) | ✅ HW (VideoToolbox) | | AV1 | ✅ SW (SVT-AV1) | ⚠️ device-dependent | ⚠️ SW only | ⚠️ SW only | | VP8 / VP9 | ✅ SW | ✅ SW | ✅ SW | ✅ SW | | MJPEG | ✅ | ✅ | ✅ | ✅ | ### Audio decode / encode | Codec | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | AAC | ✅ | ✅ | ✅ | ✅ | | MP3 | ✅ | ✅ | ✅ | ✅ | | Opus | ✅ | ✅ | ✅ | ✅ | | FLAC | ✅ | ✅ | ✅ | ✅ | | Vorbis | ✅ | ✅ | ✅ | ✅ | | AC-3 / E-AC-3 | ✅ decode | ✅ decode | ✅ decode | ✅ decode | ## Effects and processing | Feature | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | `BufferSinkBlock` RGBA frame callback | ✅ | ✅ | ✅ | ✅ | | Audio effects (volume, EQ, normalize) | ✅ | ✅ | ✅ | ✅ | | Video effects (color, transform, deinterlace) | ✅ | ✅ | ✅ | ✅ | | `TextOverlayBlock` / `ImageOverlayBlock` (text / image on video) | ✅ | ✅ | ✅ | ✅ | | `VideoMixerBlock` / `AudioMixerBlock` (live compositing) | ✅ | ✅ | ✅ | ✅ | ## Network protocols | Protocol | Windows | Android | macOS | iOS | | --- | --- | --- | --- | --- | | RTSP (TCP / UDP / multicast) | ✅ | ✅ | ✅ | ✅ | | RTSPS (TLS) | ✅ | ✅ | ✅ | ✅ | | RTMP / RTMPS | ✅ | ✅ | ✅ | ✅ | | SRT (caller / listener) | ✅ | ✅ | ✅ | ✅ | | HLS (read / write) | ✅ | ✅ | ✅ | ✅ | | HTTP / HTTPS | ✅ | ✅ | ✅ | ✅ | | WebRTC | ✅ | ✅ | ✅ | ✅ | | NDI | ✅ | ❌ | ✅ | ❌ | WebRTC is supported on every target. Like any WebRTC deployment it needs a signalling server and ICE / STUN / TURN configuration for your network — that wiring is app-specific, not a platform limitation. ## Cumulative-package shipping The cumulative `.unitypackage` contains the platforms its build was opted into. The package shipped from `https://files.visioforge.com/unity/` carries: - Windows-x64 (always) - Android arm64 - macOS Universal - iOS device arm64 If a private build skipped a platform with the matching `-Include*` switch left out, the package's `PluginImporter` slots for that platform are absent and Unity will fail to load the SDK when the Build Target is switched to it. ## See also - [Install the Media Blocks SDK in Unity](../../../install/unity/) — install + targeting - [Bootstrap and lifecycle](../bootstrap/) — runtime bring-up across platforms - [Build for Windows](../windows/) · [Android](../android/) · [macOS](../macos/) · [iOS](../ios/) - [Platform matrix (.NET, full SDK surface)](../../../platform-matrix/) — feature support across every .NET host (WPF, WinForms, MAUI, Avalonia, Uno, Unity, raw .NET) - [Media Blocks SDK .NET overview](../../../mediablocks/) — the full block catalog ---END OF PAGE--- ## RTSP Camera in Unity with Media Blocks or VideoCaptureCoreX **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/rtsp-viewer/ **Description:** View a live RTSP / IP camera in Unity 6 with the Media Blocks RTSPViewer pipeline or the high-level VideoCaptureCoreX engine, with optional recording. **Tags:** Media Blocks SDK, Video Capture SDK, .NET, Unity, Windows, Android, macOS, iOS, RTSP, IP Camera, Streaming, C# **API:** MediaBlocksPipeline, RTSPSourceBlock, BufferSinkBlock, VideoCaptureCoreX, RTSPSourceSettings, MP4Output # View an RTSP camera in Unity [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) There are two ways to view a live RTSP / IP camera stream in Unity, and the package ships a ready scene for each. Both render into a Unity `RawImage` and run on **Windows**, **Android**, **macOS Standalone**, and **iOS**. This article assumes you have imported the Unity package and applied the two required project settings — see [Using VisioForge in Unity](../) first. ## Two scenes, two engines | Scene | Engine | Level | Best for | | --- | --- | --- | --- | | **`RTSPViewer`** | `MediaBlocksPipeline` (Media Blocks SDK) | Low-level | Full control over the pipeline — pick your own sinks, effects, and outputs. | | **`IPCameraX`** | `VideoCaptureCoreX` (Video Capture SDK) | High-level | Ready-made capture engine — adds recording outputs, snapshots, audio routing, and overlays on top of the same stream. | Pick `RTSPViewer` when you want to assemble the pipeline yourself; pick `IPCameraX` when you want a capture engine that can also record while it previews. Both feed the same bundled `VisioForgeVideoView`, so the texture upload, aspect handling, and vertical flip are identical. ## RTSPViewer — the Media Blocks pipeline The **`RTSPViewer`** scene displays a live RTSP / IP camera stream with the low-level **Media Blocks SDK .NET**, rendered into a `RawImage`. ### Run the RTSPViewer scene 1. In the **Project** window open `Assets/Scenes/RTSPViewer.unity` (double-click it). 2. In the **Hierarchy** select the **RawImage** GameObject. The `RTSPViewerPlayer` component is attached to it. 3. In the **Inspector**, set **Rtsp Url** (and **Login** / **Password** if the camera requires authentication). 4. Press **▶ Play** — the stream renders in the Game view. ### Inspector fields (RTSPViewerPlayer) | Field | Default | Description | | --- | --- | --- | | **Rtsp Url** | `rtsp://192.168.1.10:554/stream` | RTSP URL of the camera/stream. | | **Login** | *(empty)* | RTSP username — leave empty if the stream needs no auth. | | **Password** | *(empty)* | RTSP password. | | **Auto Play On Start** | `true` | Connect automatically in `Start()`. | | **Render Audio** | `true` | Render audio through the system default device. | | **Aspect Mode** | `Letterbox` | How the video is fitted into the `RawImage`: `Stretch`, `Letterbox`, or `Crop`. | ### The RTSPViewer pipeline `RTSPViewerPlayer` builds this pipeline: ``` graph LR; src[RTSPSourceBlock] -->|video| sink["BufferSinkBlock (RGBA)"]; sink --> view["VisioForgeVideoView (Texture2D)"]; src -->|audio, optional| audio[AudioRendererBlock]; ``` The core of `PlayAsync`: ``` _pipeline = new MediaBlocksPipeline(); // readInfo:false skips the media pre-probe (it can fail under the Unity runtime, and // probing a live stream adds connect latency); the codec is negotiated when playback starts. var settings = await RTSPSourceSettings.CreateAsync( new Uri(rtspUrl), login ?? string.Empty, password ?? string.Empty, audioEnabled: _renderAudio, readInfo: false); _source = new RTSPSourceBlock(settings); _videoSink = new BufferSinkBlock(VideoFormatX.RGBA); _videoSink.OnVideoFrameBuffer += _videoView.OnFrameBuffer; _pipeline.Connect(_source.VideoOutput, _videoSink.Input); if (_renderAudio && _source.AudioOutput != null) { _audioRenderer = new AudioRendererBlock(); _pipeline.Connect(_source.AudioOutput, _audioRenderer.Input); } await _pipeline.StartAsync(); ``` ## IPCameraX — the VideoCaptureCoreX engine The **`IPCameraX`** scene views the same RTSP / IP camera with the high-level **`VideoCaptureCoreX`** engine. On top of the live preview it can record to MP4 and exposes snapshots, audio routing, and overlays — the capture-engine features the hand-built `RTSPViewer` pipeline does not provide out of the box. ### The OnVideoFrameUnity event `VideoCaptureCoreX` exposes the Unity-only **`OnVideoFrameUnity`** event: each frame arrives as tightly packed **RGBA32** (`Stride == Width * 4`), ready for `Texture2D.LoadRawTextureData` with no conversion. Subscribe before `StartAsync`. ### Run the IPCameraX scene 1. In the **Project** window open `Assets/Scenes/SampleScene.unity`. 2. In the **Hierarchy** select the **RawImage** GameObject — the `IPCameraXViewer` component is attached to it. 3. In the **Inspector** set **Rtsp Url** (and **Login** / **Password** if the camera needs them). 4. Press **▶ Play** — the camera stream appears in the Game view. ### Inspector fields (IPCameraXViewer) | Field | Default | Description | | --- | --- | --- | | **Rtsp Url** | `rtsp://192.168.1.10:554/stream` | RTSP / HTTP camera URL. | | **Login** | *(empty)* | Camera user name (empty for open streams). | | **Password** | *(empty)* | Camera password (empty for open streams). | | **Render Audio** | `false` | Request and render the camera audio stream, if present. | | **Record To File** | `false` | Record the stream to MP4 while previewing. | | **Output Path** | *(empty)* | MP4 path. Empty → `/ipcamera.mp4`. | | **Auto Play On Start** | `true` | Connect automatically in `Start()`. | | **Aspect Mode** | `Letterbox` | How the video is fitted into the `RawImage`. | ### The IPCameraX pipeline ``` graph LR; rtsp["VideoCaptureCoreX (RTSP source)"] -->|OnVideoFrameUnity, RGBA32| view["VisioForgeVideoView (Texture2D)"]; rtsp -->|optional record| mp4["MP4Output (H264 + AAC)"]; ``` The core of `PlayAsync`: ``` _capture = new VideoCaptureCoreX(); // readInfo:false skips the media pre-probe (it can fail under the Unity runtime and adds latency). var rtspSettings = await RTSPSourceSettings.CreateAsync( new Uri(rtspUrl), login, password, audioEnabled: renderAudio, readInfo: false); _capture.Video_Source = rtspSettings; // Texture-ready RGBA32 frames straight into the view. _capture.OnVideoFrameUnity += _videoView.OnFrameBuffer; if (recordToFile) _capture.Outputs_Add(new MP4Output(outputPath), autostart: true); await _capture.StartAsync(); ``` ## Use it in your own scene Add a **Canvas → Raw Image** (*GameObject → UI → Raw Image*), select it, **Add Component →** `RTSPViewerPlayer` (Media Blocks pipeline) or `IPCameraXViewer` (VideoCaptureCoreX engine), set **Rtsp Url**, and press **▶ Play**. The `RawImage` layout, aspect handling, and vertical flip are handled by the bundled `VisioForgeVideoView`. For local file playback instead of RTSP, use `MediaBlocksPlayer` or `MediaPlayerXPlayer` (see [Play a media file](../simple-player/)). ## Per-platform Build Settings and network permissions Both scenes run unchanged on every supported platform — but each target has its own network-permission and Build Profile requirements. WindowsAndroidmacOSiOS | Setting | Value | | --- | --- | | Architecture | x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | Outbound TCP / UDP to the camera's RTSP port works with no special declaration. Windows Defender Firewall may prompt the first time the player binds a UDP socket — accept the private-network prompt. See [Build for Windows](../windows/) for the full checklist. | Setting | Value | | --- | --- | | Architecture | arm64-v8a (**uncheck ARMv7**) | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | **IL2CPP** (mandatory) | | Internet Access | **Require** | `AndroidManifest.xml` must declare: ``` ``` For RTSP over UDP on a public network, Android 9+ (API 28+) also requires `android:usesCleartextTraffic="true"` on the `` element if the camera is reachable only via plain RTSP / RTP without TLS. See [Build for Android](../android/) for the full checklist. | Setting | Value | | --- | --- | | Architecture | Universal arm64 + x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | No additional manifest entries — outbound connections are unrestricted by default. For Mac App Store distribution add the **com.apple.security.network.client** entitlement to the signed bundle so the App Sandbox allows outbound network access. See [Build for macOS](../macos/) for code-signing and notarization notes. | Setting | Value | | --- | --- | | Architecture | device arm64 (Simulator not supported) | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | **IL2CPP** (mandatory) | iOS 14+ blocks the first connection attempt to any local-network address until your app declares why. Add to `Info.plist`: ``` NSLocalNetworkUsageDescription This app streams video from local IP cameras on your network. ``` For plain `rtsp://` (no TLS) or `http://` URLs, add an App Transport Security exception: ``` NSAppTransportSecurity NSAllowsArbitraryLoads ``` Public `https://` / `rtsps://` URLs with CA-signed certificates need no ATS exception. See [Build for iOS](../ios/) for the full Xcode workflow. ## Auto-reconnect Both engines reconnect automatically when the stream drops, with backoff between attempts — no manual state machine in your script. For `RTSPViewer`, raise the timeout on the underlying `RTSPSourceSettings` before passing them to `RTSPSourceBlock` if you need a longer window; `IPCameraX` (`VideoCaptureCoreX`) handles camera reboots and brief interruptions the same way. ## Frequently Asked Questions ### Which scene should I use — RTSPViewer or IPCameraX? Use **`RTSPViewer`** (`MediaBlocksPipeline`) for a lean view-only pipeline you assemble yourself. Use **`IPCameraX`** (`VideoCaptureCoreX`) when you also want recording to MP4, snapshots, audio routing, or overlays on the same stream — they are ready-made on the capture engine. ### How do I provide camera credentials? Set the **Login** and **Password** fields on either component. Leave them empty for streams that need no authentication; the credentials are sent to the camera, not embedded in the URL. ### What URL format should I use? The standard `rtsp://host:port/path` form your camera exposes, e.g. `rtsp://192.168.1.21:554/Streaming/Channels/101` (Hikvision) or `rtsp://192.168.1.22:554/cam/realmonitor?channel=1&subtype=0` (Dahua). Check your camera's manual for its exact stream path. ### Does it record the camera? `IPCameraX` does — enable **Record To File** to add an `MP4Output` alongside the preview. `RTSPViewer` is view-only; add a recording branch to its pipeline yourself if you need it. ### What if the camera has no audio? Both work as video-only. The audio branch is connected only when the stream actually carries audio, so a video-only camera needs no changes. ### Can I display several cameras at once? Yes. Add a `RawImage` with its own `RTSPViewerPlayer` or `IPCameraXViewer` for each camera; each builds an independent pipeline. ## See Also - [Using VisioForge in Unity](../) — package overview, setup, and how rendering works - [Play a media file in Unity](../simple-player/) — the local file / URL playback scenes - [Capture a webcam in Unity](../video-capture-x/) — local-camera capture (Windows / macOS) - [RTSP streaming guide](../../network-streaming/rtsp/) — RTSP across the VisioForge .NET SDKs - [IP camera brands directory](../../../camera-brands/) — tested camera URLs and settings - [Media Blocks RTSP player in C#](../../../mediablocks/Guides/rtsp-player-csharp/) — a non-Unity RTSP example ---END OF PAGE--- ## Play Media in Unity with Media Blocks or MediaPlayerCoreX **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/simple-player/ **Description:** Play files and URLs in Unity 6 with the Media Blocks SimplePlayer pipeline or the high-level MediaPlayerCoreX engine, rendering into a RawImage. **Tags:** Media Blocks SDK, Media Player SDK, .NET, Unity, Windows, Android, macOS, iOS, Playback, C# **API:** MediaBlocksPipeline, UniversalSourceBlock, BufferSinkBlock, MediaPlayerCoreX, UniversalSourceSettings # Play a media file in Unity [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) There are two ways to play a local file or a network URL in Unity, and the package ships a ready scene for each. Both render into a Unity `RawImage` and run on **Windows**, **Android**, **macOS Standalone**, and **iOS**. This article assumes you have imported the Unity package and applied the two required project settings; see [Using VisioForge in Unity](../) first. ## Two scenes, two engines | Scene | Engine | Level | Best for | | --- | --- | --- | --- | | **`SimplePlayer`** | `MediaBlocksPipeline` (Media Blocks SDK) | Low-level | Full control over the pipeline — pick your own source, sinks, effects, and encoders. | | **`MediaPlayerX`** | `MediaPlayerCoreX` (Media Player SDK) | High-level | Ready-made playback control — play, pause, resume, seek, volume, and rate with no manual wiring. | Pick `SimplePlayer` when you want to assemble the pipeline yourself; pick `MediaPlayerX` when you want a player engine that already exposes transport controls. Both feed the same bundled `VisioForgeVideoView`, so the texture upload, aspect handling, and vertical flip are identical. ## SimplePlayer — the Media Blocks pipeline The **`SimplePlayer`** scene plays a local video file with the low-level **Media Blocks SDK .NET** and renders it into a `RawImage`. ### Run the SimplePlayer scene 1. In the **Project** window open `Assets/Scenes/SimplePlayer.unity` (double-click it). 2. In the **Hierarchy** select the **RawImage** GameObject. The `MediaBlocksPlayer` component is attached to it. 3. In the **Inspector**, set **File Path** to an absolute path to a local media file. 4. Press **▶ Play** — the video appears in the Game view and audio plays through the system default device. The RawImage is blank until you press Play The video texture is created at runtime, so the `RawImage` shows nothing in edit mode. ### Inspector fields (MediaBlocksPlayer) | Field | Default | Description | | --- | --- | --- | | **File Path** | `C:\Samples\!video.avi` | Absolute path to the media file to play. | | **Auto Play On Start** | `true` | Start playback automatically in `Start()`. | | **Render Audio** | `true` | Render audio through the system default device. | | **Use Test Pattern** | `false` | Play a synthetic test pattern instead of the file (diagnostic baseline). | | **Aspect Mode** | `Letterbox` | How the video is fitted into the `RawImage`: `Stretch`, `Letterbox`, or `Crop`. | ### The SimplePlayer pipeline `MediaBlocksPlayer` builds this pipeline: ``` graph LR; src[UniversalSourceBlock] -->|video| sink["BufferSinkBlock (RGBA)"]; sink --> view["VisioForgeVideoView (Texture2D)"]; src -->|audio, optional| audio[AudioRendererBlock]; ``` The core of `PlayAsync`: ``` _pipeline = new MediaBlocksPipeline(); _videoSink = new BufferSinkBlock(VideoFormatX.RGBA); _videoSink.OnVideoFrameBuffer += _videoView.OnFrameBuffer; // ignoreMediaInfoReader:true skips the media pre-probe (it can fail under the Unity // runtime); the codec is negotiated when the pipeline starts. var settings = await UniversalSourceSettings.CreateAsync( filePath, renderVideo: true, renderAudio: _renderAudio, ignoreMediaInfoReader: true); _source = new UniversalSourceBlock(settings); _pipeline.Connect(_source.VideoOutput, _videoSink.Input); if (_renderAudio && _source.AudioOutput != null) { _audioRenderer = new AudioRendererBlock(); _pipeline.Connect(_source.AudioOutput, _audioRenderer.Input); } await _pipeline.StartAsync(); ``` `UniversalSourceBlock` auto-detects the container and codec. The audio branch is connected only when the file has an audio stream (`_source.AudioOutput != null`). ## MediaPlayerX — the MediaPlayerCoreX engine The **`MediaPlayerX`** scene plays the same files and URLs with the high-level **`MediaPlayerCoreX`** engine. Unlike the hand-built `SimplePlayer` pipeline, `MediaPlayerCoreX` gives you ready-made playback control — play, pause, resume, seek, volume, and playback rate — with no manual pipeline wiring. ### The OnVideoFrameUnity event `MediaPlayerCoreX`, `VideoCaptureCoreX`, and `VideoEditCoreX` expose a Unity-only event, **`OnVideoFrameUnity`**, that delivers each preview frame as tightly packed **RGBA32** (`Stride == Width * 4`, no row padding). It is uploaded straight into a `Texture2D` with no pixel conversion. Subscribe to it before opening the source so the engine wires its internal frame grabber into the pipeline. ### Run the MediaPlayerX scene 1. In the **Project** window open `Assets/Scenes/SampleScene.unity`. 2. In the **Hierarchy** select the **RawImage** GameObject — the `MediaPlayerXPlayer` component is attached to it. 3. In the **Inspector**, set **File Path** to an absolute path or a URL. 4. Press **▶ Play** — the video appears in the Game view and audio plays through the default device. ### Inspector fields (MediaPlayerXPlayer) | Field | Default | Description | | --- | --- | --- | | **File Path** | `C:\Samples\!video.mp4` | Absolute path, or a `file`/`http`/`https`/`rtsp`/`hls` URL. | | **Auto Play On Start** | `true` | Start playback automatically in `Start()`. | | **Render Audio** | `true` | Render audio through the system default output device. | | **Volume** | `1.0` | Initial audio volume (0..1). | | **Aspect Mode** | `Letterbox` | How the video is fitted into the `RawImage`: `Stretch`, `Letterbox`, or `Crop`. | ### The MediaPlayerX pipeline ``` graph LR; player["MediaPlayerCoreX (headless)"] -->|OnVideoFrameUnity, RGBA32| view["VisioForgeVideoView (Texture2D)"]; player -->|audio| out["Audio output device"]; ``` The core of `PlayAsync`: ``` _player = new MediaPlayerCoreX(); // Texture-ready RGBA32 frames straight into the view. _player.OnVideoFrameUnity += _videoView.OnFrameBuffer; // MediaPlayerCoreX only renders audio when an output device is set. var outputs = await _player.Audio_OutputDevicesAsync(); if (outputs != null && outputs.Length > 0) { _player.Audio_OutputDevice = new AudioRendererSettings(outputs[0]); _player.Audio_OutputDevice_Volume = 1.0; } // ignoreMediaInfoReader:true skips the media pre-probe (it can fail under the Unity runtime). var source = await UniversalSourceSettings.CreateAsync( filePath, renderVideo: true, renderAudio: true, renderSubtitle: false, deepDiscovery: false, ignoreMediaInfoReader: true); await _player.OpenAsync(source); await _player.PlayAsync(); ``` `PauseAsync`, `ResumeAsync`, and `Position_SetAsync(TimeSpan)` give you transport control; the sample exposes them as `PauseAsync()`, `ResumeAsync()`, and `SeekAsync(position)`. ## Use it in your own scene You do not have to use a sample scene: 1. Add a **Canvas → Raw Image** (*GameObject → UI → Raw Image*). 2. Select the **Raw Image** and **Add Component →** `MediaBlocksPlayer` (Media Blocks pipeline) or `MediaPlayerXPlayer` (MediaPlayerCoreX engine). 3. Set **File Path** and press **▶ Play**. The aspect handling (`Stretch` / `Letterbox` / `Crop`), the `RawImage` layout, and the vertical flip are handled for you by the bundled `VisioForgeVideoView` — you do not write any texture code. To switch the same GameObject to RTSP playback, use `RTSPViewerPlayer` or `IPCameraXViewer` (see [View an RTSP camera](../rtsp-viewer/)). ## Per-platform Build Settings Both scenes run unchanged on every supported platform. Switch Build Target and apply the matching settings: WindowsAndroidmacOSiOS | Setting | Value | | --- | --- | | Architecture | x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | Local file paths use the standard Windows form (`C:\Samples\video.mp4`). See [Build for Windows](../windows/) for the full checklist. | Setting | Value | | --- | --- | | Architecture | arm64-v8a (**uncheck ARMv7**) | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | **IL2CPP** (mandatory) | | Internet Access | Require (for network URLs) | Local files live under `Application.persistentDataPath` or `Application.streamingAssetsPath` — absolute Windows paths are not portable. To read media from external storage, declare `READ_MEDIA_VIDEO` / `READ_MEDIA_AUDIO` in `AndroidManifest.xml`. See [Build for Android](../android/) for the full checklist. | Setting | Value | | --- | --- | | Architecture | Universal arm64 + x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | Local file paths use Unix form (`/Users//Movies/video.mp4`). See [Build for macOS](../macos/) for code-signing and notarization notes. | Setting | Value | | --- | --- | | Architecture | device arm64 (Simulator not supported) | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | **IL2CPP** (mandatory) | | App Transport Security | Add an ATS exception for plain-HTTP/RTSP URLs | Local files must live inside the app sandbox — typically `Application.persistentDataPath` (the Documents folder) or `Application.streamingAssetsPath` (read-only inside the `.app` bundle). See [Build for iOS](../ios/) for the Xcode workflow. ## Frequently Asked Questions ### Which scene should I use — SimplePlayer or MediaPlayerX? Use **`SimplePlayer`** (`MediaBlocksPipeline`) when you want to build the pipeline yourself — add effects, multiple sinks, recording, or custom sources. Use **`MediaPlayerX`** (`MediaPlayerCoreX`) when you want a player engine that already provides seeking, pause/resume, duration, audio device selection, and rate control as ready-made methods. ### Which video and audio formats can it play? The package bundles FFmpeg/libav, so common formats decode out of the box — MP4, MKV, AVI, MOV with H.264/H.265, MPEG-4, plus MP3/AAC audio, among others. Both engines auto-detect the format. ### Can it play network streams? Yes. `MediaPlayerX` takes an `http`/`https`/`rtsp`/`hls` URL directly in **File Path** (`UniversalSourceSettings` handles both local files and URLs). `SimplePlayer` plays local files; for a dedicated live-camera pipeline use [View an RTSP camera](../rtsp-viewer/). ### How do I seek or pause? On `MediaPlayerX`, call `SeekAsync(TimeSpan)`, `PauseAsync()`, and `ResumeAsync()` on the component — they wrap `Position_SetAsync`, `PauseAsync`, and `ResumeAsync` on `MediaPlayerCoreX`. The low-level `SimplePlayer` does not expose transport controls; rebuild the pipeline to change source. ### Why does MediaPlayerX need an audio output device set? `MediaPlayerCoreX` renders audio only when `Audio_OutputDevice` is set. The sample enumerates output devices with `Audio_OutputDevicesAsync()` and selects the first one. `SimplePlayer` instead routes audio through an `AudioRendererBlock`. ### How do I control how the video fits the RawImage? Use the **Aspect Mode** field on either component: `Stretch` (fill, may distort), `Letterbox` (fit with bars), or `Crop` (fill and crop the overflow). ## See Also - [Using VisioForge in Unity](../) — package overview, setup, and how rendering works - [View an RTSP camera in Unity](../rtsp-viewer/) — the live RTSP / IP camera scenes - [Capture a webcam in Unity](../video-capture-x/) — the VideoCaptureCoreX recorder sample - [Edit and render in Unity](../video-edit-x/) — the VideoEditCoreX timeline sample - [Media Blocks SDK .NET overview](../../../mediablocks/) — the full block catalog ---END OF PAGE--- ## Troubleshoot the Media Blocks SDK in Unity — Common Errors **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/troubleshooting/ **Description:** Common errors and fixes for the VisioForge Media Blocks SDK .NET in Unity 6 — bootstrap, missing natives, IL2CPP, TLS and Editor lifecycle. **Tags:** Media Blocks SDK, .NET, Unity, Troubleshooting, Windows, Android, macOS, iOS, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline # Troubleshooting [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) This page collects the symptoms you are most likely to hit and the root cause for each. Errors are grouped by category. The per-platform pages ([Windows](../windows/), [Android](../android/), [macOS](../macos/), [iOS](../ios/)) also have a target-specific Troubleshooting table — check both. ## Bootstrap and initialization ### `[VisioForge] Native runtime not found at ` `VisioForgeEnvironment.Configure()` could not find the bundled natives folder on disk. Causes: - The `.unitypackage` import was partial. Re-import with all items checked. - On Standalone macOS, the Build Target did not include the macOS flavor — the package was built without `-IncludeMacOS`. Re-build the package or import the cumulative variant. - On Android, the per-Build-Target flavor staging step did not run. Open `Assets/Plugins/Android/libs/arm64-v8a/` in the Project window and confirm `libgstreamer_android.so` is present. ### `[VisioForge] InitializeSdk() called before Configure() succeeded` A platform branch of `Configure()` failed and left `s_envConfigured = false`. The earlier Console line (`[VisioForge] Android GStreamer init failed: …`, `[VisioForge] SetDllDirectoryW failed (Win32 error …)`, etc.) explains why. Fix the underlying issue and let `Configure()` retry on the next scene load. ### `UnityException: get_dataPath can only be called from the main thread` A background thread inside the SDK or your script read `Application.dataPath` (or `Application.streamingAssetsPath`, or `Application.platform`) without going through the cached path. The fix: - On iOS, `Configure()` primes `s_cachedNativesPath` on the main thread — confirm the Console shows `[VisioForge] iOS environment configured (GStreamerX.framework via @rpath).`. If absent, the bootstrap aborted before priming and the next reader hits the lazy path off the main thread. - In your own code, do not call Unity API from a `Task.Run`, GStreamer pad-added callback, or bus signal handler. Marshal the call back to the main thread with `UnitySynchronizationContext` or by setting a flag the `Update()` method checks. ### `InvalidOperationException: Unity Android bootstrap requires com.unity3d.player.UnityPlayer.currentActivity to be available` The Android Java bootstrap could not get a non-null `currentActivity` at `BeforeSceneLoad`. Happens on Wear OS, Android TV variants without `UnityPlayerActivity`, and Unity-as-a-library hosts that have not assigned the field yet. Defer `Configure()` to your first observable Activity event: ``` private void Start() { if (!VisioForgeIsConfigured()) VisioForgeEnvironment.Configure(); // re-run after Activity is ready VisioForgeEnvironment.InitializeSdk(); } ``` `Configure()` is idempotent — a redundant call after a successful one is harmless. ## Missing libraries ### `DllNotFoundException: gstreamer-1.0-0` Windows: the natives folder is missing from `Assets/StreamingAssets/VisioForge/x64/`. Re-import the package. If you are running a Standalone build, confirm `_Data/StreamingAssets/VisioForge/x64/` is also populated — Unity copies it verbatim, so a missing folder in the build means it was missing in the project. ### `DllNotFoundException: libgstreamer_android` Android: Scripting Backend is set to **Mono**. Switch to **IL2CPP** under Project Settings → Player → Other Settings → Configuration. Mono is not supported on Android by Unity itself. ### `DllNotFoundException: libgstreamer-1.0.0` *(macOS)* The `.app` bundle does not contain `libgstreamer-1.0.0.dylib` at any of the probed locations (`Contents/PlugIns`, `Contents/PlugIns/macOS`, `Contents/Frameworks`, `Contents/Resources/Data/Plugins/macOS`). Re-build the package with `-IncludeMacOS` and re-export the Standalone build. ### `dyld: Library not loaded: @rpath/GStreamerX.framework/GStreamerX` iOS: the framework's PluginImporter slot did not get **Add To Embedded Binaries = YES**. Re-import the package; the package's `.meta` file marks the framework correctly. If you replaced the framework manually, restore the `.meta` from a fresh import. ## IL2CPP / managed stripping ### `MissingMethodException: GLib.SignalArgs..ctor` *(or similar GStreamer / GLib types)* IL2CPP stripped a managed type the SDK references through reflection. `Assets/VisioForge/link.xml` preserves these types — confirm the file exists in your project. If you accidentally deleted it, re-import the `.unitypackage`. Do **not** edit `link.xml` to remove rules; the package ships a tested set. ### `MarshalDirectiveException` at the first SDK call A `[DllImport]` signature was stripped or its delegate marshalling failed. Same root cause as `MissingMethodException` — confirm `link.xml` is in place and IL2CPP is not configured with an extra-aggressive stripping level that overrides it. ## TLS / network ### RTSP stream times out before connecting *(iOS 14+)* iOS blocks the first connection attempt to any local-network address until your `Info.plist` declares why your app needs LAN access. Add: ``` NSLocalNetworkUsageDescription This app streams video from local IP cameras on your network. ``` App Store reviewers expect a user-facing reason, not boilerplate. ### RTSPS / HTTPS fails with TLS / certificate verification error GIO's OpenSSL TLS backend could not find a CA bundle: - Windows / macOS: `Configure()` sets `SSL_CERT_FILE` to the bundled `ca-certificates.crt`. If missing, the Console logs `[VisioForge] CA certificate bundle not found at …`. Re-stage the natives via `deploy-unity-natives.ps1` and re-build. - Android / iOS: the CA bundle is an embedded managed resource extracted to `/ssl/certs/`. If extraction fails, the Console logs `[VisioForge] CA cert extraction failed`. Confirm `VisioForge.Core.dll` is in `Assets/Plugins/Android/` (Android) or `Assets/Plugins/iOS/Managed/` (iOS). For self-signed certificates, either install them into the system trust store (out of scope for the SDK) or — for testing only — disable peer verification on the source block. The block-level property name varies; see [View an RTSP camera in Unity](../rtsp-viewer/) for the RTSP example. ### Plain `http://` URLs fail on iOS App Transport Security (ATS) blocks `http://` by default. Either move to `https://` or, if you must keep `http://`, add `NSAppTransportSecurity → NSAllowsArbitraryLoads = YES` to your `Info.plist`. Be aware that App Store reviewers may ask why you need it. ## Editor lifecycle ### Editor hangs on "Reloading domain" after Play / Stop Disable Domain Reload is off. Re-enable it under Project Settings → Editor → Enter Play Mode Settings → set **When entering Play Mode** to **Reload Scene only** or **Do not reload Domain or Scene**. The package's one-time setup dialog configures this for you; if you clicked **Skip**, set it manually. ### Editor crashes on the second Play The SDK was shut down on Stop and re-initialized on Play. The fix: - Do not call `VisioForgeX.DestroySDK()` in `OnDestroy` or anywhere else. The SDK is process-global and reused across Play sessions. - The sample players (`MediaBlocksPlayer`, `RTSPViewerPlayer`) follow this pattern — copy their teardown shape (dispose only the per-play pipeline; never destroy the SDK). See [Bootstrap and lifecycle](../bootstrap/#the-editor-lifecycle) for the full explanation. ### Editor becomes unstable after a long editing session Repeated script recompiles accumulate GStreamer state across domain reloads. Restart the Editor to recover. This is mostly cosmetic — Standalone Player builds do not exhibit it. ## Build / packaging ### Bundle launched from Finder shows "Damaged app" *(macOS)* The `.app` is unsigned and downloaded with the quarantine flag set. For distribution, sign and notarize the bundle (see [Build for macOS](../macos/#code-signing-and-notarization)). For local testing only, run `xattr -d com.apple.quarantine ` once. ### App rejected from App Store review for "missing privacy reason" *(iOS)* A capture source needs an explicit `Info.plist` key: - `NSCameraUsageDescription` if your app captures from the camera - `NSMicrophoneUsageDescription` if your app captures from the microphone - `NSLocalNetworkUsageDescription` if your app talks to a LAN device The user-facing string should describe the actual use, not "Required by SDK". ### `[VisioForge] Native runtime folder not found at '…' for runtime platform …` The `.unitypackage` you imported does not contain a flavor for the current Build Target. For example, a Windows-only package opened in a Mac-host Editor surfaces this on the first `InitializeSdk()` call. Re-build (or re-download) the package with the matching `-Include*` switch, or import the cumulative variant that contains every platform. ## When all else fails Collect a log and contact support: 1. Editor or Player Console export (`Window → General → Console`, right-click → Save All / via Logcat / via Xcode → Devices → Open Console). 2. The `.unitypackage` file name and its build date. 3. Unity version, Build Target, Scripting Backend, Api Compatibility Level. 4. A minimal reproducible scene if possible. Open an issue at . ## See also - [Bootstrap and lifecycle](../bootstrap/) — how the runtime is brought up on each platform - [Build for Windows](../windows/) · [Android](../android/) · [macOS](../macos/) · [iOS](../ios/) — per-platform troubleshooting tables - [Platform matrix](../platform-matrix/) — feature support by Unity platform ---END OF PAGE--- ## Capture Webcam Video in Unity with VideoCaptureCoreX **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/video-capture-x/ **Description:** Capture a webcam and microphone in Unity 6 with VideoCaptureCoreX — live preview into a RawImage via OnVideoFrameUnity plus MP4 recording to disk. **Tags:** Video Capture SDK, Media Blocks SDK, .NET, Unity, Windows, macOS, Capture, C# **API:** VideoCaptureCoreX, VideoCaptureDeviceSourceSettings, MP4Output, DeviceEnumerator, MediaBlocksPipeline, SystemVideoSourceBlock, BufferSinkBlock # Capture a webcam in Unity with VideoCaptureCoreX [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The **`VideoCaptureX`** scene captures from a local webcam (and microphone) with the high-level **`VideoCaptureCoreX`** engine, previews the live frames into a Unity `RawImage`, and records to an MP4 file at the same time. You can also capture a webcam with the low-level **`MediaBlocksPipeline`** API — that recipe is in [Capture with the Media Blocks pipeline](#capture-with-the-media-blocks-pipeline-low-level) below. This article assumes you have imported the Unity package and applied the required project settings; see [Using VisioForge in Unity](../) first. Platform support for local-camera capture Local webcam/microphone capture in the Unity package targets **Windows** and **macOS Standalone** in this release. On **Android** and **iOS**, use the [IP / RTSP camera sample](../rtsp-viewer/) — `VideoCaptureCoreX` over RTSP works on all four platforms. Local device capture on Android/iOS depends on platform camera APIs that are not yet wired into the cross-platform package. ## The OnVideoFrameUnity event `VideoCaptureCoreX` exposes the Unity-only **`OnVideoFrameUnity`** event: each frame arrives as tightly packed **RGBA32** (`Stride == Width * 4`), ready for `Texture2D.LoadRawTextureData` with no conversion. Subscribe before `StartAsync`. ## Run the sample 1. Connect a webcam, then open `Assets/Scenes/SampleScene.unity`. 2. In the **Hierarchy** select the **RawImage** GameObject — the `VideoCaptureXRecorder` component is attached to it. 3. In the **Inspector** set **Camera Index** and the **Output Path**. 4. Press **▶ Play** — the live camera renders into the Game view. Toggle recording with `StartRecordingAsync()` / `StopRecordingAsync()` (for example from a UI button). ## Inspector fields | Field | Default | Description | | --- | --- | --- | | **Camera Index** | `0` | Index into `DeviceEnumerator.VideoSourcesAsync()`. | | **Capture Audio** | `true` | Capture and record audio from the default microphone. | | **Record On Start** | `false` | Begin recording to file as soon as preview starts. | | **Output Path** | *(empty)* | MP4 path. Empty → `/capture.mp4`. | | **Aspect Mode** | `Letterbox` | How the video is fitted into the `RawImage`. | ## The pipeline ``` graph LR; cap["VideoCaptureCoreX (headless)"] -->|OnVideoFrameUnity, RGBA32| view["VisioForgeVideoView (Texture2D)"]; cap -->|record| mp4["MP4Output (H264 + AAC)"]; ``` The core of the preview + record setup: ``` var cameras = await DeviceEnumerator.Shared.VideoSourcesAsync(); _capture = new VideoCaptureCoreX(); _capture.Video_Source = new VideoCaptureDeviceSourceSettings(cameras[cameraIndex]); var audioSources = await DeviceEnumerator.Shared.AudioSourcesAsync(); if (audioSources.Length > 0) _capture.Audio_Source = audioSources[0].CreateSourceSettingsVC(); // Texture-ready RGBA32 frames straight into the view. _capture.OnVideoFrameUnity += _videoView.OnFrameBuffer; // Pre-register the MP4 output (autostart:false) so preview runs without recording. _capture.Outputs_Add(new MP4Output(outputPath), autostart: false); await _capture.StartAsync(); ``` Recording is toggled at runtime so the preview keeps running independently of capture-to-file: ``` await _capture.StartCaptureAsync(0, outputPath); // begin recording await _capture.StopCaptureAsync(0); // stop recording ``` ## Capture with the Media Blocks pipeline (low-level) `VideoCaptureCoreX` is the high-level engine. For full control over the pipeline you can capture the same webcam with the low-level **`MediaBlocksPipeline`** API — the approach the [SimplePlayer / RTSPViewer scenes](../simple-player/) use. There is no prebuilt webcam scene for this path; add the recipe below to your own `MonoBehaviour` (model it on the bundled `MediaBlocksPlayer`): A `TeeBlock` splits the camera video so it feeds the preview (`BufferSinkBlock`) and the recording (`MP4OutputBlock`, which bundles the H.264 + AAC encoders and the MP4 muxer) at the same time. The microphone is added straight to the MP4 output: ``` graph LR; cam[SystemVideoSourceBlock] --> tee[TeeBlock]; tee -->|preview| sink["BufferSinkBlock (RGBA)"]; sink --> view["VisioForgeVideoView (Texture2D)"]; tee -->|record| mp4["MP4OutputBlock (H264 + AAC)"]; mic[SystemAudioSourceBlock] -->|record| mp4; ``` ``` _pipeline = new MediaBlocksPipeline(); // Capture sources var cameras = await DeviceEnumerator.Shared.VideoSourcesAsync(); var videoSource = new SystemVideoSourceBlock(new VideoCaptureDeviceSourceSettings(cameras[cameraIndex])); var mics = await DeviceEnumerator.Shared.AudioSourcesAsync(); var audioSource = new SystemAudioSourceBlock(mics[0].CreateSourceSettings()); // Preview: tightly packed RGBA frames into the Unity view var videoSink = new BufferSinkBlock(VideoFormatX.RGBA); videoSink.OnVideoFrameBuffer += _videoView.OnFrameBuffer; // Record: H.264 video + AAC audio muxed to MP4 var mp4 = new MP4OutputBlock(outputPath); // Tee the camera video to both the preview sink and the recording var videoTee = new TeeBlock(2, MediaBlockPadMediaType.Video); _pipeline.Connect(videoSource, videoTee); // Preview branch — one tee output to the buffer sink _pipeline.Connect(videoTee.Outputs[0], videoSink.Input); // Record branch — MP4OutputBlock has no fixed inputs; call CreateNewInput once per stream _pipeline.Connect(videoTee.Outputs[1], mp4.CreateNewInput(MediaBlockPadMediaType.Video)); _pipeline.Connect(audioSource.Output, mp4.CreateNewInput(MediaBlockPadMediaType.Audio)); await _pipeline.StartAsync(); // preview + recording both run ``` `MP4OutputBlock` starts with no input pads — each `CreateNewInput(MediaBlockPadMediaType.Video|Audio)` call adds a typed input wired to the internal H.264 / AAC encoder, so create exactly one per stream. `BufferSinkBlock.OnVideoFrameBuffer` has the same `VisioForgeVideoView.OnFrameBuffer` signature as the engine's `OnVideoFrameUnity`, so the same view renders the preview. Drop the `videoTee` / `MP4OutputBlock` / audio branch to preview only; or use the high-level `VideoCaptureCoreX` path above, which lets you start and stop recording at runtime without rebuilding the pipeline. This low-level path uses the same device source as the engine, so local-camera capture has the same **Windows / macOS** scope. ## Per-platform Build Settings WindowsmacOS | Setting | Value | | --- | --- | | Architecture | x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | No manifest entry is required for camera access. See [Build for Windows](../windows/). | Setting | Value | | --- | --- | | Architecture | Universal arm64 + x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | | Privacy | Add camera + microphone usage descriptions / entitlements | The camera is selected through `avfvideosrc`. See [Build for macOS](../macos/). ## Frequently Asked Questions ### How do I record to a file? The sample pre-registers an `MP4Output` and toggles capture with `StartCaptureAsync(0, path)` / `StopCaptureAsync(0)`, so the live preview runs whether or not you are recording. ### Can I capture from a local camera on Android or iOS? Not in this release. Use the [IP / RTSP camera sample](../rtsp-viewer/) on mobile — `VideoCaptureCoreX` over RTSP works on all four platforms. Local device capture on Android/iOS is planned for a future package. ### How do I pick a specific camera? Set **Camera Index** to the device's position in `DeviceEnumerator.Shared.VideoSourcesAsync()`. ### Which encoders does it record with? `MP4Output` defaults to H.264 video + AAC audio. Adjust the `MP4Output` settings for custom encoders. ## See Also - [Using VisioForge in Unity](../) — package overview, setup, and how rendering works - [View an IP / RTSP camera in Unity](../rtsp-viewer/) — `VideoCaptureCoreX` over RTSP (all platforms) - [Play media in Unity with MediaPlayerCoreX](../simple-player/) — the high-level player sample - [Edit and render in Unity](../video-edit-x/) — the VideoEditCoreX timeline sample ---END OF PAGE--- ## Edit and Render Video in Unity with VideoEditCoreX **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/video-edit-x/ **Description:** Combine clips, apply effects, and render to MP4 in Unity 6 with VideoEditCoreX — timeline preview into a RawImage via OnVideoFrameUnity, plus file rendering. **Tags:** Video Edit SDK, .NET, Unity, Windows, Android, macOS, iOS, Editing, C# **API:** VideoEditCoreX, MP4Output, GrayscaleVideoEffect # Edit and render video in Unity with VideoEditCoreX [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) The **`VideoEditX`** scene combines clips on a **`VideoEditCoreX`** timeline, optionally applies a grayscale effect, and either **previews** the timeline into a Unity `RawImage` or **renders** it to an MP4 file. This article assumes you have imported the Unity package and applied the required project settings; see [Using VisioForge in Unity](../) first. ## The OnVideoFrameUnity event `VideoEditCoreX` previews the timeline into Unity through the Unity-only **`OnVideoFrameUnity`** event. Because the engine is built on GStreamer Editing Services, the sample redirects the preview video sink to an internal RGBA frame grabber when the event is subscribed and no output file is set. Frames are tightly packed **RGBA32** (`Stride == Width * 4`), ready for `Texture2D.LoadRawTextureData`. In **render** mode (an output file is set) the event is inactive — the timeline is encoded to disk as fast as the host allows. ## Run the sample 1. Open `Assets/Scenes/SampleScene.unity`. 2. In the **Hierarchy** select the **RawImage** GameObject — the `VideoEditXRenderer` component is attached to it. 3. In the **Inspector** set **Clip 1** and **Clip 2** to local files. 4. Leave **Render To File On Start** off to **preview** the timeline, or enable it to **render** an MP4. Press **▶ Play**. ## Inspector fields | Field | Default | Description | | --- | --- | --- | | **Clip 1** | `C:\Samples\clip1.mp4` | First clip (absolute path). | | **Clip 2** | `C:\Samples\clip2.mp4` | Second clip; leave empty for a single clip. | | **Grayscale** | `true` | Apply a grayscale video effect to the timeline. | | **Render To File On Start** | `false` | Render to file on `Start()`; off = preview into the texture. | | **Output Path** | *(empty)* | MP4 path for render mode. Empty → `/edited.mp4`. | | **Output Width / Height** | `1920` / `1080` | Output resolution for render mode. | | **Output Frame Rate** | `30` | Output frame rate for render mode. | | **Aspect Mode** | `Letterbox` | How the preview is fitted into the `RawImage`. | ## The pipeline ``` graph LR; clips["Clips + GrayscaleVideoEffect"] --> edit["VideoEditCoreX timeline"]; edit -->|preview, OnVideoFrameUnity RGBA32| view["VisioForgeVideoView (Texture2D)"]; edit -->|render| mp4["MP4Output (H264 + AAC)"]; ``` The core of the build + run: ``` // VideoEditCoreX is built on GStreamer Editing Services — initialize GES once. VideoEditCoreX.SDKInit(); _editor = new VideoEditCoreX(); _editor.Input_AddAudioVideoFile(clip1); _editor.Input_AddAudioVideoFile(clip2); if (grayscale) _editor.Video_Effects.Add(new GrayscaleVideoEffect()); if (renderToFile) { _editor.Output_VideoSize = new Size(1920, 1080); _editor.Output_VideoFrameRate = new VideoFrameRate(30.0); _editor.Output_Format = new MP4Output(outputPath); } else { // Preview mode: no Output_Format → the timeline plays into the OnVideoFrameUnity grabber. _editor.OnVideoFrameUnity += _videoView.OnFrameBuffer; _editor.Output_Format = null; } _editor.Start(); ``` In render mode, subscribe to `OnProgress` for progress percentages and `OnStop` for completion. ## Per-platform Build Settings WindowsAndroidmacOSiOS | Setting | Value | | --- | --- | | Architecture | x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | See [Build for Windows](../windows/). | Setting | Value | | --- | --- | | Architecture | arm64-v8a (**uncheck ARMv7**) | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | **IL2CPP** (mandatory) | Clips must live under `Application.persistentDataPath`. See [Build for Android](../android/). | Setting | Value | | --- | --- | | Architecture | Universal arm64 + x86\_64 | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | Mono *(default)* or IL2CPP | See [Build for macOS](../macos/). | Setting | Value | | --- | --- | | Architecture | device arm64 (Simulator not supported) | | Api Compatibility Level | `.NET Standard 2.1` | | Scripting Backend | **IL2CPP** (mandatory) | Clips and output must live inside the app sandbox. See [Build for iOS](../ios/). ## Frequently Asked Questions ### What is the difference between preview and render mode? Preview (no `Output_Format`) plays the timeline live into the `RawImage` through `OnVideoFrameUnity`. Render (`Output_Format` set to an `MP4Output`) encodes the timeline to a file as fast as the host allows; live preview is not produced during a render. ### Do I need a separate SDK init call? Yes. Call `VideoEditCoreX.SDKInit()` once (in addition to the package's `VisioForgeEnvironment.InitializeSdk()`) — it initializes GStreamer Editing Services. ### How do I add more clips or effects? Call `Input_AddAudioVideoFile` for each clip and add more entries to `Video_Effects`. The sample uses a single `GrayscaleVideoEffect` for illustration. ### How do I know when a render finishes? Subscribe to `OnStop`; subscribe to `OnProgress` for progress updates while rendering. ## See Also - [Using VisioForge in Unity](../) — package overview, setup, and how rendering works - [Play media in Unity with MediaPlayerCoreX](../simple-player/) — the high-level player sample - [Capture a webcam in Unity](../video-capture-x/) — the VideoCaptureCoreX recorder sample - [View an IP / RTSP camera in Unity](../rtsp-viewer/) — `VideoCaptureCoreX` over RTSP ---END OF PAGE--- ## Build a Unity Game with Video Playback for Windows x64 **URL:** https://www.visioforge.com/help/docs/dotnet/general/unity/windows/ **Description:** Build settings, native runtime layout, and troubleshooting for the VisioForge Media Blocks SDK .NET in Unity 6 on Windows x64 — Editor and Standalone Player. **Tags:** Media Blocks SDK, .NET, Unity, Windows, Standalone Player, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline # Build for Windows [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) Windows x64 is the baseline target for the Unity package — it ships in every `.unitypackage` variant the build pipeline produces. This page covers the Player Settings, the on-disk layout, and the issues you might hit on Windows specifically. For the rest, see [Bootstrap and lifecycle](../bootstrap/). ## Player Settings | Setting | Value | Where | | --- | --- | --- | | Architecture | **x86\_64** | File → Build Profiles → Windows | | Target Platform | **Windows** | File → Build Profiles → Windows | | Api Compatibility Level | **.NET Standard 2.1** | Project Settings → Player → Other Settings → Configuration | | Scripting Backend | **Mono** *(IL2CPP also works; Mono is the default on Windows)* | Project Settings → Player → Other Settings → Configuration | | Enter Play Mode → Reload Domain | **Off** | Project Settings → Editor → Enter Play Mode Settings | If you imported the package with the **Apply** dialog, the two mandatory project settings (`.NET Standard 2.1` plus Disable Domain Reload) are already in place. ## On-disk layout The `deploy-unity-natives.ps1` build step stages the Windows runtime into your project as follows: | Path | Contents | | --- | --- | | `Assets/StreamingAssets/VisioForge/x64/` | Flat layout: core GStreamer libs, every plugin DLL, GIO modules, `ca-certificates.crt`. ~300 files. | | `Assets/Plugins/` | Managed assemblies (`VisioForge.Core.dll`, `VisioForge.Libs.dll`, `GstSharp.dll`, `GLibSharp.dll`, etc.) with their `.meta`. | | `Assets/Scripts/` | The shared helpers (`VisioForgeEnvironment.cs`, `VisioForgeVideoView.cs`) plus the six sample scripts (`MediaBlocksPlayer.cs`, `RTSPViewerPlayer.cs`, `MediaPlayerXPlayer.cs`, `IPCameraXViewer.cs`, `VideoCaptureXRecorder.cs`, `VideoEditXRenderer.cs`). | | `Assets/Scenes/` | The six sample scenes: `SimplePlayer.unity`, `RTSPViewer.unity`, `MediaPlayerX.unity`, `IPCameraX.unity`, `VideoCaptureX.unity`, `VideoEditX.unity`. | `StreamingAssets` (not `Plugins/x64`) is used because Unity copies the folder verbatim into a Standalone build, which is exactly what `VisioForgeEnvironment.Configure()` then points the DLL loader at. The same path resolves in both the Editor and the player — `Application.streamingAssetsPath` returns the project's `Assets/StreamingAssets` in the Editor and `_Data/StreamingAssets` in the player. ## Standalone Player build **File → Build Profiles → Windows → x86\_64 → Build** produces a self-contained player. No extra steps: - Unity copies `Assets/StreamingAssets/VisioForge/x64/` into `_Data/StreamingAssets/VisioForge/x64/` automatically. - The managed plugins from `Assets/Plugins/` are staged into `_Data/Managed/`. - `VisioForgeEnvironment.Configure()` runs `BeforeSceneLoad` and points `SetDllDirectoryW` at the staged natives folder. The resulting `.exe` plus its `_Data/` folder is the entire shippable artifact. ## On-disk size The Windows runtime adds roughly **50 MB** of native libraries to your build (down to ~30 MB if you exclude libav with `-SkipLibav` when rebuilding the package). The managed assemblies add another ~5 MB. ## Troubleshooting | Symptom | Cause | Fix | | --- | --- | --- | | `DllNotFoundException: gstreamer-1.0-0` on Play | `Assets/StreamingAssets/VisioForge/x64/` is missing or empty. | Re-import the `.unitypackage` with all items checked, or check the `[VisioForge] Native runtime not found at …` Console line for the resolved path. | | Pipeline hangs at startup, log shows two `gst_init` calls | A system GStreamer install on `PATH` is loading a second copy of `gstreamer-1.0-0.dll`. | `Configure()` already prunes `PATH` — confirm by inspecting the Console: stripped-count is logged. If the count is 0 but you still see the symptom, an external launcher is re-injecting GStreamer after `Configure()`. | | `TypeLoadException` at first SDK call | Api Compatibility Level is `.NET Framework` instead of `.NET Standard 2.1`. | Set it to `.NET Standard 2.1` (Project Settings → Player → Other Settings → Configuration → Api Compatibility Level). | | RTSPS / HTTPS streams fail to connect with TLS error | `SSL_CERT_FILE` not pointing at the bundled CA bundle. | `Configure()` sets it when `ca-certificates.crt` is present in the natives folder. A missing CA bundle is logged as a warning — re-stage the runtime via `deploy-unity-natives.ps1`. | | Editor hangs on "Reloading domain" after Play/Stop | Disable Domain Reload was turned back on. | Re-enable it under Project Settings → Editor → Enter Play Mode Settings (set **When entering Play Mode** to a non-reloading option). | ## Frequently Asked Questions ### Can I use IL2CPP on Windows? Yes — it compiles and runs. Mono is the default and is what the package's CI build matrix exercises. Switch to IL2CPP only if you have a project-wide reason (other plugins that require it, smaller deployment surface). The same `link.xml` that ships with the package preserves the SDK's managed types from IL2CPP stripping on every backend. ### Does Windows 11 ARM64 work? Not from this `.unitypackage`. The bundled native runtime is x86\_64 only — running it under x64 emulation on ARM64 is unsupported. An ARM64 native build is not part of the current Unity package. ### Does the SDK need administrator rights? No. Everything runs from the project folder / player `_Data` folder. The runtime touches no registry keys, installs no global drivers, and writes only to `Application.persistentDataPath` (for logs / temp files when enabled). ## See also - [Install the Media Blocks SDK in Unity](../../../install/unity/) — package setup - [Bootstrap and lifecycle](../bootstrap/) — how `Configure()` brings up the Windows runtime - [Play a media file in Unity](../simple-player/) — the `SimplePlayer` sample - [View an RTSP camera in Unity](../rtsp-viewer/) — the `RTSPViewer` sample - [Troubleshooting](../troubleshooting/) — common runtime errors across platforms ---END OF PAGE--- ## Video Effects SDK — Add and Configure Effects in .NET C# **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/add/ **Description:** Add and configure video effects in .NET SDK environments for capture, playback, and editing with parameter management and practical C# examples. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, C# **API:** VideoEffectLightness # Implementing Video Effects in .NET SDK Applications Video effects can significantly enhance the visual quality and user experience of your media applications. This guide demonstrates how to properly implement and manage video effects across various .NET SDK environments. [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Implementation Overview When working with video processing in .NET applications, you'll often need to apply various effects to enhance or modify the video content. The following sections explain the process step-by-step. ## C# Code Implementation ### Example: Lightness Effect in Media Player SDK This detailed example demonstrates how to implement a lightness effect, which is a common video enhancement technique. The same implementation approach applies to Video Edit SDK .Net and Video Capture SDK .Net environments. ### Step 1: Define the Effect Interface First, you need to declare the appropriate interface for your desired effect: ``` IVideoEffectLightness lightness; ``` ### Step 2: Retrieve or Create the Effect Instance Each effect requires a unique identifier. The following code checks if the effect already exists in the SDK control: ``` var effect = MediaPlayer1.Video_Effects_Get("Lightness"); ``` ### Step 3: Add the Effect if Not Present If the effect doesn't exist yet, you'll need to instantiate and add it to your video processing pipeline: ``` if (effect == null) { lightness = new VideoEffectLightness(true, 100); MediaPlayer1.Video_Effects_Add(lightness); } ``` ### Step 4: Update Existing Effect Parameters If the effect is already present, you can modify its parameters to achieve the desired visual outcome: ``` else { lightness = effect as IVideoEffectLightness; if (lightness != null) { lightness.Value = 100; } } ``` ## Important Implementation Notes For proper functionality, ensure you enable effects processing before starting video playback or capture: - Set the `Video_Effects_Enabled` property to `true` before calling any `Play()` or `Start()` methods - Effects will not be applied if this property is not enabled - Changing effect parameters during playback will update the visual output in real-time ## System Requirements To successfully implement video effects in your .NET application, you'll need: - SDK redistributable packages properly installed - Sufficient system resources for real-time video processing - Appropriate .NET framework version ## Additional Resources For more advanced implementations and examples of video effect techniques: --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) repository for additional code samples and complete projects. ---END OF PAGE--- ## Video Effects SDK Reference — Filters, Overlays, and More **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/effects-reference/ **Description:** Comprehensive reference guide for all video effects available in VisioForge .NET SDKs including Classic (Windows-only) and Cross-platform effects. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaPlayerCoreX, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Playback, Editing, Effects, Decklink, NDI, GIF, C# **API:** VideoEffect, VideoEffectGrayscale, GPUVideoEffect, GrayscaleVideoEffect, GaussianBlurVideoEffect # Complete Video Effects Reference [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction This document provides a comprehensive reference for all video effects available in VisioForge .NET SDKs. Effects are available in two distinct implementations: ### Effect Types by SDK Engine #### Classic Effects (Windows Only) - **Available in**: VideoCaptureCore, MediaPlayerCore, VideoEditCore - **Platform**: Windows only (.NET Framework 4.7.2+ and .NET 6-10) - **Types**: - `VideoEffect*` - CPU-based processing - `GPUVideoEffect*` - GPU-accelerated (DirectX) - `Maxine*` - NVIDIA AI-powered effects (RTX GPUs) - **Location**: `VisioForge.Core.Types.VideoEffects` namespace #### Cross-Platform Effects - **Available in**: VideoCaptureCoreX, MediaPlayerCoreX, VideoEditCoreX, Media Blocks SDK - **Platform**: Windows, Linux, macOS, Android, iOS - **Types**: - `*VideoEffect` classes in `VisioForge.Core.Types.X.VideoEffects` - Cross-platform processing for universal compatibility - **Location**: `VisioForge.Core.Types.X.VideoEffects` namespace > **Important**: When choosing effects, select based on your target SDK and platform requirements. Cross-platform effects provide broader compatibility, while Classic effects offer Windows-specific optimizations and DirectX GPU acceleration. ## Effect Categories The following sections list all available effects. Each effect includes SDK availability markers: - 🪟 **Classic** = VideoCaptureCore/MediaPlayerCore/VideoEditCore (Windows only) - 🌍 **Cross-platform** = VideoCaptureCoreX/MediaPlayerCoreX/VideoEditCoreX/Media Blocks (Cross-platform) ### Color Adjustment Effects #### Brightness and Darkness | Effect | SDK | Description | | --- | --- | --- | | VideoEffectDarkness | 🪟 Classic | Adjusts overall darkness/lightness. Values above 128 darken, values below lighten the image. | | GPUVideoEffectDarkness | 🪟 Classic (GPU) | GPU-accelerated darkness adjustment. | | GPUVideoEffectBrightness | 🪟 Classic (GPU) | GPU-accelerated brightness adjustment. Adds or subtracts uniform values to RGB components. | | VideoEffectLightness | 🪟 Classic | Adjusts lightness in HSL color space, preserving hue and saturation relationships. | | VideoBalanceVideoEffect | 🌍 Cross-platform | Cross-platform brightness, contrast, saturation, and hue adjustment. | #### Contrast and Color | Effect | SDK | Description | | --- | --- | --- | | VideoEffectContrast | 🪟 Classic | Adjusts the difference between light and dark areas. Supports animated transitions. | | GPUVideoEffectContrast | 🪟 Classic (GPU) | GPU-accelerated contrast adjustment. | | VideoEffectSaturation | 🪟 Classic | Controls color intensity from grayscale (0) to full saturation (255). | | GPUVideoEffectSaturation | 🪟 Classic (GPU) | GPU-accelerated saturation adjustment. | | VideoBalanceVideoEffect | 🌍 Cross-platform | Provides contrast and saturation control (cross-platform). | | GammaVideoEffect | 🌍 Cross-platform | Gamma correction for brightness curve adjustment. | ### Color Filters and Conversions #### Grayscale and Monochrome | Effect | SDK | Description | | --- | --- | --- | | VideoEffectGrayscale | 🪟 Classic | Converts color video to black and white using perceptual luminance weights. | | GPUVideoEffectGrayscale | 🪟 Classic (GPU) | GPU-accelerated grayscale conversion. | | GPUVideoEffectMonoChrome | 🪟 Classic (GPU) | Creates monochrome effect with customizable tint color. | | GrayscaleVideoEffect | 🌍 Cross-platform | Cross-platform grayscale conversion using videobalance element. | | ColorEffectsVideoEffect | 🌍 Cross-platform | Various color presets including monochrome, sepia, heat map, and more. | #### Color Inversion | Effect | SDK | Description | | --- | --- | --- | | VideoEffectInvert | 🪟 Classic | Inverts all RGB color values, creating photographic negative effect. | | GPUVideoEffectInvert | 🪟 Classic (GPU) | GPU-accelerated color inversion. | #### Color Channel Filters | Effect | SDK | Description | | --- | --- | --- | | VideoEffectRed | 🪟 Classic | Isolates red color channel, removing green and blue components. | | VideoEffectGreen | 🪟 Classic | Isolates green color channel, removing red and blue components. | | VideoEffectBlue | 🪟 Classic | Isolates blue color channel, removing red and green components. | | VideoEffectFilterRed | 🪟 Classic | Applies red color filter effect with adjustable intensity. | | VideoEffectFilterGreen | 🪟 Classic | Applies green color filter effect with adjustable intensity. | | VideoEffectFilterBlue | 🪟 Classic | Applies blue color filter effect with adjustable intensity. | #### Color Grading | Effect | SDK | Description | | --- | --- | --- | | VideoEffectLUT | 🪟 Classic | Look-up table color grading using 3D LUT files for professional color correction. | | LUTVideoEffect | 🌍 Cross-platform | Cross-platform 3D LUT support with multiple interpolation modes. | | VideoEffectPosterize | 🪟 Classic | Reduces number of colors, creating poster-like effect with discrete color levels. | | VideoEffectSolorize | 🪟 Classic | Solarization effect that inverts colors above a threshold brightness level. | ### Image Enhancement #### Sharpening and Blur | Effect | SDK | Description | | --- | --- | --- | | VideoEffectSharpen | 🪟 Classic | Enhances edges and fine details for crisper images. | | GPUVideoEffectSharpen | 🪟 Classic (GPU) | GPU-accelerated sharpening. | | VideoEffectBlur | 🪟 Classic | Applies smoothing filter, softening image and reducing detail. | | GPUVideoEffectBlur | 🪟 Classic (GPU) | GPU-accelerated blur. | | GPUVideoEffectDirectionalBlur | 🪟 Classic (GPU) | Blur with directional component for motion blur effects. | | VideoEffectSmooth | 🪟 Classic | Softening filter for noise reduction and gentle image smoothing. | | GaussianBlurVideoEffect | 🌍 Cross-platform | Cross-platform Gaussian blur with adjustable sigma. | | SmoothVideoEffect | 🌍 Cross-platform | Cross-platform smoothing/softening filter. | #### Noise Reduction | Effect | SDK | Description | | --- | --- | --- | | VideoEffectDenoiseAdaptive | 🪟 Classic | Adaptive noise reduction that preserves edges while removing noise. | | VideoEffectDenoiseCAST | 🪟 Classic | CAST (Cellular Automata-based Spatio-Temporal) denoise algorithm with multiple parameters. | | VideoEffectDenoiseMosquito | 🪟 Classic | Reduces mosquito noise artifacts common in compressed video. | | GPUVideoEffectDenoise | 🪟 Classic (GPU) | GPU-accelerated general noise reduction. | ### Geometric Transformations #### Rotation and Flipping | Effect | SDK | Description | | --- | --- | --- | | VideoEffectRotate | 🪟 Classic | Rotates video by any angle with options for stretching or preserving full frame. | | FlipRotateVideoEffect | 🌍 Cross-platform | Cross-platform flip and rotation (90°, 180°, 270°, horizontal/vertical flip). | | VideoEffectFlipHorizontal | 🪟 Classic | Flips video horizontally (left-right mirror). | | VideoEffectFlipVertical | 🪟 Classic | Flips video vertically (top-bottom mirror). | | VideoEffectMirrorHorizontal | 🪟 Classic | Creates horizontal mirror effect at center of frame. | | VideoEffectMirrorVertical | 🪟 Classic | Creates vertical mirror effect at center of frame. | #### Scaling and Transformation | Effect | SDK | Description | | --- | --- | --- | | VideoEffectZoom | 🪟 Classic | Zooms into specific region of video with pan and scale control. | | VideoEffectPan | 🪟 Classic | Pan and crop effect for selecting specific video region. | | ResizeVideoEffect | 🌍 Cross-platform | Cross-platform video scaling/resizing with multiple interpolation methods. | | CropVideoEffect | 🌍 Cross-platform | Cross-platform video cropping to specific dimensions. | | AspectRatioCropVideoEffect | 🌍 Cross-platform | Automatically crops video to target aspect ratio. | | BoxVideoEffect | 🌍 Cross-platform | Adds letterboxing/pillarboxing with custom fill color. | ### Artistic and Stylistic Effects #### Classic Film Effects | Effect | SDK | Description | | --- | --- | --- | | GPUVideoEffectOldMovie | 🪟 Classic (GPU) | Vintage film effect with grain, scratches, and sepia tone. | | GPUVideoEffectNightVision | 🪟 Classic (GPU) | Night vision camera simulation with green phosphor look. | | AgingVideoEffect | 🌍 Cross-platform | Cross-platform aging/vintage film effect. | | OpticalAnimationBWVideoEffect | 🌍 Cross-platform | Optical illusion animation effects in black and white. | #### Edge and Texture Effects | Effect | SDK | Description | | --- | --- | --- | | GPUVideoEffectEmboss | 🪟 Classic (GPU) | Creates embossed or raised relief effect highlighting edges. | | GPUVideoEffectContour | 🪟 Classic (GPU) | Edge detection and contour enhancement. | | GPUVideoEffectPixelate | 🪟 Classic (GPU) | Pixelation effect with adjustable block size. | | VideoEffectMosaic | 🪟 Classic | Creates mosaic pattern with adjustable tile size. | | EdgeVideoEffect | 🌍 Cross-platform | Cross-platform edge detection filter. | | DiceVideoEffect | 🌍 Cross-platform | Creates dice/cubist effect by dividing image into rotated squares. | #### Special Distortion Effects (Cross-platform only) The following artistic effects are available exclusively in the cross-platform implementation: | Effect | Description | | --- | --- | | FishEyeVideoEffect | Fish-eye lens distortion effect. | | GLTwirlVideoEffect | Twirl/swirl distortion effect (OpenGL). | | GLBulgeVideoEffect | Bulge/magnification distortion (OpenGL). | | StretchVideoEffect | Stretch distortion effect. | | GLLightTunnelVideoEffect | Tunnel perspective effect (OpenGL). | | SquareVideoEffect | Square warping effect. | | CircleVideoEffect | Circular warping effect. | | KaleidoscopeVideoEffect | Kaleidoscope mirror effect. | | MarbleVideoEffect | Marble texture effect. | | Pseudo3DVideoEffect | Pseudo 3D stereo effect. | | QuarkVideoEffect | Quark particle effect. | | RippleVideoEffect | Water ripple effect. | | WaterRippleVideoEffect | Enhanced water ripple with multiple modes. | | WarpVideoEffect | General warp distortion effect. | | MovingBlurVideoEffect | Motion blur with directional control. | | MovingEchoVideoEffect | Motion echo/trail effect. | | MovingZoomEchoVideoEffect | Combined zoom and echo effect. | | SMPTEVideoEffect | SMPTE transition effects (wipes, fades). | | SMPTEAlphaVideoEffect | SMPTE transitions with alpha channel. | #### Special Effects | Effect | SDK | Description | | --- | --- | --- | | VideoEffectColorNoise | 🪟 Classic | Adds random color noise for grain or interference effects. | | VideoEffectMonoNoise | 🪟 Classic | Adds monochrome (grayscale) noise. | | VideoEffectSpray | 🪟 Classic | Spray paint or pointillist effect. | | VideoEffectShakeDown | 🪟 Classic | Vertical shake effect for impact or earthquake simulation. | ### Deinterlacing | Effect | SDK | Description | | --- | --- | --- | | VideoEffectDeinterlaceBlend | 🪟 Classic | Blends interlaced fields for progressive output. | | GPUVideoEffectDeinterlaceBlend | 🪟 Classic (GPU) | GPU-accelerated deinterlace blend. | | VideoEffectDeinterlaceCAVT | 🪟 Classic | Content Adaptive Vertical Temporal deinterlacing. | | VideoEffectDeinterlaceTriangle | 🪟 Classic | Triangle interpolation deinterlacing method. | | DeinterlaceVideoEffect | 🌍 Cross-platform | Cross-platform deinterlacing with multiple methods (linear, greedy, vfir, yadif, etc.). | | AutoDeinterlaceSettings | 🌍 Cross-platform | Automatic deinterlacing when interlaced content is detected. | | InterlaceSettings | 🌍 Cross-platform | Creates interlaced output from progressive content. | ### Transition Effects | Effect | SDK | Description | | --- | --- | --- | | VideoEffectFadeIn | 🪟 Classic | Gradual fade from black to video content. | | VideoEffectFadeOut | 🪟 Classic | Gradual fade from video content to black. | ### Overlays and Graphics #### Text Overlays | Effect | SDK | Description | | --- | --- | --- | | VideoEffectTextLogo | 🪟 Classic | Flexible text overlay with extensive customization including fonts, colors, rotation, effects, and animated text. | | VideoEffectScrollingTextLogo | 🪟 Classic | Scrolling text banner with direction and speed control. | | TextOverlayVideoEffect | 🌍 Cross-platform | Cross-platform text overlay with advanced typography control. Supports timestamps, system time, and dynamic text. | | OverlayManagerText | 🌍 Cross-platform | Advanced text overlay with shadows, gradients, and animations. | | OverlayManagerScrollingText | 🌍 Cross-platform | Scrolling text with full control over speed, direction, and appearance. | | OverlayManagerDateTime | 🌍 Cross-platform | Date/time overlay with customizable formatting. | See: [Text Overlay Guide](../text-overlay/) #### Image Overlays | Effect | SDK | Description | | --- | --- | --- | | VideoEffectImageLogo | 🪟 Classic | Image overlay supporting PNG, JPG, BMP, animated GIF, with transparency and positioning control. | | ImageOverlayVideoEffect | 🌍 Cross-platform | Cross-platform image overlay with positioning and alpha blending. | | ImageOverlayCairoVideoEffect | 🌍 Cross-platform | Advanced image overlay using Cairo graphics with transformations. | | OverlayManagerImage | 🌍 Cross-platform | Professional image overlay with animations, transitions, and effects. | | OverlayManagerGIF | 🌍 Cross-platform | Animated GIF overlay support. | | SVGOverlayVideoEffect | 🌍 Cross-platform | SVG vector graphics overlay. | See: [Image Overlay Guide](../image-overlay/) #### Advanced Overlay Features (Cross-platform only) | Feature | Description | | --- | --- | | OverlayManagerVideo | Video-in-video overlay (picture-in-picture). | | OverlayManagerDecklinkVideo | Blackmagic Decklink video source overlay. | | OverlayManagerNDIVideo | NDI video source overlay. | | OverlayManagerGroup | Group multiple overlays together for synchronized control. | | OverlayManagerPan | Pan overlay animation. | | OverlayManagerZoom | Zoom overlay animation. | | OverlayManagerFade | Fade in/out overlay animation. | | OverlayManagerSqueezeback | Squeezeback effect (shrink main video to show background). | | OverlayManagerBackgroundImage | Background image layer. | | OverlayManagerBackgroundRectangle | Colored rectangle background. | | OverlayManagerBackgroundSquare | Colored square background. | | OverlayManagerBackgroundStar | Star-shaped background. | | OverlayManagerBackgroundTriangle | Triangle-shaped background. | | OverlayManagerCircle | Circular shape overlay. | | OverlayManagerLine | Line drawing overlay. | | OverlayManagerRectangle | Rectangle shape overlay. | | OverlayManagerStar | Star shape overlay. | | OverlayManagerTriangle | Triangle shape overlay. | ### Chroma Key (Cross-platform) | Effect | Description | | --- | --- | | ChromaKeySettingsX | Green screen / blue screen keying for background removal (use with `MediaBlocksPipeline` + chroma-key filter block). | ### 360° Video and VR (Classic only) | Effect | SDK | Description | | --- | --- | --- | | GPUVideoEffectEquirectangular360 | 🪟 Classic (GPU) | Processes equirectangular 360° video format. | | GPUVideoEffectEquiangularCubemap360 | 🪟 Classic (GPU) | Converts between equiangular and cubemap projections for 360° video. | | GPUVideoEffectVR360Base | 🪟 Classic (GPU) | Base class for VR 360° video effects. | ### AI-Powered Effects (NVIDIA Maxine - Classic only) Requires NVIDIA RTX GPU with Maxine SDK support. For setup, code samples, and effect modes, see the [NVIDIA Maxine AI Video Enhancement](../nvidia-maxine/) guide. #### Video Enhancement | Effect | Description | | --- | --- | | MaxineDenoiseVideoEffect | AI-powered noise reduction that intelligently preserves details. | | MaxineArtifactReductionVideoEffect | Reduces compression artifacts and video degradation using AI. | | MaxineSuperResSettings | Settings POCO for AI super-resolution upscaling (wire into the Maxine effect pipeline). | #### Content Effects | Effect | Description | | --- | --- | | MaxineAIGSVideoEffect | AI-powered green screen/background removal without requiring actual green screen. | | MaxineUpscaleSettings | Settings POCO for AI upscaling (wire into the Maxine effect pipeline). | #### Special Effects - **VideoEffectColorNoise** - Adds random color noise for grain or interference effects. - **VideoEffectMonoNoise** - Adds monochrome (grayscale) noise. - **VideoEffectSpray** - Spray paint or pointillist effect. - **VideoEffectShakeDown** - Vertical shake effect for impact or earthquake simulation. ### Deinterlacing - **VideoEffectDeinterlaceBlend** / **GPUVideoEffectDeinterlaceBlend** - Blends interlaced fields for progressive output. - **VideoEffectDeinterlaceCAVT** - Content Adaptive Vertical Temporal deinterlacing. - **VideoEffectDeinterlaceTriangle** - Triangle interpolation deinterlacing method. ### Transition Effects #### Fade Effects - **VideoEffectFadeIn** - Gradual fade from black to video content. - **VideoEffectFadeOut** - Gradual fade from video content to black. ### Overlays and Graphics #### Text Overlays - **VideoEffectTextLogo** - Flexible text overlay with extensive customization including fonts, colors, rotation, effects, and animated text. - **VideoEffectScrollingTextLogo** - Scrolling text banner with direction and speed control. See: [Text Overlay Guide](../text-overlay/) #### Image Overlays - **VideoEffectImageLogo** - Image overlay supporting PNG, JPG, BMP, animated GIF, with transparency and positioning control. See: [Image Overlay Guide](../image-overlay/) ### 360° Video and VR - **GPUVideoEffectEquirectangular360** - Processes equirectangular 360° video format. - **GPUVideoEffectEquiangularCubemap360** - Converts between equiangular and cubemap projections for 360° video. - **GPUVideoEffectVR360Base** - Base class for VR 360° video effects. ### AI-Powered Effects (NVIDIA Maxine) Requires NVIDIA RTX GPU with Maxine SDK support. #### Video Enhancement - **MaxineDenoiseVideoEffect** - AI-powered noise reduction that intelligently preserves details. - **MaxineArtifactReductionVideoEffect** - Reduces compression artifacts and video degradation using AI. - **MaxineSuperResSettings** - Settings POCO for AI super-resolution upscaling. #### Content Effects - **MaxineAIGSVideoEffect** - AI-powered green screen/background removal without requiring actual green screen. - **MaxineUpscaleSettings** - Settings POCO for AI upscaling. ## Effect Parameters ### Common Parameters All video effects support these standard parameters: - **Enabled** - Whether the effect is active (can be toggled on/off) - **Name** - Identifier for retrieving specific effect instances - **StartTime** - When effect begins (TimeSpan.Zero = from start) - **StopTime** - When effect ends (TimeSpan.Zero = until end) ### Classic Effects Value Ranges Most Classic adjustment effects use 0-255 value ranges where: - **128** typically represents neutral/no change - **0** represents minimum (often darkest/weakest) - **255** represents maximum (often brightest/strongest) ### Animated Transitions (Classic Effects) Many Classic effects support **ValueStop** parameter for smooth animation: - Set **Value** for starting value - Set **ValueStop** for ending value - Define **StartTime** and **StopTime** for animation duration ### Cross-platform Effects Parameters Cross-platform effects use multimedia element properties with varying ranges. Refer to individual effect documentation for specific parameter details. ## SDK Comparison ### Classic Effects (VideoCaptureCore/MediaPlayerCore) - **Platform**: Windows only (.NET Framework 4.7.2+ and .NET 6-10) - **Processing Types**: - CPU-based: `VideoEffect*` classes - GPU-accelerated: `GPUVideoEffect*` classes (DirectX) - AI-powered: `Maxine*` classes (NVIDIA RTX required) - **Performance**: Optimized for Windows, DirectX GPU acceleration - **Compatibility**: Desktop Windows only - **Namespace**: `VisioForge.Core.Types.VideoEffects` ### Cross-platform Effects (VideoCaptureCoreX/Media Blocks) - **Platform**: Cross-platform (Windows, Linux, macOS, Android, iOS) - **Processing**: Cross-platform, hardware acceleration through multimedia plugins - **Performance**: Good performance on all platforms, GPU acceleration varies by platform - **Compatibility**: Universal - desktop and mobile - **Namespace**: `VisioForge.Core.Types.X.VideoEffects` - **Additional Features**: - More artistic effects (distortions, warps) - Advanced overlay system (OverlayManager) - Chroma key / motion detection - Better suited for mobile platforms ## Usage Examples ### Classic Effect Application ``` // CPU-based effect var effect = new VideoEffectGrayscale( enabled: true, name: "BWEffect" ); capture.Video_Effects_Add(effect); // GPU-accelerated effect var gpuEffect = new GPUVideoEffectBrightness( enabled: true, value: 180, name: "Brighten" ); capture.Video_Effects_Add(gpuEffect); ``` ### Cross-platform Effect Application ``` // Cross-platform grayscale var grayscale = new GrayscaleVideoEffect("bw_effect"); await videoCapture.Video_Effects_AddOrUpdateAsync(grayscale); // Cross-platform text overlay var textOverlay = new TextOverlayVideoEffect { Text = "Hello World", Font = new FontSettings("Arial", "Bold", 24), Color = SKColors.Yellow, HorizontalAlignment = TextOverlayHAlign.Left, VerticalAlignment = TextOverlayVAlign.Top }; await videoCapture.Video_Effects_AddOrUpdateAsync(textOverlay); ``` ### Animated Effect (Classic) ``` // Fade to black over 3 seconds var fade = new VideoEffectDarkness( enabled: true, value: 128, // Start normal valueStop: 255, // End at maximum darkness name: "FadeOut", startTime: TimeSpan.FromSeconds(57), stopTime: TimeSpan.FromSeconds(60) ); capture.Video_Effects_Add(fade); ``` ### Time-Limited Effect (Both) ``` // Classic: Apply effect only during specific time range var flashback = new VideoEffectGrayscale( enabled: true, name: "Flashback", startTime: TimeSpan.FromMinutes(2), stopTime: TimeSpan.FromMinutes(2.5) ); player.Video_Effects_Add(flashback); // Cross-platform: Time-limited effect // Ctor: GaussianBlurVideoEffect(double sigma, string name = "gaussian_blur") var blur = new GaussianBlurVideoEffect(5.0, "blur") { StartTime = TimeSpan.FromSeconds(10), StopTime = TimeSpan.FromSeconds(15) }; await player.Video_Effects_AddOrUpdateAsync(blur); ``` ## Performance Considerations ### Classic Effects 1. **GPU Effects**: Best performance for high-resolution video on Windows 2. **Effect Stacking**: Minimize simultaneous effects for better performance 3. **Animated Effects**: Smooth animations add minimal overhead 4. **AI Effects**: Most resource-intensive, use on RTX GPUs 5. **Resolution Impact**: Higher resolutions significantly increase processing requirements ### Cross-platform Effects 1. **Hardware Acceleration**: Varies by platform and multimedia framework build 2. **Cross-Platform**: Generally good performance on all supported platforms 3. **Mobile Optimization**: Better suited for mobile than Classic effects 4. **Overlay System**: Efficient multi-overlay rendering 5. **Plugin Availability**: Some effects require specific multimedia plugins ## Platform Availability ### Classic Effects | Platform | CPU Effects | GPU Effects | AI Maxine | | --- | --- | --- | --- | | Windows Desktop | ✅ Full | ✅ Full | ✅ RTX GPUs | | Linux | ❌ | ❌ | ❌ | | macOS | ❌ | ❌ | ❌ | | Android | ❌ | ❌ | ❌ | | iOS | ❌ | ❌ | ❌ | ### Cross-platform Effects | Platform | Support | Hardware Acceleration | | --- | --- | --- | | Windows | ✅ Full | ✅ Via multimedia plugins | | Linux | ✅ Full | ✅ VA-API, VDPAU, etc. | | macOS | ✅ Full | ✅ VideoToolbox | | Android | ✅ Full | ✅ Hardware codecs | | iOS | ✅ Full | ✅ VideoToolbox | ## Choosing the Right Effect Type ### Use Classic Effects When: - ✅ Targeting Windows desktop only - ✅ Need maximum performance on Windows - ✅ Using DirectX GPU acceleration - ✅ Need NVIDIA Maxine AI features - ✅ Working with VideoCaptureCore/MediaPlayerCore engines ### Use Cross-platform Effects When: - ✅ Need cross-platform support - ✅ Targeting mobile platforms (Android/iOS) - ✅ Targeting Linux or macOS - ✅ Using VideoCaptureCoreX/Media Blocks - ✅ Need advanced overlay features - ✅ Need chroma key or motion detection ## Additional Resources - [Text Overlay Guide](../text-overlay/) - [Image Overlay Guide](../image-overlay/) - [Video Sample Grabber](../video-sample-grabber/) - [How to Add Effects](../add/) --- Visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for complete code samples and implementation examples. ---END OF PAGE--- ## Image Overlay on Video in .NET — PNG, GIF, and Bitmap **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/image-overlay/ **Description:** Overlay images, animated GIFs, and transparent PNGs on video streams in .NET for watermarks, logos, and visual enhancements with transparency. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaPlayerCore, VideoCaptureCore, VideoEditCore, Windows, Capture, Playback, Editing, GIF, C# **API:** VideoEffectImageLogo # Image overlay [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCore](#) [MediaPlayerCore](#) [VideoEditCore](#) ## Introduction This example demonstrates how to overlay an image on a video stream. JPG, PNG, BMP, and GIF images are supported. ## Sample code Most simple image overlay with image added from a file with custom position: ``` var effect = new VideoEffectImageLogo(true, "imageoverlay"); effect.Filename = @"logo.png"; effect.Left = 100; effect.Top = 100; VideoCapture1.Video_Effects_Add(effect); ``` ### Transparent image overlay SDK fully supports transparency in PNG images. If you want to set a custom transparency level, you can use the `TransparencyLevel` property with a range (0..255). ``` var effect = new VideoEffectImageLogo(true, "imageoverlay"); effect.Filename = @"logo.jpg"; effect.TransparencyLevel = 50; VideoCapture1.Video_Effects_Add(effect); ``` ### Animated GIF overlay You can overlay an animated GIF image on a video stream. The SDK will play the GIF animation in the overlay. ``` var effect = new VideoEffectImageLogo(true, "imageoverlay"); effect.Filename = @"animated.gif"; effect.Animated = true; effect.AnimationEnabled = true; VideoCapture1.Video_Effects_Add(effect); ``` ### Image overlay from `System.Drawing.Bitmap` You can overlay an image from a `System.Drawing.Bitmap` object. ``` var effect = new VideoEffectImageLogo(true, "imageoverlay"); effect.MemoryBitmap = new Bitmap("logo.jpg"); VideoCapture1.Video_Effects_Add(effect); ``` ### Image overlay from RGB/RGBA byte array You can overlay an image from RGB/RGBA data. ``` // add image logo var effect = new VideoEffectImageLogo(true, "imageoverlay"); // load image from JPG file var bitmap = new Bitmap("logo.jpg"); // lock bitmap data and save to byte data (IntPtr) var bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); var pixels = Marshal.AllocCoTaskMem(bitmapData.Stride * bitmapData.Height); NativeAPI.CopyMemory(pixels, bitmapData.Scan0, bitmapData.Stride * bitmapData.Height); bitmap.UnlockBits(bitmapData); // set data to effect effect.Bitmap = pixels; // set bitmap properties effect.BitmapWidth = bitmap.Width; effect.BitmapHeight = bitmap.Height; effect.BitmapDepth = 3; // RGB24 // free bitmap bitmap.Dispose(); // add effect VideoCapture1.Video_Effects_Add(effect); ``` --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Video Effects SDK for .NET - Overlays and Processing **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/ **Description:** Implement professional video effects, text/image overlays, and custom video processing with powerful visual enhancement tools for .NET apps. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture, Playback, Editing **API:** VideoEffect, GPUVideoEffect, VideoBalanceVideoEffect, ColorEffectsVideoEffect, GrayscaleVideoEffect # Video Effects and Processing for .Net Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net)[Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction Our .Net SDKs provide developers with two distinct implementations of video effects to match your platform and performance requirements: ### Classic Effects (Windows Only) Available in **VideoCaptureCore**, **MediaPlayerCore**, and **VideoEditCore**: - CPU-based effects (`VideoEffect*`) - GPU-accelerated effects (`GPUVideoEffect*`) using DirectX - AI-powered effects (`Maxine*`) using NVIDIA technology - Windows-only, optimized for desktop performance ### Cross-Platform Effects Available in **VideoCaptureCoreX**, **MediaPlayerCoreX**, **VideoEditCoreX**, and **Media Blocks SDK**: - Cross-platform implementation (`*VideoEffect` classes) - Works on Windows, Linux, macOS, Android, and iOS - Hardware acceleration through platform-specific multimedia plugins - Extended overlay system and advanced features - Better suited for mobile and cross-platform deployment ## Complete Effects Reference **[View Complete Video Effects Reference →](effects-reference/)** Our comprehensive effects reference provides detailed information on all 100+ available video effects across both implementations: - **Classic effects** for Windows-only applications - **Cross-platform effects** for universal compatibility - Effect parameters, usage examples, and SDK availability - Platform-specific features and capabilities ## Available Video Effect Categories The following effect categories are available in both Classic and Cross-Platform implementations (where applicable): ### Color and Image Adjustment - **Brightness, Darkness, Contrast** - Control luminance and tonal range - Classic: `VideoEffect*` / `GPUVideoEffect*` - Cross-platform: `VideoBalanceVideoEffect`, `GammaVideoEffect` - **Saturation and Color Grading** - Adjust color intensity and apply color corrections - Classic: `VideoEffectSaturation` / `GPUVideoEffectSaturation` - Cross-platform: `VideoBalanceVideoEffect`, `ColorEffectsVideoEffect`, `LUTVideoEffect` - **Lightness** - HSL-based brightness adjustment preserving color relationships - Classic: `VideoEffectLightness` - **Color Filters** - Isolate or enhance specific color channels (Red, Green, Blue) - Classic: `VideoEffectRed/Green/Blue`, `VideoEffectFilterRed/Green/Blue` ### Creative and Artistic Effects - **Grayscale and Monochrome** - Black and white conversions with optional tinting - Classic: `VideoEffectGrayscale` / `GPUVideoEffectGrayscale` - Cross-platform: `GrayscaleVideoEffect`, `ColorEffectsVideoEffect` - **Invert and Solarize** - Photographic negative and partial inversion effects - Classic: `VideoEffectInvert` / `GPUVideoEffectInvert`, `VideoEffectSolorize` - **Old Movie and Night Vision** - Vintage film and surveillance camera simulations - Classic: `GPUVideoEffectOldMovie`, `GPUVideoEffectNightVision` - Cross-platform: `AgingVideoEffect`, `OpticalAnimationBWVideoEffect` - **Emboss and Contour** - Edge detection and relief effects - Classic: `GPUVideoEffectEmboss`, `GPUVideoEffectContour` - Cross-platform: `EdgeVideoEffect` - **Pixelate and Mosaic** - Stylized block and tile effects - Classic: `GPUVideoEffectPixelate`, `VideoEffectMosaic` - Cross-platform: Various distortion effects ### Image Enhancement - **Sharpening** - Enhance edge definition and fine details - Classic: `VideoEffectSharpen` / `GPUVideoEffectSharpen` - **Blur and Smoothing** - Reduce detail, noise, and create soft-focus effects - Classic: `VideoEffectBlur` / `GPUVideoEffectBlur`, `VideoEffectSmooth` - Cross-platform: `GaussianBlurVideoEffect`, `SmoothVideoEffect` - **Noise Reduction** - Adaptive, CAST, and mosquito noise removal algorithms - Classic: `VideoEffectDenoiseAdaptive/CAST/Mosquito` / `GPUVideoEffectDenoise` - **Deinterlacing** - Convert interlaced video to progressive (Blend, CAVT, Triangle methods) - Classic: `VideoEffectDeinterlaceBlend/CAVT/Triangle` / `GPUVideoEffectDeinterlaceBlend` - Cross-platform: `DeinterlaceVideoEffect`, `AutoDeinterlaceSettings` ### Geometric Transformations - **Rotation** - Rotate by any angle with stretch or no-crop options - Classic: `VideoEffectRotate` - Cross-platform: `FlipRotateVideoEffect` - **Flip and Mirror** - Horizontal and vertical flipping/mirroring - Classic: `VideoEffectFlip*`, `VideoEffectMirror*` - Cross-platform: `FlipRotateVideoEffect` - **Zoom and Pan** - Focus on specific regions with scaling control - Classic: `VideoEffectZoom`, `VideoEffectPan` - Cross-platform: `ResizeVideoEffect`, `CropVideoEffect`, `AspectRatioCropVideoEffect`, `BoxVideoEffect` - **360° Video Processing** - Equirectangular and cubemap projections for VR video - Classic: `GPUVideoEffectEquirectangular360`, `GPUVideoEffectEquiangularCubemap360` ### Artistic Distortion Effects (Cross-platform Only) The cross-platform implementation includes extensive artistic distortion effects not available in Classic: - **Lens Effects** - Fish-eye, Sphere, Twirl, Bulge, Pinch - **Pattern Effects** - Kaleidoscope, Marble, Quark, Dice - **Motion Effects** - Moving Blur, Moving Echo, Moving Zoom Echo - **Warp Effects** - Ripple, Water Ripple, Warp, Stretch, Tunnel - **Perspective Effects** - Pseudo3D, Square, Circle, Perspective - **SMPTE Transitions** - Professional broadcast-style wipes and transitions ### Transition Effects - **Fade In/Out** - Smooth transitions to/from black - Classic: `VideoEffectFadeIn`, `VideoEffectFadeOut` - **Animated Transitions** - Time-based effect value interpolation for dynamic changes - Classic: Supported via ValueStop parameter - Cross-platform: Time-based with StartTime/StopTime ## Overlay Capabilities - [**Text overlay**](text-overlay/) - Add customizable text with control over font, size, color, rotation, and animation - Classic: `VideoEffectTextLogo`, `VideoEffectScrollingTextLogo` - Cross-platform: `TextOverlayVideoEffect`, `OverlayManagerText`, `OverlayManagerScrollingText`, `OverlayManagerDateTime` - [**Image overlay**](image-overlay/) - Incorporate logos, watermarks, and graphic elements with transparency support - Classic: `VideoEffectImageLogo` - Cross-platform: `ImageOverlayVideoEffect`, `ImageOverlayCairoVideoEffect`, `OverlayManagerImage`, `OverlayManagerGIF` - Support for PNG, JPG, BMP, animated GIF formats - Transparency and alpha channel support - Positioning and alignment control ### Advanced Overlay Features (Cross-platform Only) The cross-platform implementation includes an extensive OverlayManager system: - **Video Overlays** - Picture-in-picture, Decklink, NDI video sources - **Shape Overlays** - Circles, rectangles, stars, triangles, lines - **Background Layers** - Images, solid colors, geometric shapes - **Animations** - Pan, zoom, fade, squeezeback effects - **Group Management** - Synchronized control of multiple overlays - **SVG Support** - Vector graphics overlays - **QR Codes** - Generate and overlay QR codes ## Chroma Key and Motion Detection (Cross-platform Only) - **ChromaKeySettings** - Green screen / blue screen keying for background removal - **MotionDetectionProcessor** - Real-time motion detection with configurable sensitivity ## AI-Powered Video Enhancement (Classic Only) NVIDIA Maxine AI effects (requires NVIDIA RTX GPU with Maxine SDK support): - **AI Denoise** - Intelligent noise reduction preserving fine details - **Artifact Reduction** - Remove compression artifacts and video degradation - **Super Resolution** - AI upscaling for enhanced resolution - **AI Green Screen** - Background removal without physical green screen - **Upscaling** - Advanced quality improvement through AI ## Video Processing Features ### Real-time Processing - Apply effects during video capture, playback, or editing - Chain multiple effects for complex processing pipelines - GPU acceleration for real-time high-resolution processing (Classic) - Hardware acceleration for cross-platform performance (Cross-platform) - CPU fallback for universal compatibility ### Advanced Processing - Timeline-based effect application (start/stop times) - Animated effect transitions (interpolation between values - Classic) - Dynamic effect control during playback - [**Video sample grabber**](video-sample-grabber/) - Extract frames and process video data in real-time ## Performance Optimization ### Classic Effects (Windows Only) - **GPU Effects** (`GPUVideoEffect*`): Best performance for high-resolution video on Windows - **CPU Effects** (`VideoEffect*`): Universal Windows compatibility, moderate performance - **AI Effects** (`Maxine*`): State-of-the-art quality, requires NVIDIA RTX GPU - Use GPU-accelerated effects for real-time HD/4K processing - DirectX hardware acceleration for optimal Windows performance ### Cross-platform Effects (Cross-Platform) - **Hardware Acceleration**: Varies by platform via multimedia plugins - Windows: DirectX, DXVA - Linux: VA-API, VDPAU, OpenGL - macOS: VideoToolbox, Metal - Android/iOS: Hardware codecs - **Performance**: Generally good across all platforms - **Mobile Optimization**: Better suited for mobile than Classic effects - **Overlay System**: Efficient multi-overlay rendering ### Best Practices - Choose GPU/accelerated effects for high-resolution video - Consider effect combinations and their performance impact - Apply time-limited effects where appropriate to reduce processing overhead - Test performance on target hardware configurations - Use Cross-platform effects for cross-platform deployment ## Platform Support ### Classic Effects | Platform | CPU Effects | GPU Effects | AI Maxine | SDK | | --- | --- | --- | --- | --- | | Windows Desktop | ✅ Full | ✅ Full | ✅ RTX GPUs | VideoCaptureCore MediaPlayerCore VideoEditCore | | Linux | ❌ | ❌ | ❌ | N/A | | macOS | ❌ | ❌ | ❌ | N/A | | Android | ❌ | ❌ | ❌ | N/A | | iOS | ❌ | ❌ | ❌ | N/A | ### Cross-platform Effects | Platform | Support | Hardware Acceleration | SDK | | --- | --- | --- | --- | | Windows | ✅ Full | ✅ DirectX, DXVA | VideoCaptureCoreX MediaPlayerCoreX VideoEditCoreX Media Blocks SDK | | Linux | ✅ Full | ✅ VA-API, VDPAU, OpenGL | ✓ | | macOS | ✅ Full | ✅ VideoToolbox, Metal | ✓ | | Android | ✅ Full | ✅ Hardware codecs | ✓ | | iOS | ✅ Full | ✅ VideoToolbox | ✓ | ## Integration Methods Our SDKs provide two distinct APIs for video effects integration based on the SDK engine you're using. ### Basic Usage Example (Classic Effects) ``` // Windows-only: CPU-based effect var bwEffect = new VideoEffectGrayscale( enabled: true, name: "BlackAndWhite" ); videoCapture.Video_Effects_Add(bwEffect); // Windows-only: GPU-accelerated effect var brighten = new GPUVideoEffectBrightness( enabled: true, value: 180, name: "Brighten" ); videoCapture.Video_Effects_Add(brighten); ``` ### Basic Usage Example (Cross-platform Effects) ``` // Cross-platform: Grayscale effect var grayscale = new GrayscaleVideoEffect("bw_effect"); await videoCaptureX.Video_Effects_AddOrUpdateAsync(grayscale); // Cross-platform: Video balance (brightness, contrast, saturation) var balance = new VideoBalanceVideoEffect("color_adjust") { Brightness = 0.2, // Range: -1.0 to 1.0 Contrast = 1.2, // Range: 0.0 to 2.0 Saturation = 1.5, // Range: 0.0 to 2.0 Hue = 0.0 // Range: -1.0 to 1.0 }; await videoCaptureX.Video_Effects_AddOrUpdateAsync(balance); ``` ### Animated Effect Example (Classic) ``` // Fade to black over 3 seconds (Windows only) var fadeOut = new VideoEffectDarkness( enabled: true, value: 128, // Start at normal valueStop: 255, // End at black name: "FadeOut", startTime: TimeSpan.FromSeconds(57), stopTime: TimeSpan.FromSeconds(60) ); mediaPlayer.Video_Effects_Add(fadeOut); ``` ### Time-Limited Effect Example (Cross-platform) ``` // Apply Gaussian blur for specific time range (Cross-platform) // Ctor: GaussianBlurVideoEffect(double sigma, string name = "gaussian_blur") var blur = new GaussianBlurVideoEffect(5.0, "scene_blur") { StartTime = TimeSpan.FromSeconds(10), StopTime = TimeSpan.FromSeconds(15) }; await mediaPlayerX.Video_Effects_AddOrUpdateAsync(blur); ``` ### Advanced Overlay Example (Cross-platform) ``` // Complex text overlay with a drop shadow (Cross-platform) var textOverlay = new OverlayManagerText { Text = "Breaking News", Font = new FontSettings { Name = "Arial", Size = 48, Weight = FontWeight.Bold }, Color = SKColors.Yellow, X = 50, Y = 100, Shadow = new OverlayManagerShadowSettings { Enabled = true, Color = SKColors.Black, BlurRadius = 5 } }; videoCaptureX.Video_Overlay_Add(textOverlay); ``` ## Documentation Resources - **[Complete Effects Reference](effects-reference/)** - Comprehensive guide to all available effects - **[Text Overlay Guide](text-overlay/)** - Detailed text overlay implementation - **[Image Overlay Guide](image-overlay/)** - Image and logo overlay techniques - **[Video Sample Grabber](video-sample-grabber/)** - Frame extraction and processing - **[How to Add Effects](add/)** - General guide to applying effects ## More Information Numerous additional video effects and processing features are available in the SDKs. Please refer to the [Complete Effects Reference](effects-reference/) for detailed information on all effects, or visit the documentation for the specific SDK you are using for implementation examples and API references. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to access more code samples and implementation examples. ---END OF PAGE--- ## NVIDIA Maxine AI Video Enhancement & Upscaling in C# **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/nvidia-maxine/ **Description:** Enhance video with NVIDIA Maxine AI in C# .NET — super resolution, upscaling, denoise, and artifact reduction on RTX GPUs with the VisioForge SDK. **Tags:** Video Capture SDK, Media Player SDK, .NET, NVIDIA Maxine, AI, Super Resolution, Windows **API:** MaxineDenoiseVideoEffect, MaxineArtifactReductionVideoEffect, MaxineSuperResSettings, MaxineUpscaleSettings # NVIDIA Maxine AI Video Enhancement in C# .NET NVIDIA Maxine brings GPU-accelerated, AI-powered video enhancement to the VisioForge classic engines (`VideoCaptureCore` and `MediaPlayerCore`). The effects run on the NVIDIA Maxine SDK and require an **NVIDIA RTX GPU** (Tensor cores). They are Windows-only. | Effect | API type | Applied via | | --- | --- | --- | | Denoise | `MaxineDenoiseVideoEffect` | `Video_Effects_Add` | | Artifact reduction | `MaxineArtifactReductionVideoEffect` | `Video_Effects_Add` | | Super resolution | `MaxineSuperResSettings` | `Video_Resize` | | Upscale | `MaxineUpscaleSettings` | `Video_Resize` | ## Requirements - NVIDIA RTX GPU (GeForce RTX 2060 or higher) with current drivers. - The NVIDIA Maxine SDK with its **models directory** on disk — most constructors take the path to it. - Windows 10/11. These effects target the DirectShow-backed `VideoCaptureCore` / `MediaPlayerCore` engines. The denoise/artifact effect classes live in `VisioForge.Core.Types.VideoEffects` (denoise in `VisioForge.Core.Types.VideoEffects.NvidiaMaxine`); the super-resolution and upscale settings live in `VisioForge.Core.Types`. Enable the effect pipeline Filter effects added with `Video_Effects_Add` only run when the effect pipeline is enabled. Set `Video_Effects_Enabled = true` once before adding effects — it is `false` by default. ## Denoise Removes camera/sensor noise while preserving detail. `Strength` ranges 0.0–1.0 (default 0.7). ``` using VisioForge.Core.Types.VideoEffects.NvidiaMaxine; VideoCapture1.Video_Effects_Enabled = true; // effects are off by default var denoise = new MaxineDenoiseVideoEffect(modelsDir, strength: 0.7f); VideoCapture1.Video_Effects_Add(denoise); ``` ## Artifact reduction Removes compression artifacts (blocking, ringing, banding). Pick the mode to match the source bitrate. ``` using VisioForge.Core.Types.VideoEffects; VideoCapture1.Video_Effects_Enabled = true; var artifactReduction = new MaxineArtifactReductionVideoEffect( modelsDir, mode: MaxineArtifactReductionEffectMode.LowBitrate); VideoCapture1.Video_Effects_Add(artifactReduction); ``` | `MaxineArtifactReductionEffectMode` | Use for | | --- | --- | | `HighBitrate` | 10+ Mbps sources; gentler, preserves gradients and fine detail. | | `LowBitrate` | Below ~5 Mbps; aggressive removal of strong artifacts (default). | ## Super resolution AI upscaling to a target height. Assign the settings to `Video_Resize` and enable resize/crop. Width is computed to preserve the aspect ratio. ``` using VisioForge.Core.Types; VideoCapture1.Video_Resize = new MaxineSuperResSettings(modelsDir, height: 2160) { Mode = MaxineSuperResolutionEffectMode.HQSource, }; VideoCapture1.Video_ResizeOrCrop_Enabled = true; ``` | `MaxineSuperResolutionEffectMode` | Use for | | --- | --- | | `HQSource` | High-quality/high-bitrate sources; prioritizes artifact removal (default). | | `LQSource` | Heavily compressed sources; prioritizes detail enhancement. | ## Upscale A lighter-weight upscaler (vs. super resolution) with a tunable `Strength` (0.0–1.0, default 0.4). ``` using VisioForge.Core.Types; VideoCapture1.Video_Resize = new MaxineUpscaleSettings(modelsDir, height: 1080, strength: 0.4f); VideoCapture1.Video_ResizeOrCrop_Enabled = true; ``` ## Media Player engine The same effects apply to the `MediaPlayerCore` engine for AI enhancement during playback. Set `MediaPlayer1.Video_Effects_Enabled = true`, then use `MediaPlayer1.Video_Effects_Add(...)` for denoise/artifact, and assign `MediaPlayer1.Video_Resize` for super resolution/upscale. The player has no `Video_ResizeOrCrop_Enabled` flag — set `Video_Resize` before starting playback; it is applied when the playback graph is built (changing it during active playback only takes effect on the next start). ## Demos - **Nvidia Maxine Demo** (Video Capture, WPF) — `_DEMOS/Video Capture SDK/WPF/CSharp/Nvidia Maxine Demo`. - **Nvidia Maxine Player** (Media Player, WPF) — `_DEMOS/Media Player SDK/WPF/CSharp/Nvidia Maxine Player`. ## See also - [Effects Reference](../effects-reference/) — full catalog of CPU, GPU, and AI effects. - [Adding Effects](../add/) ---END OF PAGE--- ## Add Text Overlay to Video in C# with Custom Fonts and Fade **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/text-overlay/ **Description:** Create dynamic text overlays with font, color, position, rotation, and animation control for timestamps, captions, and branding in .NET video. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaPlayerCoreX, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Playback, Editing, Effects, C# **API:** TextOverlayVideoEffect, FontSettings, VideoEffectTextLogo # Implementing Text Overlays in Video Streams [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCore](#) [MediaPlayerCore](#) [VideoEditCore](#) ## Introduction Text overlays provide a powerful way to enhance video streams with dynamic information, branding, captions, or timestamps. This guide explores how to implement fully customizable text overlays with precise control over appearance, positioning, and animations. ## Classic Engine Implementation Our classic engines (VideoCaptureCore, MediaPlayerCore, VideoEditCore) offer a straightforward API for adding text to video streams. ### Basic Text Overlay Implementation The following example demonstrates a simple text overlay with custom positioning: ``` var effect = new VideoEffectTextLogo(true, "textoverlay"); // set position effect.Left = 20; effect.Top = 20; // set Font (System.Drawing.Font) effect.Font = new Font("Arial", 40); // set text effect.Text = "Hello, world!"; // set text color effect.FontColor = Color.Yellow; MediaPlayer1.Video_Effects_Add(effect); ``` ### Dynamic Information Display Options #### Timestamp and Date Display You can automatically display current date, time, or video timestamp information using specialized modes: ``` // set mode and mask effect.Mode = TextLogoMode.DateTime; effect.DateTimeMask = "yyyy-MM-dd. hh:mm:ss"; ``` The SDK supports custom formatting masks for timestamps and dates, allowing precise control over the displayed information format. Frame number display requires no additional configuration. ### Animation and Transition Effects #### Implementing Fade Effects Create smooth text appearances and disappearances with customizable fade effects: ``` // add the fade-in effect.FadeIn = true; effect.FadeInDuration = TimeSpan.FromMilliseconds(5000); // add the fade-out effect.FadeOut = true; effect.FadeOutDuration = TimeSpan.FromMilliseconds(5000); ``` ### Text Rotation Options Rotate your text overlay to match your design requirements: ``` // set rotation mode effect.RotationMode = TextRotationMode.Rm90; ``` ### Text Flip Transformations Apply mirror effects to your text for creative presentations: ``` // set flip mode effect.FlipMode = TextFlipMode.XAndY; ``` ## X-Engine Implementation Our newer X-engines (VideoCaptureCoreX, MediaPlayerCoreX, VideoEditCoreX) provide an enhanced API with additional features. ### Basic X-Engine Text Overlay ``` // text overlay var textOverlay = new TextOverlayVideoEffect() { Text = "Hello World!" }; // set position textOverlay.XPad = 20; textOverlay.YPad = 20; textOverlay.HorizontalAlignment = TextOverlayHAlign.Left; textOverlay.VerticalAlignment = TextOverlayVAlign.Top; // set Font - using object initializer textOverlay.Font = new FontSettings { Name = "Arial", Size = 24, Weight = FontWeight.Bold }; // Alternative: using constructor with font face string // textOverlay.Font = new FontSettings("Arial", "Bold", 24); // set text textOverlay.Text = "Hello, world!"; // set text color textOverlay.Color = SKColors.Yellow; // add the effect await videoCapture1.Video_Effects_AddOrUpdateAsync(textOverlay); ``` ### Advanced Dynamic Content Display #### Video Timestamp Integration Display the current position within the video: ``` // text overlay var textOverlay = new TextOverlayVideoEffect(); // set text textOverlay.Text = "Timestamp: "; // set Timestamp mode textOverlay.Mode = TextOverlayMode.Timestamp; // add the effect await videoCapture1.Video_Effects_AddOrUpdateAsync(textOverlay); ``` #### System Time Integration Show the current system time alongside your video content: ``` // text overlay var textOverlay = new TextOverlayVideoEffect(); // set text textOverlay.Text = "Time: "; // set System Time mode textOverlay.Mode = TextOverlayMode.SystemTime; // add the effect await videoCapture1.Video_Effects_AddOrUpdateAsync(textOverlay); ``` ## Best Practices for Text Overlays - Consider readability against different backgrounds - Use appropriate font sizes for the target display resolution - Implement fade effects for less intrusive overlays - Test performance impact with complex text effects --- For more code examples and implementation details, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ---END OF PAGE--- ## Video Sample Grabber — Extract RAW Frames in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-effects/video-sample-grabber/ **Description:** Extract RAW video frames from Video Capture, Media Player, and Video Edit SDKs with managed memory access and bitmap conversion in C#. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Editing, C#, NuGet **API:** VideoSampleGrabberBlock, VideoFrameXBufferEventArgs, VideoFrameBitmapEventArgs, VideoFrameSKBitmapEventArgs, VideoFrameBufferEventArgs # Video sample grabber usage [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Getting RAW video frames as unmanaged memory pointer inside the structure X-enginesClassic enginesMedia Blocks SDK ``` // Subscribe to the video frame buffer event VideoCapture1.OnVideoFrameBuffer += OnVideoFrameBuffer; private void OnVideoFrameBuffer(object sender, VideoFrameXBufferEventArgs e) { // Process the VideoFrameX object ProcessFrame(e.Frame); // If you've modified the frame and want to update the video stream e.UpdateData = true; } // Example of processing a VideoFrameX frame - adjusting brightness private void ProcessFrame(VideoFrameX frame) { // Only process RGB/BGR/RGBA/BGRA formats if (frame.Format != VideoFormatX.RGB && frame.Format != VideoFormatX.BGR && frame.Format != VideoFormatX.RGBA && frame.Format != VideoFormatX.BGRA) { return; } // Get the data as a byte array for manipulation byte[] data = frame.ToArray(); // Determine the pixel size based on format int pixelSize = (frame.Format == VideoFormatX.RGB || frame.Format == VideoFormatX.BGR) ? 3 : 4; // Brightness factor (1.2 = 20% brighter, 0.8 = 20% darker) float brightnessFactor = 1.2f; // Process each pixel for (int i = 0; i < data.Length; i += pixelSize) { // Adjust R, G, B channels for (int j = 0; j < 3; j++) { int newValue = (int)(data[i + j] * brightnessFactor); data[i + j] = (byte)Math.Min(255, newValue); } } // Copy the modified data back to the frame Marshal.Copy(data, 0, frame.Data, data.Length); } ``` ``` // Subscribe to the video frame buffer event VideoCapture1.OnVideoFrameBuffer += OnVideoFrameBuffer; private void OnVideoFrameBuffer(object sender, VideoFrameBufferEventArgs e) { // Process the VideoFrame structure ProcessFrame(e.Frame); // If you've modified the frame and want to update the video stream e.UpdateData = true; } // Example of processing a VideoFrame - adjusting brightness private void ProcessFrame(VideoFrame frame) { // Only process RGB format for this example if (frame.Info.Colorspace != RAWVideoColorSpace.RGB24) { return; } // Get the data as a byte array for manipulation byte[] data = frame.ToArray(); // Brightness factor (1.2 = 20% brighter, 0.8 = 20% darker) float brightnessFactor = 1.2f; // Process each pixel (RGB24 format = 3 bytes per pixel) for (int i = 0; i < data.Length; i += 3) { // Adjust R, G, B channels for (int j = 0; j < 3; j++) { int newValue = (int)(data[i + j] * brightnessFactor); data[i + j] = (byte)Math.Min(255, newValue); } } // Copy the modified data back to the frame Marshal.Copy(data, 0, frame.Data, data.Length); } ``` ``` // Create and set up video sample grabber block var videoSampleGrabberBlock = new VideoSampleGrabberBlock(VideoFormatX.RGB); videoSampleGrabberBlock.OnVideoFrameBuffer += OnVideoFrameBuffer; private void OnVideoFrameBuffer(object sender, VideoFrameXBufferEventArgs e) { // Process the VideoFrameX object ProcessFrame(e.Frame); // If you've modified the frame and want to update the video stream e.UpdateData = true; } // Example of processing a VideoFrameX frame - adjusting brightness private void ProcessFrame(VideoFrameX frame) { if (frame.Format != VideoFormatX.RGB) { return; } // Get the data as a byte array for manipulation byte[] data = frame.ToArray(); // Brightness factor (1.2 = 20% brighter, 0.8 = 20% darker) float brightnessFactor = 1.2f; // Process each pixel (RGB format = 3 bytes per pixel) for (int i = 0; i < data.Length; i += 3) { // Adjust R, G, B channels for (int j = 0; j < 3; j++) { int newValue = (int)(data[i + j] * brightnessFactor); data[i + j] = (byte)Math.Min(255, newValue); } } // Copy the modified data back to the frame Marshal.Copy(data, 0, frame.Data, data.Length); } ``` ## Working with bitmap frames If you need to work with managed Bitmap objects instead of raw memory pointers, you can use the `OnVideoFrameBitmap` event of the `core` classes or the SampleGrabberBlock: ``` // Subscribe to the bitmap frame event VideoCapture1.OnVideoFrameBitmap += OnVideoFrameBitmap; private void OnVideoFrameBitmap(object sender, VideoFrameBitmapEventArgs e) { // Process the Bitmap object ProcessBitmap(e.Frame); // If you've modified the bitmap and want to update the video stream e.UpdateData = true; } // Example of processing a Bitmap - adjusting brightness private void ProcessBitmap(Bitmap bitmap) { // Use Bitmap methods or Graphics to manipulate the image // This example uses ColorMatrix for brightness adjustment // Create a graphics object from the bitmap using (Graphics g = Graphics.FromImage(bitmap)) { // Create a color matrix for brightness adjustment float brightnessFactor = 1.2f; // 1.0 = no change, >1.0 = brighter, <1.0 = darker ColorMatrix colorMatrix = new ColorMatrix(new float[][] { new float[] {brightnessFactor, 0, 0, 0, 0}, new float[] {0, brightnessFactor, 0, 0, 0}, new float[] {0, 0, brightnessFactor, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }); // Create an ImageAttributes object and set the color matrix using (ImageAttributes attributes = new ImageAttributes()) { attributes.SetColorMatrix(colorMatrix); // Draw the image with the brightness adjustment g.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel, attributes); } } } ``` ## Working with SkiaSharp for cross-platform applications For cross-platform applications, the VideoSampleGrabberBlock provides the ability to work with SkiaSharp, a high-performance 2D graphics API for .NET. This is especially useful for applications targeting multiple platforms including mobile and web. ### Using the OnVideoFrameSKBitmap event ``` // First, add the SkiaSharp NuGet package to your project // Install-Package SkiaSharp // Import necessary namespaces using SkiaSharp; using VisioForge.Core.MediaBlocks.VideoProcessing; using VisioForge.Core.Types.X.Events; // Create a VideoSampleGrabberBlock with RGBA or BGRA format // Note: OnVideoFrameSKBitmap event works only with RGBA or BGRA formats var videoSampleGrabberBlock = new VideoSampleGrabberBlock(VideoFormatX.BGRA); // Enable the SaveLastFrame property if you want to take snapshots later videoSampleGrabberBlock.SaveLastFrame = true; // Subscribe to the SkiaSharp bitmap event videoSampleGrabberBlock.OnVideoFrameSKBitmap += OnVideoFrameSKBitmap; // Event handler for SkiaSharp bitmap frames private void OnVideoFrameSKBitmap(object sender, VideoFrameSKBitmapEventArgs e) { // Process the SKBitmap ProcessSKBitmap(e.Frame); // Note: Unlike VideoFrameBitmapEventArgs, VideoFrameSKBitmapEventArgs does not have // an UpdateData property as it's designed for frame viewing/analysis only } // Example of processing an SKBitmap - adjusting brightness private void ProcessSKBitmap(SKBitmap bitmap) { // Create a new bitmap to hold the processed image using (var surface = SKSurface.Create(new SKImageInfo(bitmap.Width, bitmap.Height))) { var canvas = surface.Canvas; // Set up a paint with a color filter for brightness adjustment using (var paint = new SKPaint()) { // Create a brightness filter (1.2 = 20% brighter) float brightnessFactor = 1.2f; var colorMatrix = new float[] { brightnessFactor, 0, 0, 0, 0, 0, brightnessFactor, 0, 0, 0, 0, 0, brightnessFactor, 0, 0, 0, 0, 0, 1, 0 }; paint.ColorFilter = SKColorFilter.CreateColorMatrix(colorMatrix); // Draw the original bitmap with the brightness filter applied canvas.DrawBitmap(bitmap, 0, 0, paint); // If you need to get the result as a new SKBitmap: var processedImage = surface.Snapshot(); using (var processedBitmap = SKBitmap.FromImage(processedImage)) { // Use processedBitmap for further operations or display // For example, display it in a SkiaSharp view // mySkiaView.SKBitmap = processedBitmap.Copy(); } } } } ``` ### Taking snapshots with SkiaSharp ``` // Create a method to capture and save a snapshot private void CaptureSnapshot(string filePath) { // Make sure SaveLastFrame was enabled on the VideoSampleGrabberBlock if (videoSampleGrabberBlock.SaveLastFrame) { // Get the last frame as an SKBitmap using (var bitmap = videoSampleGrabberBlock.GetLastFrameAsSKBitmap()) { if (bitmap != null) { // Save the bitmap to a file using (var image = SKImage.FromBitmap(bitmap)) using (var data = image.Encode(SKEncodedImageFormat.Png, 100)) using (var stream = File.OpenWrite(filePath)) { data.SaveTo(stream); } } } } } ``` ### Advantages of using SkiaSharp 1. **Cross-platform compatibility**: Works on Windows, macOS, Linux, iOS, Android, and WebAssembly 2. **Performance**: Provides high-performance graphics processing 3. **Modern API**: Offers a comprehensive set of drawing, filtering, and transformation functions 4. **Memory efficiency**: More efficient memory management compared to System.Drawing 5. **No platform dependencies**: No dependency on platform-specific imaging libraries ## Frame processing information You can get video frames from live sources or files using the `OnVideoFrameBuffer` and `OnVideoFrameBitmap` events. The `OnVideoFrameBuffer` event is faster and provides the unmanaged memory pointer for the decoded frame. The `OnVideoFrameBitmap` event is slower, but you get the decoded frame as the `Bitmap` class object. ### Understanding the frame objects - **VideoFrameX** (X-engines): Contains frame data, dimensions, format, timestamp, and methods for manipulating raw video data - **VideoFrame** (Classic engines): Similar structure but with a different memory layout - **Common properties**: - Width/Height: Frame dimensions - Format/Colorspace: Pixel format (RGB, BGR, RGBA, etc.) - Stride: Number of bytes per scan line - Timestamp: Frame's position in the video timeline - Data: Pointer to unmanaged memory with pixel data ### Important considerations 1. The frame's pixel format affects how you process the data: 2. RGB/BGR: 3 bytes per pixel 3. RGBA/BGRA/ARGB: 4 bytes per pixel (with alpha channel) 4. YUV formats: Different component arrangements 5. Set `e.UpdateData = true` if you've modified the frame data and want the changes to be visible in the video stream. 6. For processing that requires multiple frames or complex operations, consider using a buffer or queue to store frames. 7. When using `OnVideoFrameSKBitmap`, select either RGBA or BGRA as the frame format when creating the VideoSampleGrabberBlock. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## AV1 Video Encoding in C# .NET - Configuration Guide **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-encoders/av1/ **Description:** Configure AV1 encoders for cross-platform video capture, editing, and media pipelines. Next-gen compression with VisioForge SDK C# code examples. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, Conversion, AV1, C# **API:** VideoCaptureCoreX, VideoEditCoreX, AMFAV1EncoderSettings, NVENCAV1EncoderSettings, QSVAV1EncoderSettings # AV1 Encoders [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) VisioForge supports multiple AV1 encoder implementations, each with its own unique features and capabilities. This document covers the available encoders and their configuration options. Currently, AV1 encoder are supported in the cross-platform engines: `VideoCaptureCoreX`, `VideoEditCoreX`, and `Media Blocks SDK`. ## Available Encoders 1. [AMD AMF AV1 Encoder (AMF)](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.AMFAV1EncoderSettings.html) 2. [NVIDIA NVENC AV1 Encoder (NVENC)](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.NVENCAV1EncoderSettings.html) 3. [Intel QuickSync AV1 Encoder (QSV)](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.QSVAV1EncoderSettings.html) 4. [AOM AV1 Encoder](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.AOMAV1EncoderSettings.html) 5. [RAV1E Encoder](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.RAV1EEncoderSettings.html) You can use AV1 encoder with [WebM output](../../output-formats/webm/) or for network streaming. ## AMD AMF AV1 Encoder The AMD AMF AV1 encoder provides hardware-accelerated encoding using AMD graphics cards. ### Features - Multiple quality presets - Variable bitrate control modes - GOP size control - QP (Quantization Parameter) control - Smart Access Video support ### Rate Control Modes - `Default`: Depends on Usage - `CQP`: Constant QP - `LCVBR`: Latency Constrained VBR - `VBR`: Peak Constrained VBR - `CBR`: Constant Bitrate ### Sample Usage ``` var encoderSettings = new AMFAV1EncoderSettings { Bitrate = 3000, // 3 Mbps GOPSize = 30, // GOP size of 30 frames Preset = AMFAV1EncoderPreset.Quality, // Quality preset RateControl = AMFAV1RateControlMode.VBR, // Variable Bitrate mode Usage = AMFAV1EncoderUsage.Transcoding, // Transcoding usage MaxBitrate = 5000, // 5 Mbps max bitrate QpI = 26, // I-frame QP QpP = 26, // P-frame QP RefFrames = 1, // Number of reference frames SmartAccessVideo = false // Smart Access Video disabled }; ``` ## NVIDIA NVENC AV1 Encoder NVIDIA's NVENC AV1 encoder provides hardware-accelerated encoding using NVIDIA GPUs. ### Features - Multiple encoding presets - Adaptive B-frame support - Temporal AQ (Adaptive Quantization) - VBV (Video Buffering Verifier) buffer control - Spatial AQ support ### Rate Control Modes - `Default`: Default mode - `ConstQP`: Constant Quantization Parameter - `CBR`: Constant Bitrate - `VBR`: Variable Bitrate - `CBR_LD_HQ`: Low-delay CBR, high quality - `CBR_HQ`: CBR, high quality (slower) - `VBR_HQ`: VBR, high quality (slower) ### Sample Usage ``` var encoderSettings = new NVENCAV1EncoderSettings { Bitrate = 3000, // 3 Mbps Preset = NVENCPreset.HighQuality, // High quality preset RateControl = NVENCRateControl.VBR, // Variable Bitrate mode GOPSize = 75, // GOP size of 75 frames MaxBitrate = 5000, // 5 Mbps max bitrate BFrames = 2, // 2 B-frames between I and P RCLookahead = 8, // 8 frames lookahead TemporalAQ = true, // Enable temporal AQ Tune = NVENCTune.HighQuality, // High quality tuning VBVBufferSize = 6000 // 6000k VBV buffer }; ``` ## Intel QuickSync AV1 Encoder Intel's QuickSync AV1 encoder provides hardware-accelerated encoding using Intel GPUs. ### Features - Low latency mode support - Configurable target usage - Reference frame control - Flexible GOP size settings ### Rate Control Modes - `CBR`: Constant Bitrate - `VBR`: Variable Bitrate - `CQP`: Constant Quantizer ### Sample Usage ``` var encoderSettings = new QSVAV1EncoderSettings { Bitrate = 2000, // 2 Mbps LowLatency = false, // Standard latency mode TargetUsage = 4, // Balanced quality/speed GOPSize = 30, // GOP size of 30 frames MaxBitrate = 4000, // 4 Mbps max bitrate QPI = 26, // I-frame QP QPP = 28, // P-frame QP RateControl = QSVAV1EncRateControl.VBR, // Variable Bitrate mode RefFrames = 1 // Number of reference frames }; ``` ## AOM AV1 Encoder The Alliance for Open Media (AOM) AV1 encoder is a software-based reference implementation. ### Features - Buffer control settings - CPU usage optimization - Frame dropping support - Multi-threading capabilities - Super-resolution support ### Rate Control Modes - `VBR`: Variable Bit Rate Mode - `CBR`: Constant Bit Rate Mode - `CQ`: Constrained Quality Mode - `Q`: Constant Quality Mode ### Sample Usage ``` var encoderSettings = new AOMAV1EncoderSettings { BufferInitialSize = TimeSpan.FromMilliseconds(4000), BufferOptimalSize = TimeSpan.FromMilliseconds(5000), BufferSize = TimeSpan.FromMilliseconds(6000), CPUUsed = 4, // CPU usage level DropFrame = 0, // Disable frame dropping RateControl = AOMAV1EncoderEndUsageMode.VBR, // Variable Bitrate mode TargetBitrate = 256, // 256 Kbps Threads = 0, // Auto thread count UseRowMT = true, // Enable row-based threading SuperResMode = AOMAV1SuperResolutionMode.None // No super-resolution }; ``` ## RAV1E Encoder RAV1E is a fast and safe AV1 encoder written in Rust. ### Features - Speed preset control - Quantizer settings - Key frame interval control - Low latency mode - Psychovisual tuning ### Sample Usage ``` var encoderSettings = new RAV1EEncoderSettings { Bitrate = 3000, // 3 Mbps LowLatency = false, // Standard latency mode MaxKeyFrameInterval = 240, // Maximum keyframe interval MinKeyFrameInterval = 12, // Minimum keyframe interval MinQuantizer = 0, // Minimum quantizer value Quantizer = 100, // Base quantizer value SpeedPreset = 6, // Speed preset (0-10) Tune = RAV1EEncoderTune.Psychovisual // Psychovisual tuning }; ``` ## General Usage Notes 1. All encoders implement the `IAV1EncoderSettings` interface, providing a consistent way to create encoder blocks. 2. Each encoder has its own specific set of optimizations and trade-offs. 3. Hardware encoders (AMF, NVENC, QSV) generally provide better performance but may have specific hardware requirements. 4. Software encoders (AOM, RAV1E) offer more flexibility but may require more CPU resources. ## Recommendations - For AMD GPUs: Use AMF encoder - For NVIDIA GPUs: Use NVENC encoder - For Intel GPUs: Use QSV encoder - For maximum quality: Use AOM encoder - For CPU-efficient encoding: Use RAV1E encoder ## Best Practices 1. Always check encoder availability before using it 2. Set appropriate bitrates based on your target resolution and framerate 3. Use appropriate GOP sizes based on your content type 4. Consider the trade-off between quality and encoding speed 5. Test different rate control modes to find the best fit for your use case ---END OF PAGE--- ## H264 Encoders for .NET — Hardware and Software Options **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-encoders/h264/ **Description:** Implement H264 video encoding with software and hardware acceleration, rate control options, and cross-platform support in .NET SDKs. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, H.264, C# **API:** H264EncoderBlock, AndroidH264EncoderSettings, OpenH264EncoderSettings, AMFH264EncoderSettings, NVENCH264EncoderSettings # H264 Encoders [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) This document provides detailed information about available H264 encoders, their features, rate control options, and usage examples. For Windows-only engines check the [MP4 output](../../output-formats/mp4/) page. ## Overview The following H264 encoders are available: 1. AMD AMF H264 Encoder (GPU-accelerated) 2. NVIDIA NVENC H264 Encoder (GPU-accelerated) 3. Intel QSV H264 Encoder (GPU-accelerated) 4. OpenH264 Encoder (Software) 5. Apple Media H264 Encoder (Hardware-accelerated for Apple devices) 6. VAAPI H264 Encoder (Linux hardware acceleration) 7. Android Hardware H264 Encoder (MediaCodec, auto-selects best SoC encoder) ## AMD AMF H264 Encoder AMD's Advanced Media Framework (AMF) provides hardware-accelerated encoding on AMD GPUs. ### Key Features - Hardware-accelerated encoding - Multiple preset options (Balanced, Speed, Quality) - Configurable GOP size - CABAC entropy coding support - Various rate control methods ### Rate Control Options ``` public enum AMFH264EncoderRateControl { Default = -1, // Default, depends on usage CQP = 0, // Constant QP CBR = 1, // Constant bitrate VBR = 2, // Peak constrained VBR LCVBR = 3 // Latency Constrained VBR } ``` ### Sample Usage ``` var settings = new AMFH264EncoderSettings { Bitrate = 5000, // 5 Mbps CABAC = true, RateControl = AMFH264EncoderRateControl.CBR, Preset = AMFH264EncoderPreset.Quality, Profile = AMFH264EncoderProfile.Main, Level = AMFH264EncoderLevel.Level4_2, GOPSize = 30 }; var encoder = new H264EncoderBlock(settings); ``` ## NVIDIA NVENC H264 Encoder NVIDIA's hardware-based video encoder provides efficient H264 encoding on NVIDIA GPUs. ### Key Features - Hardware-accelerated encoding - B-frame support - Adaptive quantization - Multiple reference frames - Weighted prediction - Look-ahead support ### Rate Control Options Inherited from NVENCBaseEncoderSettings with additional H264-specific options: - Constant Bitrate (CBR) - Variable Bitrate (VBR) - Constant QP (CQP) - Quality-based VBR ### Sample Usage ``` var settings = new NVENCH264EncoderSettings { Bitrate = 5000, MaxBitrate = 8000, RCLookahead = 20, BFrames = 2, Profile = NVENCH264Profile.High, Level = NVENCH264Level.Level4_2, TemporalAQ = true }; var encoder = new H264EncoderBlock(settings); ``` ## Intel Quick Sync Video (QSV) H264 Encoder Intel's hardware-based video encoder available on Intel processors with integrated graphics. ### Key Features - Hardware-accelerated encoding - Low latency mode - Multiple rate control methods - B-frame support - Intelligent rate control options ### Rate Control Options ``` public enum QSVH264EncRateControl { CBR = 1, // Constant Bitrate VBR = 2, // Variable Bitrate CQP = 3, // Constant Quantizer AVBR = 4, // Average Variable Bitrate LA_VBR = 8, // Look Ahead VBR ICQ = 9, // Intelligent CQP VCM = 10, // Video Conferencing Mode LA_ICQ = 11, // Look Ahead ICQ LA_HRD = 13, // HRD compliant LA QVBR = 14 // Quality-defined VBR } ``` ### Sample Usage ``` var settings = new QSVH264EncoderSettings { Bitrate = 5000, MaxBitrate = 8000, RateControl = QSVH264EncRateControl.VBR, Profile = QSVH264EncProfile.High, Level = QSVH264EncLevel.Level4_2, LowLatency = true, BFrames = 2 }; var encoder = new H264EncoderBlock(settings); ``` ## OpenH264 Encoder Cisco's open-source H264 software encoder. ### Key Features - Software-based encoding - Multiple complexity levels - Scene change detection - Adaptive quantization - Denoising support ### Rate Control Options ``` public enum OpenH264RCMode { Quality = 0, // Quality mode Bitrate = 1, // Bitrate mode Buffer = 2, // Buffer based Off = -1 // Rate control off } ``` ### Sample Usage ``` var settings = new OpenH264EncoderSettings { Bitrate = 5000, RateControl = OpenH264RCMode.Bitrate, Profile = OpenH264Profile.Main, Level = OpenH264Level.Level4_2, Complexity = OpenH264Complexity.Medium, EnableDenoise = true, SceneChangeDetection = true }; var encoder = new H264EncoderBlock(settings); ``` ## Apple Media H264 Encoder Hardware-accelerated encoder for Apple platforms. ### Key Features - Hardware acceleration on Apple devices - Real-time encoding support - Frame reordering options - Quality-based encoding ### Sample Usage ``` var settings = new AppleMediaH264EncoderSettings { Bitrate = 5000, AllowFrameReordering = true, Quality = 0.8, Realtime = true }; var encoder = new H264EncoderBlock(settings); ``` ## VAAPI H264 Encoder Video Acceleration API encoder for Linux systems. ### Key Features - Hardware acceleration on Linux - Multiple profile support - Trellis quantization - B-frame support - Various rate control methods ### Rate Control Options ``` public enum VAAPIH264RateControl { CQP = 1, // Constant QP CBR = 2, // Constant bitrate VBR = 4, // Variable bitrate VBRConstrained = 5, // Constrained VBR ICQ = 7, // Intelligent CQP QVBR = 8 // Quality-defined VBR } ``` ### Sample Usage ``` var settings = new VAAPIH264EncoderSettings { Bitrate = 5000, RateControl = VAAPIH264RateControl.CBR, Profile = VAAPIH264EncoderProfile.Main, MaxBFrames = 2, Trellis = true, CABAC = true }; var encoder = new H264EncoderBlock(settings); ``` ## Android Hardware H264 Encoder On Android (API 21+), use `AndroidH264EncoderSettings`. It wraps the Android `MediaCodec` API via GStreamer's `amcvidenc-*` element family, auto-detecting the best hardware encoder on the device (Qualcomm, Exynos, MediaTek, etc.) — so a single settings class covers every Android SoC. ### Sample usage ``` // Build is Android-only (this type is gated by the __ANDROID__ preprocessor). var settings = new AndroidH264EncoderSettings { Bitrate = 8_000, // kbit/s (so 8000 = 8 Mbps) IFrameInterval = TimeSpan.FromSeconds(2), // Keyframe cadence ParseStream = true, // Leave true unless you are piping raw frames into SRT }; // Optional: pin a specific encoder element name, bypassing auto-detection. // settings.CodecName = "amcvidenc-c2qtiavcencoder"; // Qualcomm Codec2 path, for example var encoder = new H264EncoderBlock(settings); ``` ### Key characteristics - Single settings class for every Android SoC — no per-vendor types - `Bitrate` in kbit/s (the GStreamer element receives bits/sec internally) - `IFrameInterval` is a `TimeSpan` — on Android 25+ fractional seconds work (`i-frame-interval-float`); older versions truncate to whole seconds - `CodecName` overrides auto-detection when you know which `amcvidenc-*` element you want ### Properties bag Only `CustomH264EncoderSettings` and `AndroidH264EncoderSettings` expose a `Properties` dictionary for forwarding raw GStreamer element properties that don't have first-class C# wrappers. The standard implementations (OpenH264, NVENCH264, QSVH264, AMFH264, AppleMediaH264, VAAPIH264) do **not** — their tuning knobs are exposed as typed C# properties on the settings class. ``` // Custom or Android settings only var settings = new CustomH264EncoderSettings("x264enc"); settings.Properties["bitrate-mode"] = "constant"; settings.Properties["complexity"] = "max"; ``` ## Best Practices 1. **Encoder Selection** 2. Use hardware encoders (AMD, NVIDIA, Intel) when available for better performance 3. Fall back to OpenH264 when hardware encoding is not available 4. Use platform-specific encoders (Apple Media, VAAPI, Android hardware) when targeting specific platforms 5. **Rate Control Selection** 6. Use CBR for streaming applications where consistent bitrate is important 7. Use VBR for offline encoding where quality is more important than bitrate consistency 8. Use CQP for highest quality when bitrate is not a concern 9. Consider using look-ahead options for better quality when latency is not critical 10. **Performance Optimization** 11. Adjust GOP size based on content type (smaller for high motion, larger for static content) 12. Enable CABAC for better compression efficiency when latency is not critical 13. Use appropriate profile and level for target devices 14. Consider B-frames for better compression but be aware of latency impact 15. **Platform Detection** — use the `IsAvailable()` static on each settings class to pick a concrete encoder at runtime: ``` if (NVENCH264EncoderSettings.IsAvailable()) { encoder = new H264EncoderBlock(new NVENCH264EncoderSettings { Bitrate = 6_000 }); } else if (QSVH264EncoderSettings.IsAvailable()) { encoder = new H264EncoderBlock(new QSVH264EncoderSettings { Bitrate = 6_000 }); } else if (AMFH264EncoderSettings.IsAvailable()) { encoder = new H264EncoderBlock(new AMFH264EncoderSettings { Bitrate = 6_000 }); } else { // Software fallback encoder = new H264EncoderBlock(new OpenH264EncoderSettings { Bitrate = 6_000 }); } ``` ---END OF PAGE--- ## HEVC Hardware Encoding with AMD, NVIDIA, and Intel GPUs **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-encoders/hevc/ **Description:** Implement hardware-accelerated HEVC (H.265) encoding with AMD, NVIDIA, and Intel GPUs for efficient video compression in .NET applications. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, Conversion, Webcam, H.265, C# **API:** AMFHEVCEncoderSettings, NVENCHEVCEncoderSettings, QSVHEVCEncoderSettings, IHEVCEncoderSettings, SVTHEVCEncoderSettings # HEVC Hardware Encoding in .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) This guide explores hardware-accelerated HEVC (H.265) encoding options available in VisioForge .NET SDKs. We'll cover implementation details for AMD, NVIDIA, and Intel GPU encoders, helping you choose the right solution for your video processing needs. For Windows-specific output formats, refer to our [MP4 output documentation](../../output-formats/mp4/). ## Hardware HEVC Encoders Overview Modern GPUs offer powerful hardware encoding capabilities that significantly outperform software-based solutions. VisioForge SDKs support three major hardware HEVC encoders: - **AMD AMF** - For AMD Radeon GPUs - **NVIDIA NVENC** - For NVIDIA GeForce and professional GPUs - **Intel QuickSync** - For Intel CPUs with integrated graphics Each encoder provides unique features and optimization options. Let's explore their capabilities and implementation details. ## AMD AMF HEVC Encoder AMD's Advanced Media Framework (AMF) delivers hardware-accelerated HEVC encoding on compatible Radeon GPUs. It balances encoding speed, quality, and efficiency for various scenarios. ### Key Features and Settings - **Rate Control Methods**: - `CQP` (Constant QP) for fixed quality settings - `LCVBR` (Latency Constrained VBR) for streaming - `VBR` (Variable Bitrate) for offline encoding - `CBR` (Constant Bitrate) for reliable bandwidth usage - **Usage Profiles**: - Transcoding (highest quality) - Ultra Low Latency (for real-time applications) - Low Latency (for interactive streaming) - Web Camera (optimized for webcam sources) - **Quality Presets**: Balance between encoding speed and output quality ### Implementation Example ``` var encoder = new AMFHEVCEncoderSettings { Bitrate = 3000, // 3 Mbps target bitrate MaxBitrate = 5000, // 5 Mbps peak bitrate RateControl = AMFHEVCEncoderRateControl.CBR, // Quality optimization Preset = AMFHEVCEncoderPreset.Quality, Usage = AMFHEVCEncoderUsage.Transcoding, // GOP and frame settings GOPSize = 30, // Keyframe interval QP_I = 22, // I-frame quantization parameter QP_P = 22, // P-frame quantization parameter RefFrames = 1 // Reference frames count }; ``` ## NVIDIA NVENC HEVC Encoder NVIDIA's NVENC technology provides dedicated encoding hardware on GeForce and professional GPUs, offering excellent performance and quality across various bitrates. ### Key Capabilities - **Multiple Profile Support**: - Main (8-bit) - Main10 (10-bit HDR) - Main444 (high color precision) - Extended bit depth options (12-bit) - **Advanced Encoding Features**: - B-frame support with adaptive placement - Temporal Adaptive Quantization - Weighted Prediction - Look-ahead rate control - **Performance Presets**: From quality-focused to ultra-fast encoding ### Implementation Example ``` var encoder = new NVENCHEVCEncoderSettings { // Bitrate configuration Bitrate = 3000, // 3 Mbps target MaxBitrate = 5000, // 5 Mbps maximum // Profile settings Profile = NVENCHEVCProfile.Main, Level = NVENCHEVCLevel.Level5_1, // Quality enhancement options BFrames = 2, // Number of B-frames BAdaptive = true, // Adaptive B-frame placement TemporalAQ = true, // Temporal adaptive quantization WeightedPrediction = true, // Improves quality for fades RCLookahead = 20, // Frames to analyze for rate control // Buffer settings VBVBufferSize = 0 // Use default buffer size }; ``` ## Intel QuickSync HEVC Encoder Intel QuickSync leverages the integrated GPU present in modern Intel processors for efficient hardware encoding, making it accessible without a dedicated graphics card. ### Key Features - **Versatile Rate Control Options**: - `CBR` (Constant Bitrate) - `VBR` (Variable Bitrate) - `CQP` (Constant Quantizer) - `ICQ` (Intelligent Constant Quality) - `VCM` (Video Conferencing Mode) - `QVBR` (Quality-defined VBR) - **Optimization Settings**: - Target Usage parameter (quality vs speed balance) - Low-latency mode for streaming - HDR conformance controls - Closed caption insertion options - **Profile Support**: - Main (8-bit) - Main10 (10-bit HDR) ### Implementation Example ``` var encoder = new QSVHEVCEncoderSettings { // Bitrate settings Bitrate = 3000, // 3 Mbps target MaxBitrate = 5000, // 5 Mbps peak RateControl = QSVHEVCEncRateControl.VBR, // Quality tuning TargetUsage = 4, // 1=Best quality, 7=Fastest encoding // Stream structure GOPSize = 30, // Keyframe interval RefFrames = 2, // Reference frames // Feature configuration Profile = QSVHEVCEncProfile.Main, LowLatency = false, // Enable for streaming // Advanced options CCInsertMode = QSVHEVCEncSEIInsertMode.Insert, DisableHRDConformance = false }; ``` ## Quality Presets for Simplified Configuration All encoders support standardized quality presets through the `VideoQuality` enum, providing a simplified configuration approach: - **Low**: 1 Mbps target, 2 Mbps max (for basic streaming) - **Normal**: 3 Mbps target, 5 Mbps max (for standard content) - **High**: 6 Mbps target, 10 Mbps max (for detailed content) - **Very High**: 15 Mbps target, 25 Mbps max (for premium quality) ### Using Quality Presets ``` // For AMD AMF var amfEncoder = new AMFHEVCEncoderSettings(VideoQuality.High); // For NVIDIA NVENC var nvencEncoder = new NVENCHEVCEncoderSettings(VideoQuality.High); // For Intel QuickSync var qsvEncoder = new QSVHEVCEncoderSettings(VideoQuality.High); ``` ## Hardware Detection and Fallback Strategy A robust implementation should check for encoder availability and implement appropriate fallbacks: ``` // Create the most appropriate encoder for the current system IHEVCEncoderSettings GetOptimalHEVCEncoder() { if (AMFHEVCEncoderSettings.IsAvailable()) { return new AMFHEVCEncoderSettings(VideoQuality.High); } else if (NVENCHEVCEncoderSettings.IsAvailable()) { return new NVENCHEVCEncoderSettings(VideoQuality.High); } else if (QSVHEVCEncoderSettings.IsAvailable()) { return new QSVHEVCEncoderSettings(VideoQuality.High); } else { #if NET_LINUX // Fall back to the SVT-HEVC software encoder on Linux (Linux-only — see SVTHEVCEncoderSettings). return new SVTHEVCEncoderSettings(); #else // The X engine does NOT ship a typed IHEVCEncoderSettings fallback for Windows or Apple. // (On Apple platforms, VideoToolbox HEVC is reachable only via lower-level GStreamer wiring — // no `AppleMedia*HEVC*Settings` class exists; only AppleMediaH264EncoderSettings is provided.) // Let the caller decide: keep H.264 output, install a GPU driver enabling QSV/NVENC/AMF, or // use the classic engine's FFMPEG-EXE pipeline. throw new NotSupportedException("No HEVC encoder available on this platform. Install a GPU driver or switch to H.264."); #endif } } ``` ## Best Practices for HEVC Encoding ### 1. Encoder Selection - **AMD GPUs**: Best for applications where you know users have AMD hardware - **NVIDIA GPUs**: Provides consistent quality across generations, ideal for professional applications - **Intel QuickSync**: Great universal option when a dedicated GPU isn't guaranteed ### 2. Rate Control Selection - **Streaming**: Use CBR for consistent bandwidth utilization - **VoD Content**: VBR provides better quality at the same file size - **Archival**: CQP ensures consistent quality regardless of content complexity ### 3. Performance Optimization - Lower the reference frames count for faster encoding - Adjust GOP size based on content type (smaller for high motion, larger for static scenes) - Consider disabling B-frames for ultra-low latency applications ### 4. Quality Enhancement - Enable adaptive quantization features for content with varying complexity - Use weighted prediction for content with fades or gradual transitions - Implement look-ahead when encoding quality is more important than latency ## Common Troubleshooting 1. **Encoder unavailability**: Ensure GPU drivers are up-to-date 2. **Lower than expected quality**: Check if quality presets match your content type 3. **Performance issues**: Monitor GPU utilization and adjust settings accordingly 4. **Compatibility problems**: Verify target devices support the selected HEVC profile ## Conclusion Hardware-accelerated HEVC encoding offers significant performance advantages for .NET applications dealing with video processing. By leveraging AMD AMF, NVIDIA NVENC, or Intel QuickSync through VisioForge SDKs, you can achieve optimal balance between quality, speed, and efficiency. Choose the right encoder and settings based on your specific requirements, target audience, and content type to deliver the best possible experience in your applications. Start by detecting available hardware encoders, implementing appropriate quality settings, and testing across various content types to ensure optimal results. ---END OF PAGE--- ## Video Encoders for VisioForge .NET — H264, HEVC, AV1 **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-encoders/ **Description:** Comprehensive overview of video encoders with hardware acceleration, codec features, and performance optimization for .NET video applications. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming **API:** NVENCH264EncoderSettings, NVENCHEVCEncoderSettings, AMFH264EncoderSettings, AMFHEVCEncoderSettings, QSVH264EncoderSettings, QSVHEVCEncoderSettings, OpenH264EncoderSettings, AOMAV1EncoderSettings # Video Encoders for VisioForge .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Video Encoders Video encoders are essential components in multimedia processing applications, responsible for compressing video data while maintaining optimal quality. VisioForge .NET SDKs incorporate multiple advanced encoders to meet diverse development requirements across different platforms and use cases. This guide provides detailed information about each encoder's capabilities, performance characteristics, and implementation details to help .NET developers make informed decisions for their multimedia applications. ## Hardware vs. Software Encoding When developing video processing applications, choosing between hardware and software encoders significantly impacts application performance and user experience. ### Hardware-Accelerated Encoders Hardware encoders utilize dedicated processing units (GPUs or specialized hardware): - **Advantages**: Lower CPU usage, higher encoding speeds, improved battery efficiency - **Use cases**: Real-time streaming, live video processing, mobile applications - **Examples in our SDK**: NVIDIA NVENC, AMD AMF, Intel QuickSync ### Software Encoders Software encoders run on the CPU without specialized hardware: - **Advantages**: Greater compatibility, more quality control options, platform independence - **Use cases**: High-quality offline encoding, environments without compatible hardware - **Examples in our SDK**: OpenH264, Software MJPEG encoder ## Available Video Encoders Our SDKs provide extensive encoder options to accommodate various project requirements: ### H.264 (AVC) Encoders H.264 remains one of the most widely used video codecs, offering excellent compression efficiency and broad compatibility. #### Key Features: - Multiple profile support (Baseline, Main, High) - Adjustable bitrate controls (CBR, VBR, CQP) - B-frame and reference frame configuration - Hardware acceleration options from major vendors [Learn more about H.264 encoders →](h264/) ### HEVC (H.265) Encoders HEVC delivers superior compression efficiency compared to H.264, enabling higher quality video at the same bitrate or comparable quality at lower bitrates. #### Key Features: - Approximately 50% better compression than H.264 - 8-bit and 10-bit color depth support - Multiple hardware acceleration options - Advanced rate control mechanisms [Learn more about HEVC encoders →](hevc/) ### AV1 Encoder AV1 represents the next generation of video codecs, offering superior compression efficiency particularly suited for web streaming. #### Key Features: - Royalty-free open standard - Better compression than HEVC - Increasing browser and device support - Optimized for web content delivery [Learn more about AV1 encoder →](av1/) ### MJPEG Encoders Motion JPEG provides frame-by-frame JPEG compression, useful for specific applications where individual frame access is important. #### Key Features: - Simple implementation - Low encoding latency - Independent frame access - Hardware and software implementations [Learn more about MJPEG encoders →](mjpeg/) ### VP8 and VP9 Encoders These open codecs developed by Google offer royalty-free alternatives with good compression efficiency. #### Key Features: - Open-source implementation - Competitive quality-to-bitrate ratio - Wide web browser support - Suitable for WebM container format [Learn more about VP8/VP9 encoders →](vp8-vp9/) ### Windows Media Video Encoder The WMV encoder provides compatibility with Windows ecosystem and legacy applications. #### Key Features: - Native Windows integration - Multiple profile options - Compatible with Windows Media framework - Efficient for Windows-centric deployments [Learn more about WMV encoder →](../output-formats/wmv/) ## Encoder Selection Guidelines Selecting the optimal encoder depends on various factors: ### Platform Compatibility - **Windows**: All encoders supported - **macOS**: Apple Media encoders, OpenH264, AV1 - **Linux**: VAAPI, OpenH264, software implementations ### Hardware Requirements When using hardware-accelerated encoders, verify system compatibility: Hardware-encoder availability checks live on the codec-specific settings classes (there is no shared `NVENCEncoderSettings` / `AMFEncoderSettings` / `QSVEncoderSettings` base type — instantiate `NVENCH264EncoderSettings`, `AMFHEVCEncoderSettings`, `QSVH264EncoderSettings`, etc., depending on the codec you need): ``` // Probe H.264 hardware encoders in priority order. if (NVENCH264EncoderSettings.IsAvailable()) { // NVIDIA GPU available — use NVENC H.264. var settings = new NVENCH264EncoderSettings(); } else if (QSVH264EncoderSettings.IsAvailable()) { // Intel CPU with Quick Sync available. var settings = new QSVH264EncoderSettings(); } else if (AMFH264EncoderSettings.IsAvailable()) { // AMD GPU available — use AMF H.264. var settings = new AMFH264EncoderSettings(); } else { // Fallback to software encoder (cross-platform). var settings = new OpenH264EncoderSettings(); } ``` ### Quality vs. Performance Tradeoffs Different encoders offer varying balances between quality and encoding speed: | Encoder Type | Quality | Performance | CPU Usage | | --- | --- | --- | --- | | NVENC H.264 | Good | Excellent | Very Low | | NVENC HEVC | Very Good | Very Good | Very Low | | AMF H.264 | Good | Very Good | Very Low | | QSV H.264 | Good | Excellent | Very Low | | OpenH264 | Good-Excellent | Moderate | High | | AV1 | Excellent | Poor-Moderate | Very High | ### Encoding Scenarios - **Live streaming**: Prefer hardware encoders with CBR rate control - **Video recording**: Hardware encoders with VBR for better quality/size balance - **Offline processing**: Quality-focused encoders with VBR or CQP - **Low-latency applications**: Hardware encoders with low-latency presets ## Performance Optimization Maximize encoder efficiency with these best practices: 1. **Match output resolution to content requirements** - Avoid unnecessary upscaling 2. **Select appropriate bitrates** - Higher isn't always better; target your delivery medium 3. **Choose encoder presets wisely** - Faster presets use less CPU but may reduce quality 4. **Enable scene detection** for improved quality at scene changes 5. **Use hardware acceleration** when available for real-time applications ## Conclusion VisioForge .NET SDKs provide a comprehensive set of video encoders to meet diverse requirements across different platforms and use cases. By understanding the strengths and configurations of each encoder, developers can create high-performance video applications with optimal quality and efficiency. For specific encoder configuration details, refer to the dedicated documentation pages for each encoder type linked throughout this guide. ---END OF PAGE--- ## Motion JPEG (MJPEG) Encoders in VisioForge .NET SDKs **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-encoders/mjpeg/ **Description:** Implement MJPEG video encoders in .NET with CPU and GPU acceleration for frame-by-frame compression and streaming applications. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, MJPEG, C# **API:** QSVMJPEGEncoderSettings, MJPEGEncoderSettings, IMJPEGEncoderSettings # Motion JPEG (MJPEG) Video Encoders for .NET Applications [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) ## Introduction to MJPEG Encoding in VisioForge The VisioForge .NET SDK suite provides robust Motion JPEG (MJPEG) encoder implementations designed for efficient video processing in your applications. MJPEG remains a popular choice for many video applications due to its simplicity, compatibility, and specific use cases where frame-by-frame compression is advantageous. This documentation provides a detailed exploration of the two MJPEG encoder options available in the VisioForge library: 1. CPU-based MJPEG encoder - The default implementation utilizing processor resources 2. GPU-accelerated Intel QuickSync MJPEG encoder - Hardware-accelerated option for compatible systems Both implementations offer developers flexible configuration options while maintaining the core MJPEG functionality through the unified `IMJPEGEncoderSettings` interface. ## What is MJPEG and Why Use It? Motion JPEG (MJPEG) is a video compression format where each video frame is compressed separately as a JPEG image. Unlike more modern codecs such as H.264 or H.265 that use temporal compression across frames, MJPEG treats each frame independently. ### Key Advantages of MJPEG - **Frame-by-frame processing**: Each frame maintains independent quality without temporal artifacts - **Lower latency**: Minimal processing delay makes it suitable for real-time applications - **Editing friendly**: Individual frame access simplifies non-linear editing workflows - **Resilience to motion**: Maintains quality during scenes with significant movement - **Universal compatibility**: Works across platforms without specialized hardware decoders - **Simplified development**: Straightforward implementation in various programming environments ### Common Use Cases MJPEG encoding is particularly valuable in scenarios such as: - **Security and surveillance systems**: Where frame quality and reliability are critical - **Video capture applications**: Real-time video recording with minimal latency - **Medical imaging**: When individual frame fidelity is essential - **Industrial vision systems**: For consistent frame-by-frame analysis - **Multimedia editing software**: Where rapid seeking and frame extraction is required - **Streaming in bandwidth-limited environments**: Where consistent quality is preferred over file size ## MJPEG Implementation in VisioForge Both MJPEG encoder implementations in VisioForge SDKs derive from the `IMJPEGEncoderSettings` interface, ensuring a consistent approach regardless of which encoder you choose. This design allows for easy switching between implementations based on performance requirements and hardware availability. ### Core Interface and Common Properties The shared interface exposes essential properties and methods: - **Quality**: Integer value from 10-100 controlling compression level - **CreateBlock()**: Factory method to generate the encoder processing block - **IsAvailable()**: Static method to verify encoder support on the current system ## CPU-based MJPEG Encoder The CPU-based encoder serves as the default implementation, providing reliable encoding across virtually all system configurations. It performs all encoding operations using the CPU, making it a universally compatible choice for MJPEG encoding. ### Features and Specifications - **Processing method**: Pure CPU-based encoding - **Quality range**: 10-100 (higher values = better quality, larger files) - **Default quality**: 85 (balances quality and file size) - **Performance characteristics**: Scales with CPU cores and processing power - **Memory usage**: Moderate, dependent on frame resolution and processing settings - **Compatibility**: Works on any system supporting the .NET runtime - **Specialized hardware**: None required ### Detailed Implementation Example ``` // Import the necessary VisioForge namespaces using VisioForge.Core.Types.Output; // Create a new instance of the CPU-based encoder settings var mjpegSettings = new MJPEGEncoderSettings(); // Configure quality (10-100) mjpegSettings.Quality = 85; // Default balanced quality // Optional: Verify encoder availability if (MJPEGEncoderSettings.IsAvailable()) { // Create the encoder processing block var encoderBlock = mjpegSettings.CreateBlock(); // Add the encoder block to your processing pipeline pipeline.AddBlock(encoderBlock); // Additional pipeline configuration // ... // Start the encoding process await pipeline.StartAsync(); } else { // Handle encoder unavailability Console.WriteLine("CPU-based MJPEG encoder is not available on this system."); } ``` ### Quality-to-Size Relationship The quality setting directly affects both the visual quality and resulting file size: | Quality Setting | Visual Quality | File Size | Recommended Use Case | | --- | --- | --- | --- | | 10-30 | Very Low | Smallest | Archival, minimal bandwidth | | 31-60 | Low | Small | Web previews, thumbnails | | 61-80 | Medium | Moderate | Standard recording | | 81-95 | High | Large | Professional applications | | 96-100 | Maximum | Largest | Critical visual analysis | ## Intel QuickSync MJPEG Encoder For systems with compatible Intel hardware, the QuickSync MJPEG encoder offers GPU-accelerated encoding performance. This implementation leverages Intel's QuickSync Video technology to offload encoding operations from the CPU to dedicated media processing hardware. ### Hardware Requirements - Intel CPU with integrated graphics supporting QuickSync Video - Supported processor families: - Intel Core i3/i5/i7/i9 (6th generation or newer recommended) - Intel Xeon with compatible graphics - Select Intel Pentium and Celeron processors with HD Graphics ### Features and Advantages - **Hardware acceleration**: Dedicated media processing engines - **Quality range**: 10-100 (same as CPU-based encoder) - **Default quality**: 85 - **Preset profiles**: Four predefined quality configurations - **Reduced CPU load**: Frees processor resources for other tasks - **Power efficiency**: Lower energy consumption during encoding - **Performance gain**: Up to 3x faster than CPU-based encoding (hardware dependent) ### Implementation Examples #### Basic Implementation ``` // Import required namespaces using VisioForge.Core.Types.Output; // Create QuickSync MJPEG encoder with default settings var qsvEncoder = new QSVMJPEGEncoderSettings(); // Verify hardware support if (QSVMJPEGEncoderSettings.IsAvailable()) { // Set custom quality value qsvEncoder.Quality = 90; // Higher quality setting // Create and add encoder block var encoderBlock = qsvEncoder.CreateBlock(); pipeline.AddBlock(encoderBlock); // Continue pipeline setup } else { // Fall back to CPU-based encoder Console.WriteLine("QuickSync hardware not detected. Falling back to CPU encoder."); var cpuEncoder = new MJPEGEncoderSettings(); pipeline.AddBlock(cpuEncoder.CreateBlock()); } ``` #### Using Preset Quality Profiles ``` // Create encoder with preset quality profile var highQualityEncoder = new QSVMJPEGEncoderSettings(VideoQuality.High); // Or select other preset profiles var lowQualityEncoder = new QSVMJPEGEncoderSettings(VideoQuality.Low); var normalQualityEncoder = new QSVMJPEGEncoderSettings(VideoQuality.Normal); var veryHighQualityEncoder = new QSVMJPEGEncoderSettings(VideoQuality.VeryHigh); // Check availability and create encoder block if (QSVMJPEGEncoderSettings.IsAvailable()) { var encoderBlock = highQualityEncoder.CreateBlock(); // Use encoder in pipeline } ``` ### Quality Preset Mapping The QuickSync implementation provides convenient preset quality profiles that map to specific quality values: | Preset Profile | Quality Value | Suitable Applications | | --- | --- | --- | | Low | 60 | Surveillance, monitoring, archiving | | Normal | 75 | Standard recording, web content | | High | 85 | Default for most applications | | VeryHigh | 95 | Professional video production | ## Performance Optimization Guidelines Achieving optimal MJPEG encoding performance requires careful consideration of several factors: ### System Configuration Recommendations 1. **Memory allocation**: Ensure sufficient RAM for frame buffering (minimum 8GB recommended) 2. **Storage throughput**: Use SSD storage for best write performance during encoding 3. **CPU considerations**: Multi-core processors benefit the CPU-based encoder 4. **GPU drivers**: Keep Intel graphics drivers updated for QuickSync performance 5. **Background processes**: Minimize competing system processes during encoding ### Code-Level Optimization Techniques 1. **Frame size selection**: Consider downscaling before encoding for better performance 2. **Quality selection**: Balance visual requirements against performance needs 3. **Pipeline design**: Minimize unnecessary processing stages before encoding 4. **Error handling**: Implement graceful fallback between encoder types 5. **Threading model**: Respect the threading model of the VisioForge pipeline ## Best Practices for MJPEG Implementation To ensure reliable and efficient MJPEG encoding in your applications: 1. **Always check availability**: Use the `IsAvailable()` method before creating encoder instances 2. **Implement encoder fallback**: Have CPU-based encoding as a backup when QuickSync is unavailable 3. **Quality testing**: Test different quality settings with your specific video content 4. **Performance monitoring**: Monitor CPU/GPU usage during encoding to identify bottlenecks 5. **Exception handling**: Handle potential encoder initialization failures gracefully 6. **Version compatibility**: Ensure SDK version compatibility with your development environment 7. **License validation**: Verify proper licensing for your production environment ## Troubleshooting Common Issues ### QuickSync Availability Problems - Ensure Intel drivers are up-to-date - Verify BIOS settings haven't disabled integrated graphics - Check for competing GPU-accelerated applications ### Performance Issues - Monitor system resource usage during encoding - Reduce input frame resolution or frame rate if necessary - Consider quality setting adjustments ### Quality Problems - Increase quality settings for better visual results - Examine source material for pre-existing quality issues - Consider frame pre-processing for problematic source material ## Conclusion The VisioForge .NET SDK provides flexible MJPEG encoding options suitable for a wide range of development scenarios. By understanding the characteristics and configuration options of both the CPU-based and QuickSync implementations, developers can make informed decisions about which encoder best fits their application requirements. Whether prioritizing universal compatibility with the CPU-based encoder or leveraging hardware acceleration with the QuickSync implementation, the consistent interface and comprehensive feature set enable efficient video processing while maintaining the frame-independent nature of MJPEG encoding that makes it valuable for specific video processing applications. ---END OF PAGE--- ## VP8 and VP9 Video Encoding — Configuration and Tuning **URL:** https://www.visioforge.com/help/docs/dotnet/general/video-encoders/vp8-vp9/ **Description:** Configure VP8 and VP9 video encoders for optimal streaming, recording, and processing performance in VisioForge .NET applications. **Tags:** Video Capture SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Streaming, Encoding, Editing, WebM, VP8, VP9, C# **API:** VP9EncoderSettings, VP8EncoderSettings, WebMOutput, QSVVP9EncoderSettings, WebMVideoEncoder # VP8 and VP9 Encoders in VisioForge .NET [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) This guide shows you how to implement VP8 and VP9 video encoding in VisioForge .NET SDKs. You'll learn about the available encoder options and how to optimize them for your specific application needs. ## Encoder Options Overview VisioForge SDK provides multiple encoder implementations based on your platform requirements: ### Windows Platform Encoders [VideoCaptureCore](#) [VideoEditCore](#) - Software-based VP8 and VP9 encoders configured through the [WebMOutput](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.Output.WebMOutput.html) class ### Cross-Platform X-Engine Options [VideoCaptureCoreX](#) [VideoEditCoreX](#) [MediaBlocksPipeline](#) - VP8 software encoder via [VP8EncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.VP8EncoderSettings.html) - VP9 software encoder via [VP9EncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.VP9EncoderSettings.html) - Hardware-accelerated Intel GPU VP9 encoder via [QSVVP9EncoderSettings](https://api.visioforge.org/dotnet/api/VisioForge.Core.Types.X.VideoEncoders.QSVVP9EncoderSettings.html) for integrated GPUs ## Bitrate Control Strategies All VP8 and VP9 encoders support different bitrate control modes to match your application requirements: ### Constant Bitrate (CBR) CBR maintains consistent bitrate throughout the encoding process, making it ideal for: - Live streaming applications - Scenarios with bandwidth limitations - Real-time video communication **Implementation Examples:** With `WebMOutput` (Windows): ``` var webmOutput = new WebMOutput(); webmOutput.Video_EndUsage = VP8EndUsageMode.CBR; webmOutput.Video_Encoder = WebMVideoEncoder.VP8; webmOutput.Video_Bitrate = 2000; // 2 Mbps ``` With `VP8EncoderSettings`: ``` var vp8 = new VP8EncoderSettings(); vp8.RateControl = VPXRateControl.CBR; vp8.TargetBitrate = 2000; // 2 Mbps ``` With `VP9EncoderSettings`: ``` var vp9 = new VP9EncoderSettings(); vp9.RateControl = VPXRateControl.CBR; vp9.TargetBitrate = 2000; // 2 Mbps ``` With Intel GPU encoder: ``` var vp9qsv = new QSVVP9EncoderSettings(); vp9qsv.RateControl = QSVVP9EncRateControl.CBR; vp9qsv.Bitrate = 2000; // 2 Mbps ``` ### Variable Bitrate (VBR) VBR dynamically adjusts bitrate based on content complexity, best for: - Non-live video encoding - Scenarios prioritizing visual quality over file size - Content with varying visual complexity **Implementation Examples:** With `WebMOutput` (Windows): ``` var webmOutput = new WebMOutput(); webmOutput.Video_EndUsage = VP8EndUsageMode.VBR; webmOutput.Video_Encoder = WebMVideoEncoder.VP8; webmOutput.Video_Bitrate = 3000; // 3 Mbps target ``` With `VP8EncoderSettings`: ``` var vp8 = new VP8EncoderSettings(); vp8.RateControl = VPXRateControl.VBR; vp8.TargetBitrate = 3000; ``` With `VP9EncoderSettings`: ``` var vp9 = new VP9EncoderSettings(); vp9.RateControl = VPXRateControl.VBR; vp9.TargetBitrate = 3000; ``` With Intel GPU encoder: ``` var vp9qsv = new QSVVP9EncoderSettings(); vp9qsv.RateControl = QSVVP9EncRateControl.VBR; vp9qsv.Bitrate = 3000; ``` ## Quality-Focused Encoding Modes These modes prioritize consistent visual quality over specific bitrate targets: ### Constant Quality (CQ) Mode Available for software VP8 and VP9 encoders: ``` var vp8 = new VP8EncoderSettings(); vp8.RateControl = VPXRateControl.CQ; vp8.CQLevel = 20; // Quality level (0-63, lower values = better quality) ``` ``` var vp9 = new VP9EncoderSettings(); vp9.RateControl = VPXRateControl.CQ; vp9.CQLevel = 20; ``` ### Intel QSV Quality Modes Intel's hardware encoder supports two quality-focused modes: **Intelligent Constant Quality (ICQ):** ``` var vp9qsv = new QSVVP9EncoderSettings(); vp9qsv.RateControl = QSVVP9EncRateControl.ICQ; vp9qsv.ICQQuality = 25; // 20-27 recommended for balanced quality ``` **Constant Quantization Parameter (CQP):** ``` var vp9qsv = new QSVVP9EncoderSettings(); vp9qsv.RateControl = QSVVP9EncRateControl.CQP; vp9qsv.QPI = 26; // I-frame QP vp9qsv.QPP = 28; // P-frame QP ``` ## VP9 Performance Optimization VP9 encoders offer additional features for enhanced performance: ### Adaptive Quantization Improves visual quality by allocating more bits to complex areas: ``` var vp9 = new VP9EncoderSettings(); vp9.AQMode = VPXAdaptiveQuantizationMode.Variance; // Enable variance-based AQ ``` ### Parallel Processing Speeds up encoding through multi-threading and tile-based processing: ``` var vp9 = new VP9EncoderSettings(); vp9.FrameParallelDecoding = true; // Enable parallel frame processing vp9.RowMultithread = true; // Enable row-based multithreading vp9.TileColumns = 6; // Set number of tile columns (log2) vp9.TileRows = 0; // Set number of tile rows (log2) ``` ## Error Resilience Settings Both VP8 and VP9 support error resilience for robust streaming over unreliable networks: Using `WebMOutput` (Windows): ``` var webmOutput = new WebMOutput(); webmOutput.Video_ErrorResilient = true; // Enable error resilience ``` Using software encoders: ``` var vpx = new VP8EncoderSettings(); // or VP9EncoderSettings vpx.ErrorResilient = VPXErrorResilientFlags.Default | VPXErrorResilientFlags.Partitions; ``` ## Performance Tuning Options Optimize encoding performance with these settings: ``` var vpx = new VP8EncoderSettings(); // or VP9EncoderSettings vpx.CPUUsed = 0; // Range: -16 to 16, higher values favor speed over quality vpx.NumOfThreads = 4; // Specify number of encoding threads vpx.TokenPartitions = VPXTokenPartitions.Eight; // Enable parallel token processing ``` ## Best Practices for VP8/VP9 Encoding ### Rate Control Selection Choose the appropriate rate control mode based on your application: - **CBR** for live streaming and real-time communication - **VBR** for offline encoding where quality is the priority - **Quality-based modes** (CQ, ICQ, CQP) for highest possible quality regardless of bitrate ### Performance Optimization - Adjust `CPUUsed` to balance quality and encoding speed - Enable multithreading for faster encoding on multi-core systems - Use tile-based parallelism in VP9 for better hardware utilization ### Error Recovery - Enable error resilience when streaming over unreliable networks - Configure token partitioning for improved error recovery - Consider frame reordering limitations for low-latency applications ### Quality Optimization - Use adaptive quantization in VP9 for better quality distribution - Consider two-pass encoding for offline encoding scenarios - Adjust quantizer settings based on content type and target quality By following this guide, you'll be able to effectively implement and configure VP8 and VP9 encoders in your VisioForge .NET applications for optimal performance and quality. ---END OF PAGE--- ## VisioForge .NET SDKs — Video Capture, Editing & Playback **URL:** https://www.visioforge.com/help/docs/dotnet/ **Description:** .NET SDKs for video capture, editing, playback, and processing. Cross-platform support for Windows, macOS, Linux, Android, and iOS. **Tags:** .NET, Streaming, Editing # .NET SDKs for Professional Media Development ## Introduction to Our .NET SDKs Our powerful .NET SDKs empower developers to seamlessly integrate advanced video capture, sophisticated video editing, smooth playback, and efficient media processing capabilities into their software applications. These professionally engineered tools provide a complete solution for all your multimedia development needs. ## Multi-Platform Compatibility All our .NET SDKs are designed with cross-platform functionality in mind, providing robust support across: - Windows desktop environments - Linux distributions - macOS systems - Android mobile devices - iOS applications This versatility ensures your media applications can reach users on virtually any platform without compromising functionality. ## Hardware Acceleration Technologies Our SDKs leverage cutting-edge GPU-accelerated encoding and decoding technologies to maximize performance: ### Desktop Platforms - Intel Quick Sync Video for efficient hardware acceleration - NVIDIA NVENC for superior encoding performance - AMD VCE (Video Coding Engine) for optimized processing ### Mobile Platforms - Native hardware encoding and decoding capabilities - Performance-optimized implementations for battery efficiency ## Getting Started Resources ### SDK Usage Tutorials - [Installation Guide](install/) - Step-by-step setup instructions - [SDK Initialization](init/) - Proper initialization procedures - [System Requirements](system-requirements/) - Detailed compatibility information ## Available SDK Products ### [Video Capture SDK .NET](videocapture/) Efficiently capture high-quality video from multiple sources including: - Webcams and USB cameras - Network IP cameras — [browse supported brands](camera-brands/) - HDMI capture devices - Screen recording - Custom video sources ### [Video Edit SDK .NET](videoedit/) Professional video editing capabilities including: - Timeline-based video editing - Filter and effect application - Video montage creation - Format conversion - Frame-accurate editing ### [Media Player SDK .NET](mediaplayer/) Feature-rich media playback functionality: - Multi-format video and audio playback - Real-time effect application - Customizable player interfaces - Streaming support - Advanced control options ### [Media Blocks SDK .NET](mediablocks/) Modular building blocks for creating: - Custom multimedia applications - Specialized media processing tools - Cross-platform media solutions - Integrated workflow systems ## Additional Developer Resources - [Migration Guide: v15 to v2026](migration-from-v15/) - Step-by-step upgrade instructions - [Changelog](changelog/) - Detailed version history and updates - [Feature and Platform Matrix](platform-matrix/) - Compatibility overview - [API Reference Documentation](https://api.visioforge.org/dotnet/api/index.html) - Complete API specifications ---END OF PAGE--- ## Initialize and Configure VisioForge .NET Video SDKs **URL:** https://www.visioforge.com/help/docs/dotnet/init/ **Description:** Initialize and deinitialize .NET SDKs for video capture, editing, and playback with DirectShow and cross-platform X-engines. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, DirectShow, MediaPlayerCoreX, MediaBlocksPipeline, VideoCaptureCoreX, VideoEditCoreX, Windows, macOS, Linux, Android, iOS, Capture, Playback, Editing # Initialization [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Type of SDK engines All SDKs contain Windows-only DirectShow-based engines and cross-platform X-engines. ### Windows-only engines - VideoCaptureCore - VideoEditCore - MediaPlayerCore ### X-engines - VideoCaptureCoreX - VideoEditCoreX - MediaPlayerCoreX - MediaBlocksPipeline X-engines require additional initialization and de-initialization steps. ## SDK initialization and de-initialization for X-engines You need to initialize SDK before any SDK class usage and de-initialize SDK before the application exits. To initialize SDK, use the following code: ``` VisioForge.Core.VisioForgeX.InitSDK(); ``` To de-initialize SDK, use the following code: ``` VisioForge.Core.VisioForgeX.DestroySDK(); ``` If the SDK is not properly deinitialized, the application may experience a hang-on exit due to the inability to finalize one of its threads. This issue arises because the SDK continues to operate, preventing the application from closing smoothly. To ensure a clean exit, it is crucial to deinitialize the SDK appropriately based on the UI framework you are using. For applications developed using different UI frameworks, you can deinitialize the SDK in the `FormClosing` event or another relevant event handler. This approach ensures that the SDK is properly destroyed before the application closes, allowing for all threads to terminate correctly. Moreover, the SDK can be destroyed from any thread, providing flexibility in how you manage the deinitialization process. To enhance the user experience and prevent the UI from freezing during this process, you can utilize asynchronous API calls. By using async methods, you allow the deinitialization to occur in the background, keeping the user interface responsive and avoiding any potential lag or freezing issues. Implementing these practices ensures that your application exits smoothly without hanging, providing a seamless experience for the users. Properly managing the SDK deinitialization is crucial for maintaining the stability and performance of your application. --- Visit our [GitHub](https://github.com/visioforge/.Net-SDK-s-samples) page to get more code samples. ---END OF PAGE--- ## Install VisioForge Media SDKs in Avalonia .NET Apps **URL:** https://www.visioforge.com/help/docs/dotnet/install/avalonia/ **Description:** Build cross-platform Avalonia apps with multimedia capabilities for Windows, macOS, Linux, Android, and iOS using VisioForge video SDKs. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, C++, Windows, macOS, Linux, Android, iOS, Avalonia, C#, NuGet **API:** VideoView # Building Media-Rich Avalonia Applications with VisioForge ## Framework Overview Avalonia UI stands out as a versatile, truly cross-platform .NET UI framework with support spanning desktop environments (Windows, macOS, Linux) and mobile platforms (iOS and Android). VisioForge enhances this ecosystem through the specialized `VisioForge.DotNet.Core.UI.Avalonia` package, which delivers high-performance multimedia controls tailored for Avalonia's architecture. Our suite of SDKs empowers Avalonia developers with extensive multimedia capabilities: [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Setup and Configuration ### Essential Package Installation Creating an Avalonia application with VisioForge multimedia capabilities requires installing several key NuGet components: 1. Avalonia-specific UI layer: `VisioForge.DotNet.Core.UI.Avalonia` 2. Core functionality package: `VisioForge.DotNet.Core` (or specialized SDK variant) 3. Platform-specific native bindings (covered in detail in later sections) Add these to your project manifest (`.csproj`): ``` ``` ### Avalonia Initialization Architecture A key advantage of VisioForge's Avalonia integration is its seamless initialization model. Unlike some frameworks requiring explicit global setup, the Avalonia controls become available immediately once the core package is referenced. Your standard Avalonia bootstrap code in `Program.cs` remains unchanged: ``` using Avalonia; using System; namespace YourAppNamespace; class Program { [STAThread] public static void Main(string[] args) => BuildAvaloniaApp() .StartWithClassicDesktopLifetime(args); public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() .LogToTrace(); } ``` ### Implementing the VideoView Component The `VideoView` control serves as the central rendering element. Integrate it into your `.axaml` files using: 1. First, declare the VisioForge namespace: ``` xmlns:vf="clr-namespace:VisioForge.Core.UI.Avalonia;assembly=VisioForge.Core.UI.Avalonia" ``` 1. Then, implement the control in your layout structure: ``` ``` This control adapts automatically to the platform-specific rendering pipeline while maintaining a consistent API surface. ## Desktop Platform Integration ### Windows Implementation Guide Windows deployment requires specific native components packaged as NuGet references. #### Core Windows Components Add the following Windows-specific packages to your desktop project: ``` ``` #### Advanced Media Format Support For extended codec compatibility, include the size-optimized UPX variant of the libAV libraries: ``` ``` The UPX variant delivers significant size optimization while maintaining full codec compatibility. ### macOS Integration For macOS deployment: #### Native Binding Package Include the macOS-specific native components: ``` ``` #### Framework Configuration Configure your project with the appropriate macOS framework target: ``` net8.0-macos14.0 Exe ``` ### Linux Deployment Linux support includes: #### Framework Configuration Set up the appropriate target framework for Linux environments: ``` net8.0 Exe ``` #### System Dependencies For Linux deployment, ensure required system libraries are available on the target system. Unlike Windows and macOS which use NuGet packages, Linux may require system-level dependencies. Consult the VisioForge Linux documentation for specific platform requirements. ## Mobile Development ### Android Configuration Android implementation requires additional steps unique to Avalonia's Android integration model: #### Java Interoperability Layer The VisioForge Android implementation requires a binding bridge between .NET and Android native APIs: 1. Obtain the Java binding project from the [VisioForge samples repository](https://github.com/visioforge/.Net-SDK-s-samples) in the `AndroidDependency` directory 2. Add the appropriate binding project to your solution: 3. Use `VisioForge.Core.Android.X8.csproj` for .NET 8 applications 4. Reference this project in your Android head project: ``` ``` #### Android-Specific Package Add the Android redistributable package: ``` ``` #### Runtime Permissions Configure the `AndroidManifest.xml` with appropriate permissions: - `android.permission.CAMERA` - `android.permission.RECORD_AUDIO` - `android.permission.READ_EXTERNAL_STORAGE` - `android.permission.WRITE_EXTERNAL_STORAGE` - `android.permission.INTERNET` ### iOS Development iOS integration with Avalonia requires: #### Native Components Add the iOS-specific redistributable to your iOS head project: ``` ``` #### Important Implementation Notes - Physical device testing is essential, as simulator support is limited - Update your `Info.plist` with privacy descriptions: - `NSCameraUsageDescription` for camera access - `NSMicrophoneUsageDescription` for audio recording ## Performance Engineering Maximize application performance with these Avalonia-specific optimizations: 1. Enable hardware acceleration when supported by the underlying platform 2. Implement adaptive resolution scaling based on device capabilities 3. Optimize memory usage patterns, especially for mobile targets 4. Utilize Avalonia's compositing model effectively by minimizing visual tree complexity around the `VideoView` ## Troubleshooting Guide ### Media Format Problems - **Playback failures**: - Ensure all platform packages are correctly referenced - Verify codec availability for the target media format - Check for platform-specific format restrictions ### Performance Concerns - **Slow playback or rendering**: - Enable hardware acceleration where available - Reduce processing resolution when appropriate - Utilize Avalonia's threading model correctly ### Deployment Challenges - **Platform-specific runtime errors**: - Validate target framework specifications - Verify native dependency availability - Ensure proper provisioning for mobile targets ## Multi-Platform Project Architecture VisioForge's Avalonia integration excels with a specialized multi-headed project structure. The `SimplePlayerMVVM` sample demonstrates this architecture: - **Core shared project** (`SimplePlayerMVVM.csproj`): Contains cross-platform views, view models, and shared logic with conditional multi-targeting: ``` enable latest true net8.0-android;net8.0-ios;net8.0-windows net8.0-android;net8.0-ios;net8.0-macos14.0 net8.0-android;net8.0 ``` - **Platform-specific head projects**: - `SimplePlayerMVVM.Android.csproj`: Contains Android-specific configuration and binding references - `SimplePlayerMVVM.iOS.csproj`: Handles iOS initialization and dependencies - `SimplePlayerMVVM.Desktop.csproj`: Manages desktop platform detection and appropriate redistributable loading For simpler desktop-only applications, `SimpleVideoCaptureA.csproj` provides a streamlined model with platform detection occurring within a single project file. ## Conclusion VisioForge's Avalonia integration offers a sophisticated approach to cross-platform multimedia development that leverages Avalonia's unique architectural advantages. Through carefully structured platform-specific components and a unified API, developers can build rich media applications that span desktop and mobile platforms without compromising on performance or capabilities. For complete code examples and sample applications, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples), which contains specialized Avalonia demonstrations in the Video Capture SDK X and Media Player SDK X sections. ---END OF PAGE--- ## Install VisioForge .NET SDKs — NuGet, Visual Studio, Rider **URL:** https://www.visioforge.com/help/docs/dotnet/install/ **Description:** Setup files or NuGet packages. Target frameworks for Windows, macOS, iOS, Android, and Linux. SDK initialization, VideoView controls, and native dependencies. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, DirectShow, Windows, macOS, Linux, Android, iOS, Capture, Streaming **API:** VideoView, VideoCaptureCore, VideoCaptureCoreX # VisioForge .NET SDKs Installation Guide [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) VisioForge offers powerful multimedia SDKs for .NET developers that enable advanced video capture, editing, playback, and media processing capabilities in your applications. This guide covers everything you need to know to properly install and configure our SDKs in your development environment. ## Available .NET SDKs VisioForge provides several specialized SDKs to address different multimedia needs: - [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) - For capturing video from cameras, screen recording, and streaming - [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) - For video editing, processing, and format conversion - [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) - For building custom media processing pipelines - [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) - For creating custom media players with advanced features ## Installation Methods You can install our SDKs using two primary methods: ### Using Setup Files The setup file installation method is recommended for Windows development environments. This approach: 1. Automatically installs all required dependencies 2. Configures Visual Studio integration 3. Includes sample projects to help you get started quickly 4. Provides documentation and additional resources Setup files can be downloaded from the respective SDK product pages on our website. ### Using NuGet Packages For cross-platform development or CI/CD pipelines, our NuGet packages offer flexibility and easy integration: ``` Install-Package VisioForge.DotNet.Core ``` Additional UI-specific packages may be required depending on your target platform: ``` Install-Package VisioForge.DotNet.Core.UI.MAUI Install-Package VisioForge.DotNet.Core.UI.WinUI Install-Package VisioForge.DotNet.Core.UI.Avalonia Install-Package VisioForge.DotNet.Core.UI.Uno ``` ## IDE Integration and Setup Our SDKs seamlessly integrate with popular .NET development environments: ### Visual Studio Integration [Visual Studio](visual-studio/) offers the most complete experience with our SDKs: - Full IntelliSense support for SDK components - Built-in debugging for media processing components - Designer support for visual controls - NuGet package management For detailed Visual Studio setup instructions, see our [Visual Studio integration guide](visual-studio/). ### JetBrains Rider Integration [Rider](rider/) provides excellent cross-platform development support: - Full code completion for SDK APIs - Smart navigation features for exploring SDK classes - Integrated NuGet package management - Cross-platform debugging capabilities For Rider-specific instructions, visit our [Rider integration documentation](rider/). ### Visual Studio for Mac [Visual Studio for Mac](visual-studio-mac/) users can develop applications for macOS, iOS, and Android: - Built-in NuGet package manager for installing SDK components - Project templates for quick setup - Integrated debugging tools Learn more in our [Visual Studio for Mac setup guide](visual-studio-mac/). ## Platform-Specific Configuration ### Target Framework Configuration Each operating system requires specific target framework settings for optimal compatibility: #### Windows Applications Windows applications must use the `-windows` target framework suffix: ``` net8.0-windows ``` This enables access to Windows-specific APIs and UI frameworks like WPF and Windows Forms. #### Android Development Android projects require the `-android` framework suffix: ``` net8.0-android ``` Ensure that Android workloads are installed in your development environment: ``` dotnet workload install android ``` #### iOS Development iOS applications must use the `-ios` target framework: ``` net8.0-ios ``` iOS development requires a Mac with Xcode installed, even when using Visual Studio on Windows. #### macOS Applications macOS native applications use either the `-macos` or `-maccatalyst` framework: ``` net8.0-macos ``` For .NET MAUI applications targeting macOS, use: ``` net8.0-maccatalyst ``` #### Linux Development Linux applications use the standard target framework without a platform suffix: ``` net8.0 ``` Ensure required .NET workloads are installed: ``` dotnet workload install linux ``` ## Special Framework Support ### .NET MAUI Applications [MAUI projects](maui/) require special configuration: - Add the `VisioForge.DotNet.Core.UI.MAUI` NuGet package - Configure platform-specific permissions in your project - Use MAUI-specific video view controls See our [detailed MAUI guide](maui/) for complete instructions. ### Avalonia UI Framework [Avalonia projects](avalonia/) provide a cross-platform UI alternative: - Install the `VisioForge.DotNet.Core.UI.Avalonia` package - Use Avalonia-specific video rendering controls - Configure platform-specific dependencies Our [Avalonia integration guide](avalonia/) provides complete setup instructions. ### Uno Platform Applications [Uno Platform projects](uno/) enable building applications for Windows, Android, iOS, macOS, and Linux from a single codebase: - Add the `VisioForge.DotNet.Core.UI.Uno` NuGet package - Use Uno Platform-specific video view controls - Configure platform-specific redistributables See our [Uno Platform guide](uno/) for complete setup instructions. ### Unity [Unity](unity/) integration uses a ready-to-import `.unitypackage` instead of NuGet: - Self-contained for Unity 6 on Windows x64 — managed SDK, native runtime, and sample scenes - No source build, no NuGet, and no external dependencies - Video renders into a Unity `RawImage` via the bundled scripts See our [Unity installation guide](unity/) for the step-by-step setup. ## SDK Initialization for Cross-Platform Engines Our SDKs include both Windows-specific DirectShow engines (like `VideoCaptureCore`) and cross-platform X-engines (like `VideoCaptureCoreX`). The X-engines require explicit initialization and cleanup. ### Initializing the SDK Before using any X-engine components, initialize the SDK: ``` // Initialize at application startup VisioForge.Core.VisioForgeX.InitSDK(); // Or use the async version await VisioForge.Core.VisioForgeX.InitSDKAsync(); ``` ### Cleaning Up Resources When your application exits, properly release resources: ``` // Clean up at application exit (sync — DestroySDK has no async variant) VisioForge.Core.VisioForgeX.DestroySDK(); ``` Failing to initialize or clean up properly may result in memory leaks or unstable behavior. ## Video Rendering Controls Each UI framework requires specific video view controls to display media content: ### Windows Forms ``` // Add reference to VisioForge.DotNet.Core using VisioForge.Core.UI.WinForms; // In your form videoView = new VideoView(); this.Controls.Add(videoView); ``` ### WPF Applications ``` // Add reference to VisioForge.DotNet.Core using VisioForge.Core.UI.WPF; // In your XAML ``` ### MAUI Applications ``` // Add reference to VisioForge.DotNet.Core.UI.MAUI using VisioForge.Core.UI.MAUI; // In your XAML ``` ### Avalonia UI ``` // Add reference to VisioForge.DotNet.Core.UI.Avalonia using VisioForge.Core.UI.Avalonia; // In your XAML ``` ## Native Dependencies Management Our SDKs leverage native libraries for optimal performance. These dependencies must be properly managed for deployment: - Windows: Included automatically with setup installation or NuGet packages - macOS/iOS: Bundled with NuGet packages but require proper app signing - Android: Included in NuGet packages with proper architecture support - Linux: May require additional system packages depending on distribution For detailed deployment instructions, see our [deployment guide](../deployment-x/). ## Troubleshooting Common Installation Issues If you encounter issues during installation: 1. Verify target framework compatibility with your project type 2. Ensure all required workloads are installed (`dotnet workload list`) 3. Check for dependency conflicts in your project 4. Confirm proper SDK initialization for X-engines 5. Review platform-specific requirements in our documentation ## Sample Code and Resources We maintain an extensive collection of sample applications on our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) to help you get started quickly with our SDKs. These examples cover common scenarios like: - Video capture from cameras and screens - Media playback with custom controls - Video editing and processing - Cross-platform development Visit our repository for the latest code examples and best practices for using our SDKs. --- For additional support or questions, please contact our technical support team or visit our documentation portal. ---END OF PAGE--- ## Install VisioForge .NET SDKs in MAUI Apps via NuGet **URL:** https://www.visioforge.com/help/docs/dotnet/install/maui/ **Description:** Add video capture, playback, and editing to .NET MAUI apps. NuGet setup for Windows, Android, iOS, and macOS with VisioForge VideoView controls. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, C++, MediaPlayerCoreX, Windows, macOS, Android, iOS, MAUI, Playback, C#, NuGet **API:** VideoView, MediaPlayerCoreX # Integrating VisioForge SDKs with .NET MAUI Applications ## Overview .NET Multi-platform App UI (MAUI) enables developers to build cross-platform applications for mobile and desktop from a single codebase. VisioForge provides comprehensive support for MAUI applications through the `VisioForge.DotNet.Core.UI.MAUI` NuGet package (namespace: `VisioForge.Core.UI.MAUI`), which contains specialized UI controls designed specifically for the .NET MAUI platform. Our SDKs enable powerful multimedia capabilities across all MAUI-supported platforms: [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) Looking for a working tutorial? Once the packages are installed, walk through the [.NET MAUI Video Player Guide](../../mediaplayer/guides/maui-player/) — a full `VideoView` + `MediaPlayerCoreX` implementation with file picker, seek, and volume that runs on iOS, Android, macOS, and Windows from one codebase. ## Getting Started ### Installation To begin using VisioForge with your MAUI project, install the required NuGet packages: 1. The core UI package: `VisioForge.DotNet.Core.UI.MAUI` 2. Platform-specific redistributable (detailed in platform sections below) ### SDK Initialization Proper initialization is essential for the VisioForge SDKs to function correctly within your MAUI application. This process must be completed in your `MauiProgram.cs` file. ``` using SkiaSharp.Views.Maui.Controls.Hosting; using VisioForge.Core.UI.MAUI; public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() // Initialize the SkiaSharp package by adding the below line of code .UseSkiaSharp() // Initialize the VisioForge MAUI package by adding the below line of code .ConfigureMauiHandlers(handlers => handlers.AddVisioForgeHandlers()) // After initializing the VisioForge MAUI package, optionally add additional fonts .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }); // Continue initializing your .NET MAUI App here return builder.Build(); } } ``` ## Using VisioForge Controls in XAML The `VideoView` control is the primary interface for displaying video content in your MAUI application. To use VisioForge controls in your XAML files: 1. Add the VisioForge namespace to your XAML file: ``` xmlns:vf="clr-namespace:VisioForge.Core.UI.MAUI;assembly=VisioForge.Core.UI.MAUI" ``` 1. Add the VideoView control to your layout: ``` ``` The VideoView control adapts to the native rendering capabilities of each platform while providing a consistent API for your application code. ## Platform-Specific Configuration ### Android Implementation Android requires additional configuration steps to ensure proper operation: #### 1. Add Java Bindings Library The VisioForge SDK relies on native Android functionality that requires a custom Java bindings library: 1. Clone the binding library from our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/AndroidDependency) 2. Add the appropriate project to your solution: 3. Use `VisioForge.Core.Android.X8.csproj` for .NET 8 4. Use `VisioForge.Core.Android.X9.csproj` for .NET 9 5. Add the reference to your project file: ``` ``` #### 2. Add Android Redistributable Package Include the Android-specific redistributable package: ``` ``` #### 3. Android Permissions Ensure your AndroidManifest.xml includes the necessary permissions for camera, microphone, and storage access depending on your application's functionality. Common required permissions include: - `android.permission.CAMERA` - `android.permission.RECORD_AUDIO` - `android.permission.READ_EXTERNAL_STORAGE` - `android.permission.WRITE_EXTERNAL_STORAGE` ### iOS Configuration iOS integration requires fewer steps but has some important considerations: #### 1. Add iOS Redistributable Add the iOS-specific package to your project: ``` ``` #### 2. Important Notes for iOS Development - **Use physical devices**: The SDK requires testing on physical iOS devices rather than simulators for full functionality. - **Privacy descriptions**: Add the necessary usage description strings in your Info.plist file for camera and microphone access: - `NSCameraUsageDescription` - `NSMicrophoneUsageDescription` ### macOS Configuration For macOS Catalyst applications: #### 1. Configure Runtime Identifiers To ensure your application works correctly on both Intel and Apple Silicon Macs, specify the appropriate runtime identifiers: ``` maccatalyst-x64 maccatalyst-arm64 ``` #### 2. Enable Trimming For optimal performance on macOS, enable the PublishTrimmed option: ``` true ``` For more detailed information about macOS deployment, refer to our [macOS](../../deployment-x/macOS/) documentation page. ### Windows Configuration For Windows applications, you need to include several redistributable packages: #### 1. Add Base Windows Redistributables Include the core Windows packages: ``` ``` #### 2. Add Extended Codec Support (Optional but Recommended) For enhanced media format support, include the libAV (FFMPEG) package: ``` ``` ### Performance Optimization For optimal performance across platforms: 1. Use hardware acceleration when available 2. Adjust video resolution based on the target device capabilities 3. Consider memory constraints on mobile devices when processing large media files ## Troubleshooting Common Issues - **Blank video display**: Ensure proper permissions are granted on mobile platforms - **Missing codecs**: Verify all platform-specific redistributable packages are correctly installed - **Performance issues**: Check that hardware acceleration is enabled when available - **Deployment errors**: Confirm runtime identifiers are correctly specified for the target platform ## Conclusion The VisioForge SDK provides a comprehensive solution for adding powerful multimedia capabilities to your .NET MAUI applications. By following the platform-specific setup instructions and best practices outlined in this guide, you can create rich cross-platform applications with advanced video and audio features. For additional examples and sample code, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples). ## Next Steps - [.NET MAUI Video Player Guide](../../mediaplayer/guides/maui-player/) — complete `VideoView` tutorial with seek, volume, and file picker - [Avalonia Player Guide](../../mediaplayer/guides/avalonia-player/) — desktop-first cross-platform alternative (includes Linux) - [Android Player Guide](../../mediaplayer/guides/android-player/) — Android-only deployment details ---END OF PAGE--- ## Install VisioForge SDK in JetBrains Rider — NuGet Setup **URL:** https://www.visioforge.com/help/docs/dotnet/install/rider/ **Description:** Add VisioForge .NET SDKs to Rider projects via NuGet. .NET 6/7/8/9, macOS/Windows/Linux. Package references, native dependencies, troubleshooting. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, WPF, Avalonia, NuGet **API:** VideoView # .Net SDKs Integration with JetBrains Rider ## Introduction [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) This comprehensive guide walks you through the process of installing and configuring VisioForge .Net SDKs within JetBrains Rider, a powerful cross-platform IDE for .NET development. While we'll use a Windows application with WPF as our primary example, these installation steps can be readily adapted for macOS, iOS, or Android applications as well. JetBrains Rider provides a consistent development experience across Windows, macOS, and Linux platforms, making it an excellent choice for cross-platform .NET development. ## Creating Your Project ### Setting Up a Modern Project Structure Begin by launching JetBrains Rider and creating a new project. For this tutorial, we'll use WPF (Windows Presentation Foundation) as our framework. It's crucial to utilize the modern project format, which provides enhanced compatibility with VisioForge SDKs and offers a more streamlined development experience. 1. Open JetBrains Rider 2. Select "Create New Solution" from the welcome screen 3. Choose "WPF Application" from the available templates 4. Configure your project settings, ensuring you select the modern project format 5. Click "Create" to generate your project structure ## Adding Required NuGet Packages ### Installing the Main SDK Package Each VisioForge SDK has a corresponding main package that provides core functionality. You'll need to select the appropriate package based on which SDK you're working with. 1. Right-click on your project in the Solution Explorer 2. Select the "Manage NuGet Packages" menu item 3. In the NuGet Package Manager, search for the VisioForge package that corresponds to your desired SDK 4. Select the latest stable version and click "Install" ### Available Main SDK Packages Choose from the following main packages based on your development needs: - [VisioForge.DotNet.VideoCapture](https://www.nuget.org/packages/VisioForge.DotNet.VideoCapture) - For applications requiring video capture functionality - [VisioForge.DotNet.VideoEdit](https://www.nuget.org/packages/VisioForge.DotNet.VideoEdit) - For video editing and processing applications - [VisioForge.DotNet.MediaPlayer](https://www.nuget.org/packages/VisioForge.DotNet.MediaPlayer) - For media playback applications - [VisioForge.DotNet.MediaBlocks](https://www.nuget.org/packages/VisioForge.DotNet.MediaBlocks) - For applications requiring modular media processing capabilities ### Adding the UI Package, if needed Main SDK package contains the core UI components for WinForms, WPF, Android, and Apple. For other platforms, you'll need to install the appropriate UI package that corresponds to your chosen UI framework. ### Available UI Packages Depending on your target platform and UI framework, choose from these UI packages: - Core package contains the core UI components For WinForms, WPF, and Apple - [VisioForge.DotNet.Core.UI.WinUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.WinUI) - For Windows applications using the modern WinUI framework - [VisioForge.DotNet.Core.UI.MAUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.MAUI) - For cross-platform applications using .NET MAUI - [VisioForge.DotNet.Core.UI.Avalonia](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.Avalonia) - For cross-platform applications using Avalonia UI ## Integrating VideoView Control (Optional) ### Adding Video Preview Capabilities If your application requires video preview functionality, you'll need to add the VideoView control to your user interface. This can be accomplished either through XAML markup or programmatically in your code-behind file. Below, we'll demonstrate how to add it via XAML. #### Step 1: Add the WPF Namespace First, add the necessary namespace reference to your XAML file: ``` xmlns:wpf="clr-namespace:VisioForge.Core.UI.WPF;assembly=VisioForge.Core" ``` #### Step 2: Add the VideoView Control Then, add the VideoView control to your layout: ``` ``` This control provides a canvas where video content can be displayed in real-time, essential for applications that involve video capture, editing, or playback. ## Adding Required Redistribution Packages ### Platform-Specific Dependencies Depending on your target platform, chosen product, and the specific engine you're utilizing, additional redistribution packages may be needed to ensure proper functionality across all deployment environments. For comprehensive information about which redistribution packages are required for your specific scenario, please consult the Deployment documentation page for your selected VisioForge product. These resources provide detailed guidance on: - Required system dependencies - Platform-specific considerations - Deployment optimization strategies - Runtime requirements Following these deployment guidelines will ensure your application functions correctly on end-user systems without missing dependencies or runtime errors. ## Additional Resources For more examples and detailed implementation guides, visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples), which contains numerous code samples demonstrating various features and integration scenarios. Our documentation portal also offers comprehensive API references, detailed tutorials, and best practice guides to help you make the most of VisioForge SDKs in your JetBrains Rider projects. ## Conclusion By following this installation guide, you've successfully integrated VisioForge .Net SDKs with JetBrains Rider, setting the foundation for developing powerful media applications. The combination of VisioForge's robust media processing capabilities and JetBrains Rider's intelligent development environment provides an ideal platform for creating sophisticated media applications across multiple platforms. ---END OF PAGE--- ## Install VisioForge media SDKs in Unity 6 — Setup Guide **URL:** https://www.visioforge.com/help/docs/dotnet/install/unity/ **Description:** Set up VisioForge media SDKs in Unity 6 — one cumulative .unitypackage for video playback, capture and editing on Windows, Android, macOS, iOS. **Tags:** Media Blocks SDK, Media Player SDK, Video Capture SDK, Video Edit SDK, .NET, Unity, Windows, Android, macOS, iOS, RTSP, C# **API:** VisioForgeEnvironment, MediaBlocksPipeline, MediaPlayerCoreX, VideoCaptureCoreX, VideoEditCoreX # Install VisioForge media SDKs in Unity [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) This guide walks through installing the VisioForge **media SDKs** in **Unity 6**. A single, fully self-contained **`.unitypackage`** brings four products into Unity at once — the **Media Blocks SDK .NET** pipeline plus the high-level **Media Player SDK .NET** (`MediaPlayerCoreX`), **Video Capture SDK .NET** (`VideoCaptureCoreX`), and **Video Edit SDK .NET** (`VideoEditCoreX`) engines. The package bundles every supported native runtime in one file — Windows x64, Android, macOS Standalone, and iOS Standalone — and lets Unity pick the right one per Build Target at build time. You do not build anything from source, you do not need NuGet, and there are no external dependencies to install. The package targets **`netstandard2.1`** managed assemblies. For projects pinned to the older Mono Unity LTS, a legacy `net48` Windows-only flavor is still published — see the spoiler at the bottom of this page. For what's inside and how to use it, see **[Using VisioForge in Unity](../../general/unity/)** — the overview with the full product and sample catalog. For the five-step shortcut, see the **[Quickstart](../../general/unity/getting-started/)**. ## Requirements | | | | --- | --- | | Unity | **6 (6000.x)** — verified on `6000.4.6f1` | | Build targets shipped | **Windows x64**, **Android arm64**, **macOS Universal arm64+x86\_64**, **iOS device arm64** | | Managed TFM | **`netstandard2.1`** | | Mandatory Editor settings | `Api Compatibility Level = .NET Standard 2.1` and Disable Domain Reload | Use a short path on NTFS — not a Dev Drive / ReFS volume Importing the package writes thousands of small native files, and Unity's import/compile is heavy small-file I/O. On a Dev Drive (ReFS) that is **dramatically slower** (a cold import can take many minutes instead of seconds) and is more prone to the `EPERM rename` race. Keep the project on a plain **NTFS** drive with a short root path, e.g. `C:\unity\MyApp`. Unity's package cache also produces deep paths that can overflow Windows' 260-character `MAX_PATH`. ## Download Download the latest cumulative package — Windows + Android + macOS + iOS in one file: [**VisioForge.MediaBlocks.Unity.unitypackage**](https://files.visioforge.com/unity/VisioForge.MediaBlocks.Unity.unitypackage) ``` https://files.visioforge.com/unity/VisioForge.MediaBlocks.Unity.unitypackage ``` ## Step 1 — Create or open a Unity project Use an existing Unity 6 project or create a new one (any template). Keep the project root on a short NTFS path (see the warning above). ## Step 2 — Import the package In the Editor: **Assets → Import Package → Custom Package…**, select the downloaded `.unitypackage`, and click **Import** (keep all items checked). The package adds: | Content | Location | Purpose | | --- | --- | --- | | Managed SDK (`netstandard2.1`) + dependencies | `Assets/Plugins/` (+ `Android/`, `macOS/`, `iOS/Managed/` subfolders) | the Media Blocks SDK .NET assemblies, per platform | | Windows native runtime | `Assets/StreamingAssets/VisioForge/x64/` | Windows GStreamer libs and plugins | | Android native runtime | `Assets/Plugins/Android/libs/arm64-v8a/` | monolithic `libgstreamer_android.so` + Java AAR | | macOS native runtime | `Assets/Plugins/macOS/` | universal dylibs (arm64+x86\_64) | | iOS native runtime | `Assets/Plugins/iOS/GStreamerX.framework/` | embedded framework (device arm64) | | IL2CPP preservation | `Assets/VisioForge/link.xml` | type / member preservation for Android & iOS | | Reusable scripts | `Assets/Scripts/` | `VisioForgeEnvironment` and `VisioForgeVideoView` helpers plus the six sample scripts | | Six sample scenes | `Assets/Scenes/` | `SimplePlayer`, `RTSPViewer`, `MediaPlayerX`, `IPCameraX`, `VideoCaptureX`, `VideoEditX` — see the [samples overview](../../general/unity/#samples) | | One-time setup helper | `Assets/VisioForge/Editor/` | applies the two required project settings | Per-flavor `PluginImporter` metadata on every native file tells Unity which Build Target each binary belongs to — switching the Build Target in Build Profiles automatically picks the right slot at build time. ## Step 3 — Apply the required project settings On first import the setup helper shows a dialog asking to apply two required project settings. Click **Apply** — both settings are configured for you. These two settings are **mandatory** — the SDK will not work without them: - **Api Compatibility Level = .NET Standard 2.1** — the SDK ships as `netstandard2.1` assemblies; the legacy `.NET Framework` setting cannot load them. - **Disable Domain Reload** — the SDK initializes once per process and is reused across Play/Stop sessions; with Domain Reload enabled the Editor can hang when leaving Play mode. For mobile targets, also switch **Scripting Backend** to **IL2CPP** — Mono is not supported on Android or iOS by Unity itself. See [Build for Android](../../general/unity/android/) and [Build for iOS](../../general/unity/ios/) for the per-target Build Profile checklists. ## Step 4 — Set the settings manually (only if you clicked Skip) If you clicked **Skip**, set both by hand: 1. **Api Compatibility Level = .NET Standard 2.1** *Edit → Project Settings → Player → Other Settings → Configuration → Api Compatibility Level*. 1. **Disable Domain Reload** *Edit → Project Settings → Editor → Enter Play Mode Settings* → set **When entering Play Mode** to an option that does **not** reload the domain — either **Reload Scene only** (matches what **Apply** does) or **Do not reload Domain or Scene**. ## Step 5 — Run a sample scene In the **Project** window open `Assets/Scenes/SimplePlayer.unity` (double-click it — do not stay on the empty default scene), select the **RawImage** GameObject, set its **File Path** in the Inspector, and press **▶ Play**. Video renders in the Game view and audio plays through the system default device. The RawImage looks empty until you press Play The video texture is created at runtime, so the `RawImage` is blank (white) in edit mode. Next, read the usage guides: - [Quickstart](../../general/unity/getting-started/) — the five-step path from import to playback. - [Using VisioForge in Unity](../../general/unity/) — the overview with the full product and sample catalog: file playback, RTSP / IP camera, webcam capture, and timeline editing. ## Build for a target platform The cumulative `.unitypackage` contains every supported platform, but each Build Target has its own settings and gotchas. Read the matching page: - [Build for Windows](../../general/unity/windows/) — x86\_64 Editor + Standalone Player. - [Build for Android](../../general/unity/android/) — IL2CPP arm64, AndroidManifest permissions. - [Build for macOS](../../general/unity/macos/) — Universal arm64+x86\_64, code-signing. - [Build for iOS](../../general/unity/ios/) — Xcode export workflow, Info.plist permissions. ## Uninstalling or upgrading the package A `.unitypackage` has no uninstaller — remove the files manually. 1. **Close the Unity Editor** first — it locks the native DLLs and the `Library/` cache. 2. Delete the VisioForge content from `Assets/`: 3. `Assets/StreamingAssets/VisioForge/` — the Windows native runtime. 4. `Assets/Plugins/Android/libs/arm64-v8a/libgstreamer_android.so`, `libVisioForge_Core.so`, and `Assets/Plugins/Android/visioforge-gstreamer.aar` — the Android runtime. 5. `Assets/Plugins/macOS/*.dylib` and `Assets/Plugins/macOS/ca-certificates.crt` — the macOS runtime. 6. `Assets/Plugins/iOS/GStreamerX.framework/` and `Assets/Plugins/iOS/libVisioForge_Core.a` — the iOS runtime. 7. `Assets/Plugins/` (with `Android/`, `macOS/`, `iOS/Managed/` subfolders) — the managed assemblies, per platform. 8. `Assets/VisioForge/` — the one-time setup helper and `link.xml`. 9. The scripts in `Assets/Scripts/`: the `VisioForgeEnvironment.cs` and `VisioForgeVideoView.cs` helpers plus the six sample scripts — `MediaBlocksPlayer.cs`, `RTSPViewerPlayer.cs`, `MediaPlayerXPlayer.cs`, `IPCameraXViewer.cs`, `VideoCaptureXRecorder.cs`, `VideoEditXRenderer.cs` (plus their `.meta`) — keep any scripts of your own that live in the same folder. 10. The sample scenes in `Assets/Scenes/`: `SimplePlayer.unity`, `RTSPViewer.unity`, `MediaPlayerX.unity`, `IPCameraX.unity`, `VideoCaptureX.unity`, `VideoEditX.unity`. 11. Delete the project's `Library/` folder (next to `Assets/`) to clear the cached import state. Unity regenerates it on the next open (the first launch is slower). **Upgrading:** import the new `.unitypackage` over the old one — the managed-plugin GUIDs are deterministic, so Unity overwrites the existing assets in place and references are preserved. If you are coming from a much older package or see duplicated DLLs in `Assets/Plugins/`, do a clean removal (steps above) first, then import the new package. ## Troubleshooting | Symptom | Cause | Fix | | --- | --- | --- | | `TypeLoadException` on play | Api Compatibility Level is `.NET Framework`, not `.NET Standard 2.1` | Set it to `.NET Standard 2.1`, or re-import and click **Apply** | | Editor hangs on "Reloading domain" on Play/Stop | Domain Reload is enabled | Keep Disable Domain Reload on | | Editor crashes on the 2nd Play | The SDK was shut down on Stop and re-initialized | Don't shut the SDK down on Stop; keep Disable Domain Reload on | | Native runtime not found | Package imported partially, or wrong Build Target's flavor missing from the package | Re-import the package with all items checked; confirm the package contains the platform you targeted | | No video, errors in the Console after import | The Editor needs a clean reload after the runtime is staged | Restart the Editor | | `DllNotFoundException` on Android | Scripting Backend is Mono | Switch to IL2CPP | For the full per-symptom reference, see [Troubleshooting](../../general/unity/troubleshooting/). ## Legacy `net48` Windows-only flavor I have an older Unity LTS pinned to Mono — what about the net48 build? The original Windows-only build of the package targets **`.NET Framework 4.8`** managed assemblies and is still produced for projects that cannot move to `.NET Standard 2.1` (for example, Unity 2019.4 LTS without the modern Api Compatibility option). It ships as a separate `.unitypackage` with `NET48` in the filename, contains only the Windows-x64 native runtime, and uses `.NET Framework` as the Api Compatibility Level. New projects should use the `netstandard2.1` package described above — it covers the same Windows-x64 use case plus every other platform, and Unity 6 defaults to it. If you have a hard requirement for the `net48` build, contact support for the latest download link. ## Frequently Asked Questions ### Can I install the SDK in Unity via NuGet? No. Unity does not run NuGet restore, and the SDK ships hundreds of native files that NuGet would not lay out for Unity. The `.unitypackage` bundles everything — managed assemblies, every platform's native runtime, scripts, and scenes — so you import a single file instead. ### Do I need to install GStreamer or any other system dependency? No. The package is fully self-contained; everything the SDK needs is inside it. A system GStreamer install on your machine is not required and is not used by the bundled runtime — on the contrary, `VisioForgeEnvironment.Configure()` actively prunes any system GStreamer from the process search path to avoid a double-init. ### Which VisioForge SDKs are included? The package ships four products from one shared `netstandard2.1` managed surface: the **Media Blocks SDK .NET** pipeline and the high-level **Media Player SDK .NET** (`MediaPlayerCoreX`), **Video Capture SDK .NET** (`VideoCaptureCoreX`), and **Video Edit SDK .NET** (`VideoEditCoreX`) engines. Each ships one or more ready sample scenes — see the [samples overview](../../general/unity/#samples). ### Does the same package work on Windows ARM64? The package's Windows native runtime is x86\_64 only — there is no ARM64 native build today. Run it via x64 emulation only at your own risk; production use on Windows 11 ARM64 is not exercised. ### Can I open the same package in the Mac-host Editor? Yes — if the package was built with `-IncludeMacOS`. The cumulative variant published at `files.visioforge.com/unity/` always contains the macOS flavor. A Windows-only variant opened in a Mac Editor surfaces a clear `[VisioForge] Native runtime folder not found at '…' for runtime platform OSXEditor` message; see [Bootstrap and lifecycle](../../general/unity/bootstrap/). ## See Also - [Using VisioForge in Unity](../../general/unity/) — overview of how the integration works - [Quickstart](../../general/unity/getting-started/) — five-step path to a playing video - [Bootstrap and lifecycle](../../general/unity/bootstrap/) — what `Configure()` and `InitializeSdk()` do - [Play a media file in Unity](../../general/unity/simple-player/) — the file-playback sample - [View an RTSP camera in Unity](../../general/unity/rtsp-viewer/) — the RTSP sample - [Capture a webcam](../../general/unity/video-capture-x/) · [Edit and render](../../general/unity/video-edit-x/) — the CoreX engine samples - [Platform matrix](../../general/unity/platform-matrix/) — feature support by Unity platform - [Media Blocks SDK .NET overview](../../mediablocks/) — the full block catalog - [Installation guide](../) — install the SDK in other .NET project types ---END OF PAGE--- ## Set Up Video SDKs for Uno Platform Cross-Platform .NET **URL:** https://www.visioforge.com/help/docs/dotnet/install/uno/ **Description:** Add video capture, playback, and editing to Uno Platform apps. NuGet setup, VideoView integration for Windows, Android, iOS, macOS, and Linux. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, WPF, Uno, GStreamer, Streaming, C#, NuGet **API:** VideoView, UniversalSourceSettings, MediaBlocksPipeline, UniversalSourceBlock, VideoRendererBlock # Integrating VisioForge SDKs with Uno Platform Applications ## Overview Uno Platform is a powerful cross-platform UI framework that enables developers to build native mobile, desktop, and embedded applications from a single C# and XAML codebase. VisioForge provides comprehensive support for Uno Platform applications through the `VisioForge.DotNet.Core.UI.Uno` package, which contains specialized UI controls designed specifically for the Uno Platform. Our SDKs enable powerful multimedia capabilities across all Uno Platform-supported platforms: [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Supported Platforms Uno Platform with VisioForge SDKs supports: - **Windows Desktop** - Full native WinUI 3 support with hardware acceleration - **Android** - Native Android views with MediaCodec hardware acceleration - **iOS** - Native UIKit with VideoToolbox hardware acceleration - **macOS** - Mac Catalyst support for Apple Silicon and Intel - **Linux Desktop** - Skia-based rendering with GStreamer ## Quick Start ### 1. Install NuGet Packages Add the core VisioForge packages to your Uno Platform project: ``` ``` ### 2. Initialize the SDK Initialize the SDK at application startup. You can use either the synchronous or asynchronous version: ``` using VisioForge.Core; // Synchronous initialization VisioForgeX.InitSDK(); // Or async initialization (recommended) await VisioForgeX.InitSDKAsync(); ``` Clean up when the application exits: ``` VisioForgeX.DestroySDK(); ``` ### 3. Add VideoView to XAML Add the VisioForge namespace and VideoView control to your XAML: ``` ``` The VideoView control adapts to the native rendering capabilities of each platform while providing a consistent API for your application code. ## Implementing VideoView in Code Here's a complete example of using VideoView with the Media Blocks pipeline: ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoRendering; using VisioForge.Core.Types.X.Sources; public sealed partial class MainPage : Page { private MediaBlocksPipeline? _pipeline; private UniversalSourceBlock? _source; private VideoRendererBlock? _renderer; public MainPage() { this.InitializeComponent(); this.Loaded += MainPage_Loaded; this.Unloaded += MainPage_Unloaded; } private async void MainPage_Loaded(object sender, RoutedEventArgs e) { // Initialize SDK (once at app startup) await VisioForgeX.InitSDKAsync(); } private async Task PlayMediaAsync(string mediaPath) { // Clean up previous pipeline if any await CleanupPipelineAsync(); // Create pipeline _pipeline = new MediaBlocksPipeline(); // Create source settings - use factory method for URLs or file paths // Video-only playback: disable audio since we're not connecting audio output UniversalSourceSettings sourceSettings; if (Uri.TryCreate(mediaPath, UriKind.Absolute, out var uri) && !uri.IsFile) { // URL source sourceSettings = await UniversalSourceSettings.CreateAsync(uri, renderAudio: false); } else { // File path source sourceSettings = await UniversalSourceSettings.CreateAsync(mediaPath, renderAudio: false); } // Create source and renderer blocks _source = new UniversalSourceBlock(sourceSettings); _renderer = new VideoRendererBlock(_pipeline, videoView); // Connect blocks _pipeline.Connect(_source.VideoOutput, _renderer.Input); // Start playback await _pipeline.StartAsync(); } private async Task CleanupPipelineAsync() { if (_pipeline != null) { await _pipeline.StopAsync(); await _pipeline.DisposeAsync(); _pipeline = null; } _source?.Dispose(); _source = null; _renderer?.Dispose(); _renderer = null; } private async void MainPage_Unloaded(object sender, RoutedEventArgs e) { await CleanupPipelineAsync(); // Destroy SDK when app closes VisioForgeX.DestroySDK(); } } ``` ## Sample Applications For complete examples and sample code, visit: - Sample applications in the `_DEMOS/Media Blocks SDK/Uno/` folder - Sample applications in the `_DEMOS/Media Player SDK X/Uno/` folder - Sample applications in the `_DEMOS/Video Capture SDK X/Uno/` folder - Our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) Available samples include: - **Simple Player** - Basic media player with playback controls - **RTSP Viewer** - Network camera streaming viewer - **Video Capture** - Camera capture with recording functionality ## Next Steps For complete deployment instructions including: - Platform-specific redistributable packages - System requirements - Build commands - Platform configurations (permissions, capabilities, Info.plist settings) - Complete sample project file - Troubleshooting See the [Uno Platform Deployment Guide](../../deployment-x/uno/). ## Additional Resources - [Windows Deployment](../../deployment-x/Windows/) - [Android Deployment](../../deployment-x/Android/) - [iOS Deployment](../../deployment-x/iOS/) - [macOS Deployment](../../deployment-x/macOS/) ---END OF PAGE--- ## Install VisioForge SDK in Visual Studio — .NET NuGet Setup **URL:** https://www.visioforge.com/help/docs/dotnet/install/visual-studio/ **Description:** Add VisioForge .NET SDKs to Visual Studio 2022+ projects via NuGet. WinForms/WPF/MAUI/console templates. Native dependencies and license setup. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, WPF, Avalonia, NuGet **API:** VideoView # Comprehensive Guide to Integrating .NET SDKs with Visual Studio [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) ## Introduction to VisioForge .NET SDKs VisioForge offers a powerful suite of multimedia SDKs for .NET developers, enabling you to build feature-rich applications with advanced video capture, editing, playback, and media processing capabilities. This comprehensive guide will walk you through the process of integrating these SDKs into your Visual Studio projects, ensuring a smooth development experience. For professional developers working on multimedia applications, properly integrating these SDKs is crucial for optimal performance and functionality. Our recommended approach is to use NuGet packages, which simplifies dependency management and ensures you're always using the latest features and bug fixes. ## Installation Methods Overview There are two primary methods to install VisioForge .NET SDKs: 1. **NuGet Package Installation** (Recommended): The modern, streamlined approach that handles dependencies automatically and simplifies updates. 2. **Manual Installation**: A traditional approach for specialized scenarios, though generally not recommended for most projects. We'll cover both methods in detail, but strongly encourage the NuGet approach for most development scenarios. ## NuGet Package Installation (Recommended Method) NuGet is the package manager for .NET, providing a centralized way to incorporate libraries into your projects without the hassle of manual file management. Here's a detailed walkthrough of integrating VisioForge SDKs using NuGet. ### Step 1: Create or Open Your .NET Project First, you'll need a WinForms, WPF, or other .NET project. We recommend using the modern SDK-style project format for optimal compatibility. #### Creating a New Project 1. Launch Visual Studio (2019 or 2022 recommended) 2. Select "Create a new project" 3. Filter templates by "C#" and either "WPF" or "Windows Forms" 4. Choose "WPF Application" or "Windows Forms Application" with the .NET Core/5/6+ framework 5. Ensure you select the modern SDK-style project format (this is the default in newer Visual Studio versions) #### Configuring the Project After creating a new project, you'll need to configure basic settings: 1. Enter your project name (use a descriptive name relevant to your application) 2. Choose an appropriate location and solution name 3. Select your target framework (.NET 6 or newer recommended for best performance and features) 4. Click "Create" to generate the project structure ### Step 2: Access NuGet Package Manager Once your project is open in Visual Studio: 1. Right-click on your project in Solution Explorer 2. Select "Manage NuGet Packages..." from the context menu 3. The NuGet Package Manager will open in the center pane This interface provides search functionality and package browsing to easily find and install the VisioForge components you need. ### Step 3: Install the UI Package for Your Framework VisioForge SDKs offer specialized UI components for different .NET frameworks. You'll need to select the appropriate UI package based on your project type. 1. In the NuGet Package Manager, switch to the "Browse" tab 2. Search for "VisioForge.DotNet.Core.UI" 3. Select the appropriate UI package for your project type from the search results #### Available UI Packages VisioForge supports a wide range of UI frameworks. Choose the one that matches your project: - **[VisioForge.DotNet.Core.UI.WinUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.WinUI)**: For modern Windows UI applications - **[VisioForge.DotNet.Core.UI.MAUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.MAUI)**: For cross-platform applications using .NET MAUI - **[VisioForge.DotNet.Core.UI.Avalonia](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.Avalonia)**: For cross-platform desktop applications using Avalonia UI These UI packages provide the necessary controls and components specifically designed for video rendering and interaction within your chosen framework. ### Step 4: Install the Core SDK Package After installing the UI package, you'll need to add the main SDK package for your specific multimedia needs: 1. Return to the NuGet Package Manager "Browse" tab 2. Search for the specific VisioForge SDK you need (e.g., "VisioForge.DotNet.VideoCapture") 3. Click "Install" on the appropriate package #### Available Core SDK Packages Choose the SDK that aligns with your application's requirements: - **[VisioForge.DotNet.VideoCapture](https://www.nuget.org/packages/VisioForge.DotNet.VideoCapture)**: For applications that need to capture video from cameras, screen recording, or other sources - **[VisioForge.DotNet.VideoEdit](https://www.nuget.org/packages/VisioForge.DotNet.VideoEdit)**: For video editing, processing, and conversion applications - **[VisioForge.DotNet.MediaPlayer](https://www.nuget.org/packages/VisioForge.DotNet.MediaPlayer)**: For creating media players with advanced playback controls - **[VisioForge.DotNet.MediaBlocks](https://www.nuget.org/packages/VisioForge.DotNet.MediaBlocks)**: For building complex media processing pipelines Each package includes comprehensive documentation, and you can install multiple packages if your application requires different multimedia capabilities. ### Step 5: Implementing the VideoView Control (Optional) The VideoView control is crucial for applications that need to display video content. You can add it to your UI using XAML (for WPF) or through the designer (for WinForms). #### For WPF Applications Add the required namespace to your XAML file: ``` xmlns:wpf="clr-namespace:VisioForge.Core.UI.WPF;assembly=VisioForge.Core" ``` Then add the VideoView control to your layout: ``` ``` The VideoView control will appear in your designer: #### For WinForms Applications 1. Open the form in designer mode 2. Locate the VisioForge controls in the toolbox (if they don't appear, right-click the toolbox and select "Choose Items...") 3. Drag and drop the VideoView control onto your form 4. Adjust the size and position properties as needed ### Step 6: Install Required Redistribution Packages Depending on your specific implementation, you may need additional redistribution packages: 1. Return to the NuGet Package Manager 2. Search for "VisioForge.DotNet.Core.Redist" to see available redistribution packages 3. Install the ones relevant to your platform and SDK choice The required redistribution packages vary based on: - Target operating system (Windows, macOS, Linux) - Hardware acceleration requirements - Specific codecs and formats your application will use - Backend engine configuration Consult the specific Deployment documentation page for your selected product to determine which redistribution packages are necessary for your application. ## Manual Installation (Alternative Method) While we generally don't recommend manual installation due to its complexity and potential for configuration issues, there are specific scenarios where it might be necessary. Follow these steps if NuGet isn't an option for your project: 1. Download the [complete SDK installer](https://files.visioforge.com/trials/visioforge_sdks_installer_dotnet_setup.exe) from our website 2. Run the installer with administrator privileges and follow the on-screen instructions 3. Create your WinForms or WPF project in Visual Studio 4. Add references to the installed SDK libraries: 5. Right-click "References" in Solution Explorer 6. Select "Add Reference" 7. Navigate to the installed SDK location 8. Select the required DLL files 9. Configure the Visual Studio Toolbox: 10. Right-click the Toolbox and select "Add Tab" 11. Name the new tab "VisioForge" 12. Right-click the tab and select "Choose Items..." 13. Browse to the SDK installation directory 14. Select `VisioForge.Core.dll` 15. Drag and drop the VideoView control onto your form or window This manual approach requires additional configuration for deployment and updates must be managed manually. ## Advanced Configuration and Best Practices For production applications, consider these additional implementation details: - **License Management**: Implement proper license validation at application startup - **Error Handling**: Add comprehensive error handling around SDK initialization and operation - **Performance Optimization**: Configure hardware acceleration and threading based on your target devices - **Resource Management**: Implement proper disposal of SDK resources to prevent memory leaks ## Troubleshooting Common Issues If you encounter problems during installation or implementation: - Verify your project targets a supported .NET version - Ensure all required redistributable packages are installed - Check for NuGet package version compatibility - Review the SDK documentation for platform-specific requirements ## Conclusion and Next Steps With the VisioForge .NET SDKs properly installed in your Visual Studio project, you're now ready to leverage their powerful multimedia capabilities. The NuGet installation method ensures you have the correct dependencies and simplifies future updates. To deepen your understanding and maximize the potential of these SDKs: - Explore our [comprehensive code samples on GitHub](https://github.com/visioforge/.Net-SDK-s-samples) - Review the product-specific documentation for advanced features - Join our developer community forums for support and best practices By following this guide, you've established a solid foundation for developing sophisticated multimedia applications with VisioForge and Visual Studio. ---END OF PAGE--- ## Install VisioForge .NET SDKs in Visual Studio for Mac **URL:** https://www.visioforge.com/help/docs/dotnet/install/visual-studio-mac/ **Description:** Install and configure VisioForge .NET SDKs in Visual Studio for Mac for multimedia macOS and iOS application development. **Tags:** Video Capture SDK, Media Player SDK, Media Blocks SDK, Video Edit SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming, Webcam, C#, NuGet **API:** VideoView # Complete Guide to Integrating VisioForge .NET SDKs with Visual Studio for Mac [Video Capture SDK .Net](https://www.visioforge.com/video-capture-sdk-net) [Video Edit SDK .Net](https://www.visioforge.com/video-edit-sdk-net) [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) [Media Player SDK .Net](https://www.visioforge.com/media-player-sdk-net) Visual Studio for Mac is retired Microsoft [retired Visual Studio for Mac](https://learn.microsoft.com/en-us/visualstudio/releases/2022/what-happened-to-vs-for-mac) on August 31, 2024. No new installs are possible and the IDE no longer receives updates. For macOS .NET development with VisioForge SDKs, use **[JetBrains Rider](../rider/)** or **Visual Studio Code with the C# Dev Kit** instead. The NuGet package names, UI controls and C# snippets on this page apply identically to those IDEs. ## Introduction to VisioForge SDKs on macOS VisioForge provides powerful multimedia SDKs for .NET developers working on macOS and iOS platforms. This detailed guide will walk you through the entire process of integrating these SDKs into your Visual Studio for Mac projects. While this tutorial primarily focuses on macOS application development, the same principles apply to iOS applications with minimal adaptations. By following this guide, you'll learn how to properly set up your development environment, install the necessary packages, configure UI components, and prepare your application for deployment. This knowledge will serve as a solid foundation for building sophisticated multimedia applications using VisioForge technology. ## Prerequisites for Development Before starting the integration process, ensure you have: - Visual Studio for Mac (latest version recommended) - .NET SDK installed (minimum version 6.0) - Basic knowledge of C# and .NET development - Administrative access to your macOS system - Active internet connection for NuGet package downloads - Optional: XCode for storyboard editing Having these prerequisites in place will ensure a smooth installation process and prevent common setup issues. ## Setting Up a New macOS Project Let's begin by creating a new macOS project in Visual Studio for Mac. This will serve as the foundation for our VisioForge SDK integration. ### Creating the Project Structure 1. Launch Visual Studio for Mac. 2. Select **File > New Solution** from the menu bar. 3. In the template selection dialog, navigate to **.NET > App**. 4. Choose **macOS Application** as your project template. 5. Configure your project settings, including: 6. Project name (choose something descriptive) 7. Organization identifier (typically in reverse domain format) 8. Target framework (.NET 6.0 or later recommended) 9. Solution name (can match your project name) 10. Click **Create** to generate your project template. This creates a basic macOS application with the standard project structure required for VisioForge SDK integration. ## Installing VisioForge SDK Packages After creating your project, the next step is to install the necessary VisioForge SDK packages via NuGet. These packages contain the core functionality and UI components required for multimedia operations. ### Adding the Main SDK Package Each VisioForge product line has a dedicated main package that contains the core functionality. You'll need to choose the appropriate package based on your development requirements. 1. Right-click on your project in the Solution Explorer. 2. Select **Manage NuGet Packages** from the context menu. 3. Click on the **Browse** tab in the NuGet Package Manager. 4. In the search box, type "VisioForge" to find all available packages. 5. Select one of the following packages based on your requirements: Available NuGet packages: - [VisioForge.DotNet.VideoCapture](https://www.nuget.org/packages/VisioForge.DotNet.VideoCapture) - For video capture, webcam, and screen recording functionality - [VisioForge.DotNet.VideoEdit](https://www.nuget.org/packages/VisioForge.DotNet.VideoEdit) - For video editing, processing, and conversion - [VisioForge.DotNet.MediaPlayer](https://www.nuget.org/packages/VisioForge.DotNet.MediaPlayer) - For media playback and streaming - [VisioForge.DotNet.MediaBlocks](https://www.nuget.org/packages/VisioForge.DotNet.MediaBlocks) - For advanced media processing workflows - Click **Add Package** to install your selected package. - Accept any license agreements that appear. The installation process will automatically resolve dependencies and add references to your project. ### Apple UI Controls For macOS and iOS applications, the Apple-specific UI controls (`VideoView`, `GLView`) are **shipped inside the main `VisioForge.DotNet.Core` package** — there is no separate `UI.Apple` NuGet. Once you've added `VisioForge.DotNet.Core` above, reference the controls via the `VisioForge.Core.UI.Apple` namespace: ``` using VisioForge.Core.UI.Apple; ``` ## Integrating Video Preview Capabilities Most multimedia applications require video preview functionality. VisioForge SDKs provide specialized controls for this purpose that integrate seamlessly with macOS applications. ### Adding the VideoView Control The VideoView control is the primary component for displaying video content in your application. Here's how to add it to your interface: 1. Open your application's main storyboard file by double-clicking it in the Solution Explorer. 2. Visual Studio for Mac will open XCode Interface Builder for storyboard editing. 3. From the Object Library, find the **Custom View** control. 4. Drag the Custom View control onto your window where you want the video to appear. 5. Set appropriate constraints to ensure proper sizing and positioning. 6. Using the Identity Inspector, set a descriptive name for your Custom View (e.g., "videoViewHost"). 7. Save your changes and return to Visual Studio for Mac. This Custom View will serve as a container for the VisioForge VideoView control, which will be added programmatically. ### Initializing the VideoView in Code After adding the container Custom View, you need to initialize the VideoView control programmatically: 1. Open your ViewController.cs file. 2. Add the necessary using directives at the top of the file: ``` using VisioForge.Core.UI.Apple; using CoreGraphics; ``` 1. Add a private field to your ViewController class to hold the VideoView reference: ``` private VideoView _videoView; ``` 1. Modify the ViewDidLoad method to initialize and add the VideoView: ``` public override void ViewDidLoad() { base.ViewDidLoad(); // Create and add VideoView _videoView = new VideoView(new CGRect(0, 0, videoViewHost.Bounds.Width, videoViewHost.Bounds.Height)); this.videoViewHost.AddSubview(_videoView); // Configure VideoView properties _videoView.AutoresizingMask = Foundation.NSViewResizingMask.WidthSizable | Foundation.NSViewResizingMask.HeightSizable; // Additional initialization code InitializeMediaComponents(); } private async void InitializeMediaComponents() { // Initialize your VisioForge SDK components here. On macOS, always use the // cross-platform X engines — classic VideoCaptureCore / MediaPlayerCore / // VideoEditCore are Windows-only. await VisioForgeX.InitSDKAsync(); // For example, for playback: // var player = new MediaPlayerCoreX(_videoView); // var settings = await UniversalSourceSettings.CreateAsync(new Uri("https://example.com/video.mp4")); // await player.OpenAsync(settings); // await player.PlayAsync(); } ``` This code creates a `VideoView` instance, sizes it to match your container view, and adds it as a subview. The `AutoresizingMask` property ensures that the video view resizes properly when the window size changes. ## Adding Required Redistribution Packages VisioForge SDKs rely on various native libraries and components that must be included in your application bundle. These dependencies vary based on the specific SDK you're using and your target platform. Check the [deployment documentation](../../deployment-x/) for detailed information on which redistribution packages are required for your specific scenario. ## Troubleshooting Common Issues If you encounter issues during installation or integration, consider these common solutions: 1. **Missing dependencies**: Ensure all required redistribution packages are installed 2. **Build errors**: Verify that your project targets a compatible .NET version 3. **Runtime crashes**: Check for platform-specific initialization issues 4. **Black video display**: Verify that the VideoView is properly initialized and added to the view hierarchy 5. **Performance issues**: Consider enabling hardware acceleration where available For more specific troubleshooting guidance, refer to the VisioForge documentation or contact their support team. ## Next Steps and Resources Now that you've successfully integrated VisioForge SDKs into your Visual Studio for Mac project, you can explore more advanced features and capabilities: - Create custom video processing workflows - Implement recording and capture functionality - Develop sophisticated media editing features - Build streaming media applications ### Additional Resources - Visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples) for code samples and example projects - Join the [developer forum](https://support.visioforge.com/) to connect with other developers - Subscribe to our newsletter for updates on new features and best practices By following this guide, you've established a solid foundation for developing powerful multimedia applications on macOS and iOS using VisioForge SDKs and Visual Studio for Mac. ---END OF PAGE--- ## Apple Platform Media Blocks in C# .NET — iOS, macOS **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/_Apple/ **Description:** Build iOS and macOS media apps with ProRes encoding, VideoToolbox acceleration, and native audio blocks using VisioForge Media Blocks SDK. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS **API:** MetalVideoCompositorBlock, MediaBlocksPipeline, VideoRendererBlock, OSXAudioSourceBlock, OSXAudioSinkBlock # Apple Platform Blocks - VisioForge Media Blocks SDK .Net [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) This section covers MediaBlocks specifically optimized for Apple platforms (iOS, macOS, tvOS). ## Available Blocks ### Audio Sources - **OSXAudioSourceBlock**: macOS audio capture using Core Audio - See [Audio Sources Documentation](../Sources/#system-audio-source) - **IOSAudioSourceBlock**: iOS audio capture - See [Audio Sources Documentation](../Sources/#system-audio-source) ### Audio Sinks - **OSXAudioSinkBlock**: macOS audio playback - See [Audio Rendering Documentation](../AudioRendering/) - **IOSAudioSinkBlock**: iOS audio playback - See [Audio Rendering Documentation](../AudioRendering/) ### Video Sources - **IOSVideoSourceBlock**: iOS camera capture - See [Video Sources Documentation](../Sources/#system-video-source) ### Video Encoders - **AppleProResEncoderBlock**: Apple ProRes professional video codec - See [ProRes Encoder Documentation](../VideoEncoders/#apple-prores-encoder) ### Video Processing - **MetalVideoCompositorBlock**: GPU-accelerated multi-input video compositor using Apple Metal - **MetalConvertScaleBlock**: GPU-accelerated format conversion and scaling using Apple Metal - **MetalDeinterlaceBlock**: GPU-accelerated deinterlacing using Apple Metal - **MetalOverlayBlock**: GPU-accelerated image overlay using Apple Metal - **MetalTransformBlock**: GPU-accelerated flip, rotate, and crop using Apple Metal ## Metal Video Compositor ### Metal Video Compositor Block The `MetalVideoCompositorBlock` composites multiple video streams in real time using the Apple Metal GPU framework. Each input stream has configurable position, size, z-order, alpha, and blend operator. The block produces a single BGRA video output. #### Block info Name: MetalVideoCompositorBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | Uncompressed video | N (one per stream) | | Output video | Uncompressed video | 1 | #### Settings The block takes a `MetalVideoCompositorSettings` instance: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Width` | `int` | 1920 | Output width in pixels | | `Height` | `int` | 1080 | Output height in pixels | | `FrameRate` | `VideoFrameRate` | FPS\_30 | Output frame rate | | `Background` | `VideoMixerBackground` | Transparent | Background mode | | `Streams` | `List` | Empty | Input stream configurations | Each input stream is a `MetalVideoMixerStream`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Rectangle` | `Rect` | required | Position and size within the output frame | | `ZOrder` | `uint` | required | Stacking order (higher = in front) | | `Alpha` | `double` | 1.0 | Opacity (0.0 transparent – 1.0 opaque) | | `BlendOperator` | `MetalVideoMixerBlendOperator` | Over | Blend mode: Source, Over, or Add | | `KeepAspectRatio` | `bool` | false | Preserve source aspect ratio during scaling | #### The sample pipeline ``` graph LR; VideoSource1-->MetalVideoCompositorBlock; VideoSource2-->MetalVideoCompositorBlock; MetalVideoCompositorBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); // Configure compositor: 1920x1080 @ 30fps var settings = new MetalVideoCompositorSettings(1920, 1080, VideoFrameRate.FPS_30); // First stream: left half of screen settings.AddStream(new MetalVideoMixerStream( rectangle: new Rect(0, 0, 960, 1080), zorder: 0)); // Second stream: right half of screen // Rect ctor is (left, top, right, bottom). For the right half of a 1920x1080 // canvas use right=1920 and bottom=1080 — the previous form (960, 0, 960, 1080) // has left==right and produces a zero-width box. settings.AddStream(new MetalVideoMixerStream( rectangle: new Rect(960, 0, 1920, 1080), zorder: 1)); var compositor = new MetalVideoCompositorBlock(settings); // Render composited output var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(compositor.Output, videoRenderer.Input); await pipeline.StartAsync(); // Real-time: fade out stream 0 over 2 seconds compositor.StartFadeOut(settings.Streams[0].ID, TimeSpan.FromSeconds(2)); ``` #### Availability ``` bool available = MetalVideoCompositorBlock.IsAvailable(); ``` Returns `true` if the `vfmetalcompositor` GStreamer plugin is available on the current system. #### Platforms macOS, iOS. ## Metal Convert/Scale ### Metal Convert/Scale Block The `MetalConvertScaleBlock` performs pixel-format conversion and scaling in a single GPU pass using the Apple Metal framework. It can optionally add letterbox/pillarbox borders to preserve the source aspect ratio. #### Block info Name: MetalConvertScaleBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | Uncompressed video | 1 | | Output video | Uncompressed video | 1 | #### Settings The block takes a `MetalConvertScaleSettings` instance: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Method` | `MetalScalingMethod` | Bilinear | Scaling interpolation: `Bilinear` or `Nearest` | | `AddBorders` | `bool` | false | Add letterbox/pillarbox borders to preserve aspect ratio | | `BorderColor` | `uint` | 0xFF000000 | Border color in ARGB format (opaque black) | #### The sample pipeline ``` graph LR; VideoSource-->MetalConvertScaleBlock; MetalConvertScaleBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var videoSource = new IOSVideoSourceBlock(videoSettings); // Bilinear scaling with letterbox borders var settings = new MetalConvertScaleSettings { Method = MetalScalingMethod.Bilinear, AddBorders = true, BorderColor = 0xFF000000 }; var convertScale = new MetalConvertScaleBlock(settings); pipeline.Connect(videoSource.Output, convertScale.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(convertScale.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Availability ``` bool available = MetalConvertScaleBlock.IsAvailable(); ``` Returns `true` if the `vfmetalconvertscale` GStreamer plugin is available on the current system. #### Platforms macOS, iOS. ## Metal Deinterlace ### Metal Deinterlace Block The `MetalDeinterlaceBlock` removes interlacing artifacts on the GPU using the Apple Metal framework. It supports bob, weave, linear, and greedy-H (motion-adaptive) algorithms. #### Block info Name: MetalDeinterlaceBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | Uncompressed video | 1 | | Output video | Uncompressed video | 1 | #### Settings The block takes a `MetalDeinterlaceSettings` instance: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Method` | `MetalDeinterlaceMethod` | Bob | Algorithm: `Bob`, `Weave`, `Linear`, or `GreedyH` | | `FieldLayout` | `MetalDeinterlaceFieldLayout` | Auto | Field order: `Auto`, `TopFieldFirst`, or `BottomFieldFirst` | | `MotionThreshold` | `double` | 0.1 | Motion detection threshold for the greedy-H algorithm (0.0–1.0) | #### The sample pipeline ``` graph LR; VideoSource-->MetalDeinterlaceBlock; MetalDeinterlaceBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var videoSource = new IOSVideoSourceBlock(videoSettings); // Motion-adaptive greedy-H deinterlacing var settings = new MetalDeinterlaceSettings { Method = MetalDeinterlaceMethod.GreedyH, FieldLayout = MetalDeinterlaceFieldLayout.Auto, MotionThreshold = 0.1 }; var deinterlace = new MetalDeinterlaceBlock(settings); pipeline.Connect(videoSource.Output, deinterlace.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(deinterlace.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Availability ``` bool available = MetalDeinterlaceBlock.IsAvailable(); ``` Returns `true` if the `vfmetaldeinterlace` GStreamer plugin is available on the current system. #### Platforms macOS, iOS. ## Metal Overlay ### Metal Overlay Block The `MetalOverlayBlock` composites a PNG or JPEG image onto video frames on the GPU using the Apple Metal framework. The overlay can be positioned in absolute pixels or as a fraction of the frame size, with adjustable opacity. #### Block info Name: MetalOverlayBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | Uncompressed video | 1 | | Output video | Uncompressed video | 1 | #### Settings The block takes a `MetalOverlaySettings` instance: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Location` | `string` | null | Path to the overlay image (PNG or JPEG); null disables the overlay | | `X` | `int` | 0 | X position in pixels (ignored when `RelativeX` is not -1) | | `Y` | `int` | 0 | Y position in pixels (ignored when `RelativeY` is not -1) | | `Width` | `int` | 0 | Overlay width in pixels (0 = original image width) | | `Height` | `int` | 0 | Overlay height in pixels (0 = original image height) | | `Alpha` | `double` | 1.0 | Opacity (0.0 transparent – 1.0 opaque) | | `RelativeX` | `double` | -1.0 | Relative X as a fraction of video width; -1.0 uses pixel `X` | | `RelativeY` | `double` | -1.0 | Relative Y as a fraction of video height; -1.0 uses pixel `Y` | #### The sample pipeline ``` graph LR; VideoSource-->MetalOverlayBlock; MetalOverlayBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var videoSource = new IOSVideoSourceBlock(videoSettings); // Logo at top-left with 80% opacity var settings = new MetalOverlaySettings { Location = "logo.png", X = 20, Y = 20, Alpha = 0.8 }; var overlay = new MetalOverlayBlock(settings); pipeline.Connect(videoSource.Output, overlay.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(overlay.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Availability ``` bool available = MetalOverlayBlock.IsAvailable(); ``` Returns `true` if the `vfmetaloverlay` GStreamer plugin is available on the current system. #### Platforms macOS, iOS. ## Metal Transform ### Metal Transform Block The `MetalTransformBlock` applies flip, rotate, and crop operations on the GPU using the Apple Metal framework. #### Block info Name: MetalTransformBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | Uncompressed video | 1 | | Output video | Uncompressed video | 1 | #### Settings The block takes a `MetalTransformSettings` instance: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Method` | `MetalTransformMethod` | None | Rotation/flip: `None`, `Clockwise`, `Rotate180`, `CounterClockwise`, `HorizontalFlip`, `VerticalFlip`, `UpperLeftDiagonal`, or `UpperRightDiagonal` | | `CropTop` | `int` | 0 | Pixels to crop from the top | | `CropBottom` | `int` | 0 | Pixels to crop from the bottom | | `CropLeft` | `int` | 0 | Pixels to crop from the left | | `CropRight` | `int` | 0 | Pixels to crop from the right | #### The sample pipeline ``` graph LR; VideoSource-->MetalTransformBlock; MetalTransformBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var videoSource = new IOSVideoSourceBlock(videoSettings); // Rotate 90 degrees clockwise and crop 10px from each side var settings = new MetalTransformSettings { Method = MetalTransformMethod.Clockwise, CropLeft = 10, CropRight = 10 }; var transform = new MetalTransformBlock(settings); pipeline.Connect(videoSource.Output, transform.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(transform.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Availability ``` bool available = MetalTransformBlock.IsAvailable(); ``` Returns `true` if the `vfmetaltransform` GStreamer plugin is available on the current system. #### Platforms macOS, iOS. ## Platform Requirements - **iOS**: iOS 12.0 or later - **macOS**: macOS 10.13 or later - **tvOS**: tvOS 12.0 or later ## Features - Native integration with Apple frameworks (AVFoundation, Core Audio, Core Video) - Hardware-accelerated processing on Apple Silicon and Intel Macs - Optimized for low power consumption on mobile devices - Support for high-quality ProRes encoding - Integration with iOS camera and microphone permissions ## Sample Code ### iOS Camera Capture ``` var pipeline = new MediaBlocksPipeline(); // iOS video source var videoSource = new IOSVideoSourceBlock(videoSettings); // Process and display var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(videoSource.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### macOS Audio Capture and Playback ``` var pipeline = new MediaBlocksPipeline(); // macOS audio source var audioSource = new OSXAudioSourceBlock(audioSettings); // macOS audio sink var audioSink = new OSXAudioSinkBlock(); pipeline.Connect(audioSource.Output, audioSink.Input); await pipeline.StartAsync(); ``` ### ProRes Encoding ``` var pipeline = new MediaBlocksPipeline(); var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("input.mp4")); // Apple ProRes encoder // AppleProResEncoderSettings exposes Quality (double 0.0-1.0), Bitrate, MaxKeyframeInterval, // MaxKeyFrameIntervalDuration, AllowFrameReordering, PreserveAlpha, Realtime — not a named profile enum. var proresSettings = new AppleProResEncoderSettings { Quality = 0.8 }; var proresEncoder = new AppleProResEncoderBlock(proresSettings); pipeline.Connect(fileSource.VideoOutput, proresEncoder.Input); // Output to MOV file var movSink = new MOVSinkBlock(new MOVSinkSettings("output.mov")); pipeline.Connect(proresEncoder.Output, movSink.CreateNewInput(MediaBlockPadMediaType.Video)); await pipeline.StartAsync(); ``` ## Platforms iOS, macOS, tvOS. ## Related Documentation - [Sources](../Sources/) - All source blocks including Apple-specific - [VideoEncoders](../VideoEncoders/) - Video encoding including ProRes - [AudioRendering](../AudioRendering/) - Audio playback ---END OF PAGE--- ## Linux VA-API Hardware Video Acceleration in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/_Linux/ **Description:** Use VA-API GPU-accelerated video encoding and decoding on Linux with VisioForge Media Blocks SDK. Ubuntu and Debian platform support for .NET apps. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS **API:** VAAPIH264DecoderBlock, UniversalSourceBlock, UniversalSourceSettings, VideoRendererBlock, VAAPIHEVCDecoderBlock # Linux Platform Blocks - VisioForge Media Blocks SDK .Net [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) This section covers MediaBlocks specifically optimized for Linux platforms. ## Available Blocks ### VA-API Hardware Decoders Linux provides hardware-accelerated video decoding through VA-API (Video Acceleration API): - **VAAPIH264DecoderBlock**: Hardware H.264/AVC decoding - **VAAPIHEVCDecoderBlock**: Hardware H.265/HEVC decoding - **VAAPIJPEGDecoderBlock**: Hardware JPEG decoding - **VAAPIVC1DecoderBlock**: Hardware VC-1 decoding See [Video Decoders Documentation](../VideoDecoders/) ## Platform Requirements - **Linux**: Any modern Linux distribution - **VA-API**: libva and appropriate driver for your GPU - **Hardware**: Intel, AMD, or other GPU with VA-API support ## Features - **Hardware Acceleration**: GPU-based video decoding - **Low CPU Usage**: Offload decoding to dedicated hardware - **Wide Compatibility**: Works with Intel, AMD, and other GPUs - **Power Efficiency**: Reduced power consumption - **Multi-Stream**: Handle multiple HD/4K streams ## Sample Code ### Hardware H.264 Decoding ``` var pipeline = new MediaBlocksPipeline(); var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("video.mp4")); // VA-API hardware decoder if (VAAPIH264DecoderBlock.IsAvailable()) { var vaapiDecoder = new VAAPIH264DecoderBlock(); pipeline.Connect(fileSource.VideoOutput, vaapiDecoder.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(vaapiDecoder.Output, videoRenderer.Input); } else { // Fallback to software decoder var decoder = new UniversalDecoderBlock(MediaBlockPadMediaType.Video); pipeline.Connect(fileSource.VideoOutput, decoder.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(decoder.VideoOutput, videoRenderer.Input); } await pipeline.StartAsync(); ``` ### Multiple Hardware Decoders ``` var pipeline = new MediaBlocksPipeline(); // Decode H.264 stream var h264Source = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("h264.mp4")); var h264Decoder = new VAAPIH264DecoderBlock(); pipeline.Connect(h264Source.VideoOutput, h264Decoder.Input); // Decode H.265 stream var h265Source = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("h265.mp4")); var h265Decoder = new VAAPIHEVCDecoderBlock(); pipeline.Connect(h265Source.VideoOutput, h265Decoder.Input); // Mix both streams (example) var mixer = new VideoMixerBlock(mixerSettings); pipeline.Connect(h264Decoder.Output, mixer.Inputs[0]); pipeline.Connect(h265Decoder.Output, mixer.Inputs[1]); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(mixer.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ## Setup and Configuration ### Installing VA-API **Ubuntu/Debian:** ``` sudo apt-get install libva2 libva-drm2 vainfo ``` **Fedora/RHEL:** ``` sudo dnf install libva libva-utils ``` ### Checking VA-API Support ``` vainfo ``` This command displays available VA-API profiles and entrypoints. ### Driver Installation **Intel GPUs:** ``` # Ubuntu/Debian sudo apt-get install intel-media-va-driver # Fedora/RHEL sudo dnf install intel-media-driver ``` **AMD GPUs:** ``` # Ubuntu/Debian sudo apt-get install mesa-va-drivers # Fedora/RHEL sudo dnf install mesa-va-drivers ``` ## Checking Hardware Support in Code ``` // Check if VA-API H.264 decoder is available if (VAAPIH264DecoderBlock.IsAvailable()) { Console.WriteLine("VA-API H.264 hardware decoding is available"); var decoder = new VAAPIH264DecoderBlock(); } else { Console.WriteLine("VA-API not available, using software decoder"); var decoder = new UniversalDecoderBlock(MediaBlockPadMediaType.Video); } ``` ## Performance Tips - Ensure VA-API drivers are properly installed - Use hardware decoders when available for best performance - Check decoder availability before creating blocks - Monitor GPU memory usage when processing multiple streams - Use `vainfo` command to verify hardware support ## Troubleshooting **VA-API not working:** 1. Verify driver installation with `vainfo` 2. Check user permissions (may need to be in `video` or `render` group) 3. Ensure GStreamer VA-API plugins are installed: `gstreamer1.0-vaapi` **Permission issues:** ``` # Add user to video group sudo usermod -a -G video $USER # Log out and back in for changes to take effect ``` ## Platforms Linux (Ubuntu, Debian, Fedora, RHEL, Arch, and other distributions). Requires VA-API support with appropriate drivers. ## Related Documentation - [VideoDecoders](../VideoDecoders/) - Hardware decoding blocks - [Nvidia](../Nvidia/) - Nvidia GPU acceleration (also works on Linux) ---END OF PAGE--- ## AI Blocks — OCR and License Plate Recognition (ANPR) **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/AI/ **Description:** Recognize text and vehicle license plates in video with the Media Blocks SDK .Net using cross-platform PaddleOCR ONNX models on CPU or GPU. **Tags:** Media Blocks SDK, OCR, ANPR, PaddleOCR, ONNX **API:** OcrBlock, LicensePlateRecognizerBlock, ObjectAnalyticsBlock, OcrSettings, LicensePlateRecognizerSettings, ObjectAnalyticsSettings # AI Blocks: OCR, License Plate Recognition, and Object Analytics The Media Blocks SDK .Net ships deep-learning AI blocks built on [ONNX Runtime](https://onnxruntime.ai/) and [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) PP-OCR models. They run on the CPU or, when available, the GPU — DirectML on Windows, CoreML on Apple, and CUDA on NVIDIA — and are fully cross-platform (Windows, Linux, macOS, Android). These blocks live in the `VisioForge.Core.AI` package (`VisioForge.DotNet.Core.AI`) alongside the [`YOLOObjectDetectorBlock`](../). ## OcrBlock — text recognition `OcrBlock` recognizes text in any video or image source. Internally it runs the multi-stage PP-OCR pipeline — text detection (DBNet) → optional 0°/180° angle classification → text-line recognition (CRNN/SVTR + CTC decoding) — on each processed frame, raises the recognized regions, and optionally draws them into the video. ``` graph LR; Source-->OcrBlock; OcrBlock-->VideoRendererBlock; OcrBlock-. OnTextDetected .->App[Your app]; ``` ### Usage ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AI; using VisioForge.Core.Types.X.AI; var ocrSettings = new OcrSettings( detectionModelPath: "ch_PP-OCRv5_mobile_det.onnx", recognitionModelPath: "latin_PP-OCRv5_rec_mobile_infer.onnx", characterDictionaryPath: "ppocrv5_latin_dict.txt", classificationModelPath: "ch_ppocr_mobile_v2.0_cls_infer.onnx") { Provider = OnnxExecutionProvider.Auto, // CPU / CUDA / DirectML / CoreML FramesToSkip = 3, // run OCR every 4th frame on live video DrawResults = true, // burn boxes + text into the frame }; var ocr = new OcrBlock(ocrSettings); ocr.OnTextDetected += (sender, e) => { foreach (var region in e.Regions) { Console.WriteLine($"{region.Text} ({region.Confidence:P0}) at {region.BoundingBox}"); } }; pipeline.Connect(source.Output, ocr.Input); pipeline.Connect(ocr.Output, videoRenderer.Input); ``` Each `OcrTextRegion` carries the recognized `Text`, an average `Confidence` (0..1), an axis-aligned `BoundingBox`, and the detection `Polygon` (4 points, in source-frame pixels). ### Key settings | Property | Default | Description | | --- | --- | --- | | `DetectionModelPath` | — | Text-detection (DBNet) ONNX model. Required. | | `RecognitionModelPath` | — | Text-recognition (CRNN/SVTR) ONNX model. Required. | | `CharacterDictionaryPath` | — | Recognizer character dictionary; must match the recognition model's language. Required. | | `ClassificationModelPath` | `null` | Optional 0°/180° angle classifier. | | `UseAngleClassifier` | `true` | Apply the angle classifier (needs `ClassificationModelPath`). | | `Provider` | `Auto` | ONNX execution provider. | | `FramesToSkip` | `0` | Frames skipped between OCR runs. Use a non-zero value for live video. | | `MaxSideLength` | `1024` | Detector input is capped at this longer-side length. | | `BoxThreshold` / `BoxScoreThreshold` / `UnclipRatio` | `0.3` / `0.5` / `1.6` | Detector tuning. | | `TextScoreThreshold` | `0.5` | Minimum mean recognition score for a line to be reported. | | `DrawResults` | `true` | Draw boxes + text into the frame. | ## LicensePlateRecognizerBlock — ANPR / LPR `LicensePlateRecognizerBlock` reads vehicle number plates. It runs the same PP-OCR pipeline on the whole frame and filters the recognized text down to plate candidates by pattern, length, confidence, and shape — so it needs **no separate, license-encumbered plate-detection model**. ``` using VisioForge.Core.MediaBlocks.AI; using VisioForge.Core.Types.X.AI; var anprSettings = new LicensePlateRecognizerSettings(ocrSettings) { PlatePattern = "^[A-Z0-9]{4,10}$", // .NET regex over the normalized candidate MinCharacters = 4, MaxCharacters = 10, MinConfidence = 0.5f, MinAspectRatio = 1.5f, // plates are wider than tall DrawResults = true, }; var anpr = new LicensePlateRecognizerBlock(anprSettings); anpr.OnPlateRecognized += (sender, e) => { foreach (var plate in e.Plates) { Console.WriteLine($"Plate: {plate.Text} ({plate.Confidence:P0})"); } }; pipeline.Connect(source.Output, anpr.Input); pipeline.Connect(anpr.Output, videoRenderer.Input); ``` For higher accuracy on busy scenes, run a dedicated plate detector (for example a [`YOLOObjectDetectorBlock`](../) with an Apache/MIT-licensed plate model) upstream and feed cropped plates in. ## Models and licensing These blocks run third-party ONNX models. The samples ship the Apache-2.0 **PP-OCRv5 mobile** models (detection, angle classification, Latin recognition) and a Latin dictionary; the models are distributed next to the sample executables, not inside the NuGet package. PP-OCR supports 100+ languages — download the matching recognition model and dictionary for other languages. Model licenses A model's license is set by its origin (training code + published weights), not by the ONNX format. Verify the license of any model — code, weights, and dataset — before shipping it. Avoid AGPL/GPL-licensed models (for example Ultralytics YOLO) in a closed-source product. The bundled PP-OCR models are Apache-2.0. ## ObjectAnalyticsBlock — multi-object tracking and tripwire `ObjectAnalyticsBlock` performs stable multi-object tracking (ByteTrack), directed tripwire line crossing, and polygon zone occupancy on top of any supported ONNX object detector (YOLOX, RT-DETR, YOLOv8). It draws overlays (boxes, labels, track IDs, traces, lines, zones, counters) and raises an `OnAnalyticsUpdated` event with tracked objects, crossing events, and zone snapshots. ``` graph LR; Source-->ObjectAnalyticsBlock; ObjectAnalyticsBlock-->VideoRendererBlock; ObjectAnalyticsBlock-. OnAnalyticsUpdated .->App[Your app]; ``` ### Usage ``` using SkiaSharp; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AI; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.AI; // Detector settings — reuse any supported YOLO model. var detector = new YoloDetectorSettings("yolox_nano.onnx") { Model = ObjectDetectorModel.YOLOX, ConfidenceThreshold = 0.25f, DrawDetections = false, // Analytics renderer draws instead. }; var settings = new ObjectAnalyticsSettings(detector); // Add a tripwire line (directed Start -> End). settings.Lines.Add(new LineZoneSettings { Id = "door", Start = new SKPoint(200, 200), End = new SKPoint(400, 200), Anchor = DetectionAnchor.BottomCenter, // feet contact }); // Add a polygon zone. settings.Zones.Add(new PolygonZoneSettings { Id = "area", Points = new[] { new SKPoint(100, 100), new SKPoint(300, 100), new SKPoint(300, 300), new SKPoint(100, 300) }, }); var analytics = new ObjectAnalyticsBlock(settings); analytics.OnAnalyticsUpdated += (s, e) => { foreach (var obj in e.Objects) Console.WriteLine($"ID #{obj.TrackerId}: {obj.Label} {obj.Confidence:P0}"); foreach (var c in e.LineCrossings) Console.WriteLine($"{c.LineId}: {c.Label}#{c.TrackerId} {c.Direction}"); }; ``` The block runs inference synchronously on the pipeline streaming thread. Use `FramesToSkip` to reduce inference frequency. On skipped frames only static geometry and counters are drawn — no stale object boxes or traces. The pure C# analytics API (`ByteTracker`, `LineZone`, `PolygonZone`, `DetectionFilter`) is also available directly for use without a MediaBlocks pipeline. ## Demos - **YOLO Object Detection Demo** (`_DEMOS/Media Blocks SDK/WPF/CSharp/YOLO Object Detection Demo`) — includes both ordinary object detection and object analytics modes - **OCR Text Recognition Demo** (`_DEMOS/Media Blocks SDK/WPF/CSharp/OCR Text Recognition Demo`) - **License Plate Recognition Demo** (`_DEMOS/Media Blocks SDK/WPF/CSharp/License Plate Recognition Demo`) ---END OF PAGE--- ## Audio Encoder Blocks - AAC, MP3, FLAC, Opus in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/AudioEncoders/ **Description:** Encode audio to AAC, MP3, FLAC, Opus, Vorbis, and WMA using VisioForge Media Blocks SDK. Configurable bitrate, sample rate, and channel settings. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming **API:** UniversalSourceBlock, MediaBlocksPipeline, UniversalSourceSettings, FileSinkBlock, AACEncoderBlock # Audio encoders blocks [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Audio encoding is the process of converting raw audio data into a compressed format. This process is essential for reducing the size of audio files, making them easier to store and stream over the internet. VisioForge Media Blocks SDK provides a wide range of audio encoders that support various formats and codecs. ## Availability checks Before using any encoder, you should check if it's available on the current platform. Each encoder block provides a static `IsAvailable()` method for this purpose: ``` // For most encoders if (EncoderBlock.IsAvailable()) { // Use the encoder } // For AAC encoder which requires passing settings if (AACEncoderBlock.IsAvailable(settings)) { // Use the AAC encoder } ``` This check is important because not all encoders are available on all platforms. Always perform this check before attempting to use an encoder to avoid runtime errors. ## AAC encoder `AAC (Advanced Audio Coding)`: A lossy compression format known for its efficiency and superior sound quality compared to MP3, widely used in digital music and broadcasting. AAC encoder is used for encoding files in MP4, MKV, M4A and some other formats, as well as for network streaming using RTSP and HLS. Use the `AACEncoderSettings` class to set the parameters. ### Block info Name: AACEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | AAC | 1 | ### Constructor options ``` // Constructor with custom settings public AACEncoderBlock(IAACEncoderSettings settings) // Constructor without parameters (uses default settings) public AACEncoderBlock() // Uses GetDefaultSettings() internally ``` ### Settings The `AACEncoderBlock` works with any implementation of the `IAACEncoderSettings` interface. Different implementations are available depending on the platform: - `AVENCAACEncoderSettings` - Available on Windows and macOS/Linux (preferred when available) - `MFAACEncoderSettings` - Windows Media Foundation implementation (Windows only) - `VOAACEncoderSettings` - Used on Android and iOS You can use the static `GetDefaultSettings()` method to get the optimal encoder settings for the current platform: ``` var settings = AACEncoderBlock.GetDefaultSettings(); ``` ### The sample pipeline ``` graph LR; UniversalSourceBlock-->AACEncoderBlock; AACEncoderBlock-->MP4SinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var aacEncoderBlock = new AACEncoderBlock(new MFAACEncoderSettings() { Bitrate = 192 }); pipeline.Connect(fileSource.AudioOutput, aacEncoderBlock.Input); var m4aSinkBlock = new MP4SinkBlock(new MP4SinkSettings(@"output.m4a")); pipeline.Connect(aacEncoderBlock.Output, m4aSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## ADPCM encoder `ADPCM (Adaptive Differential Pulse Code Modulation)`: A type of audio compression that reduces the bit rate required for audio storage and transmission while maintaining audio quality through adaptive prediction. ADPCM encoder is used for embedding audio streams in DV, WAV and AVI formats. Use the `ADPCMEncoderSettings` class to set the parameters. ### Block info Name: ADPCMEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | ADPCM | 1 | ### Constructor options ``` // Constructor with block align parameter public ADPCMEncoderBlock(int blockAlign = 1024) ``` The `blockAlign` parameter defines the block alignment in bytes. The default value is 1024. ### The sample pipeline ``` graph LR; UniversalSourceBlock-->ADPCMEncoderBlock; ADPCMEncoderBlock-->WAVSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // ADPCMEncoderBlock takes an optional block-align int (default 1024) — no Settings class. var adpcmEncoderBlock = new ADPCMEncoderBlock(blockAlign: 1024); pipeline.Connect(fileSource.AudioOutput, adpcmEncoderBlock.Input); var wavSinkBlock = new WAVSinkBlock(@"output.wav"); pipeline.Connect(adpcmEncoderBlock.Output, wavSinkBlock.Input); await pipeline.StartAsync(); ``` ## AptX encoder `AptX`: A psychoacoustic audio codec algorithm that provides CD-like audio quality with low latency for Bluetooth audio applications. Uses 4:1 compression ratio and supports stereo audio only, making it ideal for wireless audio transmission. ### Block info Name: AptXEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM | 1 | | Output | AptX | 1 | ### Constructor options ``` // Constructor with custom settings public AptXEncoderBlock(AptXEncoderSettings settings) ``` ### Settings The `AptXEncoderBlock` requires `AptXEncoderSettings` for configuration. ### The sample pipeline ``` graph LR; UniversalSourceBlock-->AptXEncoderBlock; AptXEncoderBlock-->AudioRendererBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.wav"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var aptxSettings = new AptXEncoderSettings(); var aptxEncoder = new AptXEncoderBlock(aptxSettings); pipeline.Connect(fileSource.AudioOutput, aptxEncoder.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(aptxEncoder.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, Linux (requires GStreamer AptX plugin). ## AptX decoder `AptX Decoder`: Decodes AptX compressed audio streams into raw PCM audio. This decoder handles AptX bitstreams from Bluetooth audio sources and outputs high-quality stereo PCM audio. ### Block info Name: AptXDecoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | AptX | 1 | | Output | PCM | 1 | ### Constructor options ``` // Constructor with custom settings public AptXDecoderBlock(AptXDecoderSettings settings) ``` ### Settings The `AptXDecoderBlock` requires `AptXDecoderSettings` for configuration. ### The sample pipeline ``` graph LR; AptXSourceBlock-->AptXDecoderBlock; AptXDecoderBlock-->AudioRendererBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); // Assume we have an AptX source (e.g., Bluetooth receiver) var aptxSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("aptx_stream")); var aptxSettings = new AptXDecoderSettings(); var aptxDecoder = new AptXDecoderBlock(aptxSettings); pipeline.Connect(aptxSource.AudioOutput, aptxDecoder.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(aptxDecoder.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, Linux (requires GStreamer AptX plugin). ## ALAW encoder `ALAW (A-law algorithm)`: A standard companding algorithm used in digital communications systems to optimize the dynamic range of an analog signal for digitizing. ALAW encoder is used for embedding audio streams in WAV format or transmitting over IP. Use the `ALAWEncoderSettings` class to set the parameters. ### Block info Name: ALAWEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | ALAW | 1 | ### Constructor options ``` // Default constructor public ALAWEncoderBlock() ``` ### The sample pipeline ``` graph LR; UniversalSourceBlock-->ALAWEncoderBlock; ALAWEncoderBlock-->WAVSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // ALAWEncoderBlock has a parameterless constructor. var alawEncoderBlock = new ALAWEncoderBlock(); pipeline.Connect(fileSource.AudioOutput, alawEncoderBlock.Input); var wavSinkBlock = new WAVSinkBlock(@"output.wav"); pipeline.Connect(alawEncoderBlock.Output, wavSinkBlock.Input); await pipeline.StartAsync(); ``` ## FLAC encoder `FLAC (Free Lossless Audio Codec)`: A lossless audio compression format that preserves audio quality while significantly reducing file size compared to uncompressed formats like WAV. FLAC encoder is used for encoding audio in FLAC format. Use the `FLACEncoderSettings` class to set the parameters. ### Block info Name: FLACEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | FLAC | 1 | ### Constructor options ``` // Constructor with settings public FLACEncoderBlock(FLACEncoderSettings settings) ``` ### The sample pipeline ``` graph LR; UniversalSourceBlock-->FLACEncoderBlock; FLACEncoderBlock-->FileSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var flacEncoderBlock = new FLACEncoderBlock(new FLACEncoderSettings()); pipeline.Connect(fileSource.AudioOutput, flacEncoderBlock.Input); var fileSinkBlock = new FileSinkBlock(@"output.flac"); pipeline.Connect(flacEncoderBlock.Output, fileSinkBlock.Input); await pipeline.StartAsync(); ``` ## MP2 encoder `MP2 (MPEG-1 Audio Layer II)`: An older audio compression format that preceded MP3, still used in some broadcasting applications due to its efficiency at specific bitrates. MP2 encoder is used for transmitting over IP or embedding to AVI/MPEG-2 formats. Use the `MP2EncoderSettings` class to set the parameters. ### Block info Name: MP2EncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | audio/mpeg | 1 | ### Constructor options ``` // Constructor with settings public MP2EncoderBlock(MP2EncoderSettings settings) ``` The `MP2EncoderSettings` class allows you to configure parameters such as: - Bitrate (default: 192 kbps) ### The sample pipeline ``` graph LR; UniversalSourceBlock-->MP2EncoderBlock; MP2EncoderBlock-->FileSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var mp2EncoderBlock = new MP2EncoderBlock(new MP2EncoderSettings() { Bitrate = 192 }); pipeline.Connect(fileSource.AudioOutput, mp2EncoderBlock.Input); var fileSinkBlock = new FileSinkBlock(@"output.mp2"); pipeline.Connect(mp2EncoderBlock.Output, fileSinkBlock.Input); await pipeline.StartAsync(); ``` ## MP3 encoder `MP3 (MPEG Audio Layer III)`: A popular lossy audio format that revolutionized digital music distribution by compressing files while retaining a reasonable sound quality. An MP3 encoder can convert audio streams into MP3 files or embed MP3 audio streams in formats like AVI, MKV, and others. Use the `MP3EncoderSettings` class to set the parameters. ### Block info Name: MP3EncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | audio/mpeg | 1 | ### Constructor options ``` // Constructor with settings and optional parser flag public MP3EncoderBlock(MP3EncoderSettings settings, bool addParser = false) ``` The `addParser` parameter is used to add a parser to the output stream, which is required for certain streaming applications like RTMP (YouTube/Facebook) streaming. ### The sample pipeline ``` graph LR; UniversalSourceBlock-->MP3EncoderBlock; MP3EncoderBlock-->FileSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var mp3EncoderBlock = new MP3EncoderBlock(new MP3EncoderSettings() { Bitrate = 192 }); pipeline.Connect(fileSource.AudioOutput, mp3EncoderBlock.Input); var fileSinkBlock = new FileSinkBlock(@"output.mp3"); pipeline.Connect(mp3EncoderBlock.Output, fileSinkBlock.Input); await pipeline.StartAsync(); ``` ### Streaming to RTMP example ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Add parser is set to true for RTMP streaming var mp3EncoderBlock = new MP3EncoderBlock(new MP3EncoderSettings() { Bitrate = 192 }, addParser: true); pipeline.Connect(fileSource.AudioOutput, mp3EncoderBlock.Input); // Connect to RTMP sink — RTMPSinkSettings has no string ctor; URL goes into the Location property. var rtmpSink = new RTMPSinkBlock(new RTMPSinkSettings { Location = "rtmp://streaming-server/live/stream" }); pipeline.Connect(mp3EncoderBlock.Output, rtmpSink.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## OPUS encoder `OPUS`: A highly efficient lossy audio compression format designed for the internet with low latency and high audio quality, making it ideal for real-time applications like WebRTC. OPUS encoder is used for embedding audio streams in WebM or OGG formats. Use the `OPUSEncoderSettings` class to set the parameters. ### Block info Name: OPUSEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | OPUS | 1 | ### Constructor options ``` // Constructor with settings public OPUSEncoderBlock(OPUSEncoderSettings settings) ``` The `OPUSEncoderSettings` class allows you to configure parameters such as: - Bitrate (default: 128 kbps) - Audio bandwidth - Frame size and other encoding parameters ### The sample pipeline ``` graph LR; UniversalSourceBlock-->OPUSEncoderBlock; OPUSEncoderBlock-->WebMSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var opusEncoderBlock = new OPUSEncoderBlock(new OPUSEncoderSettings() { Bitrate = 192 }); pipeline.Connect(fileSource.AudioOutput, opusEncoderBlock.Input); var webmSinkBlock = new WebMSinkBlock(new WebMSinkSettings(@"output.webm")); pipeline.Connect(opusEncoderBlock.Output, webmSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## Speex encoder `Speex`: A patent-free audio compression format designed specifically for speech, offering high compression rates while maintaining clarity for voice recordings. Speex encoder is used for embedding audio streams in OGG format. Use the `SpeexEncoderSettings` class to set the parameters. ### Block info Name: SpeexEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | Speex | 1 | ### Constructor options ``` // Constructor with settings public SpeexEncoderBlock(SpeexEncoderSettings settings) ``` The `SpeexEncoderSettings` class allows you to configure parameters such as: - Mode (SpeexEncoderMode): NarrowBand, WideBand, UltraWideBand - Quality - Complexity - VAD (Voice Activity Detection) - DTX (Discontinuous Transmission) ### The sample pipeline ``` graph LR; UniversalSourceBlock-->SpeexEncoderBlock; SpeexEncoderBlock-->OGGSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var speexEncoderBlock = new SpeexEncoderBlock(new SpeexEncoderSettings() { Mode = SpeexEncoderMode.NarrowBand }); pipeline.Connect(fileSource.AudioOutput, speexEncoderBlock.Input); // OGGSinkBlock has dynamic inputs — call CreateNewInput(...) to get a typed audio pad. var oggSinkBlock = new OGGSinkBlock(new OGGSinkSettings(@"output.ogg")); pipeline.Connect(speexEncoderBlock.Output, oggSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## Vorbis encoder `Vorbis`: An open-source, lossy audio compression format designed as a free alternative to MP3, often used within the OGG container format. Vorbis encoder is used for embedding audio streams in OGG or WebM formats. Use the `VorbisEncoderSettings` class to set the parameters. ### Block info Name: VorbisEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | Vorbis | 1 | ### Constructor options ``` // Constructor with settings public VorbisEncoderBlock(VorbisEncoderSettings settings) ``` The `VorbisEncoderSettings` class allows you to configure parameters such as: - Quality: Integer value between -1 and 10 (default 4). Used when `RateControl = VorbisEncoderRateControl.Quality`. - Bitrate: Target bitrate in Kbit/s. Used when `RateControl = VorbisEncoderRateControl.Bitrate`. - RateControl: `VorbisEncoderRateControl.Quality` (VBR quality mode) or `VorbisEncoderRateControl.Bitrate` (bitrate-based). ### The sample pipeline ``` graph LR; UniversalSourceBlock-->VorbisEncoderBlock; VorbisEncoderBlock-->OGGSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var vorbisEncoderBlock = new VorbisEncoderBlock(new VorbisEncoderSettings { Quality = 5 }); pipeline.Connect(fileSource.AudioOutput, vorbisEncoderBlock.Input); // OGGSinkBlock has dynamic inputs — call CreateNewInput(...) to get a typed audio pad. var oggSinkBlock = new OGGSinkBlock(new OGGSinkSettings(@"output.ogg")); pipeline.Connect(vorbisEncoderBlock.Output, oggSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## WAV encoder `WAV (Waveform Audio File Format)`: An uncompressed audio format that preserves audio quality but results in larger file sizes compared to compressed formats. WAV encoder is used for encoding audio into WAV format. Use the `WAVEncoderSettings` class to set the parameters. ### Block info Name: WAVEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | WAV | 1 | ### Constructor options ``` // Constructor with settings public WAVEncoderBlock(WAVEncoderSettings settings) ``` The `WAVEncoderSettings` class allows you to configure various parameters for the WAV format. ### The sample pipeline ``` graph LR; UniversalSourceBlock-->WAVEncoderBlock; WAVEncoderBlock-->FileSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var wavEncoderBlock = new WAVEncoderBlock(new WAVEncoderSettings()); pipeline.Connect(fileSource.AudioOutput, wavEncoderBlock.Input); var fileSinkBlock = new FileSinkBlock(@"output.wav"); pipeline.Connect(wavEncoderBlock.Output, fileSinkBlock.Input); await pipeline.StartAsync(); ``` ## WavPack encoder `WavPack`: A free and open-source lossless audio compression format that offers high compression rates while maintaining excellent audio quality, supporting hybrid lossy/lossless modes. WavPack encoder is used for encoding audio in WavPack format, which is ideal for archiving audio with perfect fidelity. Use the `WavPackEncoderSettings` class to set the parameters. ### Block info Name: WavPackEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | WavPack | 1 | ### Constructor options ``` // Constructor with settings public WavPackEncoderBlock(WavPackEncoderSettings settings) ``` ### The sample pipeline ``` graph LR; UniversalSourceBlock-->WavPackEncoderBlock; WavPackEncoderBlock-->FileSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var wavpackEncoderBlock = new WavPackEncoderBlock(new WavPackEncoderSettings()); pipeline.Connect(fileSource.AudioOutput, wavpackEncoderBlock.Input); var fileSinkBlock = new FileSinkBlock(@"output.wv"); pipeline.Connect(wavpackEncoderBlock.Output, fileSinkBlock.Input); await pipeline.StartAsync(); ``` ## WMA encoder `WMA (Windows Media Audio)`: A proprietary audio compression format developed by Microsoft, offering various compression levels and features for different audio applications. WMA encoder is used for encoding audio in WMA format. Use the `WMAEncoderSettings` class to set the parameters. ### Block info Name: WMAEncoderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | PCM/IEEE | 1 | | Output | WMA | 1 | ### Constructor options ``` // Constructor with settings public WMAEncoderBlock(WMAEncoderSettings settings) ``` The `WMAEncoderSettings` class allows you to configure parameters such as: - Bitrate (default: 128 kbps) - Quality settings - VBR (Variable Bit Rate) options ### Default settings You can use the static method to get default settings: ``` var settings = WMAEncoderBlock.GetDefaultSettings(); ``` ### The sample pipeline ``` graph LR; UniversalSourceBlock-->WMAEncoderBlock; WMAEncoderBlock-->ASFSinkBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var wmaEncoderBlock = new WMAEncoderBlock(new WMAEncoderSettings() { Bitrate = 192 }); pipeline.Connect(fileSource.AudioOutput, wmaEncoderBlock.Input); var asfSinkBlock = new ASFSinkBlock(new ASFSinkSettings(@"output.wma")); pipeline.Connect(wmaEncoderBlock.Output, asfSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio)); await pipeline.StartAsync(); ``` ## Resource management All encoder blocks implement `IDisposable` and have internal cleanup mechanisms. It's recommended to properly dispose of them when they're no longer needed: ``` // Using block using (var encoder = new MP3EncoderBlock(settings)) { // Use encoder } // Or manual disposal var encoder = new MP3EncoderBlock(settings); try { // Use encoder } finally { encoder.Dispose(); } ``` ## Platforms Windows, macOS, Linux, iOS, Android. Note that not all encoders are available on all platforms. Always use the `IsAvailable()` method to check for availability before using an encoder. ---END OF PAGE--- ## Audio Processing Blocks for C# .NET - Mixer, EQ, Effects **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/AudioProcessing/ **Description:** Build audio pipelines in C# with VisioForge Media Blocks SDK — mixer, equalizer, reverb, noise reduction, and 30+ blocks. Cross-platform support. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS **API:** AudioRendererBlock, UniversalSourceBlock, MediaBlocksPipeline, UniversalSourceSettings, AudioMixerBlock, AudioDelayBlock # Audio Processing and Effect Blocks for .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) VisioForge Media Blocks SDK provides a pipeline-based approach to audio processing in C# and .NET. Connect audio blocks — converters, resamplers, mixers, equalizers, effects, and analyzers — to build real-time audio processing chains for your applications. Each block has typed input/output pins that you wire together using `pipeline.Connect()`. For detailed audio effect parameters and properties, see the [Audio Effects Reference](../../general/audio-effects/reference/). All blocks are cross-platform and work on Windows, macOS, Linux, iOS, and Android. ## Basic Audio Processing ### Audio Converter The audio converter block converts audio from one format to another. #### Block info Name: AudioConverterBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings No configurable parameters. Automatically negotiates and converts audio formats between connected elements. **GStreamer Element**: `audioconvert` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioConverterBlock; AudioConverterBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var audioConverter = new AudioConverterBlock(); pipeline.Connect(fileSource.AudioOutput, audioConverter.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioConverter.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Audio Resampler The audio resampler block changes the sample rate of an audio stream. #### Block info Name: AudioResamplerBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `AudioResamplerSettings`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Format` | `AudioFormatX` | `S16LE` | Target audio sample format | | `SampleRate` | `int` | `44100` | Target sample rate in Hz | | `Channels` | `int` | `2` | Target number of audio channels | | `Quality` | `int` | `4` | Resample quality (0 = lowest, 10 = best) | | `ResampleMethod` | `AudioResamplerMethod` | `Kaiser` | Resampling algorithm: `Nearest`, `Linear`, `Cubic`, `BlackmanNuttall`, `Kaiser` | **GStreamer Element**: `audioresample` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioResamplerBlock; AudioResamplerBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Resample to 48000 Hz, stereo var settings = new AudioResamplerSettings(AudioFormatX.S16LE, 48000, 2); var audioResampler = new AudioResamplerBlock(settings); pipeline.Connect(fileSource.AudioOutput, audioResampler.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioResampler.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Audio Timestamp Corrector The audio timestamp corrector block can add or remove frames to correct input stream from unstable sources. #### Block info Name: AudioTimestampCorrectorBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `AudioTimestampCorrectorSettings`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Silent` | `bool` | `true` | Suppresses notify signals for dropped and duplicated frames | | `SkipToFirst` | `bool` | `false` | Does not produce buffers before the first one is received | | `Tolerance` | `TimeSpan` | `40 ms` | Minimum timestamp difference before samples are added or dropped | **GStreamer Element**: `audiorate` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioTimestampCorrectorBlock; AudioTimestampCorrectorBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var settings = new AudioTimestampCorrectorSettings(); var corrector = new AudioTimestampCorrectorBlock(settings); pipeline.Connect(fileSource.AudioOutput, corrector.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(corrector.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Audio Delay The audio delay block shifts audio buffer timestamps to delay the entire audio stream. Use it when the captured or decoded audio arrives earlier than video and you need to correct A/V sync, or when only one branch of an audio pipeline should be delayed before recording or streaming. `AudioDelayBlock` is different from echo effects such as `EchoBlock` or `RSAudioEchoBlock`: it does not mix a delayed copy back into the signal. It delays the stream itself by applying a timestamp offset. #### Block info Name: AudioDelayBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `AudioDelaySettings` or pass a `TimeSpan` directly to the constructor: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Delay` | `TimeSpan` | `TimeSpan.Zero` | Non-negative audio delay to apply to the stream | | `Sync` | `bool` | `true` | Synchronizes the underlying element to the pipeline clock | | `Silent` | `bool` | `true` | Suppresses handoff messages from the underlying element | **GStreamer Element**: `identity` with `ts-offset`. #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioDelayBlock; AudioDelayBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp4"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Delay audio by 500 ms. var audioDelay = new AudioDelayBlock(TimeSpan.FromMilliseconds(500)); pipeline.Connect(fileSource.AudioOutput, audioDelay.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioDelay.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Delaying only the recording branch When you preview and record at the same time, place `AudioDelayBlock` only on the branch that needs the offset. ``` var audioTee = new TeeBlock(2, MediaBlockPadMediaType.Audio); pipeline.Connect(audioSource.Output, audioTee.Input); // Preview branch without additional delay. pipeline.Connect(audioTee.Outputs[0], audioRenderer.Input); // Recording branch with delayed audio. var audioDelay = new AudioDelayBlock(TimeSpan.FromMilliseconds(250)); pipeline.Connect(audioTee.Outputs[1], audioDelay.Input); pipeline.Connect(audioDelay.Output, aacEncoder.Input); pipeline.Connect(aacEncoder.Output, mp4Sink.CreateNewInput(MediaBlockPadMediaType.Audio)); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Volume The volume block allows you to control the volume of the audio stream. #### Block info Name: VolumeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Level` | `double` | `1.0` | Volume level multiplier (0.0 = silence, 1.0 = original, values > 1.0 amplify) | | `Mute` | `bool` | `false` | Mutes the audio stream without changing the volume level | **GStreamer Element**: `volume` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->VolumeBlock; VolumeBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // VolumeBlock has a parameterless constructor; set Level on the property (0.0 silence, 1.0 normal, >1.0 amplified). var volume = new VolumeBlock { Level = 0.8 }; pipeline.Connect(fileSource.AudioOutput, volume.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(volume.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Audio mixer The audio mixer block mixes multiple audio streams into one. Block mixes the streams regardless of their format, converting if necessary. All input streams will be synchronized. The mixer block handles the conversion of different input audio formats to a common format for mixing. By default, it will try to match the format of the first connected input, but this can be explicitly configured. Use the `AudioMixerSettings` class to set the custom output format. This is useful if you need a specific sample rate, channel layout, or audio format (like S16LE, Float32LE, etc.) for the mixed output. #### Block info Name: AudioMixerBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 (dynamically created) | | Output | Uncompressed audio | 1 | #### Settings Configure via `AudioMixerSettings`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Format` | `AudioInfoX` | `S16LE, 48000 Hz, 2 ch` | Output audio format (sample format, sample rate, channel count) | **Runtime methods:** | Method | Description | | --- | --- | | `CreateNewInput()` | Creates a new input pad (before pipeline start) | | `CreateNewInputLive()` | Creates a new input pad during playback | | `RemoveInputLive(MediaBlockPad)` | Removes an input pad during playback | | `SetVolume(int streamIndex, double value)` | Sets volume for a specific input by 0-based index (0.0–10.0) | | `SetMute(int streamIndex, bool value)` | Mutes or unmutes a specific input by 0-based index | **GStreamer Element**: `audiomixer` #### The sample pipeline ``` graph LR; VirtualAudioSourceBlock#1-->AudioMixerBlock; VirtualAudioSourceBlock#2-->AudioMixerBlock; AudioMixerBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource1Block = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings()); var audioSource2Block = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings()); // Configure the mixer with specific output settings if needed // For example, to output 48kHz, 2-channel, S16LE audio: // var mixerSettings = new AudioMixerSettings() { Format = new AudioInfoX(AudioFormatX.S16LE, 48000, 2) }; // var audioMixerBlock = new AudioMixerBlock(mixerSettings); var audioMixerBlock = new AudioMixerBlock(new AudioMixerSettings()); // Each call to CreateNewInput() adds a new input to the mixer var inputPad1 = audioMixerBlock.CreateNewInput(); pipeline.Connect(audioSource1Block.Output, inputPad1); var inputPad2 = audioMixerBlock.CreateNewInput(); pipeline.Connect(audioSource2Block.Output, inputPad2); // Output the mixed audio to the default audio renderer var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioMixerBlock.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Controlling Individual Input Streams You can control the volume and mute state of individual input streams connected to the `AudioMixerBlock`. The `streamIndex` for these methods corresponds to the order in which the inputs were added via `CreateNewInput()` or `CreateNewInputLive()` (starting from 0). - **Set Volume**: Use the `SetVolume(int streamIndex, double value)` method. The `value` ranges from 0.0 (silence) to 1.0 (normal volume), and can be higher for amplification (e.g., up to 10.0, though specifics might depend on the underlying implementation limits). - **Set Mute**: Use the `SetMute(int streamIndex, bool value)` method. Set `value` to `true` to mute the stream and `false` to unmute it. ``` // Assuming audioMixerBlock is already created and inputs are connected // Set volume of the first input stream (index 0) to 50% audioMixerBlock.SetVolume(0, 0.5); // Mute the second input stream (index 1) audioMixerBlock.SetMute(1, true); ``` #### Dynamic Input Management (Live Pipeline) The `AudioMixerBlock` supports adding and removing inputs dynamically while the pipeline is running: - **Adding Inputs**: Use the `CreateNewInputLive()` method to get a new input pad that can be connected to a source. The underlying GStreamer elements will be set up to handle the new input. - **Removing Inputs**: Use the `RemoveInputLive(MediaBlockPad blockPad)` method. This will disconnect the specified input pad and clean up associated resources. This is particularly useful for applications where the number of audio sources can change during operation, such as a live mixing console or a conferencing application. #### Platforms Windows, macOS, Linux, iOS, Android. ### Audio sample grabber The audio sample grabber block allows you to access the raw audio samples from the audio stream. #### Block info Name: AudioSampleGrabberBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `format` (constructor) | `AudioFormatX` | `S16LE` | Audio sample format for captured frames | | Event | Args Type | Description | | --- | --- | --- | | `OnAudioFrameBuffer` | `AudioFrameBufferEventArgs` | Fires for each captured audio frame with raw audio data, sample rate, channels, and timestamp | #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioSampleGrabberBlock; AudioSampleGrabberBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var audioSampleGrabber = new AudioSampleGrabberBlock(); audioSampleGrabber.OnAudioFrameBuffer += (sender, args) => { // args.Frame.Data — IntPtr to the raw PCM buffer // args.Frame.DataSize — byte length of the buffer // args.Frame.Info.Format — AudioFormat (e.g., S16LE, F32LE) // args.Frame.Info.SampleRate / Channels / BPS // Set args.UpdateData = true if you mutate the buffer and want it propagated downstream. }; pipeline.Connect(fileSource.AudioOutput, audioSampleGrabber.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioSampleGrabber.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Audio Effects ### Amplify Block amplifies an audio stream by an amplification factor. Several clipping modes are available. Use method and level values to configure. #### Block info Name: AmplifyBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Level` | `double` | `1.0` | Amplification multiplier (1.0 = no change, 2.0 = double volume, 0.5 = half volume) | | `Method` | `AmplifyClippingMethod` | `Normal` | Clipping method when amplified audio exceeds the valid range | `AmplifyClippingMethod` values: | Value | Description | | --- | --- | | `Normal` | Hard clip at maximum level | | `WrapNegative` | Push overdriven values back from the opposite side | | `WrapPositive` | Push overdriven values back from the same side | | `NoClip` | No clipping applied | **GStreamer Element**: `audioamplify` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AmplifyBlock; AmplifyBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var amplify = new AmplifyBlock(AmplifyClippingMethod.Normal, 2.0); pipeline.Connect(fileSource.AudioOutput, amplify.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(amplify.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Echo The echo block adds echo effect to the audio stream. #### Block info Name: EchoBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Delay` | `TimeSpan` | `200 ms` | Echo delay time between the original signal and its repetitions | | `MaxDelay` | `TimeSpan` | `500 ms` | Maximum echo delay (determines internal buffer size). Must be >= `Delay` | | `Intensity` | `float` | `0` | Volume of the delayed signal (0.0 = no echo, 1.0 = full volume) | | `Feedback` | `float` | `0` | Feedback amount for echo repetitions (0.0 = single echo, values near 1.0 = infinite feedback) | **GStreamer Element**: `audioecho` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->EchoBlock; EchoBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // EchoBlock has a parameterless constructor; set properties directly. var echo = new EchoBlock { Delay = TimeSpan.FromMilliseconds(200), // echo delay MaxDelay = TimeSpan.FromMilliseconds(500), // internal buffer size (must be >= Delay) Intensity = 0.5f, // volume of delayed signal (0.0-1.0) Feedback = 0.3f // feedback amount (0.0-near 1.0) }; pipeline.Connect(fileSource.AudioOutput, echo.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(echo.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Karaoke The karaoke block applies a karaoke effect to the audio stream, removing center-panned vocals. #### Block info Name: KaraokeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `KaraokeAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Level` | `float` | `1.0` | Vocal suppression strength (0.0 = no effect, 1.0 = maximum suppression) | | `MonoLevel` | `float` | `1.0` | Suppression level for mono/center channel content (0.0–1.0) | | `FilterBand` | `float` | `220` | Center frequency of the filter band in Hz targeting vocal range | | `FilterWidth` | `float` | `100` | Width of the frequency band to process in Hz | **GStreamer Element**: `audiokaraoke` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->KaraokeBlock; KaraokeBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var settings = new KaraokeAudioEffect(); var karaoke = new KaraokeBlock(settings); pipeline.Connect(fileSource.AudioOutput, karaoke.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(karaoke.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Reverberation The reverberation block adds reverb effects to the audio stream. #### Block info Name: ReverberationBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `ReverberationAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `RoomSize` | `float` | `0.5` | Size of the simulated room (0.0 = small room, 1.0 = large hall) | | `Damping` | `float` | `0.2` | High frequency damping (0.0 = bright, 1.0 = dark/muffled) | | `Width` | `float` | `1.0` | Stereo width of the reverb (0.0 = mono, 1.0 = full stereo) | | `Level` | `float` | `0.5` | Wet/dry mix level (0.0 = dry only, 1.0 = wet only) | **GStreamer Element**: `freeverb` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->ReverberationBlock; ReverberationBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var settings = new ReverberationAudioEffect(); var reverb = new ReverberationBlock(settings); pipeline.Connect(fileSource.AudioOutput, reverb.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(reverb.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Wide Stereo The wide stereo block enhances the stereo image of the audio. #### Block info Name: WideStereoBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `WideStereoAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Level` | `float` | `0.01` | Stereo widening amount (0.0 = no widening, higher values = wider stereo image). Typical: 0.01–0.03 subtle, 0.05–0.10 moderate, 0.15+ strong | **GStreamer Element**: `stereo` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->WideStereoBlock; WideStereoBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var settings = new WideStereoAudioEffect(); var wideStereo = new WideStereoBlock(settings); pipeline.Connect(fileSource.AudioOutput, wideStereo.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(wideStereo.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Equalization and Filtering ### Balance Block allows you to control the balance between left and right channels. #### Block info Name: AudioBalanceBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Balance` | `float` | `0.0` | Stereo balance position (-1.0 = full left, 0.0 = center, +1.0 = full right) | **GStreamer Element**: `audiopanorama` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioBalanceBlock; AudioBalanceBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Balance: -1.0 (full left) to 1.0 (full right), 0.0 = center. The ctor takes a float, not double. var balance = new AudioBalanceBlock(0.5f); pipeline.Connect(fileSource.AudioOutput, balance.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(balance.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Equalizer (10 bands) The 10-band equalizer block provides a 10-band equalizer for audio processing. #### Block info Name: Equalizer10Block. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings The equalizer provides 10 fixed-frequency bands. Use `SetBand(int index, double gain)` to adjust individual bands. Gain range: -24 dB to +12 dB. | Band Index | Center Frequency | Bandwidth | | --- | --- | --- | | 0 | 29 Hz | 19 Hz | | 1 | 59 Hz | 39 Hz | | 2 | 119 Hz | 79 Hz | | 3 | 237 Hz | 157 Hz | | 4 | 474 Hz | 314 Hz | | 5 | 947 Hz | 628 Hz | | 6 | 1889 Hz | 1257 Hz | | 7 | 3770 Hz | 2511 Hz | | 8 | 7523 Hz | 5765 Hz | | 9 | 15011 Hz | 11498 Hz | Constructor is parameterless. Use `SetBand(int index, double gain)` to adjust each of the 10 bands after construction. **GStreamer Element**: `equalizer-10bands` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->Equalizer10Block; Equalizer10Block-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Create 10-band equalizer (parameterless ctor; bands default to 0 dB) var equalizer = new Equalizer10Block(); // Set bands individually equalizer.SetBand(0, 3); // Band 0 (31 Hz) to +3 dB equalizer.SetBand(1, 2); // Band 1 (62 Hz) to +2 dB equalizer.SetBand(9, -3); // Band 9 (16 kHz) to -3 dB pipeline.Connect(fileSource.AudioOutput, equalizer.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(equalizer.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Equalizer (Parametric) The parametric equalizer block provides a parametric equalizer for audio processing. #### Block info Name: EqualizerParametricBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Use `SetNumBands(int count)` to set the number of bands (1–64, default 3), then configure each band with `SetState(int index, ParametricEqualizerBand band)`. `ParametricEqualizerBand` properties: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Frequency` | `float` | varies | Center frequency in Hz | | `Gain` | `float` | `0.0` | Band gain in dB (-24 to +12) | | `Width` | `float` | `1.0` | Bandwidth (width) in Hz | Default bands (when 3 bands configured): | Band | Frequency | Bandwidth | | --- | --- | --- | | 0 | 110 Hz | 100 Hz | | 1 | 1100 Hz | 1000 Hz | | 2 | 11000 Hz | 10000 Hz | **GStreamer Element**: `equalizer-nbands` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->EqualizerParametricBlock; EqualizerParametricBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Create parametric equalizer var equalizer = new EqualizerParametricBlock(); // Configure the number of bands, then set each band via SetState(int index, ParametricEqualizerBand). // ParametricEqualizerBand(freq: Hz, width: Hz bandwidth, gain: dB). Properties: Frequency, Width, Gain. equalizer.SetNumBands(4); equalizer.SetState(0, new ParametricEqualizerBand(freq: 100f, width: 50f, gain: 3f)); equalizer.SetState(1, new ParametricEqualizerBand(freq: 1000f, width: 500f, gain: -2f)); pipeline.Connect(fileSource.AudioOutput, equalizer.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(equalizer.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Chebyshev Band Pass/Reject The Chebyshev band pass/reject block applies a band pass or band reject filter to the audio stream using Chebyshev filters. #### Block info Name: ChebyshevBandPassRejectBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `ChebyshevBandPassRejectAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Mode` | `ChebyshevBandMode` | `BandPass` | Filter mode: `BandPass` (pass frequencies in range) or `BandReject` (reject frequencies in range) | | `LowerFrequency` | `float` | `220.0` | Lower cutoff frequency in Hz | | `UpperFrequency` | `float` | `3000.0` | Upper cutoff frequency in Hz | | `Poles` | `int` | `4` | Number of filter poles (2–32, must be even). Higher values = sharper cutoff | | `Type` | `int` | `1` | Chebyshev filter type: 1 (ripple in passband) or 2 (ripple in stopband) | | `Ripple` | `float` | `0.25` | Amount of ripple in dB (Type 1: passband ripple, Type 2: stopband ripple) | **GStreamer Element**: `audiochebband` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->ChebyshevBandPassRejectBlock; ChebyshevBandPassRejectBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var settings = new ChebyshevBandPassRejectAudioEffect(); var filter = new ChebyshevBandPassRejectBlock(settings); pipeline.Connect(fileSource.AudioOutput, filter.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(filter.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Chebyshev Limit The Chebyshev limit block applies low-pass or high-pass filtering to the audio using Chebyshev filters. #### Block info Name: ChebyshevLimitBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `ChebyshevLimitAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Mode` | `ChebyshevLimitMode` | `LowPass` | Filter mode: `LowPass` (remove high frequencies) or `HighPass` (remove low frequencies) | | `CutOffFrequency` | `float` | `1000.0` | Cutoff frequency in Hz | | `Poles` | `int` | `4` | Number of filter poles (2–32, must be even). Higher values = sharper cutoff | | `Type` | `int` | `1` | Chebyshev filter type: 1 (ripple in passband) or 2 (ripple in stopband) | | `Ripple` | `float` | `0.25` | Amount of ripple in dB | **GStreamer Element**: `audiocheblimit` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->ChebyshevLimitBlock; ChebyshevLimitBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var settings = new ChebyshevLimitAudioEffect(); var filter = new ChebyshevLimitBlock(settings); pipeline.Connect(fileSource.AudioOutput, filter.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(filter.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Dynamic Processing ### Compressor/Expander The compressor/expander block provides dynamic range compression or expansion. #### Block info Name: CompressorExpanderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `CompressorExpanderAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Mode` | `AudioCompressorMode` | `Compressor` | Processing mode: `Compressor` (reduce dynamic range) or `Expander` (increase dynamic range) | | `Characteristics` | `AudioDynamicCharacteristics` | `HardKnee` | Knee type: `HardKnee` (abrupt transition) or `SoftKnee` (gradual transition) | | `Ratio` | `float` | `1.0` | Compression/expansion ratio (e.g., 2.0 = 2:1 compression) | | `Threshold` | `float` | `0.0` | Threshold level (0.0–1.0). Signal above this level is compressed/expanded | Constructor is parameterless. Configure via `Ratio`, `Threshold`, `Mode`, and `Characteristics` properties after construction. **GStreamer Element**: `audiodynamic` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->CompressorExpanderBlock; CompressorExpanderBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // CompressorExpanderBlock has a parameterless constructor; set properties directly. var compressor = new CompressorExpanderBlock { Mode = AudioCompressorMode.Compressor, Characteristics = AudioDynamicCharacteristics.HardKnee, Ratio = 4f, // 4:1 compression Threshold = 0.5f // 0.0-1.0 (linear amplitude, not dB on this block) }; pipeline.Connect(fileSource.AudioOutput, compressor.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(compressor.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Scale/Tempo The scale/tempo block allows you to change the tempo and pitch of the audio stream. #### Block info Name: ScaleTempoBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Rate` | `double` | `1.0` | Playback rate multiplier (0.5 = half speed, 1.0 = normal, 2.0 = double speed). Pitch is preserved | | `Overlap` | `double` | `0.2` | Percentage of stride to overlap (0.0–1.0). Higher values improve quality at CPU cost | | `Search` | `TimeSpan` | `14 ms` | Length of search window for best overlap position | | `Stride` | `TimeSpan` | `30 ms` | Length of output audio stride | Constructor is parameterless; set `Rate` via the property (or the underlying `SetRate` accessor is called internally when `Rate` is assigned). **GStreamer Element**: `scaletempo` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->ScaleTempoBlock; ScaleTempoBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // ScaleTempoBlock has a parameterless constructor; set Rate via property. // 1.0 = normal, 0.5 = half-speed, 2.0 = double-speed; pitch is preserved. var scaleTempo = new ScaleTempoBlock { Rate = 1.5 }; pipeline.Connect(fileSource.AudioOutput, scaleTempo.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(scaleTempo.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Analysis and Metering ### VU Meter The VU meter block allows you to measure the volume level of the audio stream. #### Block info Name: VUMeterBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Event-based block. Subscribe to the `OnAudioVUMeter` event (type: `EventHandler`) to receive level data. `VUMeterXEventArgs.MeterData` carries a `VUMeterXData` instance with per-channel arrays: | Property on `VUMeterXData` | Type | Description | | --- | --- | --- | | `ChannelsCount` | `int` | Number of audio channels reported | | `Peak` | `double[]` | Per-channel peak levels (dB) | | `RMS` | `double[]` | Per-channel RMS levels (dB) | | `Decay` | `double[]` | Per-channel decay levels (dB) | **GStreamer Element**: `level` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->VUMeterBlock; VUMeterBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var vuMeter = new VUMeterBlock(); vuMeter.OnAudioVUMeter += (sender, args) => { var data = args.MeterData; for (int i = 0; i < data.ChannelsCount; i++) { Console.WriteLine($"Ch{i}: Peak={data.Peak[i]:F2} dB, RMS={data.RMS[i]:F2} dB"); } }; pipeline.Connect(fileSource.AudioOutput, vuMeter.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(vuMeter.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Audio Effects ### Audio Effects The AudioEffects block provides a comprehensive collection of audio processing effects that can be applied to audio streams. For detailed effect parameters and properties, see the [Audio Effects Reference](../../general/audio-effects/reference/). #### Block info Name: AudioEffectsBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Collection-based effect management. Use the following methods: | Method | Description | | --- | --- | | `AddOrUpdate(BaseAudioEffect effect)` | Adds a new effect or updates an existing one of the same type | | `Remove()` | Removes the effect of the specified type | | `Clear()` | Removes all effects | | `Get()` | Returns the effect of the specified type, or null | Supported effect types include all effects from `VisioForge.Core.Types.X.AudioEffects` namespace. See [Audio Effects Reference](../../general/audio-effects/reference/) for detailed parameters. #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioEffectsBlock; AudioEffectsBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var audioEffects = new AudioEffectsBlock(); pipeline.Connect(fileSource.AudioOutput, audioEffects.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioEffects.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Audio Loudness Normalization The AudioLoudNorm block normalizes audio loudness according to EBU R128 standards, ensuring consistent perceived loudness across different audio content. #### Block info Name: AudioLoudNormBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `AudioLoudNormAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `LoudnessTarget` | `double` | `-24.0` | Target integrated loudness in LUFS (-70.0 to -5.0) | | `LoudnessRangeTarget` | `double` | `7.0` | Target loudness range in LU (1.0 to 20.0) | | `MaxTruePeak` | `double` | `-2.0` | Maximum true peak in dBTP (-9.0 to 0.0) | | `Offset` | `double` | `0.0` | Offset gain in LU (-99.0 to 99.0) | **GStreamer Element**: `audioloudnorm` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioLoudNormBlock; AudioLoudNormBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var loudNorm = new AudioLoudNormBlock(); pipeline.Connect(fileSource.AudioOutput, loudNorm.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(loudNorm.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### RNN Noise Reduction The AudioRNNoise block uses recurrent neural network (RNN) based noise reduction to remove background noise from audio streams while preserving speech quality. #### Block info Name: AudioRNNoiseBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `VadThreshold` | `float` | `0.0` | Voice Activity Detection threshold (0.0–1.0). When > 0, acts as a gate: audio below this speech probability is silenced. 0.0 = noise reduction only, no gating | **GStreamer Element**: `audiornnoise` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->AudioRNNoiseBlock; AudioRNNoiseBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "noisy_audio.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var rnnoise = new AudioRNNoiseBlock(); pipeline.Connect(fileSource.AudioOutput, rnnoise.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(rnnoise.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Remove Silence The RemoveSilence block automatically detects and removes silent portions from audio streams, useful for podcasts, voice recordings, and audio editing. #### Block info Name: RemoveSilenceBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `RemoveSilenceAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `Threshold` | `double` | `0.05` | Silence threshold (0.0–1.0). Audio below this level is considered silence | | `Squash` | `bool` | `true` | When true, removes silent portions entirely. When false, passes them through | **GStreamer Element**: `removesilence` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->RemoveSilenceBlock; RemoveSilenceBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "podcast.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var removeSilence = new RemoveSilenceBlock(); pipeline.Connect(fileSource.AudioOutput, removeSilence.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(removeSilence.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Csound Filter The CsoundFilter block provides advanced audio synthesis and processing using the Csound audio programming language. #### Block info Name: CsoundFilterBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings Configure via `CsoundAudioEffect`: | Property | Type | Default | Description | | --- | --- | --- | --- | | `CsdText` | `string` | `null` | Inline Csound CSD script text | | `Location` | `string` | `null` | Path to an external .csd file (alternative to CsdText) | | `Loop` | `bool` | `false` | Whether to loop the Csound score | | `ScoreOffset` | `double` | `0.0` | Score time offset in seconds | **GStreamer Element**: `csoundfilter` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->CsoundFilterBlock; CsoundFilterBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // CsoundFilterBlock takes the Csound (.csd) script contents directly, not a settings object. // Load the script from disk and pass the text to the constructor — optionally set Loop/ScoreOffset. var csdText = File.ReadAllText("filter.csd"); var csound = new CsoundFilterBlock(csdText, loop: false, scoreOffset: 0.0); pipeline.Connect(fileSource.AudioOutput, csound.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(csound.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux (requires Csound). ### EBU R128 Level The EbuR128Level block measures audio loudness according to the EBU R128 standard, providing accurate loudness measurements for broadcast compliance. #### Block info Name: EbuR128LevelBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Mode` | `EbuR128Mode` | `All` | Measurement mode flags: `MomentaryLoudness`, `ShortTermLoudness`, `GlobalLoudness`, `LoudnessRange`, `SamplePeak`, `TruePeak`, `All` | | `PostMessages` | `bool` | `true` | Whether to post GStreamer bus messages with measurement results | | `Interval` | `TimeSpan` | `1 s` | Interval between measurement updates | `EbuR128LevelBlock` measures loudness internally and posts results on the GStreamer bus when `PostMessages = true`. It does **not** expose a managed event — read the `level` property or handle the bus message yourself if you need the values inside .NET. **GStreamer Element**: `ebur128level` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->EbuR128LevelBlock; EbuR128LevelBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var ebuR128 = new EbuR128LevelBlock { Mode = EbuR128Mode.All, PostMessages = true, // enable GStreamer bus messages with measurement results Interval = TimeSpan.FromSeconds(1) // measurement cadence }; pipeline.Connect(fileSource.AudioOutput, ebuR128.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(ebuR128.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### HRTF Render The HRTFRender block applies Head-Related Transfer Function (HRTF) processing to create 3D spatial audio effects from stereo or multi-channel audio. #### Block info Name: HRTFRenderBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `HrirFile` | `string` | `""` | Path to the HRIR (Head-Related Impulse Response) file for spatial rendering | | `InterpolationSteps` | `ulong` | `8` | Number of interpolation steps for smooth spatial transitions | | `BlockLength` | `ulong` | `512` | Processing block length in samples | | `DistanceGain` | `float` | `1.0` | Distance-based gain attenuation factor | All properties support real-time updates during playback. **GStreamer Element**: `hrtfrender` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->HRTFRenderBlock; HRTFRenderBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // HRTFRenderBlock has a parameterless ctor; configure via properties. // Supply a HRIR (Head-Related Impulse Response) file — required for spatial rendering. var hrtf = new HRTFRenderBlock { HrirFile = "hrir.sofa", // path to HRIR file InterpolationSteps = 8, // ulong — smoother transitions = more CPU BlockLength = 512, // ulong — processing block size DistanceGain = 1.0f // float — how strongly distance attenuates }; pipeline.Connect(fileSource.AudioOutput, hrtf.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(hrtf.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### RS Audio Echo The RSAudioEcho block provides high-quality echo effects using the rsaudiofx GStreamer plugin. #### Block info Name: RSAudioEchoBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Delay` | `TimeSpan` | `500 ms` | Echo delay time | | `MaxDelay` | `TimeSpan` | `1000 ms` | Maximum allowed delay (must be >= Delay) | | `Intensity` | `double` | `0.5` | Echo intensity (0.0–1.0) | | `Feedback` | `double` | `0.0` | Feedback amount — controls echo repetitions (0.0–1.0) | All properties support real-time updates during playback. **GStreamer Element**: `rsaudioecho` #### The sample pipeline ``` graph LR; UniversalSourceBlock-->RSAudioEchoBlock; RSAudioEchoBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // RSAudioEchoBlock has a parameterless ctor; configure via properties (Delay/MaxDelay are TimeSpan). var rsEcho = new RSAudioEchoBlock { Delay = TimeSpan.FromMilliseconds(500), MaxDelay = TimeSpan.FromMilliseconds(1000), Intensity = 0.5, // 0.0-1.0 — echo volume Feedback = 0.3 // 0.0-0.9 — how many repeats before decay }; pipeline.Connect(fileSource.AudioOutput, rsEcho.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(rsEcho.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux (requires rsaudiofx plugin). ### Pitch Shifter The `PitchBlock` shifts the pitch of an audio stream without affecting playback speed. It uses the SoundTouch library via the GStreamer `pitch` element, supporting shifts from −12 to +12 semitones (one octave down to one octave up). #### Block info Name: PitchBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `Semitones` | `int` | `0` | Pitch shift in semitones (−12 to +12) | | `Pitch` | `float` | `1.0` | Direct pitch multiplier (1.0 = no change, 2.0 = one octave up, 0.5 = one octave down) | #### Availability `PitchBlock.IsAvailable()` returns `true` if the GStreamer `pitch` element (SoundTouch plugin) is present. #### The sample pipeline ``` graph LR; UniversalSourceBlock-->PitchBlock; PitchBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var pitchBlock = new PitchBlock(semitones: 5); pipeline.Connect(fileSource.AudioOutput, pitchBlock.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(pitchBlock.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux. ### Silence Detector The `SilenceDetectorBlock` analyzes audio levels in real time to detect silence periods based on a configurable dBFS threshold. It is a pass-through block — audio is forwarded unchanged while `OnSilenceStarted` and `OnSilenceEnded` events fire at state transitions. Detected periods can be retrieved as a list or exported as JSON. #### Block info Name: SilenceDetectorBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `ThresholdDb` | `double` | `-40.0` | Silence threshold in dBFS; audio below this level is treated as silence | Key methods: - `GetSilencePeriods()` — returns all detected `SilencePeriod` objects. - `FinalizeSilencePeriods(TimeSpan endTime)` — closes any in-progress period and returns the full list. - `ExportSilencePeriodsJson()` — returns a JSON string with start/end timestamps for every detected period. #### The sample pipeline ``` graph LR; UniversalSourceBlock-->SilenceDetectorBlock; SilenceDetectorBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var silenceDetector = new SilenceDetectorBlock(thresholdDb: -35.0); silenceDetector.OnSilenceStarted += (s, e) => Console.WriteLine($"Silence started at {e.Timestamp}"); silenceDetector.OnSilenceEnded += (s, e) => Console.WriteLine($"Silence ended at {e.Timestamp}"); pipeline.Connect(fileSource.AudioOutput, silenceDetector.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(silenceDetector.Output, audioRenderer.Input); await pipeline.StartAsync(); // After pipeline stops, export detected silence periods var json = silenceDetector.ExportSilencePeriodsJson(); Console.WriteLine(json); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ### Weighted Channel Mix The `WeightedChannelMixBlock` mixes the left and right stereo channels with independently adjustable weights, producing a mono or stereo output. It is primarily used for dual-mono sources such as karaoke audio where one channel carries an instrumental track and the other a full mix. Weights can be changed at runtime without rebuilding the pipeline. Values above 1.0 boost the channel but may cause clipping. #### Block info Name: WeightedChannelMixBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed stereo audio | 1 | | Output | Uncompressed audio | 1 | #### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `LeftChannelWeight` | `float` | `0.5` | Mix weight for the left channel (0.0–1.0+) | | `RightChannelWeight` | `float` | `0.5` | Mix weight for the right channel (0.0–1.0+) | #### The sample pipeline ``` graph LR; UniversalSourceBlock-->WeightedChannelMixBlock; WeightedChannelMixBlock-->AudioRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "karaoke.mp3"; var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Use only the instrumental (left) channel var mixer = new WeightedChannelMixBlock(leftWeight: 1.0f, rightWeight: 0.0f); pipeline.Connect(fileSource.AudioOutput, mixer.Input); var audioRenderer = new AudioRendererBlock(); pipeline.Connect(mixer.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Frequently Asked Questions How do I connect audio blocks in a pipeline? Create a `MediaBlocksPipeline`, instantiate the blocks you need, then connect them using `pipeline.Connect(sourceBlock.Output, destinationBlock.Input)`. Each block has typed input and output pins — the pipeline validates that connected pins have compatible media types. Can I apply multiple audio effects in a single pipeline? Yes. You can chain any number of audio blocks in sequence. For example, connect a source to an equalizer block, then to a reverb block, then to a renderer. Alternatively, use the `AudioEffectsBlock` to apply multiple effects within a single block. For effect parameters, see the [Audio Effects Reference](../../general/audio-effects/reference/). How do I mix multiple audio sources together? Use the `AudioMixerBlock` to combine multiple audio inputs into a single output. Connect each source to a separate input pin on the mixer. The mixer supports volume control per input and automatic format negotiation. What is the difference between AudioEffectsBlock and individual effect blocks? Individual effect blocks (like `AmplifyBlock`, `EchoBlock`, `ReverbBlock`) wrap a single GStreamer element and are connected as separate pipeline nodes. The `AudioEffectsBlock` lets you apply multiple effects within one block by adding effect instances to its collection — useful when you need several effects without complex wiring. Do audio blocks support real-time parameter changes? Yes. You can modify block properties during playback. For example, change the volume level, adjust EQ bands, or update mixer weights while the pipeline is running. Changes take effect immediately without stopping the pipeline. ## See Also - [Audio Effects Overview](../../general/audio-effects/) - [Audio Effects Reference](../../general/audio-effects/reference/) - [Audio Encoders](../../general/audio-encoders/) - [Media Blocks SDK Overview](../) ---END OF PAGE--- ## Cross-Platform Audio Rendering and Playback in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/AudioRendering/ **Description:** Play audio to speakers on Windows, macOS, Linux, iOS, and Android using VisioForge Media Blocks SDK. Device selection, buffer control, volume management. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Playback **API:** AudioRendererBlock, OSXAudioSinkBlock, IOSAudioSinkBlock, OSXAudioSinkSettings, MediaBlocksPipeline # Audio Rendering Block: Cross-Platform Audio Output Processing [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Audio Rendering The Audio Renderer Block serves as a critical component in media processing pipelines, enabling applications to output audio streams to sound devices across multiple platforms. This versatile block handles the complex task of converting digital audio data into audible sound through the appropriate hardware interfaces, making it an essential tool for developers building audio-enabled applications. Audio rendering requires careful management of hardware resources, buffer settings, and timing synchronization to ensure smooth, uninterrupted playback. This block abstracts these complexities and provides a unified interface for audio output across diverse computing environments. ## Core Functionality The Audio Renderer Block accepts uncompressed audio streams and outputs them to either the default audio device or a user-selected alternative. It provides essential audio playback controls including: - Volume adjustment with precise decibel control - Mute functionality for silent operation - Device selection from available system audio outputs - Buffering settings to optimize for latency or stability These capabilities allow developers to create applications with professional-grade audio output without needing to implement platform-specific code for each target operating system. ## Underlying Technology ### Platform-Specific Implementation The `AudioRendererBlock` supports various platform-specific audio rendering technologies. It can be configured to use a specific audio device and API (see Device Management section). When instantiated using its default constructor (e.g., `new AudioRendererBlock()`), it attempts to select a suitable default audio API based on the operating system: - **Windows**: The default constructor typically uses DirectSound. The block supports multiple audio APIs including: - DirectSound: Provides low-latency output with broad compatibility - WASAPI (Windows Audio Session API): Offers exclusive mode for highest quality - ASIO (Audio Stream Input/Output): Professional-grade audio with minimal latency for specialized hardware - **macOS**: Utilizes the CoreAudio framework. The default constructor will typically select a CoreAudio-based device for: - High-resolution audio output - Native integration with macOS audio subsystem - Support for audio units and professional equipment (Note: Similarly for macOS, an `OSXAudioSinkBlock` is available for direct interaction with the platform-specific GStreamer sink if needed for specialized scenarios.) - **Linux**: Implements ALSA (Advanced Linux Sound Architecture). The default constructor will typically select an ALSA-based device for: - Direct hardware access - Comprehensive device support - Integration with the Linux audio stack - **iOS**: Employs CoreAudio, optimized for mobile. The default constructor will typically select a CoreAudio-based device, enabling features like: - Power-efficient rendering - Background audio capabilities - Integration with iOS audio session management (Note: For developers requiring more direct control over the iOS-specific GStreamer sink or having advanced use cases, the SDK also provides `IOSAudioSinkBlock` as a distinct media block.) - **Android**: Defaults to using OpenSL ES to provide: - Low-latency audio output - Hardware acceleration when available ## OSXAudioSinkBlock: Direct macOS Audio Output The `OSXAudioSinkBlock` is a platform-specific media block designed for advanced scenarios where direct interaction with the macOS GStreamer audio sink is required. This block is useful for developers who need low-level control over audio output on macOS devices, such as custom device selection or integration with other native components. ### Key Features - Direct access to the macOS audio sink - Device selection via `DeviceID` - Suitable for specialized or professional audio applications on macOS ### Settings: `OSXAudioSinkSettings` The `OSXAudioSinkBlock` requires an `OSXAudioSinkSettings` object to specify the audio output device. The `OSXAudioSinkSettings` class allows you to define: - `DeviceID`: The ID of the macOS audio output device (starting from 0) Example: ``` using VisioForge.Core.Types.X.Sinks; // Select the first available audio device (DeviceID = 0) var osxSettings = new OSXAudioSinkSettings { DeviceID = 0 }; // Create the macOS audio sink block var osxAudioSink = new OSXAudioSinkBlock(osxSettings); ``` ### Availability Check You can check if the `OSXAudioSinkBlock` is available on the current platform: ``` bool isAvailable = OSXAudioSinkBlock.IsAvailable(); ``` ### Integration Example Below is a minimal example of integrating `OSXAudioSinkBlock` into a media pipeline: ``` var pipeline = new MediaBlocksPipeline(); // Set up your audio source block as needed var audioSourceBlock = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings()); // Define settings for the sink var osxSettings = new OSXAudioSinkSettings { DeviceID = 0 }; var osxAudioSink = new OSXAudioSinkBlock(osxSettings); // Connect the source to the macOS audio sink pipeline.Connect(audioSourceBlock.Output, osxAudioSink.Input); await pipeline.StartAsync(); ``` ## IOSAudioSinkBlock: Direct iOS Audio Output The `IOSAudioSinkBlock` is a platform-specific media block designed for advanced scenarios where direct interaction with the iOS GStreamer audio sink is required. This block is useful for developers who need low-level control over audio output on iOS devices, such as custom audio routing, format handling, or integration with other native components. ### Key Features - Direct access to the iOS GStreamer audio sink - Fine-grained control over audio format, sample rate, and channel count - Suitable for specialized or professional audio applications on iOS ### Settings: `AudioInfoX` The `IOSAudioSinkBlock` requires an `AudioInfoX` object to specify the audio format. The `AudioInfoX` class allows you to define: - `Format`: The audio sample format (e.g., `AudioFormatX.S16LE`, `AudioFormatX.F32LE`, etc.) - `SampleRate`: The sample rate in Hz (e.g., 44100, 48000) - `Channels`: The number of audio channels (e.g., 1 for mono, 2 for stereo) Example: ``` using VisioForge.Core.Types.X; // Define audio format: 16-bit signed little-endian, 44100 Hz, stereo var audioInfo = new AudioInfoX(AudioFormatX.S16LE, 44100, 2); // Create the iOS audio sink block var iosAudioSink = new IOSAudioSinkBlock(audioInfo); ``` ### Availability Check You can check if the `IOSAudioSinkBlock` is available on the current platform: ``` bool isAvailable = IOSAudioSinkBlock.IsAvailable(); ``` ### Integration Example Below is a minimal example of integrating `IOSAudioSinkBlock` into a media pipeline: ``` var pipeline = new MediaBlocksPipeline(); // Set up your audio source block as needed var audioSourceBlock = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings()); // Define audio format for the sink var audioInfo = new AudioInfoX(AudioFormatX.S16LE, 44100, 2); var iosAudioSink = new IOSAudioSinkBlock(audioInfo); // Connect the source to the iOS audio sink pipeline.Connect(audioSourceBlock.Output, iosAudioSink.Input); await pipeline.StartAsync(); ``` ## Technical Specifications ### Block Information Name: AudioRendererBlock | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | ### Audio Format Support The Audio Renderer Block accepts a wide range of uncompressed audio formats: - Sample rates: 8kHz to 192kHz - Bit depths: 8-bit, 16-bit, 24-bit, and 32-bit (floating point) - Channel configurations: Mono, stereo, and multichannel (up to 7.1 surround) This flexibility allows developers to work with everything from basic voice applications to high-fidelity music and immersive audio experiences. ## Device Management ### Enumerating Available Devices The Audio Renderer Block provides straightforward methods to discover and select from available audio output devices on the system using the `GetDevicesAsync` static method: ``` // Get a list of all audio output devices on the current system var availableDevices = await AudioRendererBlock.GetDevicesAsync(); // Optionally specify the API to use var directSoundDevices = await AudioRendererBlock.GetDevicesAsync(AudioOutputDeviceAPI.DirectSound); // Display device information foreach (var device in availableDevices) { Console.WriteLine($"Device: {device.Name}"); } // Create a renderer with a specific device var audioRenderer = new AudioRendererBlock(availableDevices[0]); ``` ### Default Device Handling When no specific device is selected, the block automatically routes audio to the system's default output device. The no-parameter constructor attempts to select an appropriate default device based on the platform: ``` // Create with default device var audioRenderer = new AudioRendererBlock(); ``` The block also monitors device status, handling scenarios such as: - Device disconnection during playback - Default device changes by the user - Audio endpoint format changes ## Performance Considerations ### Latency Management Audio rendering latency is critical for many applications. The block provides configuration options through the `Settings` property and synchronization control via the `IsSync` property: ``` // Control synchronization behavior audioRenderer.IsSync = true; // Enable synchronization (default) // Check if a specific API is available on this platform bool isDirectSoundAvailable = AudioRendererBlock.IsAvailable(AudioOutputDeviceAPI.DirectSound); ``` ### Volume and Mute Control The AudioRendererBlock provides precise volume control and mute functionality: ``` // Set volume (0.0 to 1.0 range) audioRenderer.Volume = 0.8; // 80% volume // Get current volume double currentVolume = audioRenderer.Volume; // Mute/unmute audioRenderer.Mute = true; // Mute audio audioRenderer.Mute = false; // Unmute audio // Check mute state bool isMuted = audioRenderer.Mute; ``` ### Resource Utilization The Audio Renderer Block is designed for efficiency, with optimizations for: - CPU usage during playback - Memory footprint for buffer management - Power consumption on mobile devices ## Integration Examples ### Basic Pipeline Setup The following example demonstrates how to set up a simple audio rendering pipeline using a virtual audio source: ``` var pipeline = new MediaBlocksPipeline(); var audioSourceBlock = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings()); // Create audio renderer with default settings var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioSourceBlock.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` ### Real-World Audio Pipeline For a more practical application, here's how to capture system audio and render it: ``` graph LR; SystemAudioSourceBlock-->AudioRendererBlock; ``` ``` var pipeline = new MediaBlocksPipeline(); // Capture system audio var systemAudioSource = new SystemAudioSourceBlock(); // Configure the audio renderer var audioRenderer = new AudioRendererBlock(); audioRenderer.Volume = 0.8f; // 80% volume // Connect blocks pipeline.Connect(systemAudioSource.Output, audioRenderer.Input); // Start processing await pipeline.StartAsync(); // Allow audio to play for 10 seconds await Task.Delay(TimeSpan.FromSeconds(10)); // Stop the pipeline await pipeline.StopAsync(); ``` ## Compatibility and Platform Support The Audio Renderer Block is designed for cross-platform operation, supporting: - Windows 10 and later - macOS 10.13 and later - Linux (Ubuntu, Debian, Fedora) - iOS 12.0 and later - Android 8.0 and later This wide platform support enables developers to create consistent audio experiences across different operating systems and devices. ## Conclusion The Audio Renderer Block provides developers with a powerful, flexible solution for audio output across multiple platforms. By abstracting the complexities of platform-specific audio APIs, it allows developers to focus on creating exceptional audio experiences without worrying about the underlying implementation details. Whether building a simple media player, a professional audio editing application, or a real-time communications platform, the Audio Renderer Block provides the tools needed for high-quality, reliable audio output. ---END OF PAGE--- ## Audio Visualizer Blocks for .NET - Spectrum and Waveform **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/AudioVisualizers/ **Description:** Build audio-reactive applications with VisioForge Media Blocks SDK visualizer blocks — Spacescope, Spectroscope, Synaescope, and Wavescope renderers. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS **API:** VideoRendererBlock, UniversalSourceBlock, MediaBlocksPipeline, UniversalSourceSettings, SynaescopeBlock # Audio visualizer blocks [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) VisioForge Media Blocks SDK .Net includes a set of audio visualizer blocks that allow you to create audio-reactive visualizations for your applications. These blocks take audio input and produce video output representing the audio characteristics. The blocks can be connected to other audio and video processing blocks to create complex media pipelines. Most of the blocks are available for all platforms, including Windows, Linux, MacOS, Android, and iOS. ## Spacescope The Spacescope block is a simple audio visualization element that maps the left and right audio channels to X and Y coordinates, respectively, creating a Lissajous-like pattern. This visualizes the phase relationship between the channels. The appearance, such as using dots or lines and colors, can be customized via `SpacescopeSettings`. #### Block info Name: SpacescopeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Video | 1 | #### The sample pipeline ``` graph LR; UniversalSourceBlock-->SpacescopeBlock; SpacescopeBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; // Or any audio source var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Settings can be customized, e.g., for shader, line thickness, etc. // The style (dots, lines, color-dots, color-lines) can be set in SpacescopeSettings. var spacescopeSettings = new SpacescopeSettings(); var spacescope = new SpacescopeBlock(spacescopeSettings); pipeline.Connect(fileSource.AudioOutput, spacescope.Input); // Assuming you have a VideoRendererBlock or a way to display video output var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(spacescope.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Spectrascope The Spectrascope block is a simple spectrum visualization element. It renders the frequency spectrum of the audio input as a series of bars. #### Block info Name: SpectrascopeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Video | 1 | #### The sample pipeline ``` graph LR; UniversalSourceBlock-->SpectrascopeBlock; SpectrascopeBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; // Or any audio source var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); var spectrascope = new SpectrascopeBlock(); pipeline.Connect(fileSource.AudioOutput, spectrascope.Input); // Assuming you have a VideoRendererBlock or a way to display video output var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(spectrascope.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Synaescope The Synaescope block is an audio visualization element that analyzes frequencies and out-of-phase properties of the audio. It draws this analysis as dynamic clouds of stars, creating colorful and abstract patterns. #### Block info Name: SynaescopeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Video | 1 | #### The sample pipeline ``` graph LR; UniversalSourceBlock-->SynaescopeBlock; SynaescopeBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; // Or any audio source var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // SynaescopeBlock uses GStreamer defaults — there is no settings class on the managed surface. var synaescope = new SynaescopeBlock(); pipeline.Connect(fileSource.AudioOutput, synaescope.Input); // Assuming you have a VideoRendererBlock or a way to display video output var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(synaescope.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## Wavescope The Wavescope block is a simple audio visualization element that renders the audio waveforms, similar to an oscilloscope display. The drawing style (dots, lines, colors) can be configured using `WavescopeSettings`. #### Block info Name: WavescopeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Uncompressed audio | 1 | | Output | Video | 1 | #### The sample pipeline ``` graph LR; UniversalSourceBlock-->WavescopeBlock; WavescopeBlock-->VideoRendererBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); var filename = "test.mp3"; // Or any audio source var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(filename)); // Settings can be customized, e.g., for style, mono/stereo mode, etc. // The style (dots, lines, color-dots, color-lines) can be set in WavescopeSettings. var wavescopeSettings = new WavescopeSettings(); var wavescope = new WavescopeBlock(wavescopeSettings); pipeline.Connect(fileSource.AudioOutput, wavescope.Input); // Assuming you have a VideoRendererBlock or a way to display video output var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(wavescope.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` #### Platforms Windows, macOS, Linux, iOS, Android. ## LibVisual Bumpscope LibVisual Bumpscope creates a bumpmapped oscilloscope visualization effect. ### Block info Name: LibVisualBumpscopeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var bumpscope = new LibVisualBumpscopeBlock(); pipeline.Connect(audioSource.AudioOutput, bumpscope.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(bumpscope.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual Corona LibVisual Corona creates a radiant corona visualization effect. ### Block info Name: LibVisualCoronaBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var corona = new LibVisualCoronaBlock(); pipeline.Connect(audioSource.AudioOutput, corona.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(corona.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual Infinite LibVisual Infinite creates an infinite tunnel visualization effect. ### Block info Name: LibVisualInfiniteBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var infinite = new LibVisualInfiniteBlock(); pipeline.Connect(audioSource.AudioOutput, infinite.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(infinite.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual Jakdaw LibVisual Jakdaw creates a dynamic visualization effect. ### Block info Name: LibVisualJakdawBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var jakdaw = new LibVisualJakdawBlock(); pipeline.Connect(audioSource.AudioOutput, jakdaw.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(jakdaw.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual Jess LibVisual Jess creates a particle-based visualization effect. ### Block info Name: LibVisualJessBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var jess = new LibVisualJessBlock(); pipeline.Connect(audioSource.AudioOutput, jess.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(jess.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual LV Analyzer LibVisual LV Analyzer creates a frequency analyzer visualization. ### Block info Name: LibVisualLVAnalyzerBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var analyzer = new LibVisualLVAnalyzerBlock(); pipeline.Connect(audioSource.AudioOutput, analyzer.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(analyzer.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual LV Scope LibVisual LV Scope creates a classic oscilloscope visualization. ### Block info Name: LibVisualLVScopeBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var scope = new LibVisualLVScopeBlock(); pipeline.Connect(audioSource.AudioOutput, scope.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(scope.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ## LibVisual Oinksie LibVisual Oinksie creates a playful visualization effect. ### Block info Name: LibVisualOinksieBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | | Output video | uncompressed video | 1 | ### Sample code ``` var pipeline = new MediaBlocksPipeline(); var audioSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("test.mp3")); var oinksie = new LibVisualOinksieBlock(); pipeline.Connect(audioSource.AudioOutput, oinksie.Input); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); pipeline.Connect(oinksie.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Platforms Windows, macOS, Linux. ---END OF PAGE--- ## AWS S3 Cloud Media Storage - Source and Sink in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/AWS/ **Description:** Read and write media files to Amazon S3 in your pipeline using VisioForge Media Blocks SDK. Stream, transcode, and store video directly to cloud storage. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS **API:** AWSS3SinkBlock, AWSS3SinkSettings, MP4SinkBlock, SystemVideoSourceBlock, VideoEncoderBlock # AWS S3 Blocks - VisioForge Media Blocks SDK .Net [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) AWS S3 blocks enable interaction with Amazon Simple Storage Service (S3) to read media files as sources or write media files as sinks within your pipelines. ## AWSS3SinkBlock The `AWSS3SinkBlock` allows you to write media data from your pipeline to a file in an AWS S3 bucket. This is useful for storing recorded media, transcoded files, or other outputs directly to cloud storage. #### Block info Name: `AWSS3SinkBlock`. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Auto (depends on connected block) | 1 | #### Settings The `AWSS3SinkBlock` is configured using `AWSS3SinkSettings`. Key properties: - `Uri` (string): The S3 object URI (e.g., "s3://your-bucket-name/path/to/output/file.mp4"). Alternatively, set `Bucket` and `Key` separately. - `Bucket` (string): The target S3 bucket name. - `Key` (string): The object key (path within the bucket). - `AccessKey` (string): Your AWS Access Key. - `SecretAccessKey` (string): Your AWS Secret Access Key. - `Region` (string): The AWS region where the bucket is located (default `"us-west-1"`). - `SessionToken` (string, optional): AWS temporary session token from STS, if using temporary credentials. - `EndpointUri` (string, optional): Custom S3-compatible endpoint URI. - `ContentType` (string, optional): The MIME type of the content being uploaded (e.g., "video/mp4"). - `ContentDisposition` (string, optional): Content-Disposition header to set for the uploaded object. - `Metadata` (Dictionary, optional): A map of user metadata to store with the object. - `ForcePathStyle` (bool, optional): Force client to use path-style addressing for buckets. - `UseMultipartUpload` (bool, optional, default `true`): Use multipart upload for large files. - `PartSize` (ulong, optional, default 5 MB): Size in bytes of an individual part used for multipart upload. - `OnError` (S3SinkOnError, optional): How to handle errors during upload. - `RequestTimeout` (TimeSpan, optional, default 15s): Timeout for S3 requests (set to `TimeSpan.Zero` for infinity). - `RetryAttempts` (uint, optional, default 5): Number of retry attempts before abandoning a request. #### The sample pipeline ``` graph LR; SystemVideoSourceBlock-->VideoEncoderBlock; VideoEncoderBlock-->MP4SinkBlock; SystemAudioSourceBlock-->AudioEncoderBlock; AudioEncoderBlock-->MP4SinkBlock; MP4SinkBlock-->AWSS3SinkBlock; ``` #### Sample code ``` var pipeline = new MediaBlocksPipeline(); // Create video source (e.g., webcam) var videoDevice = (await DeviceEnumerator.Shared.VideoSourcesAsync())[0]; var videoSourceSettings = new VideoCaptureDeviceSourceSettings(videoDevice); var videoSource = new SystemVideoSourceBlock(videoSourceSettings); // Create audio source (e.g., microphone) var audioDevice = (await DeviceEnumerator.Shared.AudioSourcesAsync())[0]; var audioSourceSettings = audioDevice.CreateSourceSettings(audioDevice.Formats[0].ToFormat()); var audioSource = new SystemAudioSourceBlock(audioSourceSettings); // Create video encoder var h264Settings = new OpenH264EncoderSettings(); // Example encoder settings var videoEncoder = new H264EncoderBlock(h264Settings); // Create audio encoder var opusSettings = new OPUSEncoderSettings(); // Example encoder settings var audioEncoder = new OPUSEncoderBlock(opusSettings); // Create an MP4 muxer in mux-only mode — produces a muxed output pad instead of writing a file. var mp4MuxSettings = new MP4SinkSettings(string.Empty) { MuxOnly = true }; var mp4Muxer = new MP4SinkBlock(mp4MuxSettings); // Configure AWSS3SinkSettings var s3SinkSettings = new AWSS3SinkSettings { Uri = "s3://your-bucket-name/output/recorded-video.mp4", AccessKey = "YOUR_AWS_ACCESS_KEY", SecretAccessKey = "YOUR_AWS_SECRET_ACCESS_KEY", Region = "your-aws-region", // e.g., "us-east-1" ContentType = "video/mp4" }; var s3Sink = new AWSS3SinkBlock(s3SinkSettings); // Connect video path pipeline.Connect(videoSource.Output, videoEncoder.Input); pipeline.Connect(videoEncoder.Output, mp4Muxer.CreateNewInput(MediaBlockPadMediaType.Video)); // Connect audio path pipeline.Connect(audioSource.Output, audioEncoder.Input); pipeline.Connect(audioEncoder.Output, mp4Muxer.CreateNewInput(MediaBlockPadMediaType.Audio)); // Connect muxer to S3 sink pipeline.Connect(mp4Muxer.Output, s3Sink.Input); // Check if AWSS3Sink is available if (!AWSS3SinkBlock.IsAvailable()) { Console.WriteLine("AWS S3 Sink Block is not available. Check SDK redistributables."); return; } // Start pipeline await pipeline.StartAsync(); // ... wait for recording to finish ... // Stop pipeline await pipeline.StopAsync(); ``` #### Remarks You can check if the `AWSS3SinkBlock` is available at runtime using the static method `AWSS3SinkBlock.IsAvailable()`. This ensures that the necessary underlying GStreamer plugins and AWS SDK components are present. #### Platforms Windows, macOS, Linux. (Availability depends on GStreamer AWS plugin and AWS SDK support on these platforms). ---END OF PAGE--- ## Bridge Blocks for Dynamic Pipeline Switching in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Bridge/ **Description:** Dynamically switch between audio, video, and subtitle pipelines without interrupting playback using VisioForge Media Blocks SDK bridge blocks. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming **API:** MediaBlocksPipeline, VideoRendererBlock, MediaBlockPadMediaType, BridgeAudioSourceBlock, BridgeAudioSinkBlock # Bridge blocks [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Bridges can be used to link two pipelines and dynamically switch between them. For example, you can switch between different files or cameras in the first Pipeline without interrupting streaming in the second Pipeline. To link source and sink, give them the same name. Each bridge pair has a unique channel name. ## Bridge audio sink and source Bridges can be used to connect different media pipelines and use them independently. `BridgeAudioSourceBlock` is used to connect to `BridgeAudioSinkBlock` and supports uncompressed audio. ### Block info #### BridgeAudioSourceBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output audio | uncompressed audio | 1 | #### BridgeAudioSinkBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | uncompressed audio | 1 | ### Sample pipelines #### First pipeline with an audio source and a bridge audio sink ``` graph LR; VirtualAudioSourceBlock-->BridgeAudioSinkBlock; ``` #### Second pipeline with a bridge audio source and an audio renderer ``` graph LR; BridgeAudioSourceBlock-->AudioRendererBlock; ``` ### Sample code The source pipeline with virtual audio source and bridge audio sink. ``` // create source pipeline var sourcePipeline = new MediaBlocksPipeline(); // create virtual audio source and bridge audio sink // BridgeAudioSinkSettings requires (string channel, AudioInfoX audioInfo) — no parameterless ctor var audioInfo = new AudioInfoX(AudioFormatX.S16LE, 48000, 2); var audioSourceBlock = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings()); var bridgeAudioSink = new BridgeAudioSinkBlock(new BridgeAudioSinkSettings("audio-bridge", audioInfo)); // connect source and sink sourcePipeline.Connect(audioSourceBlock.Output, bridgeAudioSink.Input); // start pipeline await sourcePipeline.StartAsync(); ``` The sink pipeline with bridge audio source and audio renderer. ``` // create sink pipeline var sinkPipeline = new MediaBlocksPipeline(); // create bridge audio source and audio renderer // BridgeAudioSourceSettings requires (string channel, AudioInfoX audioInfo) — must match the sink above var audioInfo = new AudioInfoX(AudioFormatX.S16LE, 48000, 2); var bridgeAudioSource = new BridgeAudioSourceBlock(new BridgeAudioSourceSettings("audio-bridge", audioInfo)); var audioRenderer = new AudioRendererBlock(); // connect source and sink sinkPipeline.Connect(bridgeAudioSource.Output, audioRenderer.Input); // start pipeline await sinkPipeline.StartAsync(); ``` ## Bridge video sink and source Bridges can be used to connect different media pipelines and use them independently. `BridgeVideoSinkBlock` is used to connect to the `BridgeVideoSourceBlock` and supports uncompressed video. ### Blocks info #### BridgeVideoSinkBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | uncompressed video | 1 | #### BridgeVideoSourceBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output video | uncompressed video | 1 | ### Sample pipelines #### First pipeline with a video source and a bridge video sink ``` graph LR; VirtualVideoSourceBlock-->BridgeVideoSinkBlock; ``` #### Second pipeline with a bridge video source and a video renderer ``` graph LR; BridgeVideoSourceBlock-->VideoRendererBlock; ``` ### Sample code Source pipeline with a virtual video source and bridge video sink. ``` // create source pipeline var sourcePipeline = new MediaBlocksPipeline(); // create virtual video source and bridge video sink var videoSourceBlock = new VirtualVideoSourceBlock(new VirtualVideoSourceSettings()); var bridgeVideoSink = new BridgeVideoSinkBlock(new BridgeVideoSinkSettings()); // connect source and sink sourcePipeline.Connect(videoSourceBlock.Output, bridgeVideoSink.Input); // start pipeline await sourcePipeline.StartAsync(); ``` Sink pipeline with a bridge video source and video renderer. ``` // create sink pipeline var sinkPipeline = new MediaBlocksPipeline(); // create bridge video source and video renderer var bridgeVideoSource = new BridgeVideoSourceBlock(new BridgeVideoSourceSettings()); var videoRenderer = new VideoRendererBlock(sinkPipeline, VideoView1); // connect source and sink sinkPipeline.Connect(bridgeVideoSource.Output, videoRenderer.Input); // start pipeline await sinkPipeline.StartAsync(); ``` ## Bridge subtitle sink and source Bridges can be used to connect different media pipelines and use them independently. `BridgeSubtitleSourceBlock` is used to connect to the `BridgeSubtitleSinkBlock`and supports text media type. ### Block info #### BridgeSubtitleSourceBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output video | text | 1 | #### BridgeSubtitleSinkBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output video | text | 1 | ## Proxy source Proxy source/proxy sink pair of blocks can be used to connect different media pipelines and use them independently. ### Block info Name: ProxySourceBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Output | Any uncompressed | 1 | ### Sample pipelines #### First pipeline with a video source and a proxy video sink ``` graph LR; VirtualVideoSourceBlock-->ProxySinkBlock; ``` #### Second pipeline with a proxy video source and a video renderer ``` graph LR; ProxySourceBlock-->VideoRendererBlock; ``` ### Sample code ``` // ProxySink and ProxySource are paired by string pairID — pick any unique value per pair. const string pairID = "video-proxy-1"; // source pipeline with virtual video source and proxy sink var sourcePipeline = new MediaBlocksPipeline(); var videoSourceBlock = new VirtualVideoSourceBlock(new VirtualVideoSourceSettings()); var proxyVideoSink = new ProxySinkBlock(pairID); sourcePipeline.Connect(videoSourceBlock.Output, proxyVideoSink.Input); // sink pipeline with proxy video source and video renderer — matching pairID links them var sinkPipeline = new MediaBlocksPipeline(); var proxyVideoSource = new ProxySourceBlock(pairID); var videoRenderer = new VideoRendererBlock(sinkPipeline, VideoView1); sinkPipeline.Connect(proxyVideoSource.Output, videoRenderer.Input); // start pipelines await sourcePipeline.StartAsync(); await sinkPipeline.StartAsync(); ``` ## Platforms All bridge blocks are supported on Windows, macOS, Linux, iOS, and Android. ## Bridge Buffer sink and source BridgeBuffer blocks provide high-performance memory buffer-based communication between pipelines, ideal for sharing video frames without encoding overhead. ### Block info #### BridgeBufferSinkBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Input video | uncompressed video | 1 | #### BridgeBufferSourceBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output | auto | 1 | ### Sample code ``` // First pipeline with video source and bridge buffer sink var sourcePipeline = new MediaBlocksPipeline(); var videoSource = new SystemVideoSourceBlock(videoSettings); var videoInfo = new VideoFrameInfoX(1920, 1080, VideoFormatX.NV12, new VideoFrameRate(30)); var bufferSink = new BridgeBufferSinkBlock("buffer-channel", videoInfo); sourcePipeline.Connect(videoSource.Output, bufferSink.Input); // Second pipeline with bridge buffer source and renderer var sinkPipeline = new MediaBlocksPipeline(); var bufferSource = new BridgeBufferSourceBlock("buffer-channel"); var videoRenderer = new VideoRendererBlock(sinkPipeline, VideoView1); sinkPipeline.Connect(bufferSource.Output, videoRenderer.Input); await sourcePipeline.StartAsync(); await sinkPipeline.StartAsync(); ``` ## InterPipe sink and source InterPipe blocks use GStreamer's interpipesink/interpipesrc elements for efficient inter-pipeline communication with support for both audio and video. ### Block info #### InterPipeSinkBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | audio or video | 1 | #### InterPipeSourceBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output | audio or video | 1 | ### Sample code ``` // First pipeline with video source and interpipe sink var sourcePipeline = new MediaBlocksPipeline(); var videoSource = new SystemVideoSourceBlock(videoSettings); var videoInfo = new VideoFrameInfoX(1920, 1080, VideoFormatX.NV12, new VideoFrameRate(30)); var interpipeSink = new InterPipeSinkBlock("interpipe-channel", videoInfo); sourcePipeline.Connect(videoSource.Output, interpipeSink.Input); // Second pipeline with interpipe source and renderer var sinkPipeline = new MediaBlocksPipeline(); var interpipeSource = new InterPipeSourceBlock("interpipe-channel", MediaBlockPadMediaType.Video); var videoRenderer = new VideoRendererBlock(sinkPipeline, VideoView1); sinkPipeline.Connect(interpipeSource.Output, videoRenderer.Input); await sourcePipeline.StartAsync(); await sinkPipeline.StartAsync(); ``` ## RS Inter sink and source RSInter blocks use the Rust-based GStreamer rsinter plugin for high-performance inter-pipeline communication. ### Block info #### RSInterSinkBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | audio or video | 1 | #### RSInterSourceBlock information | Pin direction | Media type | Pins count | | --- | --- | --- | | Output | audio or video | 1 | ### Sample code ``` // First pipeline with video source and rsinter sink var sourcePipeline = new MediaBlocksPipeline(); var videoSource = new SystemVideoSourceBlock(videoSettings); var rsinterSink = new RSInterSinkBlock(MediaBlockPadMediaType.Video, "rsinter-channel"); sourcePipeline.Connect(videoSource.Output, rsinterSink.Input); // Second pipeline with rsinter source and renderer var sinkPipeline = new MediaBlocksPipeline(); var rsinterSource = new RSInterSourceBlock(MediaBlockPadMediaType.Video, "rsinter-channel"); var videoRenderer = new VideoRendererBlock(sinkPipeline, VideoView1); sinkPipeline.Connect(rsinterSource.Output, videoRenderer.Input); await sourcePipeline.StartAsync(); await sinkPipeline.StartAsync(); ``` ## AppBridge Video and Audio AppBridge blocks use GStreamer's `appsink` and `appsrc` elements to provide direct buffer transfer between pipelines with **preserved timestamps**. Unlike other bridge types that may regenerate timestamps, AppBridge maintains the original PTS (Presentation Timestamp), DTS (Decode Timestamp), and duration values. This makes AppBridge ideal for: - **Hardware outputs** like Decklink cards that require precise timing synchronization - **Live streaming** scenarios where timestamp accuracy is critical - **Multi-pipeline architectures** where clock synchronization between pipelines is important ### How it works 1. The sink block (`AppBridgeVideoSinkBlock` or `AppBridgeAudioSinkBlock`) captures buffers using `appsink` with `sync=false` to avoid clock-based delays 2. Buffers are passed directly to the linked source with their original timestamps preserved 3. The source block (`AppBridgeVideoSourceBlock` or `AppBridgeAudioSourceBlock`) injects buffers using `appsrc` with `is-live=true` and `do-timestamp=false` 4. The downstream element (e.g., Decklink) receives properly timestamped buffers for hardware clock synchronization ### Block info #### AppBridgeVideoSinkBlock | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | uncompressed video | 1 | #### AppBridgeVideoSourceBlock | Pin direction | Media type | Pins count | | --- | --- | --- | | Output | uncompressed video | 1 | #### AppBridgeAudioSinkBlock | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | uncompressed audio | 1 | #### AppBridgeAudioSourceBlock | Pin direction | Media type | Pins count | | --- | --- | --- | | Output | uncompressed audio | 1 | ### Settings #### AppBridgeVideoSinkSettings / AppBridgeAudioSinkSettings | Property | Type | Default | Description | | --- | --- | --- | --- | | Channel | string | required | Unique channel name to match with source | | Info | VideoFrameInfoX / AudioInfoX | required | Media format specification | | MaxBuffers | int | 5 (video) / 10 (audio) | Maximum buffer queue size | | Sync | bool | false | Sync to pipeline clock (false for live sources) | #### AppBridgeVideoSourceSettings / AppBridgeAudioSourceSettings | Property | Type | Default | Description | | --- | --- | --- | --- | | Channel | string | required | Channel name matching the sink | | Info | VideoFrameInfoX / AudioInfoX | required | Media format specification | | IsLive | bool | true | Marks source as live for proper pipeline behavior | | DoTimestamp | bool | false | Set to false to preserve original timestamps | #### Generating secure channel names For security, use the `GenerateUniqueChannel()` helper method to create GUID-based channel names: ``` var channel = AppBridgeVideoSinkSettings.GenerateUniqueChannel("decklink_video"); // Returns: "decklink_video_a1b2c3d4e5f6..." ``` ### Sample pipelines #### Main pipeline with video/audio tee and AppBridge sinks ``` graph LR; VideoSource-->VideoTee; VideoTee-->VideoRenderer; VideoTee-->AppBridgeVideoSinkBlock; AudioSource-->AudioTee; AudioTee-->AudioRenderer; AudioTee-->AppBridgeAudioSinkBlock; ``` #### Output pipeline with AppBridge sources and Decklink output ``` graph LR; AppBridgeVideoSourceBlock-->DecklinkVideoAudioSinkBlock; AppBridgeAudioSourceBlock-->VolumeBlock; VolumeBlock-->DecklinkVideoAudioSinkBlock; ``` ### Sample code Complete example showing Decklink output using AppBridge for proper timestamp handling: ``` // Main pipeline with video/audio sources var mainPipeline = new MediaBlocksPipeline(); // Video and audio format definitions var videoInfo = new VideoFrameInfoX(1920, 1080, new VideoFrameRate(60)); var audioInfo = new AudioInfoX(AudioFormatX.S16LE, 48000, 2); // Create tees for splitting streams var videoTee = new TeeBlock(2, MediaBlockPadMediaType.Video); var audioTee = new TeeBlock(2, MediaBlockPadMediaType.Audio); // AppBridge sinks in main pipeline var videoSinkSettings = new AppBridgeVideoSinkSettings("decklink_video", videoInfo); var appBridgeVideoSink = new AppBridgeVideoSinkBlock(videoSinkSettings); var audioSinkSettings = new AppBridgeAudioSinkSettings("decklink_audio", audioInfo); var appBridgeAudioSink = new AppBridgeAudioSinkBlock(audioSinkSettings); // Connect tee outputs to AppBridge sinks mainPipeline.Connect(videoTee.Outputs[1], appBridgeVideoSink.Input); mainPipeline.Connect(audioTee.Outputs[1], appBridgeAudioSink.Input); // Decklink output pipeline var decklinkPipeline = new MediaBlocksPipeline(); // AppBridge sources - same channel names as sinks var videoSourceSettings = new AppBridgeVideoSourceSettings("decklink_video", videoInfo); var appBridgeVideoSource = new AppBridgeVideoSourceBlock(videoSourceSettings); var audioSourceSettings = new AppBridgeAudioSourceSettings("decklink_audio", audioInfo); var appBridgeAudioSource = new AppBridgeAudioSourceBlock(audioSourceSettings); // Decklink output var decklinkVideoSettings = new DecklinkVideoSinkSettings(0, DecklinkMode.HD1080p60); var decklinkAudioSettings = new DecklinkAudioSinkSettings(0); var decklinkOutput = new DecklinkVideoAudioSinkBlock(decklinkVideoSettings, decklinkAudioSettings); // Connect AppBridge sources to Decklink decklinkPipeline.Connect(appBridgeVideoSource.Output, decklinkOutput.VideoInput); decklinkPipeline.Connect(appBridgeAudioSource.Output, decklinkOutput.AudioInput); // Start pipelines await mainPipeline.StartAsync(); await decklinkPipeline.StartAsync(); // Cleanup when done await decklinkPipeline.StopAsync(); appBridgeVideoSource.Dispose(); appBridgeAudioSource.Dispose(); appBridgeVideoSink.Dispose(); appBridgeAudioSink.Dispose(); ``` ### When to use AppBridge vs other bridges | Bridge Type | Best For | Timestamp Handling | | --- | --- | --- | | **AppBridge** | Decklink, hardware outputs, precise timing | Preserves original PTS/DTS | | Standard Bridge | Software rendering, general use | May regenerate timestamps | | InterPipe | Multiple consumers, flexible routing | Depends on configuration | | RSInter | High-performance Rust-based | Depends on configuration | | BridgeBuffer | Memory sharing, zero-copy | Buffer-based | ## Platforms All bridge blocks are supported on Windows, macOS, Linux, iOS, and Android. Note: InterPipe and RSInter blocks require the corresponding GStreamer plugins to be installed. ---END OF PAGE--- ## VisioForge Media Blocks SDK in C# .NET — Cheat Sheet **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/cheat-sheet/ **Description:** One-page Media Blocks SDK reference with NuGet packages, pipeline APIs, a canonical example, platform support, and common pitfalls. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Avalonia, MAUI, WPF, WinForms, GStreamer, Playback, Capture, Recording, Streaming, Encoding, MP4, H.264, H.265, AAC, C#, NuGet **API:** MediaBlocksPipeline, UniversalSourceBlock, VideoRendererBlock, SystemVideoSourceBlock, H264EncoderBlock, MP4SinkBlock, DeviceEnumerator # VisioForge Media Blocks SDK in C# .NET — Cheat Sheet Media Blocks SDK is the most flexible VisioForge .NET SDK — build arbitrary media pipelines by composing blocks (sources, encoders, renderers, sinks). Choose Media Blocks when you need custom pipelines that the higher-level Media Player / Video Capture / Video Edit SDKs can't express. AI coding agents: use the VisioForge MCP server Building this with **Claude Code**, **Cursor**, or another AI coding agent? Connect to the public [VisioForge MCP server](../../general/mcp-server-usage/) at `https://mcp.visioforge.com/mcp` for structured API lookups, runnable code samples, and deployment guides — more accurate than grepping `llms.txt`. No authentication required. Claude Code: `claude mcp add --transport http visioforge-sdk https://mcp.visioforge.com/mcp` ## Platform support - Runs on Windows (x64 / x86), macOS, Linux x64, Android, and iOS. - UI frameworks: WinForms, WPF, MAUI, Avalonia, Uno, plus console. - Cross-platform processing is powered by a bundled GStreamer backend on macOS/Android/iOS and by the system GStreamer 1.22+ install on Linux. - For the full codec × platform matrix, see [platform-matrix.md](../../platform-matrix/). ## NuGet packages Main SDK package (all platforms): ``` ``` Windows x64 runtime (pick x86 for 32-bit apps): ``` ``` Windows x86: ``` ``` macOS (native and MAUI / macCatalyst): ``` ``` Linux x64 (also requires GStreamer 1.22+ installed on the system): ``` ``` Android and iOS: ``` ``` UI integration packages (optional, per framework): ``` ``` Full install walkthrough: [install/index.md](../../install/). ## Primary API classes | Class | Role | See also | | --- | --- | --- | | `MediaBlocksPipeline` | Root pipeline object. Connects blocks via `Connect(output, input)`. Exposes `StartAsync` / `StopAsync` / `DisposeAsync` and the `OnError`, `OnStart`, `OnStop` events. | [GettingStarted/pipeline.md](../GettingStarted/pipeline/) | | `UniversalSourceBlock` | Opens a file, URL, or stream as input. Analyzes streams automatically and exposes `VideoOutput` / `AudioOutput` pads. | [GettingStarted/player.md](../GettingStarted/player/) | | `VideoRendererBlock` | Binds pipeline video output to an `IVideoView` control (WinForms / WPF / MAUI / Avalonia). Supports snapshots. | [GettingStarted/player.md](../GettingStarted/player/) | | `SystemVideoSourceBlock` | Webcam / USB / built-in camera input. Configured via `VideoCaptureDeviceSourceSettings`. | [GettingStarted/camera.md](../GettingStarted/camera/) | | `H264EncoderBlock` | H.264 encoder with software and hardware (NVENC / AMF / Quick Sync) backends. | [GettingStarted/pipeline.md](../GettingStarted/pipeline/) | | `MP4SinkBlock` | Writes encoded video + audio to an `.mp4` file. Add inputs via `IMediaBlockDynamicInputs.CreateNewInput`. | [Guides/rtsp-save-original-stream.md](../Guides/rtsp-save-original-stream/) | | `DeviceEnumerator` | Lists cameras, microphones, and audio outputs asynchronously via `DeviceEnumerator.Shared.VideoSourcesAsync()` etc. | [GettingStarted/device-enum.md](../GettingStarted/device-enum/) | ## Canonical minimum example The simplest useful pipeline — load a file, render video + audio, clean up. Lift and adapt from [GettingStarted/player.md](../GettingStarted/player/). ``` using System; using System.Threading.Tasks; using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoRendering; using VisioForge.Core.MediaBlocks.AudioRendering; using VisioForge.Core.Types.X.Sources; // 1. Initialize SDK once at application startup await VisioForgeX.InitSDKAsync(); // 2. Create the pipeline and subscribe to errors var pipeline = new MediaBlocksPipeline(); pipeline.OnError += (s, e) => Console.WriteLine(e.Message); // 3. Source: open a media file (URL or local path via URI) var sourceSettings = await UniversalSourceSettings.CreateAsync( new Uri("file:///C:/Videos/sample.mp4")); var fileSource = new UniversalSourceBlock(sourceSettings); // 4. Video renderer — VideoView1 is an IVideoView on your form/page var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // 5. Audio renderer — pick the first system audio output var audioOutputs = await DeviceEnumerator.Shared.AudioOutputsAsync(); var audioRenderer = new AudioRendererBlock(audioOutputs[0]); // 6. Connect output pads → input pads pipeline.Connect(fileSource.VideoOutput, videoRenderer.Input); pipeline.Connect(fileSource.AudioOutput, audioRenderer.Input); // 7. Play await pipeline.StartAsync(); // ... later, on user stop / app exit: await pipeline.StopAsync(); await pipeline.DisposeAsync(); VisioForgeX.DestroySDK(); // sync only — no async variant ``` Swap `UniversalSourceBlock` for `SystemVideoSourceBlock` (camera) or `RTSPSourceBlock` (IP camera) without changing the rest of the wiring. ## Typical workflow 1. Init SDK — `await VisioForgeX.InitSDKAsync()`. 2. Create `MediaBlocksPipeline` and subscribe to `OnError`. 3. Instantiate source blocks (`UniversalSourceBlock`, `SystemVideoSourceBlock`, `RTSPSourceBlock`, …). 4. Instantiate processing blocks — encoders, mixers, overlays, effects (optional). 5. Instantiate sink / renderer blocks (`VideoRendererBlock`, `AudioRendererBlock`, `MP4SinkBlock`, …). 6. Wire blocks with `pipeline.Connect(output, input)` — every data path must be connected explicitly. 7. `StartAsync` → `StopAsync` → `DisposeAsync`, then `DestroySDK` at app exit. ## Common pitfalls - **No implicit dataflow.** Blocks must be explicitly wired with `pipeline.Connect(output, input)`; adding a block to the pipeline alone does not route media through it. - **Overlay / dynamic-input order.** Overlays on `OverlayManagerBlock` and dynamic pads on sinks (`MP4SinkBlock` via `IMediaBlockDynamicInputs.CreateNewInput`) must be added before the pipeline starts — adding them after `StartAsync` silently fails or throws. - **Awaited enumeration only.** `DeviceEnumerator.Shared.VideoSourcesAsync()` / `AudioOutputsAsync()` must be awaited — there is no synchronous variant. Using `.Result` from a UI thread can deadlock. - **Linux needs system GStreamer.** `VisioForge.CrossPlatform.Core.Linux.x64` expects GStreamer 1.22+ already installed (`apt install gstreamer1.0-*`); the Libav NuGet is supplementary, not a replacement. See [deployment-x/Ubuntu.md](../../deployment-x/Ubuntu/). - **Lifecycle hygiene.** Always `await pipeline.StopAsync()` and `await pipeline.DisposeAsync()` before creating another pipeline on the same engine. Skipping dispose leaks native handles and can hang on shutdown. ## See also - **Getting started** - Video file player — [GettingStarted/player.md](../GettingStarted/player/) - Camera viewer — [GettingStarted/camera.md](../GettingStarted/camera/) - Complete pipeline walkthrough — [GettingStarted/pipeline.md](../GettingStarted/pipeline/) - Device enumeration — [GettingStarted/device-enum.md](../GettingStarted/device-enum/) - **Specific pipelines** - RTSP / IP camera player — [Guides/rtsp-player-csharp.md](../Guides/rtsp-player-csharp/) - Save RTSP stream (passthrough) — [Guides/rtsp-save-original-stream.md](../Guides/rtsp-save-original-stream/) - Multi-camera grid — [Guides/multi-camera-rtsp-grid.md](../Guides/multi-camera-rtsp-grid/) - **Deployment** - Windows — [../deployment-x/Windows.md](../../deployment-x/Windows/) - macOS — [../deployment-x/macOS.md](../../deployment-x/macOS/) - Ubuntu — [../deployment-x/Ubuntu.md](../../deployment-x/Ubuntu/) - Android — [../deployment-x/Android.md](../../deployment-x/Android/) - iOS — [../deployment-x/iOS.md](../../deployment-x/iOS/) - **Install & platform matrix** — [../install/index.md](../../install/), [../platform-matrix.md](../../platform-matrix/) ## FAQ ### How does Media Blocks differ from Media Player SDK? Media Player SDK is a high-level, single-class player (`MediaPlayerCoreX`) with built-in playback controls — optimal when you just need to play a file or stream. Media Blocks exposes the underlying pipeline so you can insert encoders, effects, multi-output sinks, or custom processing. If you find yourself fighting Media Player SDK to add a step it doesn't expose, switch to Media Blocks. ### Can I run on Linux without GStreamer? No. The Linux x64 runtime NuGet is a thin bridge to the system GStreamer 1.22+ stack. Install `gstreamer1.0-plugins-base`, `-good`, `-bad`, `-ugly`, and `-libav` from your distro. See [deployment-x/Ubuntu.md](../../deployment-x/Ubuntu/) for the full package list. macOS / Android / iOS do ship a bundled GStreamer via the platform NuGet. ### How do I add a custom video effect? Use `GLShaderBlock` for a custom GLSL fragment shader (GPU-accelerated) or the pre-built `GL*Block` family (e.g. `GLBlurBlock`, `GLColorBalanceBlock`) for common effects. For CV-based processing, use the `CV*Block` family (e.g. `CVFaceDetectBlock`, `CVEdgeDetectBlock`, `CVDewarpBlock`). All slot between a decoder and renderer like any other block. Full recipe: [Guides/custom-video-effects-csharp.md](../Guides/custom-video-effects-csharp/). ---END OF PAGE--- ## Blackmagic Decklink SDI/HDMI Capture and Output in C# **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Decklink/ **Description:** Capture and render SDI/HDMI video with Blackmagic Decklink cards using VisioForge Media Blocks SDK. Multi-device support, format detection, keying. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Capture **API:** DecklinkVideoAudioSourceBlock, DecklinkAudioSinkSettings, DecklinkAudioSourceSettings, DecklinkVideoSinkSettings, DecklinkVideoSourceSettings # Blackmagic Decklink Integration with Media Blocks SDK [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction to Decklink Integration The VisioForge Media Blocks SDK for .NET provides robust support for Blackmagic Decklink devices, enabling developers to implement professional-grade audio and video functionality in their applications. This integration allows for seamless capture and rendering operations using Decklink's high-quality hardware. Our SDK includes specialized blocks designed specifically for Decklink devices, giving you full access to their capabilities including SDI, HDMI, and other inputs/outputs. These blocks are optimized for performance and offer a straightforward API for implementing complex media workflows. ### Key Capabilities - **Audio Capture and Rendering**: Capture and output audio through Decklink devices - **Video Capture and Rendering**: Capture and output video in various formats and resolutions - **Multiple Device Support**: Work with multiple Decklink devices simultaneously - **Professional I/O Options**: Utilize SDI, HDMI, and other professional interfaces - **High-Quality Processing**: Maintain professional video/audio quality throughout the pipeline - **Combined Audio/Video Blocks**: Simplified handling of synchronized audio and video streams with dedicated source and sink blocks. ## System Requirements Before using the Decklink blocks, ensure your system meets these requirements: - **Hardware**: Compatible Blackmagic Decklink device - **Software**: Blackmagic Decklink SDK or drivers installed ## Decklink Block Types The SDK provides several block types for working with Decklink devices: 1. **Audio Sink Block**: For audio output to Decklink devices. 2. **Audio Source Block**: For audio capture from Decklink devices. 3. **Video Sink Block**: For video output to Decklink devices. 4. **Video Source Block**: For video capture from Decklink devices. 5. **Video + Audio Sink Block**: For synchronized video and audio output to Decklink devices using a single block. 6. **Video + Audio Source Block**: For synchronized video and audio capture from Decklink devices using a single block. Each block type is designed to handle specific media operations while maintaining synchronization and quality. ## Working with Decklink Audio Sink Block The Decklink Audio Sink block enables audio output to Blackmagic Decklink devices. This block handles the complexities of audio timing and device interfacing. ### Device Enumeration Before creating an audio sink block, you'll need to enumerate available devices: ``` var devices = await DecklinkAudioSinkBlock.GetDevicesAsync(); foreach (var item in devices) { Console.WriteLine($"Found device: {item.Name}, Device Number: {item.DeviceNumber}"); } ``` This code retrieves all available Decklink devices that support audio output functionality. ### Block Creation and Configuration Once you've identified the target device, you can create and configure the audio sink block: ``` // Get the first available device var deviceInfo = (await DecklinkAudioSinkBlock.GetDevicesAsync()).FirstOrDefault(); // Create settings for the selected device DecklinkAudioSinkSettings audioSinkSettings = null; if (deviceInfo != null) { audioSinkSettings = new DecklinkAudioSinkSettings(deviceInfo); // Example: audioSinkSettings.DeviceNumber = deviceInfo.DeviceNumber; (already set by constructor) // Further configuration: // audioSinkSettings.BufferTime = TimeSpan.FromMilliseconds(100); // audioSinkSettings.IsSync = true; } // Create the block with configured settings var decklinkAudioSink = new DecklinkAudioSinkBlock(audioSinkSettings); ``` ### Key Audio Sink Settings The `DecklinkAudioSinkSettings` class includes properties like: - `DeviceNumber`: The output device instance to use. - `BufferTime`: Minimum latency reported by the sink (default: 50ms). - `AlignmentThreshold`: Timestamp alignment threshold (default: 40ms). - `DiscontWait`: Time to wait before creating a discontinuity (default: 1s). - `IsSync`: Enables synchronization (default: true). ### Connecting to the Pipeline The audio sink block includes an `Input` pad that accepts audio data from other blocks in your pipeline: ``` // Example: Connect an audio source/encoder to the Decklink audio sink audioEncoder.Output.Connect(decklinkAudioSink.Input); ``` ## Working with Decklink Audio Source Block The Decklink Audio Source block enables capturing audio from Blackmagic Decklink devices. It supports various audio formats and configurations. ### Device Enumeration Enumerate available audio source devices: ``` var devices = await DecklinkAudioSourceBlock.GetDevicesAsync(); foreach (var item in devices) { Console.WriteLine($"Available audio source: {item.Name}, Device Number: {item.DeviceNumber}"); } ``` ### Block Creation and Configuration Create and configure the audio source block: ``` // Get the first available device var deviceInfo = (await DecklinkAudioSourceBlock.GetDevicesAsync()).FirstOrDefault(); // Create settings for the selected device DecklinkAudioSourceSettings audioSourceSettings = null; if (deviceInfo != null) { // create settings object audioSourceSettings = new DecklinkAudioSourceSettings(deviceInfo); // Further configuration: // audioSourceSettings.Channels = DecklinkAudioChannels.Ch2; // audioSourceSettings.Connection = DecklinkAudioConnection.Embedded; // audioSourceSettings.Format = DecklinkAudioFormat.S16LE; // SampleRate is fixed at 48000 } // Create the block with the configured settings var audioSource = new DecklinkAudioSourceBlock(audioSourceSettings); ``` ### Key Audio Source Settings The `DecklinkAudioSourceSettings` class includes properties like: - `DeviceNumber`: The input device instance to use. - `Channels`: Audio channels to capture (e.g., `DecklinkAudioChannels.Ch2`, `Ch8`, `Ch16`). Default `Ch2`. - `Format`: Audio sample format (e.g., `DecklinkAudioFormat.S16LE`). Default `S16LE`. Sample rate is fixed at 48000 Hz. - `Connection`: Audio connection type (e.g., `DecklinkAudioConnection.Embedded`, `AES`, `Analog`). Default `Auto`. - `BufferSize`: Internal buffer size in frames (default: 5). - `DisableAudioConversion`: Set to `true` to disable internal audio conversion. Default `false`. ### Connecting to the Pipeline The audio source block provides an `Output` pad that can connect to other blocks: ``` // Example: Connect the audio source to an audio encoder or processor audioSource.Output.Connect(audioProcessor.Input); ``` ## Working with Decklink Video Sink Block The Decklink Video Sink block enables video output to Blackmagic Decklink devices, supporting various video formats and resolutions. ### Device Enumeration Find available video sink devices: ``` var devices = await DecklinkVideoSinkBlock.GetDevicesAsync(); foreach (var item in devices) { Console.WriteLine($"Available video output device: {item.Name}, Device Number: {item.DeviceNumber}"); } ``` ### Block Creation and Configuration Create and configure the video sink block: ``` // Get the first available device var deviceInfo = (await DecklinkVideoSinkBlock.GetDevicesAsync()).FirstOrDefault(); // Create settings for the selected device // Note: Mode is required and must be specified in the constructor DecklinkVideoSinkSettings videoSinkSettings = null; if (deviceInfo != null) { // Mode is required - specify the output video resolution and frame rate videoSinkSettings = new DecklinkVideoSinkSettings(deviceInfo, DecklinkMode.HD1080i60) { VideoFormat = DecklinkVideoFormat.YUV_10bit, // Optional: Additional configuration // KeyerMode = DecklinkKeyerMode.Internal, // KeyerLevel = 128, // Profile = DecklinkProfileID.Default, // TimecodeFormat = DecklinkTimecodeFormat.RP188Any }; } // Create the block with the configured settings var decklinkVideoSink = new DecklinkVideoSinkBlock(videoSinkSettings); ``` ### Key Video Sink Settings The `DecklinkVideoSinkSettings` class includes properties like: - `DeviceNumber`: The output device instance to use (read-only, set via constructor). - `Mode`: Specifies the video resolution and frame rate (e.g., `DecklinkMode.HD1080i60`, `HD720p60`). **Required** - must be specified in the constructor. - `VideoFormat`: Defines the pixel format using `DecklinkVideoFormat` enum (e.g., `DecklinkVideoFormat.YUV_8bit`, `YUV_10bit`). Default `YUV_8bit`. - `KeyerMode`: Controls keying/compositing options using `DecklinkKeyerMode` (if supported by the device). Default `Off`. - `KeyerLevel`: Sets the keyer level (0-255). Default `255`. - `Profile`: Specifies the Decklink profile to use with `DecklinkProfileID`. - `TimecodeFormat`: Specifies the timecode format for playback using `DecklinkTimecodeFormat`. Default `RP188Any`. - `CustomVideoSize`: Optional resize effect to apply before output. - `CustomFrameRate`: Optional frame rate conversion before output. - `IsSync`: Enables synchronization (default: true). **Important**: The `Mode` parameter is required and determines the output frame rate and resolution. If not specified correctly, the Decklink hardware may output at an unexpected frame rate. ## Working with Decklink Video Source Block The Decklink Video Source block allows capturing video from Blackmagic Decklink devices, supporting various input formats and resolutions. ### Device Enumeration Enumerate video capture devices: ``` var devices = await DecklinkVideoSourceBlock.GetDevicesAsync(); foreach (var item in devices) { Console.WriteLine($"Available video capture device: {item.Name}, Device Number: {item.DeviceNumber}"); } ``` ### Block Creation and Configuration Create and configure the video source block: ``` // Get the first available device var deviceInfo = (await DecklinkVideoSourceBlock.GetDevicesAsync()).FirstOrDefault(); // Create settings for the selected device DecklinkVideoSourceSettings videoSourceSettings = null; if (deviceInfo != null) { videoSourceSettings = new DecklinkVideoSourceSettings(deviceInfo); // Configure video input format and mode videoSourceSettings.Mode = DecklinkMode.HD1080i60; videoSourceSettings.Connection = DecklinkConnection.SDI; // videoSourceSettings.VideoFormat = DecklinkVideoFormat.Auto; // Often used with Mode=Auto } // Create the block with configured settings var videoSourceBlock = new DecklinkVideoSourceBlock(videoSourceSettings); ``` ### Key Video Source Settings The `DecklinkVideoSourceSettings` class includes properties like: - `DeviceNumber`: The input device instance to use. - `Mode`: Specifies the expected input resolution and frame rate (e.g., `DecklinkMode.HD1080i60`). Default `Unknown`. - `Connection`: Defines which physical input to use, using `DecklinkConnection` enum (e.g., `DecklinkConnection.HDMI`, `DecklinkConnection.SDI`). Default `Auto`. - `VideoFormat`: Specifies the video format type for input, using `DecklinkVideoFormat` enum. Default `Auto` (especially when `Mode` is `Auto`). - `Profile`: Specifies the Decklink profile using `DecklinkProfileID`. Default `Default`. - `DropNoSignalFrames`: If `true`, drops frames marked as having no input signal. Default `false`. - `OutputAFDBar`: If `true`, extracts and outputs AFD/Bar data as Meta. Default `false`. - `OutputCC`: If `true`, extracts and outputs Closed Captions as Meta. Default `false`. - `TimecodeFormat`: Specifies the timecode format using `DecklinkTimecodeFormat`. Default `RP188Any`. - `DisableVideoConversion`: Set to `true` to disable internal video conversion. Default `false`. ## Working with Decklink Video + Audio Source Block The `DecklinkVideoAudioSourceBlock` simplifies capturing synchronized video and audio streams from a single Decklink device. ### Device Enumeration and Configuration Device selection is managed through `DecklinkVideoSourceSettings` and `DecklinkAudioSourceSettings`. You would typically enumerate video devices using `DecklinkVideoSourceBlock.GetDevicesAsync()` and audio devices using `DecklinkAudioSourceBlock.GetDevicesAsync()`, then configure the respective settings objects for the chosen device. The `DecklinkVideoAudioSourceBlock` itself also provides `GetDevicesAsync()` which enumerates video sources. ``` // Enumerate video devices (for video part of the combined source) var videoDeviceInfo = (await DecklinkVideoAudioSourceBlock.GetDevicesAsync()).FirstOrDefault(); // or DecklinkVideoSourceBlock.GetDevicesAsync() var audioDeviceInfo = (await DecklinkAudioSourceBlock.GetDevicesAsync()).FirstOrDefault(d => d.DeviceNumber == videoDeviceInfo.DeviceNumber); // Example: match by device number DecklinkVideoSourceSettings videoSettings = null; if (videoDeviceInfo != null) { videoSettings = new DecklinkVideoSourceSettings(videoDeviceInfo); videoSettings.Mode = DecklinkMode.HD1080i60; videoSettings.Connection = DecklinkConnection.SDI; } DecklinkAudioSourceSettings audioSettings = null; if (audioDeviceInfo != null) { audioSettings = new DecklinkAudioSourceSettings(audioDeviceInfo); audioSettings.Channels = DecklinkAudioChannels.Ch2; } // Create the block with configured settings if (videoSettings != null && audioSettings != null) { var decklinkVideoAudioSource = new DecklinkVideoAudioSourceBlock(videoSettings, audioSettings); // Connect outputs // decklinkVideoAudioSource.VideoOutput.Connect(videoProcessor.Input); // decklinkVideoAudioSource.AudioOutput.Connect(audioProcessor.Input); } ``` ### Block Creation and Configuration You instantiate `DecklinkVideoAudioSourceBlock` by providing pre-configured `DecklinkVideoSourceSettings` and `DecklinkAudioSourceSettings` objects. ``` // Assuming videoSourceSettings and audioSourceSettings are configured as above var videoAudioSource = new DecklinkVideoAudioSourceBlock(videoSourceSettings, audioSourceSettings); ``` ### Connecting to the Pipeline The block provides separate `VideoOutput` and `AudioOutput` pads: ``` // Example: Connect to video and audio processors/encoders videoAudioSource.VideoOutput.Connect(videoEncoder.Input); videoAudioSource.AudioOutput.Connect(audioEncoder.Input); ``` ## Working with Decklink Video + Audio Sink Block The `DecklinkVideoAudioSinkBlock` simplifies sending synchronized video and audio streams to a single Decklink device. ### Device Enumeration and Configuration Similar to the combined source, device selection is managed via `DecklinkVideoSinkSettings` and `DecklinkAudioSinkSettings`. Enumerate devices using `DecklinkVideoSinkBlock.GetDevicesAsync()` and `DecklinkAudioSinkBlock.GetDevicesAsync()`. ``` var videoSinkDeviceInfo = (await DecklinkVideoSinkBlock.GetDevicesAsync()).FirstOrDefault(); var audioSinkDeviceInfo = (await DecklinkAudioSinkBlock.GetDevicesAsync()).FirstOrDefault(d => d.DeviceNumber == videoSinkDeviceInfo.DeviceNumber); // Example match DecklinkVideoSinkSettings videoSinkSettings = null; if (videoSinkDeviceInfo != null) { // Mode is required - specify the output video resolution and frame rate videoSinkSettings = new DecklinkVideoSinkSettings(videoSinkDeviceInfo, DecklinkMode.HD1080i60) { VideoFormat = DecklinkVideoFormat.YUV_8bit }; } DecklinkAudioSinkSettings audioSinkSettings = null; if (audioSinkDeviceInfo != null) { audioSinkSettings = new DecklinkAudioSinkSettings(audioSinkDeviceInfo); } // Create the block if (videoSinkSettings != null && audioSinkSettings != null) { var decklinkVideoAudioSink = new DecklinkVideoAudioSinkBlock(videoSinkSettings, audioSinkSettings); // Connect inputs // videoEncoder.Output.Connect(decklinkVideoAudioSink.VideoInput); // audioEncoder.Output.Connect(decklinkVideoAudioSink.AudioInput); } ``` ### Block Creation and Configuration Instantiate `DecklinkVideoAudioSinkBlock` with configured `DecklinkVideoSinkSettings` and `DecklinkAudioSinkSettings`. ``` // Assuming videoSinkSettings and audioSinkSettings are configured var videoAudioSink = new DecklinkVideoAudioSinkBlock(videoSinkSettings, audioSinkSettings); ``` ### Connecting to the Pipeline The block provides separate `VideoInput` and `AudioInput` pads: ``` // Example: Connect from video and audio encoders videoEncoder.Output.Connect(videoAudioSink.VideoInput); audioEncoder.Output.Connect(videoAudioSink.AudioInput); ``` ## Advanced Usage Examples ### Synchronized Audio/Video Capture **Using separate source blocks:** ``` // Assume videoSourceSettings and audioSourceSettings are configured for the same device/timing var videoSource = new DecklinkVideoSourceBlock(videoSourceSettings); var audioSource = new DecklinkAudioSourceBlock(audioSourceSettings); // Create an MP4 encoder var mp4Settings = new MP4SinkSettings("output.mp4"); var sink = new MP4SinkBlock(mp4Settings); // Create video encoder var videoEncoder = new H264EncoderBlock(); // Create audio encoder var audioEncoder = new AACEncoderBlock(); // Connect video and audio sources pipeline.Connect(videoSource.Output, videoEncoder.Input); pipeline.Connect(audioSource.Output, audioEncoder.Input); // Connect video encoder to sink pipeline.Connect(videoEncoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Video)); // Connect audio encoder to sink pipeline.Connect(audioEncoder.Output, sink.CreateNewInput(MediaBlockPadMediaType.Audio)); // Start the pipeline await pipeline.StartAsync(); ``` **Using `DecklinkVideoAudioSourceBlock` for simplified synchronized capture:** If you use `DecklinkVideoAudioSourceBlock` (as configured in its dedicated section), the source setup becomes: ``` // Assuming videoSourceSettings and audioSourceSettings are configured for the same device var videoAudioSource = new DecklinkVideoAudioSourceBlock(videoSourceSettings, audioSourceSettings); // ... (encoders and sink setup as above) ... // Connect video and audio from the combined source pipeline.Connect(videoAudioSource.VideoOutput, videoEncoder.Input); pipeline.Connect(videoAudioSource.AudioOutput, audioEncoder.Input); // ... (connect encoders to sink and start pipeline as above) ... ``` This ensures that audio and video are sourced from the Decklink device in a synchronized manner by the SDK. ## Troubleshooting Tips - **No Devices Found**: Ensure Blackmagic drivers/SDK are installed and up-to-date. Check if the device is recognized by Blackmagic Desktop Video Setup. - **Format Mismatch**: Verify the device supports your selected video/audio mode, format, and connection type. For sources with `Mode = DecklinkMode.Unknown` (auto-detect), ensure a stable signal is present. - **Performance Issues**: Check system resources (CPU, RAM, disk I/O). Consider lowering resolution/framerate if issues persist. - **Signal Detection**: For input devices, check cable connections and ensure the source device is outputting a valid signal. - **"Unable to build ...Block" errors**: Double-check that all settings are valid for the selected device and mode. Ensure the correct `DeviceNumber` is used if multiple Decklink cards are present. ## Sample Applications For complete working examples, refer to these sample applications: - [Decklink Demo](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK/WPF/CSharp/Decklink%20Demo) ## Conclusion The Blackmagic Decklink blocks in the VisioForge Media Blocks SDK provide a powerful and flexible way to integrate professional video and audio hardware into your .NET applications. By leveraging the specific source and sink blocks, including the combined audio/video blocks, you can efficiently implement complex capture and playback workflows. Always refer to the specific settings classes for detailed configuration options. ---END OF PAGE--- ## Media Demuxer Blocks in C# .NET - MP4, MKV, MPEG-TS **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Demuxers/ **Description:** Separate audio, video, and subtitle streams from MP4, MKV, AVI, and MPEG-TS containers using VisioForge Media Blocks SDK demuxer blocks. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming **API:** UniversalDemuxBlock, UniversalAutoDemuxerBlock, MPEGTSDemuxBlock, QTDemuxBlock, UniversalSourceBlock, MediaFileInfo # Demuxer Blocks - VisioForge Media Blocks SDK .Net [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Demuxer blocks are essential components in media processing pipelines. They take a multimedia stream, typically from a file or network source, and separate it into its constituent elementary streams, such as video, audio, and subtitles. This allows for individual processing or rendering of each stream. VisioForge Media Blocks SDK .Net provides several demuxer blocks to handle various container formats. ## MPEG-TS Demux Block The `MPEGTSDemuxBlock` is used to demultiplex MPEG Transport Streams (MPEG-TS). MPEG-TS is a standard format for transmission and storage of audio, video, and Program and System Information Protocol (PSIP) data. It is commonly used in digital television broadcasting and streaming. ### Block info Name: `MPEGTSDemuxBlock`. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | MPEG-TS Data | 1 | | Output video | Depends on stream content | 0 or 1+ | | Output audio | Depends on stream content | 0 or 1+ | | Output subtitle | Depends on stream content | 0 or 1+ | | Output metadata | Depends on stream content | 0 or 1+ | ### Settings The `MPEGTSDemuxBlock` is configured using `MPEGTSDemuxSettings`. Key properties of `MPEGTSDemuxSettings`: - `Latency` (`TimeSpan`): Gets or sets the latency. Default is 700 milliseconds. - `ProgramNumber` (int): Gets or sets the program number. Use -1 for default/automatic selection. ### The sample pipeline This example shows how to connect a source (like `HTTPSourceBlock` for a network stream or `UniversalSourceBlock` for a local file that outputs raw MPEG-TS data) to `MPEGTSDemuxBlock`, and then connect its outputs to respective renderer blocks. ``` graph LR; DataSourceBlock -- MPEG-TS Data --> MPEGTSDemuxBlock; MPEGTSDemuxBlock -- Video Stream --> VideoRendererBlock; MPEGTSDemuxBlock -- Audio Stream --> AudioRendererBlock; MPEGTSDemuxBlock -- Subtitle Stream --> SubtitleOverlayOrRendererBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); // Assume 'dataSourceBlock' is a source block providing MPEG-TS data // For example, a UniversalSourceBlock reading a .ts file or an HTTP source. // var dataSourceBlock = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync("input.ts")); // For this example, let's assume dataSourceBlock.Output provides the MPEG-TS stream. var mpegTSDemuxSettings = new MPEGTSDemuxSettings(); // mpegTSDemuxSettings.ProgramNumber = 1; // Optionally select a specific program // Create MPEG-TS Demuxer Block // Constructor parameters control which streams to attempt to render var mpegTSDemuxBlock = new MPEGTSDemuxBlock( renderVideo: true, renderAudio: true, renderSubtitle: true, renderMetadata: false); // Connect the data source to the demuxer's input // pipeline.Connect(dataSourceBlock.Output, mpegTSDemuxBlock.Input); // Assuming dataSourceBlock is defined // Create renderers var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // Assuming VideoView1 is your display control var audioRenderer = new AudioRendererBlock(); // var subtitleRenderer = ... ; // A block to handle subtitle rendering or overlay // Connect demuxer outputs if (mpegTSDemuxBlock.VideoOutput != null) { pipeline.Connect(mpegTSDemuxBlock.VideoOutput, videoRenderer.Input); } if (mpegTSDemuxBlock.AudioOutput != null) { pipeline.Connect(mpegTSDemuxBlock.AudioOutput, audioRenderer.Input); } if (mpegTSDemuxBlock.SubtitleOutput != null) { // pipeline.Connect(mpegTSDemuxBlock.SubtitleOutput, subtitleRenderer.Input); // Connect to a subtitle handler } // Start pipeline // await pipeline.StartAsync(); // Start once dataSourceBlock is connected ``` ### Remarks - Ensure that the input to `MPEGTSDemuxBlock` is raw MPEG-TS data. If you are using a `UniversalSourceBlock` with a `.ts` file, it might already demultiplex the stream. In such cases, `MPEGTSDemuxBlock` might be used if `UniversalSourceBlock` is configured to output the raw container stream or if the stream comes from a source like `SRTRAWSourceBlock`. - The availability of video, audio, or subtitle outputs depends on the content of the MPEG-TS stream. ### Platforms Windows, macOS, Linux, iOS, Android. ## QT Demux Block (MP4/MOV) The `QTDemuxBlock` is designed to demultiplex QuickTime (QT) container formats, which include MP4 and MOV files. These formats are widely used for storing video, audio, and other multimedia content. ### Block info Name: `QTDemuxBlock`. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | MP4/MOV Data | 1 | | Output video | Depends on stream content | 0 or 1+ | | Output audio | Depends on stream content | 0 or 1+ | | Output subtitle | Depends on stream content | 0 or 1+ | | Output metadata | Depends on stream content | 0 or 1+ | ### Settings The `QTDemuxBlock` does not have specific settings class beyond the implicit configuration through its constructor parameters (`renderVideo`, `renderAudio`, etc.). The underlying GStreamer element `qtdemux` handles the demultiplexing automatically. ### The sample pipeline This example shows how to connect a source block that outputs raw MP4/MOV data to `QTDemuxBlock`, and then connect its outputs to respective renderer blocks. ``` graph LR; DataSourceBlock -- MP4/MOV Data --> QTDemuxBlock; QTDemuxBlock -- Video Stream --> VideoRendererBlock; QTDemuxBlock -- Audio Stream --> AudioRendererBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); // Assume 'dataSourceBlock' is a source block providing MP4/MOV data. // This could be a StreamSourceBlock feeding raw MP4 data, or a custom source. // For typical file playback, UniversalSourceBlock directly provides decoded streams. // QTDemuxBlock is used when you have the container data and need to demux it within the pipeline. // Example: var fileStream = File.OpenRead("myvideo.mp4"); // var streamSource = new StreamSourceBlock(fileStream); // StreamSourceBlock provides raw data // Create QT Demuxer Block // Constructor parameters control which streams to attempt to render var qtDemuxBlock = new QTDemuxBlock( renderVideo: true, renderAudio: true, renderSubtitle: false, renderMetadata: false); // Connect the data source to the demuxer's input // pipeline.Connect(streamSource.Output, qtDemuxBlock.Input); // Assuming streamSource is defined // Create renderers var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // Assuming VideoView1 var audioRenderer = new AudioRendererBlock(); // Connect demuxer outputs if (qtDemuxBlock.VideoOutput != null) { pipeline.Connect(qtDemuxBlock.VideoOutput, videoRenderer.Input); } if (qtDemuxBlock.AudioOutput != null) { pipeline.Connect(qtDemuxBlock.AudioOutput, audioRenderer.Input); } // Start pipeline // await pipeline.StartAsync(); // Start once dataSourceBlock is connected and pipeline is built ``` ### Remarks - `QTDemuxBlock` is typically used when you have a stream of MP4/MOV container data that needs to be demultiplexed within the pipeline (e.g., from a `StreamSourceBlock` or a custom data source). - For playing local MP4/MOV files, `UniversalSourceBlock` is often more convenient as it handles both demuxing and decoding. - The availability of outputs depends on the actual streams present in the MP4/MOV file. ### Platforms Windows, macOS, Linux, iOS, Android. ## Universal Demux Block The `UniversalDemuxBlock` provides a flexible way to demultiplex various media container formats based on provided settings or inferred from the input stream. It can handle formats like AVI, MKV, MP4, MPEG-TS, FLV, OGG, and WebM. This block requires `MediaFileInfo` to be provided for proper initialization of its output pads, as the number and type of streams can vary greatly between files. ### Block info Name: `UniversalDemuxBlock`. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Various Container Data | 1 | | Output video | Depends on stream content and `renderVideo` flag | 0 to N | | Output audio | Depends on stream content and `renderAudio` flag | 0 to N | | Output subtitle | Depends on stream content and `renderSubtitle` flag | 0 to N | | Output metadata | Depends on stream content and `renderMetadata` flag | 0 or 1 | (N is the number of respective streams in the media file) ### Settings The `UniversalDemuxBlock` is configured using an implementation of `IUniversalDemuxSettings`. The specific settings class depends on the container format you intend to demultiplex. - `UniversalDemuxerType` (enum): Specifies the type of demuxer to use. Can be `Auto`, `MKV`, `MP4`, `AVI`, `MPEGTS`, `MPEGPS`, `FLV`, `OGG`, `WebM`. - Based on the `UniversalDemuxerType`, you would create a corresponding settings object: - `AVIDemuxSettings` - `FLVDemuxSettings` - `MKVDemuxSettings` - `MP4DemuxSettings` - `MPEGPSDemuxSettings` - `MPEGTSDemuxSettings` (includes `Latency` and `ProgramNumber` properties) - `OGGDemuxSettings` - `WebMDemuxSettings` - `UniversalDemuxSettings` (for `Auto` type) The `UniversalDemuxerTypeHelper.CreateSettings(UniversalDemuxerType type)` method can be used to create the appropriate settings object. ### Constructor `UniversalDemuxBlock(IUniversalDemuxSettings settings, MediaFileInfo info, bool renderVideo = true, bool renderAudio = true, bool renderSubtitle = false, bool renderMetadata = false)` `UniversalDemuxBlock(MediaFileInfo info, bool renderVideo = true, bool renderAudio = true, bool renderSubtitle = false, bool renderMetadata = false)` (uses `UniversalDemuxSettings` for auto type detection) **Crucially, `MediaFileInfo` must be provided to the constructor.** This object, typically obtained by analyzing the media file beforehand (e.g., using `MediaInfoReader`), informs the block about the number and types of streams, allowing it to create the correct number of output pads. ### The sample pipeline This example demonstrates using `UniversalDemuxBlock` to demultiplex a file. Note that a data source block providing the raw file data to the `UniversalDemuxBlock` is implied. ``` graph LR; DataSourceBlock -- Container Data --> UniversalDemuxBlock; UniversalDemuxBlock -- Video Stream 1 --> VideoRendererBlock1; UniversalDemuxBlock -- Audio Stream 1 --> AudioRendererBlock1; UniversalDemuxBlock -- Subtitle Stream 1 --> SubtitleHandler1; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); // 1. Obtain media info for your media file (cross-platform reader) var mediaInfoReader = new MediaInfoReaderX(); if (!await mediaInfoReader.OpenAsync("path/to/your/video.mkv")) { Console.WriteLine("Failed to get media info."); return; } var mediaInfo = mediaInfoReader.Info; // 2. Choose or create Demuxer Settings // Example: Auto-detect demuxer type IUniversalDemuxSettings demuxSettings = new UniversalDemuxSettings(); // Or, specify a type, e.g., for an MKV file: // IUniversalDemuxSettings demuxSettings = new MKVDemuxSettings(); // Or, for MPEG-TS with specific program: // var mpegTsSettings = new MPEGTSDemuxSettings { ProgramNumber = 1 }; // IUniversalDemuxSettings demuxSettings = mpegTsSettings; // 3. Create UniversalDemuxBlock var universalDemuxBlock = new UniversalDemuxBlock( demuxSettings, mediaInfo, renderVideo: true, // Process video streams renderAudio: true, // Process audio streams renderSubtitle: true // Process subtitle streams ); // 4. Connect a data source that provides the raw file stream to UniversalDemuxBlock's input. // This step is crucial and depends on how you get the file data. // For instance, using a FileSource configured to output raw data, or a StreamSourceBlock. // Example with a hypothetical RawFileSourceBlock (not a standard block, for illustration): // var rawFileSource = new RawFileSourceBlock("path/to/your/video.mkv"); // pipeline.Connect(rawFileSource.Output, universalDemuxBlock.Input); // 5. Connect outputs // Video outputs (MediaBlockPad[]) var videoOutputs = universalDemuxBlock.VideoOutputs; if (videoOutputs.Length > 0) { // Example: connect the first video stream var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // Assuming VideoView1 pipeline.Connect(videoOutputs[0], videoRenderer.Input); } // Audio outputs (MediaBlockPad[]) var audioOutputs = universalDemuxBlock.AudioOutputs; if (audioOutputs.Length > 0) { // Example: connect the first audio stream var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioOutputs[0], audioRenderer.Input); } // Subtitle outputs (MediaBlockPad[]) var subtitleOutputs = universalDemuxBlock.SubtitleOutputs; if (subtitleOutputs.Length > 0) { // Example: connect the first subtitle stream to a conceptual handler // var subtitleHandler = new MySubtitleHandlerBlock(); // pipeline.Connect(subtitleOutputs[0], subtitleHandler.Input); } // Metadata output (if renderMetadata was true and metadata stream exists) var metadataOutputs = universalDemuxBlock.MetadataOutputs; if (metadataOutputs.Length > 0 && metadataOutputs[0] != null) { // Handle metadata stream } // Start pipeline after all connections are made // await pipeline.StartAsync(); ``` ### Remarks - **`MediaFileInfo` is mandatory** for `UniversalDemuxBlock` to correctly initialize its output pads based on the streams present in the file. - The `renderVideo`, `renderAudio`, and `renderSubtitle` flags in the constructor determine if outputs for these stream types will be created and processed. If set to `false`, respective streams will be ignored (or sent to internal null renderers if present in the file but not rendered). - The `UniversalDemuxBlock` is powerful for scenarios where you need to explicitly manage the demuxing process for various formats or select specific streams from files with multiple tracks. - For simple playback of common file formats, `UniversalSourceBlock` often provides a more straightforward solution as it integrates demuxing and decoding. `UniversalDemuxBlock` offers more granular control. ### Platforms Windows, macOS, Linux, iOS, Android. (Platform support for specific formats may depend on underlying GStreamer plugins.) ## Universal Auto Demux Block The `UniversalAutoDemuxerBlock` automatically detects the container format of the incoming stream and creates the appropriate demuxer on the fly. It uses GStreamer's `typefind` element to identify the media type and then instantiates the matching demuxer element dynamically, exposing the elementary streams (video, audio, subtitle, metadata) on its output pads. Unlike `UniversalDemuxBlock`, this block does **not** require `MediaFileInfo` or an explicit settings object. The output pads are pre-created from the constructor flags, and the demuxer is selected at runtime once the format is detected. This makes it convenient for sources where the container type is unknown in advance. It supports all common container formats (MP4/MOV, MKV, WebM, AVI, MPEG-TS, MPEG-PS, FLV, OGG, ASF/WMV, WAV, FLAC, DV, and more). ### Block info Name: `UniversalAutoDemuxerBlock`. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | Various Container Data | 1 | | Output video | Depends on stream content and `renderVideo` flag | 0 or 1 | | Output audio | Depends on stream content and `renderAudio` flag | 0 or 1 | | Output subtitle | Depends on stream content and `renderSubtitle` flag | 0 or 1 | | Output metadata | Depends on stream content and `renderMetadata` flag | 0 or 1 | ### Constructor `UniversalAutoDemuxerBlock(bool renderVideo = true, bool renderAudio = true, bool renderSubtitle = false, bool renderMetadata = false)` The constructor flags determine which output pads are pre-created. There is no settings class - the demuxer is chosen automatically from the detected container format. ### The sample pipeline This example shows how to connect a source block that provides raw container data to `UniversalAutoDemuxerBlock`, and then connect its outputs to renderer blocks. The container format does not need to be known beforehand. ``` graph LR; DataSourceBlock -- Container Data --> UniversalAutoDemuxerBlock; UniversalAutoDemuxerBlock -- Video Stream --> VideoRendererBlock; UniversalAutoDemuxerBlock -- Audio Stream --> AudioRendererBlock; ``` ### Sample code ``` var pipeline = new MediaBlocksPipeline(); // Assume 'dataSourceBlock' is a source block providing raw container data // (e.g. a StreamSourceBlock or another block that outputs the container stream). // The container format is detected automatically - no MediaFileInfo required. // Create the auto demuxer block. // Constructor flags control which output pads are created. var autoDemuxBlock = new UniversalAutoDemuxerBlock( renderVideo: true, renderAudio: true, renderSubtitle: false, renderMetadata: false); // Connect the data source to the demuxer's input. // pipeline.Connect(dataSourceBlock.Output, autoDemuxBlock.Input); // Create renderers. var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // Assuming VideoView1 var audioRenderer = new AudioRendererBlock(); // Connect demuxer outputs (pads become linked once the format is detected). if (autoDemuxBlock.VideoOutput != null) { pipeline.Connect(autoDemuxBlock.VideoOutput, videoRenderer.Input); } if (autoDemuxBlock.AudioOutput != null) { pipeline.Connect(autoDemuxBlock.AudioOutput, audioRenderer.Input); } // Start pipeline once the data source is connected. // await pipeline.StartAsync(); ``` ### Remarks - No `MediaFileInfo` and no settings object are required - the container format is detected at runtime via `typefind`, and the matching demuxer is created dynamically. - Output pads are pre-created from the constructor flags. Use the convenience pads `VideoOutput`, `AudioOutput`, and `SubtitleOutput`, or the `VideoOutputs`, `AudioOutputs`, `SubtitleOutputs`, and `MetadataOutputs` arrays. - When a flag is `false`, the corresponding stream present in the container is discarded internally. - Prefer `UniversalDemuxBlock` when you have already analyzed the file and need precise control over multiple streams of the same type. Prefer `UniversalAutoDemuxerBlock` when the container type is unknown in advance and one stream per type is sufficient. For simple playback of common file formats, `UniversalSourceBlock` integrates both demuxing and decoding. ### Platforms Windows, macOS, Linux, iOS, Android. (Platform support for specific formats may depend on underlying GStreamer plugins.) ---END OF PAGE--- ## ElevenLabs Text-to-Speech and Voice Cloning Blocks for .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/ElevenLabs/ **Description:** Add ElevenLabs cloud text-to-speech and real-time voice cloning to your C# .NET audio pipelines with the cross-platform Media Blocks SDK .NET. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, ElevenLabs, Text-to-Speech, Voice Cloning, AI, C# **API:** ElevenLabsSynthesizerBlock, ElevenLabsSynthesizerSettings, ElevenLabsVoiceClonerBlock, ElevenLabsVoiceClonerSettings, ElevenLabsOverflow # ElevenLabs Blocks [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Overview The ElevenLabs blocks bring [ElevenLabs](https://elevenlabs.io/) AI audio directly into your [Media Blocks SDK .NET](https://www.visioforge.com/media-blocks-sdk-net) pipelines. Two cloud-backed blocks are available: - [`ElevenLabsSynthesizerBlock`](#elevenlabs-synthesizer) — text-to-speech: takes text input and produces speech audio. - [`ElevenLabsVoiceClonerBlock`](#elevenlabs-voice-cloner) — voice cloning: takes audio input and re-renders it in a cloned voice. Both blocks call the ElevenLabs cloud API, so they require a valid **ElevenLabs API key** and network access. Get a key from the [ElevenLabs dashboard](https://elevenlabs.io/app). Each block exposes a static `IsAvailable()` method so you can verify the underlying GStreamer ElevenLabs plugin is present before creating an instance. ## ElevenLabs Synthesizer The `ElevenLabsSynthesizerBlock` converts a text stream into spoken audio using the ElevenLabs text-to-speech API. It has a text input pad and an audio output pad, so you can route the synthesized speech into an encoder, a renderer, or a mixer. Configure it with `ElevenLabsSynthesizerSettings`. The constructor takes the API key; the most common extra settings are the `VoiceId` (which ElevenLabs voice to use), the `ModelId`, and an optional ISO 639-1 `LanguageCode`. ### Block info Name: ElevenLabsSynthesizerBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input | text | one | | Output audio | audio/x-raw | one | ### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `ApiKey` | `string` | — | ElevenLabs API key (set via the constructor). | | `VoiceId` | `string` | `"9BWtsMINqrJLrRacOk9x"` | ElevenLabs Voice ID. See the [voice library](https://elevenlabs.io/app/voice-library). | | `ModelId` | `string` | `"eleven_flash_v2_5"` | ElevenLabs Model ID. | | `LanguageCode` | `string` | `null` | Optional ISO 639-1 language code, useful with certain models. | | `Latency` | `uint` | `2000` | Milliseconds of latency to allow ElevenLabs. | | `MaxOverflow` | `uint` | `2000` | Milliseconds a text cue may overflow its duration (compress mode). | | `MaxPreviousRequests` | `uint` | `0` | How many previous request IDs to track for continuity. | | `Overflow` | `ElevenLabsOverflow` | `Clip` | How audio longer than the input text is handled: `Clip`, `Overlap`, or `Shift`. | | `RetryWithSpeed` | `bool` | `true` | Retry with higher speed when synthesis produces a longer duration. | | `UseVoiceIdEvents` | `bool` | `true` | Use received `elevenlabs/speaker-voice` events to pick the current voice. | ### The sample pipeline ``` graph LR; SubtitleSourceBlock-- text -->ElevenLabsSynthesizerBlock; ElevenLabsSynthesizerBlock-- audio -->AudioRendererBlock; ``` ### Sample code ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AudioRendering; using VisioForge.Core.MediaBlocks.ElevenLabs; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.Types.X.ElevenLabs; using VisioForge.Core.Types.X.Sources; var pipeline = new MediaBlocksPipeline(); // Text-to-speech settings. Replace with your ElevenLabs API key. var ttsSettings = new ElevenLabsSynthesizerSettings("YOUR_ELEVENLABS_API_KEY") { VoiceId = "9BWtsMINqrJLrRacOk9x", ModelId = "eleven_flash_v2_5", Overflow = ElevenLabsOverflow.Clip }; var synthesizer = new ElevenLabsSynthesizerBlock(ttsSettings); // Source of text to speak (e.g. a subtitle/text file). var textSource = new SubtitleSourceBlock(new SubtitleSourceSettings("script.srt")); // Render the synthesized speech to the default audio output device. var audioRenderer = new AudioRendererBlock(); pipeline.Connect(textSource.Output, synthesizer.Input); pipeline.Connect(synthesizer.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` ## ElevenLabs Voice Cloner The `ElevenLabsVoiceClonerBlock` takes an audio stream, clones the speaker's voice with the ElevenLabs API, and produces audio re-rendered in that cloned voice. It has an audio input pad and an audio output pad, so it slots into a pipeline between an audio source and a sink or encoder. Configure it with `ElevenLabsVoiceClonerSettings`. The constructor takes the API key. By default the block asks ElevenLabs to remove background noise and stores 10 seconds of audio per voice update; set `Speaker` to treat all incoming audio as a single speaker and skip diarization. ### Block info Name: ElevenLabsVoiceClonerBlock. | Pin direction | Media type | Pins count | | --- | --- | --- | | Input audio | audio/x-raw | one | | Output audio | audio/x-raw | one | ### Settings | Property | Type | Default | Description | | --- | --- | --- | --- | | `ApiKey` | `string` | — | ElevenLabs API key (set via the constructor). | | `RemoveBackgroundNoise` | `bool` | `true` | Ask ElevenLabs to remove background noise. | | `SegmentDuration` | `uint` | `10000` | Milliseconds of audio to store before creating/updating a voice. | | `Speaker` | `string` | `null` | Optional speaker name. When set, all audio is treated as one speaker (no diarization). | ### The sample pipeline ``` graph LR; SystemAudioSourceBlock-- audio -->ElevenLabsVoiceClonerBlock; ElevenLabsVoiceClonerBlock-- audio -->AudioRendererBlock; ``` ### Sample code ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AudioRendering; using VisioForge.Core.MediaBlocks.ElevenLabs; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.Types.X.ElevenLabs; var pipeline = new MediaBlocksPipeline(); // Voice cloning settings. Replace with your ElevenLabs API key. var clonerSettings = new ElevenLabsVoiceClonerSettings("YOUR_ELEVENLABS_API_KEY") { RemoveBackgroundNoise = true, SegmentDuration = 10000, Speaker = "narrator" }; var cloner = new ElevenLabsVoiceClonerBlock(clonerSettings); // Audio source to clone (system audio capture in this example). var audioSource = new SystemAudioSourceBlock(); // Render the cloned voice to the default audio output device. var audioRenderer = new AudioRendererBlock(); pipeline.Connect(audioSource.Output, cloner.Input); pipeline.Connect(cloner.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` ## Availability Call `ElevenLabsSynthesizerBlock.IsAvailable()` or `ElevenLabsVoiceClonerBlock.IsAvailable()` to verify the ElevenLabs blocks are available in the current environment before creating an instance. ## Platforms Windows, macOS, Linux, iOS, Android. ---END OF PAGE--- ## Build Camera Capture App - Device Setup Guide in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/GettingStarted/camera/ **Description:** Build camera apps with VisioForge Media Blocks SDK — device enumeration, format selection, video rendering, and cross-platform capture support. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Streaming, Webcam, C# **API:** MediaBlocksPipeline, SystemVideoSourceBlock, VideoRendererBlock, DeviceEnumerator, VideoCaptureDeviceSourceSettings # Building Camera Applications with Media Blocks SDK [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction This comprehensive guide demonstrates how to create a fully functional camera viewing application using the Media Blocks SDK .Net. The SDK provides a robust framework for capturing, processing, and displaying video streams across multiple platforms including Windows, macOS, iOS, and Android. ## Architecture Overview To create a camera viewer application, you'll need to understand two fundamental components: 1. **System Video Source** - Captures the video stream from connected camera devices 2. **Video Renderer** - Displays the captured video on screen with configurable settings These components work together within a pipeline architecture that manages media processing. ## Essential Media Blocks To build a camera application, you need to add the following blocks to your pipeline: - **[System Video Source Block](../../Sources/)** - Connects to and reads from camera devices - **[Video Renderer Block](../../VideoRendering/)** - Displays the video with configurable rendering options ## Setting Up the Pipeline ### Creating the Base Pipeline First, create a pipeline object that will manage the media flow: ``` using VisioForge.Core.MediaBlocks; // Initialize the pipeline var pipeline = new MediaBlocksPipeline(); // Add error handling pipeline.OnError += (sender, args) => { Console.WriteLine($"Pipeline error: {args.Message}"); }; ``` ### Camera Device Enumeration Before adding a camera source, you need to enumerate the available devices and select one: ``` // Get all available video devices asynchronously var videoDevices = await DeviceEnumerator.Shared.VideoSourcesAsync(); // Display available devices (useful for user selection) foreach (var device in videoDevices) { Console.WriteLine($"Device: {device.Name} [{device.API}]"); } // Select the first available device var selectedDevice = videoDevices[0]; ``` ### Camera Format Selection Each camera supports different resolutions and frame rates. You can enumerate and select the optimal format: ``` // Display available formats for the selected device foreach (var format in selectedDevice.VideoFormats) { Console.WriteLine($"Format: {format.Width}x{format.Height} {format.Format}"); // Display available frame rates for this format foreach (var frameRate in format.FrameRateList) { Console.WriteLine($" Frame Rate: {frameRate}"); } } // Select the optimal format (in this example, we look for HD resolution) var hdFormat = selectedDevice.GetHDVideoFormatAndFrameRate(out var frameRate); var formatToUse = hdFormat ?? selectedDevice.VideoFormats[0]; ``` ## Configuring Camera Settings ### Creating Source Settings Configure the camera source settings with your selected device and format: ``` // Create camera settings with the selected device and format var videoSourceSettings = new VideoCaptureDeviceSourceSettings(selectedDevice) { Format = formatToUse.ToFormat() }; // Set the desired frame rate (selecting the highest available) if (formatToUse.FrameRateList.Count > 0) { videoSourceSettings.Format.FrameRate = formatToUse.FrameRateList.Max(); } // Optional: Enable force frame rate to maintain consistent timing videoSourceSettings.Format.ForceFrameRate = true; // Platform-specific settings #if __ANDROID__ // Android-specific settings videoSourceSettings.VideoStabilization = true; #elif __IOS__ && !__MACCATALYST__ // iOS-specific settings videoSourceSettings.Position = IOSVideoSourcePosition.Back; videoSourceSettings.Orientation = IOSVideoSourceOrientation.Portrait; #endif ``` ### Creating the Video Source Block Now create the system video source block with your configured settings: ``` // Create the video source block var videoSource = new SystemVideoSourceBlock(videoSourceSettings); ``` ## Setting Up Video Display ### Creating the Video Renderer Add a video renderer to display the captured video: ``` // Create the video renderer and connect it to your UI component var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // Optional: keep the renderer in sync with the pipeline clock videoRenderer.IsSync = true; ``` ### Advanced Renderer Configuration `VideoRendererBlock` exposes a handful of flat properties — no nested `Settings` bag: ``` // Enable subtitle overlay if the pipeline carries a subtitle stream videoRenderer.SubtitleEnabled = true; // Disable clock-sync to get frames as fast as they arrive (useful for recording scenarios) videoRenderer.IsSync = false; ``` ## Connecting the Pipeline Connect the video source to the renderer to establish the media flow: ``` // Connect the output of the video source to the input of the renderer pipeline.Connect(videoSource.Output, videoRenderer.Input); ``` ## Managing the Pipeline Lifecycle ### Starting the Pipeline Start the pipeline to begin capturing and displaying video: ``` // Start the pipeline asynchronously await pipeline.StartAsync(); ``` ### Taking Snapshots Capture still images from the video stream: ``` // Take a snapshot and save it as a JPEG file await videoRenderer.Snapshot_SaveAsync("camera_snapshot.jpg", SkiaSharp.SKEncodedImageFormat.Jpeg, 90); // Or get the snapshot as a bitmap for further processing var bitmap = await videoRenderer.Snapshot_GetAsync(); ``` ### Stopping the Pipeline When finished, properly stop the pipeline: ``` // Stop the pipeline asynchronously await pipeline.StopAsync(); ``` ## Platform-Specific Considerations The Media Blocks SDK supports cross-platform development with specific optimizations: - **Windows**: Supports both Media Foundation and Kernel Streaming APIs - **macOS/iOS**: Utilizes AVFoundation for optimal performance - **Android**: Provides access to camera features like stabilization and orientation ## Error Handling and Troubleshooting Implement proper error handling to ensure a stable application: ``` try { // Pipeline operations await pipeline.StartAsync(); } catch (Exception ex) { Console.WriteLine($"Error starting pipeline: {ex.Message}"); // Handle the exception appropriately } ``` ## Complete Implementation Example This example demonstrates a complete camera viewer implementation: ``` using System; using System.Linq; using System.Threading.Tasks; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoRendering; using VisioForge.Core.Types.X.Sources; public class CameraViewerExample { private MediaBlocksPipeline _pipeline; private SystemVideoSourceBlock _videoSource; private VideoRendererBlock _videoRenderer; public async Task InitializeAsync(IVideoView videoView) { // Create pipeline _pipeline = new MediaBlocksPipeline(); _pipeline.OnError += (s, e) => Console.WriteLine(e.Message); // Enumerate devices var devices = await DeviceEnumerator.Shared.VideoSourcesAsync(); if (devices.Length == 0) { throw new Exception("No camera devices found"); } // Select device and format var device = devices[0]; var format = device.GetHDOrAnyVideoFormatAndFrameRate(out var frameRate); // Create settings var settings = new VideoCaptureDeviceSourceSettings(device); if (format != null) { settings.Format = format.ToFormat(); if (frameRate != null && !frameRate.IsEmpty) { settings.Format.FrameRate = frameRate; } } // Create blocks _videoSource = new SystemVideoSourceBlock(settings); _videoRenderer = new VideoRendererBlock(_pipeline, videoView); // Build pipeline _pipeline.AddBlock(_videoSource); _pipeline.AddBlock(_videoRenderer); _pipeline.Connect(_videoSource.Output, _videoRenderer.Input); // Start pipeline await _pipeline.StartAsync(); } public async Task StopAsync() { if (_pipeline != null) { await _pipeline.StopAsync(); _pipeline.Dispose(); } } public async Task TakeSnapshotAsync(string filename) { return await _videoRenderer.Snapshot_SaveAsync(filename, SkiaSharp.SKEncodedImageFormat.Jpeg, 90); } } ``` ## Conclusion With Media Blocks SDK .Net, building powerful camera applications becomes straightforward. The component-based architecture provides flexibility and performance across platforms while abstracting the complexities of camera device integration. For complete source code examples, please visit our [GitHub repository](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK/WPF/CSharp/Simple%20Capture%20Demo). ---END OF PAGE--- ## Media Device Enumeration in C# .NET - Complete Guide **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/GettingStarted/device-enum/ **Description:** List cameras, microphones, speakers, Decklink, NDI, and GenICam devices using VisioForge Media Blocks SDK with cross-platform code examples. **Tags:** Media Blocks SDK, .NET, DirectShow, Windows, macOS, Linux, Android, iOS, Decklink, NDI Source, USB3 Vision / GigE, ONVIF, NDI, C# **API:** DeviceEnumerator, VideoCaptureDeviceInfo, AudioCaptureDeviceAPI # Complete Guide to Media Device Enumeration in .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The Media Blocks SDK provides a powerful and efficient way to discover and work with various media devices in your .NET applications. This guide will walk you through the process of enumerating different types of media devices using the SDK's `DeviceEnumerator` class. ## Introduction to Device Enumeration Device enumeration is a critical first step when developing applications that interact with media hardware. The `DeviceEnumerator` class provides a centralized way to detect and list all available media devices connected to your system. The SDK uses a singleton pattern for device enumeration, making it easy to access the functionality from anywhere in your code: ``` // Access the shared DeviceEnumerator instance var enumerator = DeviceEnumerator.Shared; ``` ## Discovering Video Input Devices ### Standard Video Sources To list all available video input devices (webcams, capture cards, virtual cameras): ``` var videoSources = await DeviceEnumerator.Shared.VideoSourcesAsync(); foreach (var device in videoSources) { Debug.WriteLine($"Video device found: {device.Name}"); // You can access additional properties here if needed } ``` The `VideoCaptureDeviceInfo` objects returned provide detailed information about each device, including device name, internal identifiers, and API type. ## Working with Audio Devices ### Enumerating Audio Input Sources To discover microphones and other audio input devices: ``` var audioSources = await DeviceEnumerator.Shared.AudioSourcesAsync(); foreach (var device in audioSources) { Debug.WriteLine($"Audio input device found: {device.Name}"); // Additional device information can be accessed here } ``` You can also filter audio devices by their API type: ``` // Get only audio sources for a specific API var audioSources = await DeviceEnumerator.Shared.AudioSourcesAsync(AudioCaptureDeviceAPI.DirectSound); ``` ### Finding Audio Output Devices For speakers, headphones, and other audio output destinations: ``` var audioOutputs = await DeviceEnumerator.Shared.AudioOutputsAsync(); foreach (var device in audioOutputs) { Debug.WriteLine($"Audio output device found: {device.Name}"); // Process device information as needed } ``` Similar to audio sources, you can filter outputs by API: ``` // Get only audio outputs for a specific API var audioOutputs = await DeviceEnumerator.Shared.AudioOutputsAsync(AudioOutputDeviceAPI.DirectSound); ``` ## Professional Blackmagic Decklink Integration ### Decklink Video Input Sources For professional video workflows using Blackmagic hardware: ``` var decklinkVideoSources = await DeviceEnumerator.Shared.DecklinkVideoSourcesAsync(); foreach (var device in decklinkVideoSources) { Debug.WriteLine($"Decklink video input: {device.Name}"); // You can work with specific Decklink properties here } ``` ### Decklink Audio Input Sources To access audio channels from Decklink devices: ``` var decklinkAudioSources = await DeviceEnumerator.Shared.DecklinkAudioSourcesAsync(); foreach (var device in decklinkAudioSources) { Debug.WriteLine($"Decklink audio input: {device.Name}"); // Process Decklink audio device information } ``` ### Decklink Video Output Destinations For sending video to Decklink output devices: ``` var decklinkVideoOutputs = await DeviceEnumerator.Shared.DecklinkVideoSinksAsync(); foreach (var device in decklinkVideoOutputs) { Debug.WriteLine($"Decklink video output: {device.Name}"); // Access output device properties as needed } ``` ### Decklink Audio Output Destinations For routing audio to Decklink hardware outputs: ``` var decklinkAudioOutputs = await DeviceEnumerator.Shared.DecklinkAudioSinksAsync(); foreach (var device in decklinkAudioOutputs) { Debug.WriteLine($"Decklink audio output: {device.Name}"); // Work with audio output configuration here } ``` ## Network Device Integration ### NDI Sources Discovery To find NDI sources available on your network: ``` var ndiSources = await DeviceEnumerator.Shared.NDISourcesAsync(); foreach (var device in ndiSources) { Debug.WriteLine($"NDI source discovered: {device.Name}"); // Process NDI-specific properties and information } ``` ### ONVIF Network Camera Discovery To find IP cameras supporting the ONVIF protocol: ``` // Set a timeout for discovery (2 seconds in this example) var timeout = TimeSpan.FromSeconds(2); var onvifDevices = await DeviceEnumerator.Shared.ONVIF_ListSourcesAsync(timeout, null); foreach (var deviceUri in onvifDevices) { Debug.WriteLine($"ONVIF camera found at: {deviceUri}"); // Connect to the camera using the discovered URI } ``` ## Industrial Camera Support ### Basler Industrial Cameras For applications requiring Basler industrial cameras: ``` var baslerCameras = await DeviceEnumerator.Shared.BaslerSourcesAsync(); foreach (var device in baslerCameras) { Debug.WriteLine($"Basler camera detected: {device.Name}"); // Access Basler-specific camera features } ``` ### Allied Vision Industrial Cameras To work with Allied Vision cameras in your application: ``` var alliedCameras = await DeviceEnumerator.Shared.AlliedVisionSourcesAsync(); foreach (var device in alliedCameras) { Debug.WriteLine($"Allied Vision camera found: {device.Name}"); // Configure Allied Vision specific parameters } ``` ### Spinnaker SDK Compatible Cameras For cameras supporting the Spinnaker SDK (Windows only): ``` #if NET_WINDOWS var spinnakerCameras = await DeviceEnumerator.Shared.SpinnakerSourcesAsync(); foreach (var device in spinnakerCameras) { Debug.WriteLine($"Spinnaker SDK camera: {device.Name}"); Debug.WriteLine($"Model: {device.Model}, Vendor: {device.Vendor}"); Debug.WriteLine($"Resolution: {device.WidthMax}x{device.HeightMax}"); // Work with camera-specific properties } #endif ``` ### Generic GenICam Standard Cameras For other industrial cameras supporting the GenICam standard: ``` var genicamCameras = await DeviceEnumerator.Shared.GenICamSourcesAsync(); foreach (var device in genicamCameras) { Debug.WriteLine($"GenICam compatible device: {device.Name}"); Debug.WriteLine($"Model: {device.Model}, Vendor: {device.Vendor}"); Debug.WriteLine($"Protocol: {device.Protocol}, Serial: {device.SerialNumber}"); // Work with standard GenICam features } ``` ## Device Monitoring The SDK also supports monitoring device connections and disconnections: ``` // Start monitoring for video device changes await DeviceEnumerator.Shared.StartVideoSourceMonitorAsync(); // Start monitoring for audio device changes await DeviceEnumerator.Shared.StartAudioSourceMonitorAsync(); await DeviceEnumerator.Shared.StartAudioSinkMonitorAsync(); // Subscribe to device change events DeviceEnumerator.Shared.OnVideoSourceAdded += (sender, device) => { Debug.WriteLine($"New video device connected: {device.Name}"); }; DeviceEnumerator.Shared.OnVideoSourceRemoved += (sender, device) => { Debug.WriteLine($"Video device disconnected: {device.Name}"); }; ``` ## Platform-Specific Considerations ### Windows On Windows, the SDK can detect USB device connection and removal events at the system level: ``` #if NET_WINDOWS // Subscribe to system-wide device events DeviceEnumerator.Shared.OnDeviceAdded += (sender, args) => { // Refresh device lists when new hardware is connected RefreshDeviceLists(); }; DeviceEnumerator.Shared.OnDeviceRemoved += (sender, args) => { // Update UI when hardware is disconnected RefreshDeviceLists(); }; #endif ``` By default, Media Foundation device enumeration is disabled to avoid duplication with DirectShow devices. You can enable it if needed: ``` #if NET_WINDOWS // Enable Media Foundation device enumeration if required DeviceEnumerator.Shared.IsEnumerateMediaFoundationDevices = true; #endif ``` ### iOS and Android On mobile platforms, the SDK handles the required permission requests when enumerating devices: ``` #if __IOS__ || __ANDROID__ // This will automatically request camera permissions if needed var videoSources = await DeviceEnumerator.Shared.VideoSourcesAsync(); // This will automatically request microphone permissions if needed var audioSources = await DeviceEnumerator.Shared.AudioSourcesAsync(); #endif ``` ## Best Practices for Device Enumeration When working with device enumeration in production applications: 1. Always handle cases where no devices are found 2. Consider caching device lists when appropriate to improve performance 3. Implement proper exception handling for device access failures 4. Provide clear user feedback when required devices are missing 5. Use the async methods to avoid blocking the UI thread during enumeration 6. Clean up resources by calling `Dispose()` when you're done with the DeviceEnumerator ``` // Proper cleanup when done DeviceEnumerator.Shared.Dispose(); ``` ---END OF PAGE--- ## Media Pipeline Quick Start - Install and Setup in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/GettingStarted/ **Description:** Get started with VisioForge Media Blocks SDK — installation, pipeline architecture, block connections, and multimedia processing tutorials. **Tags:** Media Blocks SDK, .NET, Windows, macOS, Linux, Android, iOS, Streaming **API:** MediaBlocksPipeline, IMediaBlock, MediaBlockPad, IMediaBlocksPipeline, MediaBlock # Media Blocks SDK .Net - Developer Quick Start Guide [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction This guide provides a comprehensive walkthrough for integrating the Media Blocks SDK .Net into your applications. The SDK is built around a modular pipeline architecture, enabling you to create, connect, and manage multimedia processing blocks for video, audio, and more. Whether you're building video processing tools, streaming solutions, or multimedia applications, this guide will help you get started quickly and correctly. ## SDK Installation Process The SDK is distributed as a NuGet package for easy integration into your .Net projects. Install it using: ``` dotnet add package VisioForge.DotNet.MediaBlocks ``` For platform-specific requirements and additional installation details, refer to the [detailed installation guide](../../install/). ## Core Concepts and Architecture ### MediaBlocksPipeline - The central class for managing the flow of media data between processing blocks. - Handles block addition, connection, state management, and event handling. - Implements `IMediaBlocksPipeline` and exposes events such as `OnError`, `OnStart`, `OnPause`, `OnResume`, `OnStop`, and `OnLoop`. ### MediaBlock and Interfaces - Each processing unit is a `MediaBlock` (or a derived class), implementing the `IMediaBlock` interface. - Key interfaces: - `IMediaBlock`: Base interface for all blocks. Defines properties for `Name`, `Type`, `Input`, `Inputs`, `Output`, `Outputs`, and methods for pipeline context and YAML export. - `IMediaBlockDynamicInputs`: For blocks that support dynamic input creation (e.g., mixers). - `IMediaBlockInternals`/`IMediaBlockInternals2`: For internal pipeline management, building, and post-connection logic. - `IMediaBlockRenderer`: For blocks that render media (e.g., video/audio renderers), with a property to control stream synchronization. - `IMediaBlockSink`/`IMediaBlockSource`: For blocks that act as sinks (outputs) or sources (inputs). - `IMediaBlockSettings`: For settings objects that can create blocks. ### Pads and Media Types - Blocks are connected via `MediaBlockPad` objects, which have a direction (`In`/`Out`) and a media type (`Video`, `Audio`, `Subtitle`, `Metadata`, `Auto`). - Pads can be connected/disconnected, and their state can be queried. ### Block Types - The SDK provides a wide range of built-in block types (see `MediaBlockType` enum in the source code) for sources, sinks, renderers, effects, and more. ## Creating and Managing a Pipeline ### 1. Initialize the SDK (if required) ``` using VisioForge.Core; // Initialize the SDK at application startup VisioForgeX.InitSDK(); ``` ### 2. Create a Pipeline and Blocks ``` using VisioForge.Core.MediaBlocks; // Create a new pipeline instance var pipeline = new MediaBlocksPipeline(); // Example: Create a virtual video source and a video renderer var virtualSource = new VirtualVideoSourceBlock(new VirtualVideoSourceSettings()); var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // VideoView1 is your UI control // Add blocks to the pipeline pipeline.AddBlock(virtualSource); pipeline.AddBlock(videoRenderer); ``` ### 3. Connect Blocks ``` // Connect the output of the source to the input of the renderer pipeline.Connect(virtualSource.Output, videoRenderer.Input); ``` - You can also use `pipeline.Connect(sourceBlock, targetBlock)` to connect default pads, or connect multiple pads for complex graphs. - For blocks supporting dynamic inputs, use the `IMediaBlockDynamicInputs` interface. ### 4. Start and Stop the Pipeline ``` // Start the pipeline asynchronously await pipeline.StartAsync(); // ... later, stop processing await pipeline.StopAsync(); ``` ### 5. Resource Cleanup ``` // Dispose of the pipeline when done pipeline.Dispose(); ``` ### 6. SDK Cleanup (if required) ``` // Release all SDK resources at application shutdown VisioForgeX.DestroySDK(); ``` ## Error Handling and Events - Subscribe to pipeline events for robust error and state management: ``` pipeline.OnError += (sender, args) => { Console.WriteLine($"Pipeline error: {args.Message}"); // Implement your error handling logic here }; pipeline.OnStart += (sender, args) => { Console.WriteLine("Pipeline started"); }; pipeline.OnStop += (sender, args) => { Console.WriteLine("Pipeline stopped"); }; ``` ## Advanced Features - **Dynamic Block Addition/Removal:** You can add or remove blocks at runtime as needed. - **Pad Management:** Use `MediaBlockPad` methods to query and manage pad connections. - **Hardware/Software Decoder Selection:** Use helper methods in `MediaBlocksPipeline` for hardware acceleration. - **Segment Playback:** Set `StartPosition` and `StopPosition` properties for partial playback. - **Debugging:** Export pipeline graphs for debugging using provided methods. ## Example: Minimal Pipeline Setup ``` using VisioForge.Core.MediaBlocks; var pipeline = new MediaBlocksPipeline(); var source = new VirtualVideoSourceBlock(new VirtualVideoSourceSettings()); var renderer = new VideoRendererBlock(pipeline, videoViewControl); pipeline.AddBlock(source); pipeline.AddBlock(renderer); pipeline.Connect(source.Output, renderer.Input); await pipeline.StartAsync(); // ... await pipeline.StopAsync(); pipeline.Dispose(); ``` ## Reference: Key Interfaces - `IMediaBlock`: Base interface for all blocks. - `IMediaBlockDynamicInputs`: For blocks with dynamic input support. - `IMediaBlockInternals`, `IMediaBlockInternals2`: For internal pipeline logic. - `IMediaBlockRenderer`: For renderer blocks. - `IMediaBlockSink`, `IMediaBlockSource`: For sink/source blocks. - `IMediaBlockSettings`: For block settings objects. - `IMediaBlocksPipeline`: Main pipeline interface. - `MediaBlockPad`, `MediaBlockPadDirection`, `MediaBlockPadMediaType`: For pad management. ## Further Reading and Samples - [Complete Pipeline Implementation](pipeline/) - [Media Player Development Guide](player/) - [Camera Viewer Application Tutorial](camera/) - [GitHub repository with code samples](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK) For a full list of block types and advanced usage, consult the SDK API reference and source code. ---END OF PAGE--- ## Media Pipeline Architecture and Block Connections in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/GettingStarted/pipeline/ **Description:** Create media pipelines for playback, recording, and streaming with modular blocks and resource management in VisioForge Media Blocks SDK. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Streaming, Recording, Encoding, MP4, C# **API:** MediaBlocksPipeline, MediaBlockPadMediaType, IMediaBlock, MP4SinkBlock, MediaBlockType # Media Blocks Pipeline: Core Functionality [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Overview of Pipeline and Block Structure The Media Blocks SDK is built around the `MediaBlocksPipeline` class, which manages a collection of modular processing blocks. Each block implements the `IMediaBlock` interface or one of its specialized variants. Blocks are connected via input and output pads, allowing for flexible media processing chains. ### Main Block Interfaces - **IMediaBlock**: Base interface for all blocks. Exposes properties for name, type, input/output pads, and methods for YAML conversion and pipeline context retrieval. - **IMediaBlockDynamicInputs**: For blocks (like muxers) that can create new inputs dynamically. Methods: `CreateNewInput(mediaType)` and `GetInput(mediaType)`. - **IMediaBlockInternals**: Internal methods for pipeline integration (e.g., `SetContext`, `Build`, `CleanUp`, `GetElement`, `GetCore`). - **IMediaBlockInternals2**: For post-connection logic (`PostConnect()`). - **IMediaBlockRenderer**: For renderer blocks, exposes `IsSync` property. - **IMediaBlockSettings**: For settings/configuration objects that can create a block (`CreateBlock()`). - **IMediaBlockSink**: For sink blocks, exposes filename/URL getter/setter. - **IMediaBlockSource**: For source blocks (currently only commented-out pad accessors). ### Pads and Media Types - **MediaBlockPad**: Represents a connection point (input/output) on a block. Has direction (`In`/`Out`), media type (`Video`, `Audio`, `Subtitle`, `Metadata`, `Auto`), and connection logic. - **Pad connection**: Use `pipeline.Connect(outputPad, inputPad)` or `pipeline.Connect(block1.Output, block2.Input)`. For dynamic inputs, use `CreateNewInput()` on the sink block. ## Setting Up Your Pipeline Environment ### Creating a New Pipeline Instance The first step in working with Media Blocks is instantiating a pipeline object: ``` using VisioForge.Core.MediaBlocks; // Create a standard pipeline instance var pipeline = new MediaBlocksPipeline(); // Optionally, you can assign a name to your pipeline for easier identification pipeline.Name = "MainVideoPlayer"; ``` ### Implementing Robust Error Handling Media applications must handle various error scenarios that may occur during operation. Implementing proper error handling ensures your application remains stable: ``` // Subscribe to error events to capture and handle exceptions pipeline.OnError += (sender, args) => { // Log the error message Debug.WriteLine($"Pipeline error occurred: {args.Message}"); // Implement appropriate error recovery based on the message if (args.Message.Contains("Access denied")) { // Handle permission issues } else if (args.Message.Contains("File not found")) { // Handle missing file errors } }; ``` ## Managing Media Timing and Navigation ### Retrieving Duration and Position Information Accurate timing control is essential for media applications: ``` // Get the total duration of the media (returns TimeSpan.Zero for live streams) var duration = await pipeline.DurationAsync(); Console.WriteLine($"Media duration: {duration.TotalSeconds} seconds"); // Get the current playback position var position = await pipeline.Position_GetAsync(); Console.WriteLine($"Current position: {position.TotalSeconds} seconds"); ``` ### Implementing Seeking Functionality Enable your users to navigate through media content with seeking operations: ``` // Basic seeking to a specific time position await pipeline.Position_SetAsync(TimeSpan.FromSeconds(10)); // Seeking with keyframe alignment for more efficient navigation await pipeline.Position_SetAsync(TimeSpan.FromMinutes(2), seekToKeyframe: true); // Read the current position back (e.g. for a progress bar) var current = await pipeline.Position_GetAsync(); ``` ## Controlling Pipeline Execution Flow ### Starting Media Playback Control the playback of media with these essential methods: ``` // Start playback immediately await pipeline.StartAsync(); // Preload media without starting playback (useful for reducing startup delay) await pipeline.StartAsync(onlyPreload: true); await pipeline.ResumeAsync(); // Start the preloaded pipeline when ready ``` ### Managing Playback States Monitor and control the pipeline's current execution state: ``` // Check the current state of the pipeline var state = pipeline.State; if (state == PlaybackState.Play) { Console.WriteLine("Pipeline is currently playing"); } // Subscribe to important state change events pipeline.OnStart += (sender, args) => { Console.WriteLine("Pipeline playback has started"); UpdateUIForPlaybackState(); }; pipeline.OnStop += (sender, args) => { Console.WriteLine("Pipeline playback has stopped"); Console.WriteLine($"Stopped at position: {args.Position.TotalSeconds} seconds"); ResetPlaybackControls(); }; pipeline.OnPause += (sender, args) => { Console.WriteLine("Pipeline playback is paused"); UpdatePauseButtonState(); }; pipeline.OnResume += (sender, args) => { Console.WriteLine("Pipeline playback has resumed"); UpdatePlayButtonState(); }; ``` ### Pausing and Resuming Operations Implement pause and resume functionality for better user experience: ``` // Pause the current playback await pipeline.PauseAsync(); // Resume playback from paused state await pipeline.ResumeAsync(); ``` ### Stopping Pipeline Execution Properly terminate pipeline operations: ``` // Standard stop operation await pipeline.StopAsync(); // Force stop in time-sensitive scenarios (may affect output file integrity) await pipeline.StopAsync(force: true); ``` ## Building Media Processing Chains ### Connecting Media Processing Blocks The true power of the Media Blocks SDK comes from connecting specialized blocks to create processing chains: ``` // Basic connection between two blocks pipeline.Connect(block1.Output, block2.Input); // Connect blocks with specific media types pipeline.Connect(videoSource.GetOutputPadByType(MediaBlockPadMediaType.Video), videoEncoder.GetInputPadByType(MediaBlockPadMediaType.Video)); ``` Different blocks may have multiple specialized inputs and outputs: - Standard I/O: `Input` and `Output` properties - Media-specific I/O: `VideoOutput`, `AudioOutput`, `VideoInput`, `AudioInput` - Arrays of I/O: `Inputs[]` and `Outputs[]` for complex blocks ### Working with Dynamic Input Blocks Some advanced sink blocks dynamically create inputs on demand: ``` // Create a specialized MP4 muxer for recording — ctor takes the output filename (or MP4SinkSettings) var mp4Muxer = new MP4SinkBlock("output_recording.mp4"); // Request a new video input from the muxer var videoInput = mp4Muxer.CreateNewInput(MediaBlockPadMediaType.Video); // Connect a video source to the newly created input pipeline.Connect(videoSource.Output, videoInput); // Similarly for audio var audioInput = mp4Muxer.CreateNewInput(MediaBlockPadMediaType.Audio); pipeline.Connect(audioSource.Output, audioInput); ``` This flexibility enables complex media processing scenarios with multiple input streams. ## Proper Resource Management ### Disposing Pipeline Resources Media applications can consume significant system resources. Always properly dispose of pipeline objects: ``` // Synchronous disposal pattern try { // Use pipeline } finally { pipeline.Dispose(); } ``` For modern applications, use the asynchronous pattern to prevent UI freezing: ``` // Asynchronous disposal (preferred for UI applications) try { // Use pipeline } finally { await pipeline.DisposeAsync(); } ``` ### Using 'using' Statements for Automatic Cleanup Leverage C# language features for automatic resource management: ``` // Automatic disposal with 'using' statement using (var pipeline = new MediaBlocksPipeline()) { // Configure and use pipeline await pipeline.StartAsync(); // Pipeline will be automatically disposed when exiting this block } // C# 8.0+ using declaration using var pipeline = new MediaBlocksPipeline(); // Pipeline will be disposed when the containing method exits ``` ## Advanced Pipeline Features ### Playback Rate Control Adjust playback speed for slow-motion or fast-forward effects: ``` // Get current playback rate double currentRate = await pipeline.Rate_GetAsync(); // Set playback rate (1.0 is normal speed) await pipeline.Rate_SetAsync(0.5); // Slow motion (half speed) await pipeline.Rate_SetAsync(2.0); // Double speed ``` ### Loop Playback Configuration Implement continuous playback functionality: ``` // Enable looping for continuous playback pipeline.Loop = true; // Listen for loop events pipeline.OnLoop += (sender, args) => { Console.WriteLine("Media has looped back to start"); UpdateLoopCounter(); }; ``` ### Debug Mode for Development Enable debugging features during development: ``` // Enable debug mode for more detailed logging pipeline.Debug_Mode = true; pipeline.Debug_Dir = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments), "PipelineDebugLogs"); ``` ## Block Types Reference The SDK provides a wide range of block types for sources, processing, and sinks. See the `MediaBlockType` enum in the source code for a full list of available block types. ## Notes - The pipeline supports both synchronous and asynchronous methods for starting, stopping, and disposing. Prefer asynchronous methods in UI or long-running applications. - Events are available for error handling, state changes, and stream information. - Use the correct interface for each block type to access specialized features (e.g., dynamic inputs, rendering, settings). ---END OF PAGE--- ## Build a Video Player in C# .NET — Step-by-Step Guide **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/GettingStarted/player/ **Description:** Step-by-step C# tutorial for building a video player with VisioForge Media Blocks SDK — source blocks, audio/video rendering, and playback controls. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, C# **API:** MediaBlocksPipeline, UniversalSourceSettings, UniversalSourceBlock, VideoRendererBlock, DeviceEnumerator # Building a Feature-Rich Video Player with Media Blocks SDK [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) This detailed tutorial walks you through the process of creating a professional-grade video player application using Media Blocks SDK .Net. By following these instructions, you'll understand how to implement key functionalities including media loading, playback control, and audio-video rendering. ## Essential Components for Your Player Application To construct a fully functional video player, your application pipeline requires these critical building blocks: - [Universal source](../../Sources/) - This versatile component handles media input from various sources, allowing your player to read and process video files from local storage or network streams. - [Video renderer](../../VideoRendering/) - The visual component responsible for displaying video frames on screen with proper timing and formatting. - [Audio renderer](../../AudioRendering/) - Manages sound output, ensuring synchronized audio playback alongside your video content. ## Setting Up the Media Pipeline ### Creating the Foundation The first step in developing your player involves establishing the media pipeline—the core framework that manages data flow between components. ``` using VisioForge.Core.MediaBlocks; var pipeline = new MediaBlocksPipeline(); ``` ### Implementing Error Handling Robust error management is essential for a reliable player application. Subscribe to the pipeline's error events to capture and respond to exceptions. ``` pipeline.OnError += (sender, args) => { Console.WriteLine(args.Message); // Additional error handling logic can be implemented here }; ``` ### Setting Up Event Listeners For complete control over your player's lifecycle, implement event handlers for critical state changes: ``` pipeline.OnStart += (sender, args) => { // Execute code when pipeline starts Console.WriteLine("Playback started"); }; pipeline.OnStop += (sender, args) => { // Execute code when pipeline stops Console.WriteLine("Playback stopped"); }; ``` ## Configuring Media Blocks ### Initializing the Source Block The Universal Source Block serves as the entry point for media content. Configure it with the path to your media file: ``` var sourceSettings = await UniversalSourceSettings.CreateAsync(filePath); var fileSource = new UniversalSourceBlock(sourceSettings); ``` During initialization, the SDK automatically analyzes the file to extract crucial metadata about video and audio streams, enabling proper configuration of downstream components. ### Setting Up Video Display To render video content on screen, create and configure a Video Renderer Block: ``` var videoRenderer = new VideoRendererBlock(_pipeline, VideoView1); ``` The renderer requires two parameters: a reference to your pipeline and the UI control where video frames will be displayed. ### Configuring Audio Output For audio playback, you'll need to select and initialize an appropriate audio output device: ``` var audioRenderers = await DeviceEnumerator.Shared.AudioOutputsAsync(); var audioRenderer = new AudioRendererBlock(audioRenderers[0]); ``` This code retrieves available audio output devices and configures the first available option for playback. ## Establishing Component Connections Once all blocks are configured, you must establish connections between them to create a cohesive media flow: ``` pipeline.Connect(fileSource.VideoOutput, videoRenderer.Input); pipeline.Connect(fileSource.AudioOutput, audioRenderer.Input); ``` These connections define the path data takes through your application: - Video data flows from the source to the video renderer - Audio data flows from the source to the audio renderer For files containing only video or audio, you can selectively connect only the relevant outputs. ### Validating Media Content Before playback, you can inspect available streams using the Universal Source Settings: ``` var mediaInfo = await sourceSettings.ReadInfoAsync(); bool hasVideo = mediaInfo.VideoStreams.Count > 0; bool hasAudio = mediaInfo.AudioStreams.Count > 0; ``` ## Controlling Media Playback ### Starting Playback To begin media playback, call the pipeline's asynchronous start method: ``` await pipeline.StartAsync(); ``` Once executed, your application will begin rendering video frames and playing audio through the configured outputs. ### Managing Playback State To halt playback, invoke the pipeline's stop method: ``` await pipeline.StopAsync(); ``` This gracefully terminates all media processing and releases associated resources. ## Advanced Implementation For a complete implementation example with additional features like seeking, volume control, and full-screen support, refer to our comprehensive source code on [GitHub](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK/WPF/CSharp/Simple%20Player%20Demo%20WPF). The repository contains working demonstrations for various platforms including WPF, Windows Forms, and cross-platform .NET applications. ## See Also - [C# Video Player (WinForms / WPF)](../../../mediaplayer/guides/video-player-csharp/) — the Media Player SDK alternative with one-line setup for Windows desktop apps - [Avalonia Cross-Platform Player](../../../mediaplayer/guides/avalonia-player/) — the same pipeline approach for Windows, macOS, and Linux desktop targets - [.NET MAUI Player](../../../mediaplayer/guides/maui-player/) — mobile + desktop from one codebase (iOS, Android, macOS, Windows) ---END OF PAGE--- ## Write Audio Metadata Tags in C# .NET - ID3, Vorbis **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/audio-metadata-tags/ **Description:** Add ID3, Vorbis Comments, and MP4 metadata to audio files using VisioForge Media Blocks SDK. Code examples for MP3, OGG, M4A, and WMA tagging. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, GStreamer, Encoding, Metadata, MP4, WMV, OGG, AAC, MP3, Vorbis, WMA, C# **API:** MediaFileTags, MP3OutputBlock, OGGVorbisOutputBlock, M4AOutputBlock, WMVOutputBlock, MediaBlocksPipeline, SystemAudioSourceBlock # Write Audio Tags with Media Blocks SDK [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Table of Contents - [Write Audio Tags with Media Blocks SDK](#write-audio-tags-with-media-blocks-sdk) - [Table of Contents](#table-of-contents) - [Overview](#overview) - [Core Features](#core-features) - [Supported Audio Formats](#supported-audio-formats) - [Prerequisites](#prerequisites) - [MediaFileTags: The Unified Interface](#mediafiletags-the-unified-interface) - [Code Examples by Format](#code-examples-by-format) - [MP3 Output with ID3 Tags](#mp3-output-with-id3-tags) - [OGG Vorbis Output with Vorbis Comments](#ogg-vorbis-output-with-vorbis-comments) - [M4A Output with MP4 Metadata](#m4a-output-with-mp4-metadata) - [WMV/WMA Output with ASF Metadata](#wmvwma-output-with-asf-metadata) - [Complete Audio Recording Example](#complete-audio-recording-example) - [Advanced Tag Scenarios](#advanced-tag-scenarios) - [Album Artwork Support](#album-artwork-support) - [Runtime Tag Modification](#runtime-tag-modification) - [Multi-Track Albums](#multi-track-albums) - [Best Practices](#best-practices) - [Tag Data Quality](#tag-data-quality) - [Performance Considerations](#performance-considerations) - [Format-Specific Guidelines](#format-specific-guidelines) - [Troubleshooting](#troubleshooting) - [Common Issues and Solutions](#common-issues-and-solutions) - [Debug Tag Writing](#debug-tag-writing) - [Tag Format Specifications](#tag-format-specifications) - [ID3 Tags (MP3)](#id3-tags-mp3) - [Vorbis Comments (OGG)](#vorbis-comments-ogg) - [MP4 Metadata (M4A)](#mp4-metadata-m4a) - [ASF Attributes (WMV/WMA)](#asf-attributes-wmvwma) ## Overview The VisioForge Media Blocks SDK supports writing audio metadata tags to output files across all major audio formats. Whether you're building a music production application, podcast recorder, or audio content management system, you can embed rich metadata into your audio files using a unified programming interface. This guide demonstrates how to add metadata tags like artist, album, title, year, genre, and more to MP3, OGG Vorbis, M4A, and WMV/WMA audio files using format-appropriate tagging mechanisms while maintaining industry standards compliance. ## Core Features - **Universal tag support**: Write metadata to MP3 (ID3), OGG (Vorbis Comments), M4A (MP4 atoms), and WMV (ASF attributes) - **Comprehensive metadata**: 20+ tag fields including title, artist, album, year, track numbers, lyrics, and album artwork - **Standards compliant**: Uses native container tag mechanisms for optimal compatibility - **Unified API**: Single `MediaFileTags` instance works across all output formats - **Runtime flexibility**: Modify tags before pipeline execution ## Supported Audio Formats | Format | Container | Tag System | Standards | | --- | --- | --- | --- | | **MP3** | MPEG-1 Layer 3 | ID3v1/ID3v2 | ISO/IEC 11172-3, ID3v2.4 | | **OGG Vorbis** | OGG | Vorbis Comments | Xiph.Org specification | | **M4A** | MP4/MPEG-4 | MP4 metadata atoms | ISO Base Media File Format | | **WMV/WMA** | ASF | ASF metadata attributes | Microsoft ASF specification | ## Prerequisites - VisioForge Media Blocks SDK .NET - .NET Framework 4.7.2+ or .NET Core 3.1+ or .NET 5+ - Basic understanding of audio processing pipelines ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Outputs; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.Types; using VisioForge.Core.Types.X.AudioEncoders; using VisioForge.Core.Types.X.Sources; ``` ## MediaFileTags: The Unified Interface The `MediaFileTags` class provides a unified interface for audio metadata across all supported formats. It contains common metadata fields and is mapped to the appropriate tag format for each output container by the specific output block. ``` // Create audio metadata var audioTags = new MediaFileTags { // Basic metadata Title = "Bohemian Rhapsody", Performers = new[] { "Queen" }, Album = "A Night at the Opera", Year = 1975, // Track information Track = 11, TrackCount = 12, Disc = 1, DiscCount = 1, // Genre and categorization Genres = new[] { "Progressive Rock", "Opera Rock" }, // Extended metadata Composers = new[] { "Freddie Mercury" }, Conductor = "Roy Thomas Baker", Comment = "6-minute epic masterpiece", Copyright = "© 1975 Queen Productions Ltd.", // Technical metadata BeatsPerMinute = 72, Grouping = "Epic Songs", // Lyrics (for supported formats) Lyrics = @"Is this the real life? Is this just fantasy? Caught in a landslide No escape from reality..." }; ``` All string-array fields (`Performers`, `Composers`, `Genres`, `AlbumArtists`) accept multiple values and are written as repeated frames on formats that support them (Vorbis Comments, ID3v2). Numeric fields (`Year`, `Track`, `TrackCount`, `Disc`, `DiscCount`, `BeatsPerMinute`) are `uint`. ## Code Examples by Format ### MP3 Output with ID3 Tags MP3 files use ID3 tags (both v1 and v2) for metadata storage. `MP3OutputBlock` writes standards-compliant ID3 tags via the GStreamer `id3mux` element. ``` public async Task CreateMP3WithTags() { // Configure MP3 encoder settings var mp3Settings = new MP3EncoderSettings { Bitrate = 320, // Kbit/s RateControl = MP3EncoderRateControl.CBR // CBR / ABR / VBR }; // Create metadata tags var tags = new MediaFileTags { Title = "Summer Vibes", Performers = new[] { "Indie Artist" }, Album = "Seasonal Collection", Year = 2025, Track = 3, TrackCount = 10, Genres = new[] { "Indie Pop", "Electronic" }, Comment = "Recorded in home studio", Copyright = "© 2025 Independent Label" }; // Create MP3 output block with tags var mp3Output = new MP3OutputBlock("output.mp3", mp3Settings, tags); // Alternative: set tags after creation via the Tags property // var mp3Output = new MP3OutputBlock("output.mp3", mp3Settings); // mp3Output.Tags = tags; // Build the pipeline var pipeline = new MediaBlocksPipeline(); // Add an audio source (microphone, file, etc.) var audioSource = new SystemAudioSourceBlock(); // Connect source directly to MP3 output pipeline.Connect(audioSource.Output, mp3Output.Input); // Start recording with metadata await pipeline.StartAsync(); // Recording writes ID3 tags into the MP3 file await Task.Delay(TimeSpan.FromSeconds(30)); await pipeline.StopAsync(); } ``` ### OGG Vorbis Output with Vorbis Comments OGG Vorbis files use Vorbis Comments for metadata, which are embedded directly in the audio stream by the Vorbis encoder. ``` public async Task CreateOGGWithTags() { // Configure Vorbis encoder settings. // Quality is int in the range [-1..10] (default 4). Used when RateControl = Quality. var vorbisSettings = new VorbisEncoderSettings { Quality = 8, RateControl = VorbisEncoderRateControl.Quality }; // Create metadata var tags = new MediaFileTags { Title = "Acoustic Session", Performers = new[] { "Folk Artist", "Guest Vocalist" }, AlbumArtists = new[] { "Folk Artist" }, Album = "Live Sessions", Year = 2025, Track = 1, Genres = new[] { "Folk", "Acoustic" }, Composers = new[] { "Folk Artist", "Traditional" }, Comment = "Recorded live at Studio A", Conductor = "Sound Engineer", Grouping = "Live Recordings", Lyrics = @"In the quiet of the morning When the world begins to wake There's a song within the silence..." }; // Create OGG output block with Vorbis comments var oggOutput = new OGGVorbisOutputBlock("output.ogg", vorbisSettings, tags); // Build and execute the pipeline var pipeline = new MediaBlocksPipeline(); // Use UniversalSourceBlock to decode any file format into raw audio var sourceSettings = await UniversalSourceSettings.CreateAsync("input.wav"); var fileSource = new UniversalSourceBlock(sourceSettings); pipeline.Connect(fileSource.AudioOutput, oggOutput.Input); await pipeline.StartAsync(); await pipeline.WaitForStopAsync(); // Wait for EOS } ``` ### M4A Output with MP4 Metadata M4A files use MP4 metadata atoms, compatible with iTunes and most media players. The default `M4AOutputBlock` ctor picks a default AAC encoder; use the 3-arg overload to pick a specific AAC implementation (`AVENCAACEncoderSettings`, `VOAACEncoderSettings`, or `MFAACEncoderSettings` on Windows). ``` public async Task CreateM4AWithTags() { // Create podcast metadata var tags = new MediaFileTags { Title = "Episode 42: The Future of AI", Performers = new[] { "Tech Podcast Host" }, Album = "Weekly Tech Talk", Year = 2025, Track = 42, Genres = new[] { "Technology", "Podcast" }, Comment = "Special guest interview with AI researcher", Copyright = "© 2025 Tech Media Network", Subtitle = "Exploring artificial intelligence trends", Grouping = "Season 3" }; // Option A: simplest — default AAC encoder picked internally var m4aOutput = new M4AOutputBlock("podcast_episode_42.m4a", tags); // Option B: pick a specific AAC encoder and sink settings // var sinkSettings = new MP4SinkSettings("podcast_episode_42.m4a"); // var aacSettings = new AVENCAACEncoderSettings { Bitrate = 256 }; // 256 Kbit/s // var m4aOutput = new M4AOutputBlock(sinkSettings, aacSettings, tags); // Pipeline setup for podcast recording var pipeline = new MediaBlocksPipeline(); var micSource = new SystemAudioSourceBlock(); pipeline.Connect(micSource.Output, m4aOutput.Input); await pipeline.StartAsync(); } ``` ### WMV/WMA Output with ASF Metadata Windows Media formats use ASF (Advanced Systems Format) metadata attributes. `WMVOutputBlock` accepts a `MediaFileTags` parameter and handles both audio-only and audio+video outputs. ``` public async Task CreateWMVWithTags() { // Create presentation metadata var tags = new MediaFileTags { Title = "Q4 Business Review", Performers = new[] { "CEO", "CFO", "VP Sales" }, Album = "Corporate Presentations 2025", Year = 2025, Genres = new[] { "Business", "Corporate" }, Comment = "Quarterly financial review and outlook", Copyright = "© 2025 Business Corp. Confidential", Conductor = "Meeting Organizer", Grouping = "Executive Presentations" }; // Simplest form — default encoders, just filename + tags. // WMVOutputBlock will use the default WMV/WMA encoder settings internally. var wmvOutput = new WMVOutputBlock("presentation.wmv", tags); // Alternative: pass explicit sink/video/audio settings objects // var asfSettings = new ASFSinkSettings("presentation.wmv"); // var wmvSettings = WMVEncoderBlock.GetDefaultSettings(); // var wmaSettings = WMAEncoderBlock.GetDefaultSettings(); // var wmvOutput = new WMVOutputBlock(asfSettings, wmvSettings, wmaSettings, tags); // Setup for video + audio recording var pipeline = new MediaBlocksPipeline(); // Video source — pick the first available device var videoDevice = (await DeviceEnumerator.Shared.VideoSourcesAsync())[0]; var videoSource = new SystemVideoSourceBlock(new VideoCaptureDeviceSourceSettings(videoDevice)); // Audio source var audioSource = new SystemAudioSourceBlock(); // Create dynamic input pads on the WMV output var videoPad = wmvOutput.CreateNewInput(MediaBlockPadMediaType.Video); var audioPad = wmvOutput.CreateNewInput(MediaBlockPadMediaType.Audio); pipeline.Connect(videoSource.Output, videoPad); pipeline.Connect(audioSource.Output, audioPad); await pipeline.StartAsync(); } ``` ## Complete Audio Recording Example Record the same audio source to multiple tagged output formats simultaneously: ``` public class AudioRecorderWithTags { public async Task RecordAudioWithMetadata() { // Rich metadata shared across every output file var sessionTags = new MediaFileTags { Title = "Studio Session #1", Performers = new[] { "John Doe", "Jane Smith" }, Album = "Demo Recordings", Year = 2025, Track = 1, Genres = new[] { "Rock", "Alternative" }, Composers = new[] { "John Doe" }, Comment = "First studio recording session", Copyright = "© 2025 Demo Productions", BeatsPerMinute = 120, Grouping = "Demo Sessions" }; // MP3 output (CBR 320 Kbit/s + ID3 tags) var mp3Output = new MP3OutputBlock( "session1.mp3", new MP3EncoderSettings { Bitrate = 320, RateControl = MP3EncoderRateControl.CBR }, sessionTags); // OGG Vorbis output (highest quality + Vorbis Comments) var oggOutput = new OGGVorbisOutputBlock( "session1.ogg", new VorbisEncoderSettings { Quality = 10, RateControl = VorbisEncoderRateControl.Quality }, sessionTags); // M4A output (default AAC + MP4 atoms) var m4aOutput = new M4AOutputBlock("session1.m4a", sessionTags); // Pipeline with a single audio source fanned out to all three files var pipeline = new MediaBlocksPipeline(); var audioSource = new SystemAudioSourceBlock(); // Connecting the same source pad to multiple sinks auto-inserts a tee pipeline.Connect(audioSource.Output, mp3Output.Input); pipeline.Connect(audioSource.Output, oggOutput.Input); pipeline.Connect(audioSource.Output, m4aOutput.Input); Console.WriteLine("Starting recording with metadata..."); await pipeline.StartAsync(); await Task.Delay(TimeSpan.FromMinutes(3)); Console.WriteLine("Stopping recording..."); await pipeline.StopAsync(); Console.WriteLine("Recording complete — files written with metadata:"); Console.WriteLine("- session1.mp3 (ID3 tags)"); Console.WriteLine("- session1.ogg (Vorbis comments)"); Console.WriteLine("- session1.m4a (MP4 metadata)"); } } ``` ## Advanced Tag Scenarios ### Album Artwork Support Attach album artwork to supported formats (MP3, M4A, WMV). On Windows, `MediaFileTags.Pictures` accepts `System.Drawing.Bitmap[]`; cross-platform builds use `IBitmap[]`. ``` var tags = new MediaFileTags { Title = "Album Title Track", Performers = new[] { "Artist Name" }, Album = "Album Name" }; // Attach album artwork (Windows — System.Drawing) #if NET_WINDOWS if (File.Exists("album_cover.jpg")) { var albumArt = new System.Drawing.Bitmap("album_cover.jpg"); tags.Pictures = new[] { albumArt }; tags.Pictures_Descriptions = new[] { "Front Cover" }; } #endif var mp3Output = new MP3OutputBlock( "track.mp3", new MP3EncoderSettings { Bitrate = 320, RateControl = MP3EncoderRateControl.CBR }, tags); ``` ### Runtime Tag Modification Set or modify tags before starting the pipeline — once a pipeline has started, the tag payload for that output is already being emitted. ``` var mp3Settings = new MP3EncoderSettings { Bitrate = 320, RateControl = MP3EncoderRateControl.CBR }; var mp3Output = new MP3OutputBlock("output.mp3", mp3Settings); // Assign tags via the Tags property before StartAsync mp3Output.Tags = new MediaFileTags { Title = "Live Recording", Performers = new[] { "Artist" } }; // Tweak fields right up until start mp3Output.Tags.Comment = $"Recorded on {DateTime.Now:yyyy-MM-dd}"; mp3Output.Tags.Year = (uint)DateTime.Now.Year; await pipeline.StartAsync(); ``` ### Multi-Track Albums Create consistent metadata across album tracks by using a shared base tag object: ``` public class AlbumRecorder { private readonly MediaFileTags _baseAlbumTags; private readonly MP3EncoderSettings _mp3Settings = new MP3EncoderSettings { Bitrate = 320, RateControl = MP3EncoderRateControl.CBR }; public AlbumRecorder() { _baseAlbumTags = new MediaFileTags { Album = "My Album", AlbumArtists = new[] { "Main Artist" }, Year = 2025, Genres = new[] { "Pop", "Electronic" }, TrackCount = 12, Copyright = "© 2025 Record Label" }; } public MP3OutputBlock CreateTrackOutput(int trackNumber, string title, string[] performers) { var trackTags = new MediaFileTags { // Inherit album-level metadata Album = _baseAlbumTags.Album, AlbumArtists = _baseAlbumTags.AlbumArtists, Year = _baseAlbumTags.Year, Genres = _baseAlbumTags.Genres, TrackCount = _baseAlbumTags.TrackCount, Copyright = _baseAlbumTags.Copyright, // Track-specific metadata Track = (uint)trackNumber, Title = title, Performers = performers }; return new MP3OutputBlock($"track_{trackNumber:D2}.mp3", _mp3Settings, trackTags); } } ``` ## Best Practices ### Tag Data Quality - **Consistent encoding**: Use UTF-8 encoding for international characters - **Complete information**: Fill in as many relevant tag fields as possible - **Standardized genres**: Use recognized genre names for better compatibility - **Proper copyright**: Include appropriate copyright notices ### Performance Considerations - **Tag size**: Keep text fields reasonable in length to avoid bloating files - **Image compression**: Compress album artwork appropriately (JPEG recommended) - **Reuse instances**: When creating multiple files, share base tag objects and only override per-track fields ### Format-Specific Guidelines ``` // MP3: ID3v2 supports extensive metadata var mp3Tags = new MediaFileTags { Title = "Song Title", Subtitle = "Song Subtitle", // ID3v2 TIT3 frame Lyrics = "Full lyrics text", // USLT frame BeatsPerMinute = 128 // TBPM frame }; // OGG: Vorbis comments are flexible and handle multi-value fields natively var oggTags = new MediaFileTags { Composers = new[] { "Composer 1", "Composer 2" }, Performers = new[] { "Artist 1", "Artist 2" } }; // M4A: iTunes-compatible metadata var m4aTagsForPodcast = new MediaFileTags { Title = "Episode Title", Album = "Podcast Series Name", // Shows as "Album" in iTunes Performers = new[] { "Host Name" }, // Shows as "Artist" Genres = new[] { "Podcast" }, Comment = "Episode description" }; ``` ## Troubleshooting ### Common Issues and Solutions **Tags not appearing in media players:** - Ensure the output format supports the specific tag fields you're using - Verify the media player supports the tag format (some players prefer ID3v2.3 over ID3v2.4) - Check that text encoding is correct (UTF-8 recommended) **File size unexpectedly large:** - Reduce album artwork resolution (600×600 is usually enough) - Avoid extremely long text fields in comments or lyrics - Use appropriate image compression for artwork **Encoding errors:** - Validate that special characters are properly encoded - Ensure file paths are accessible and writable - Check that encoder settings are compatible with your system ### Debug Tag Writing Subscribe to the pipeline's `OnError` event to see encoder/muxer failures during tag writing. There is no "tag messages only" stream — inspect the produced file with a tag reader (TagLib, MediaInfo, or the SDK's own `MediaInfoReader`) to confirm what was written. ``` var pipeline = new MediaBlocksPipeline(); pipeline.OnError += (sender, e) => { Console.WriteLine($"Pipeline error: {e.Message}"); }; // Continue with pipeline setup... ``` ## Tag Format Specifications ### ID3 Tags (MP3) - **ID3v1**: Basic 128-byte structure with limited fields - **ID3v2**: Extensible format supporting Unicode, multiple values, and custom frames - **Common frames**: TIT2 (Title), TPE1 (Artist), TALB (Album), TDRC (Year), TCON (Genre) ### Vorbis Comments (OGG) - **Format**: UTF-8 text in NAME=VALUE format - **Standard fields**: TITLE, ARTIST, ALBUM, DATE, GENRE, TRACKNUMBER - **Flexible**: Arbitrary field names and multiple values are allowed ### MP4 Metadata (M4A) - **Atoms**: iTunes-style metadata stored in MP4 atoms - **Common atoms**: ©nam (Title), ©ART (Artist), ©alb (Album), ©day (Year) - **Binary data**: Embedded artwork goes in the `covr` atom ### ASF Attributes (WMV/WMA) - **Structure**: Key-value pairs in the ASF header - **Standard attributes**: Title, Author, Copyright, Description - **Extended**: Custom attributes are supported --- This guide covers writing audio metadata tags with the VisioForge Media Blocks SDK. The unified `MediaFileTags` class simplifies the code while keeping each container's native tag format (ID3, Vorbis Comments, MP4 atoms, ASF) intact. For more advanced audio-processing scenarios, explore the complete [VisioForge Media Blocks SDK documentation](../../). ---END OF PAGE--- ## C# Barcode and QR Code Scanner from Live Video in .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/barcode-qr-reader-guide/ **Description:** Build a C# barcode scanner and QR code reader from live video using webcams, IP cameras, or RTSP streams with VisioForge Media Blocks SDK. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Streaming, Barcode / QR, Webcam, IP Camera, Screen Capture, RTSP, ONVIF, MP4, C#, Entitlements **API:** BarcodeDetectorBlock, MediaBlocksPipeline, InputOutput, BarcodeDetectorEventArgs, UniversalSourceBlock # How to Build a C# Barcode Scanner and QR Code Reader in .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Introduction Need to read barcodes or scan QR codes from a live camera feed in C#? Unlike image-only barcode libraries, VisioForge Media Blocks SDK scans barcodes directly from real-time video streams — [webcams](../../../videocapture/guides/save-webcam-video/), [IP cameras](../../../videocapture/video-sources/ip-cameras/), [RTSP sources](../../../general/network-streaming/rtsp/), video files, and screen capture. This makes it the ideal .NET barcode scanner SDK for surveillance, inventory, and automation applications that process live video. This guide walks you through building a cross-platform C# barcode reader and QR code scanner that runs on Windows, Android, iOS, macOS, and Linux using .NET MAUI, Avalonia, or WPF. ## Why Use Video-Based Barcode Scanning? ### Key Advantages over Image-Only Libraries - **Real-time video stream scanning**: Detect barcodes continuously from webcam, IP camera, or RTSP feeds — not just static images - **Cross-platform .NET support**: Single codebase for Windows, Android, iOS, macOS, and Linux with MAUI, Avalonia, WPF, WinForms, Blazor, and console apps - **Pipeline architecture**: Combine barcode detection with video preview, recording, and other processing in one pipeline - **Multiple input sources**: Scan from cameras, video files, screen capture, or [network streams](../../../general/network-streaming/rtsp/) - **Comprehensive format support**: QR codes, DataMatrix, Code128, Code39, EAN-13, UPC-A, PDF417, Aztec, and many other 1D/2D barcode formats - **Event-driven API**: Simple `OnBarcodeDetected` event delivers barcode type, value, and timestamp ## Supported Barcode and QR Code Formats The C# barcode scanner supports a wide range of 1D and 2D barcode formats: ### 2D Barcodes - **QR Code**: Most popular 2D barcode format, widely used in mobile applications - **DataMatrix**: Compact format ideal for small items - **PDF417**: Used in driver's licenses and boarding passes - **Aztec**: Compact format used in transportation tickets ### 1D Barcodes - **Code 128**: High-density format for alphanumeric data - **Code 39**: Simple alphanumeric format - **EAN-13/EAN-8**: European Article Number for retail products - **UPC-A/UPC-E**: Universal Product Code for retail - **Codabar**: Used in libraries and blood banks - **ITF**: Interleaved 2 of 5 for shipping and distribution ## Barcode Scanner Pipeline Architecture The Media Blocks SDK uses a pipeline-based architecture where video frames flow through connected blocks for real-time barcode detection: ``` graph LR; A[Video Source] --> B[Barcode Detector]; B --> C[Video Renderer]; B -- Detection Event --> D[Type + Value]; ``` This modular approach allows you to: - Easily swap input sources (camera, file, stream) - Add additional processing blocks (filters, encoders) - Route output to multiple destinations simultaneously ## How to Read Barcodes from Camera in C Build a barcode scanner that reads from a webcam or camera device in C# step by step. ### Step 1: Setting Up the Project First, ensure you have the necessary NuGet packages installed: ``` # For Windows applications dotnet add package VisioForge.CrossPlatform.Core.Windows.x64 dotnet add package VisioForge.CrossPlatform.Libav.Windows.x64 # For Android applications dotnet add package VisioForge.CrossPlatform.Core.Android # For iOS applications dotnet add package VisioForge.CrossPlatform.Core.iOS # For macOS applications dotnet add package VisioForge.CrossPlatform.Core.macCatalyst ``` Add the required namespaces to your code: ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.Special; using VisioForge.Core.MediaBlocks.VideoRendering; using VisioForge.Core.Types; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X; using VisioForge.Core.Types.X.Sources; ``` ### Step 2: Initializing the SDK Before using any SDK features, initialize the VisioForge engine: ``` // Initialize the SDK (required on first use) await VisioForgeX.InitSDKAsync(); ``` This initialization step builds the internal registry and prepares the engine. It only needs to be done once when your application starts. ### Step 3: Enumerating Video Sources Before capturing video, you need to discover available cameras: ``` // Start monitoring for video sources await DeviceEnumerator.Shared.StartVideoSourceMonitorAsync(); // Get list of available cameras var cameras = await DeviceEnumerator.Shared.VideoSourcesAsync(); // Display available cameras foreach (var camera in cameras) { Console.WriteLine($"Camera: {camera.DisplayName}"); // List supported formats foreach (var format in camera.VideoFormats) { Console.WriteLine($" Format: {format.Name}"); } } ``` ### Step 4: Creating the Pipeline Create a pipeline and configure the necessary blocks: ``` // Create the pipeline var pipeline = new MediaBlocksPipeline(); pipeline.OnError += Pipeline_OnError; // Configure video source var device = cameras.First(); var formatItem = device.GetHDOrAnyVideoFormatAndFrameRate(out var frameRate); var videoSourceSettings = new VideoCaptureDeviceSourceSettings(device) { Format = formatItem.ToFormat() }; videoSourceSettings.Format.FrameRate = frameRate; // Create video source block var videoSource = new SystemVideoSourceBlock(videoSourceSettings); // Create barcode detector block var barcodeDetector = new BarcodeDetectorBlock(BarcodeDetectorMode.InputOutput); barcodeDetector.OnBarcodeDetected += BarcodeDetector_OnBarcodeDetected; // Create video renderer block (for preview) var videoRenderer = new VideoRendererBlock(pipeline, videoView); // Connect the blocks pipeline.Connect(videoSource.Output, barcodeDetector.Input); pipeline.Connect(barcodeDetector.Output, videoRenderer.Input); ``` ### Step 5: Handling Barcode Detection Events Implement the event handler to process detected barcodes: ``` private void BarcodeDetector_OnBarcodeDetected(object sender, BarcodeDetectorEventArgs e) { // This event is called when a barcode is detected Console.WriteLine($"Detected: {e.BarcodeType} = {e.Value}"); // Update UI (use dispatcher for thread safety) Dispatcher.Invoke(() => { BarcodeTypeLabel.Text = e.BarcodeType; BarcodeValueLabel.Text = e.Value; LastDetectionTime.Text = DateTime.Now.ToString("HH:mm:ss.fff"); }); } ``` ### Step 6: Starting and Stopping the Pipeline Control the pipeline lifecycle: ``` // Start scanning await pipeline.StartAsync(); // Stop scanning await pipeline.StopAsync(); // Pause scanning await pipeline.PauseAsync(); // Resume scanning await pipeline.ResumeAsync(); ``` ### Step 7: Cleanup Properly dispose of resources when done: ``` // Remove event handlers barcodeDetector.OnBarcodeDetected -= BarcodeDetector_OnBarcodeDetected; pipeline.OnError -= Pipeline_OnError; // Stop and cleanup await pipeline.StopAsync(); pipeline.ClearBlocks(); pipeline.Dispose(); // Destroy SDK (on application exit) VisioForgeX.DestroySDK(); ``` ## Advanced Barcode Reading Features ### Duplicate Detection Prevention To prevent multiple detections of the same barcode: ``` private Dictionary _recentDetections = new(); private TimeSpan _deduplicationWindow = TimeSpan.FromSeconds(2); private void BarcodeDetector_OnBarcodeDetected(object sender, BarcodeDetectorEventArgs e) { string key = $"{e.BarcodeType}:{e.Value}"; // Check if this barcode was recently detected if (_recentDetections.TryGetValue(key, out var lastTime)) { if (DateTime.Now - lastTime < _deduplicationWindow) { return; // Skip duplicate } } // Record this detection _recentDetections[key] = DateTime.Now; // Process the barcode ProcessBarcode(e.BarcodeType, e.Value); } ``` ### Scan Barcodes from Video Files, Screen Capture, and RTSP Streams The SDK supports various input sources beyond local cameras: #### Read Barcodes from Video File ``` var fileSettings = await UniversalSourceSettings.CreateAsync( @"C:\Videos\barcode-video.mp4"); var fileSource = new UniversalSourceBlock(fileSettings); pipeline.Connect(fileSource.VideoOutput, barcodeDetector.Input); ``` #### Scan Barcodes from Screen Capture ``` // ScreenSourceBlock takes an IScreenCaptureSourceSettings — on Windows // use ScreenCaptureD3D11SourceSettings (Windows 8+). MonitorIndex selects the monitor. var screenSource = new ScreenSourceBlock( new ScreenCaptureD3D11SourceSettings { MonitorIndex = 0, // Primary monitor FrameRate = new VideoFrameRate(10), // 10 FPS CaptureCursor = false }); pipeline.Connect(screenSource.Output, barcodeDetector.Input); ``` #### Scan Barcodes from RTSP IP Camera Stream ``` var streamSettings = await UniversalSourceSettings.CreateAsync( "rtsp://camera-ip:554/stream"); var streamSource = new UniversalSourceBlock(streamSettings); pipeline.Connect(streamSource.VideoOutput, barcodeDetector.Input); ``` ### Detection History Tracking Maintain a history of detected barcodes: ``` public class BarcodeDetection { public string Type { get; set; } public string Value { get; set; } public DateTime Timestamp { get; set; } } private ObservableCollection _detectionHistory = new(); private int _maxHistorySize = 100; private void BarcodeDetector_OnBarcodeDetected(object sender, BarcodeDetectorEventArgs e) { var detection = new BarcodeDetection { Type = e.BarcodeType, Value = e.Value, Timestamp = DateTime.Now }; // Add to beginning of list _detectionHistory.Insert(0, detection); // Maintain maximum size while (_detectionHistory.Count > _maxHistorySize) { _detectionHistory.RemoveAt(_detectionHistory.Count - 1); } } ``` ### Error Handling Implement robust error handling: ``` private void Pipeline_OnError(object sender, ErrorsEventArgs e) { Debug.WriteLine($"Pipeline Error: {e.Message}"); // Show user-friendly message Dispatcher.Invoke(() => { mmLog.Text += e.Message + Environment.NewLine; }); } ``` ## Platform Setup: Android, iOS, and macOS Barcode Scanning ### Android Camera Permissions On Android, you must request camera permissions before scanning barcodes: ``` private async Task RequestCameraPermissionAsync() { var status = await Permissions.CheckStatusAsync(); if (status != PermissionStatus.Granted) { status = await Permissions.RequestAsync(); } return status == PermissionStatus.Granted; } ``` Add to AndroidManifest.xml: ``` ``` ### iOS Camera Permissions Add to Info.plist: ``` NSCameraUsageDescription This app needs camera access to scan barcodes and QR codes ``` ### macOS Camera Permissions For macOS and Mac Catalyst, add to Entitlements.plist: ``` com.apple.security.device.camera ``` ## Optimizing Barcode Scanner Performance in .NET ### Frame Rate Optimization Balance barcode detection speed and CPU usage: ``` // Lower frame rate for better performance videoSourceSettings.Format.FrameRate = new VideoFrameRate(15); // 15 FPS instead of 30 // For screen capture, use even lower frame rates screenSourceSettings.FrameRate = new VideoFrameRate(5); // 5 FPS ``` ### Resolution Considerations Lower resolution can improve performance without significantly affecting detection: ``` // Choose a lower resolution format var format = device.VideoFormats .Where(f => f.Width <= 1280 && f.Height <= 720) .OrderByDescending(f => f.Width * f.Height) .FirstOrDefault(); ``` ### Detector Mode Selection The `BarcodeDetectorBlock` supports different modes: ``` // InputOutput mode: Passes video through for preview (default) var detector = new BarcodeDetectorBlock(BarcodeDetectorMode.InputOutput); // InputOnly mode: No video output, better performance var detector = new BarcodeDetectorBlock(BarcodeDetectorMode.InputOnly); ``` ## Barcode Scanner for .NET MAUI, Avalonia, and WPF ### .NET MAUI Barcode Scanner ``` public partial class MainPage : ContentPage { private MediaBlocksPipeline _pipeline; private BarcodeDetectorBlock _barcodeDetector; public MainPage() { InitializeComponent(); Loaded += MainPage_Loaded; } private async void MainPage_Loaded(object sender, EventArgs e) { await VisioForgeX.InitSDKAsync(); #if __ANDROID__ || __IOS__ || __MACCATALYST__ await RequestCameraPermissionAsync(); #endif _pipeline = new MediaBlocksPipeline(); // ... setup pipeline } } ``` ### Avalonia Barcode Scanner ``` public partial class MainWindow : Window { private MediaBlocksPipeline _pipeline; private BarcodeDetectorBlock _barcodeDetector; public MainWindow() { InitializeComponent(); Loaded += MainWindow_Loaded; } private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { await VisioForgeX.InitSDKAsync(); _pipeline = new MediaBlocksPipeline(); // ... setup pipeline } } ``` ## Barcode Scanner Use Cases: Inventory, Ticketing, and Payments ### Inventory Management with Barcode Scanning Track products in warehouses using barcode scanning: ``` private async void ProcessInventoryBarcode(string barcodeValue) { // Look up product in database var product = await _database.GetProductByBarcodeAsync(barcodeValue); if (product != null) { // Update inventory count product.Quantity++; await _database.SaveChangesAsync(); // Show confirmation StatusLabel.Text = $"Added: {product.Name}"; } else { StatusLabel.Text = "Product not found"; } } ``` ### QR Code Ticket Scanning for Events Scan QR code tickets at event entrances: ``` private async void ProcessTicketBarcode(string ticketCode) { var ticket = await _ticketService.ValidateTicketAsync(ticketCode); if (ticket.IsValid && !ticket.IsUsed) { await _ticketService.MarkAsUsedAsync(ticketCode); PlaySuccessSound(); ShowGreenLight(); } else { PlayErrorSound(); ShowRedLight(); StatusLabel.Text = ticket.IsUsed ? "Already used" : "Invalid ticket"; } } ``` ### QR Code Payment Processing Scan QR codes for mobile payments: ``` private async void ProcessPaymentQRCode(string qrData) { if (IsPaymentQRCode(qrData)) { var paymentInfo = ParsePaymentData(qrData); // Show payment confirmation dialog var result = await DisplayAlert( "Confirm Payment", $"Pay ${paymentInfo.Amount} to {paymentInfo.Recipient}?", "Pay", "Cancel"); if (result) { await ProcessPaymentAsync(paymentInfo); } } } ``` ## Troubleshooting C# Barcode Scanner Issues ### Issue: No Barcodes Detected **Solutions:** 1. Ensure adequate lighting - barcodes need clear visibility 2. Check camera focus - some cameras need time to focus 3. Verify barcode is within camera field of view 4. Try adjusting camera distance (15-30cm typically optimal) 5. Check that the barcode format is supported ### Issue: Multiple Detections of Same Barcode **Solution:** Implement duplicate detection prevention (shown earlier) ### Issue: Poor Performance **Solutions:** 1. Lower video resolution 2. Reduce frame rate 3. Use `BarcodeDetectorMode.InputOnly` if preview isn't needed 4. Close other applications to free system resources ### Issue: Camera Not Found **Solutions:** 1. Verify camera permissions are granted 2. Check that camera is not in use by another application 3. Restart the device 4. Try enumerating devices after a short delay ## Best Practices 1. **Always Initialize SDK Early**: Call `InitSDKAsync()` during application startup 2. **Request Permissions First**: Check and request camera permissions before accessing camera 3. **Handle Errors Gracefully**: Implement proper error handling for all pipeline operations 4. **Dispose Resources Properly**: Always clean up pipeline and blocks when done 5. **Test on Target Devices**: Performance varies by device - test on actual hardware 6. **Provide Visual Feedback**: Show users when barcodes are detected successfully 7. **Consider Offline Scenarios**: Cache necessary data for offline barcode processing 8. **Implement Logging**: Log detection events for debugging and analytics ## Sample Projects Complete sample projects are available in the SDK: - **WPF Barcode Detection**: [Barcode Detection WPF Demo](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK/WPF/CSharp/Barcode%20Detection%20Demo) - **WPF DataMatrix Detection**: [DataMatrix Detection WPF Demo](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK/WPF/CSharp/DataMatrix%20Detection%20Demo) These samples demonstrate: - Complete UI implementation - Camera selection and configuration - Real-time barcode detection - Detection history tracking - Error handling - Cross-platform compatibility ## Frequently Asked Questions ### What barcode formats can I scan from a camera in C#? The SDK supports all major 1D and 2D barcode formats including QR Code, DataMatrix, PDF417, Aztec, Code 128, Code 39, EAN-13, EAN-8, UPC-A, UPC-E, Codabar, and ITF. All formats can be scanned in real time from any video source — webcam, IP camera, RTSP stream, or video file. ### Can I scan QR codes from an IP camera or RTSP stream? Yes. Use `UniversalSourceBlock` with an RTSP URI to connect to any IP camera and scan barcodes from the live video stream. The pipeline handles decoding, buffering, and frame delivery automatically. See the [RTSP streaming guide](../../../general/network-streaming/rtsp/) for connection details. ### Does the barcode scanner work on Android, iOS, and macOS? Yes. The `BarcodeDetectorBlock` is fully cross-platform. .NET MAUI apps run on Android and iOS; Avalonia apps run on macOS and Linux. Each platform requires camera permissions — see the [Platform Setup](#platform-setup-android-ios-and-macos-barcode-scanning) section for details. ### How do I prevent duplicate barcode detections? Implement a time-based deduplication window. Store each detected barcode value with a timestamp and skip detections that match a recent entry within a configurable interval (typically 2 seconds). See the [Duplicate Detection Prevention](#duplicate-detection-prevention) code example above. ### What frame rate do I need for reliable barcode scanning? For most use cases, 10–15 FPS provides reliable detection with low CPU usage. Static barcodes (warehouse labels, product shelves) work well at 5 FPS. Fast-moving barcodes on a conveyor belt may need 25–30 FPS. Use the lowest frame rate that gives reliable results to minimize resource consumption. ## See Also - [Webcam Video Capture in C#](../../../videocapture/guides/save-webcam-video/) — capture and record webcam video using the same SDK - [RTSP Streaming and IP Camera Capture](../../../general/network-streaming/rtsp/) — connect to IP cameras for barcode scanning from network streams - [IP Camera Sources](../../../videocapture/video-sources/ip-cameras/) — configure ONVIF and RTSP camera sources - [Pre-Event Recording](../pre-event-recording/) — combine barcode detection with motion-triggered recording - [Special Blocks Reference](../../Special/) — BarcodeDetectorBlock API reference - [Getting Started with Media Blocks](../../GettingStarted/) — pipeline fundamentals - [Platform-Specific Deployment](../../../deployment-x/) — native dependency packages for all platforms ---END OF PAGE--- ## Custom GStreamer MediaBlock Guide for C# .NET Pipelines **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/custom-mediablock-from-gstreamer-element/ **Description:** Wrap any GStreamer element as a MediaBlock in C# .NET using CustomMediaBlock or a typed subclass, with a videobalance grayscale example. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, GStreamer, Effects, Custom Block, C# **API:** MediaBlock, IMediaBlockInternals, CustomMediaBlock, CustomMediaBlockSettings, MediaBlockPad # Build your own MediaBlock from a GStreamer element in C# .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The Media Blocks SDK already ships 70+ typed blocks for common video, audio, encoding, and streaming tasks. Sometimes, though, you need a GStreamer element that the SDK does not wrap yet — a third-party plugin, an experimental element from `gst-plugins-bad`, or simply something you wrote yourself. This guide shows how to integrate any single GStreamer element into a `MediaBlocksPipeline` as a first-class block. Why grayscale? The worked example wraps `videobalance` with `saturation = 0` to convert video to grayscale. **The SDK already ships `GrayscaleBlock` and `VideoBalanceBlock`** built on the same element — you don't need to re-create them in production code. We use grayscale because it is the smallest possible example that exercises the full pattern: one element, one property, sink/src pads. Once you understand it, you can wrap any GStreamer element the same way. ## Two approaches | Approach | When to use it | | --- | --- | | **A.** Use the built-in `CustomMediaBlock` — pass the element name and properties as data. | One-off use, prototyping, or wrapping any element from anywhere in the call chain. No subclassing, no new types. | | **B.** Write a typed `MediaBlock` subclass. | You want a reusable, strongly typed block with a static `IsAvailable()` check, a settings class, IntelliSense, and the same feel as built-in blocks. | Both approaches share the same idea: a MediaBlock owns a `Gst.Element`, puts it into the pipeline's `Gst.Pipeline`, and exposes the element's static `sink` and `src` pads as `MediaBlockPad` instances that `MediaBlocksPipeline.Connect(...)` can wire together. ``` flowchart LR Source[Source
Block] -- Output --> InP[ Sink
MediaBlockPad ] subgraph Custom["Your custom MediaBlock"] InP --> Elem[ Gst.Element
e.g. videobalance ] Elem --> OutP[ Src
MediaBlockPad ] end OutP -- Input --> Renderer[Encoder /
Renderer] ``` ## Approach A — `CustomMediaBlock` (no subclassing) `CustomMediaBlock` is the public, generic wrapper that does everything described above without you having to write a class. Pass it the GStreamer element name and a list of pads, set properties via a string-keyed dictionary, add it to the pipeline, and connect it. ``` using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Special; using VisioForge.Core.Types.X.Special; var settings = new CustomMediaBlockSettings("videobalance"); settings.Pads.Add(new CustomMediaBlockPad(MediaBlockPadDirection.In, MediaBlockPadMediaType.Video)); settings.Pads.Add(new CustomMediaBlockPad(MediaBlockPadDirection.Out, MediaBlockPadMediaType.Video)); settings.ElementParams["saturation"] = 0.0; // videobalance.saturation is a double var grayscale = new CustomMediaBlock(settings); pipeline.AddBlock(grayscale); pipeline.Connect(source.Output, grayscale.Input); pipeline.Connect(grayscale.Output, encoder.Input); ``` That is the whole block. `CustomMediaBlock.Build()` is invoked by the pipeline during `StartAsync` and does the work: creates the `videobalance` element via `Gst.ElementFactory.Make`, applies every entry in `ElementParams` with `SetProperty`, adds the element to the pipeline, and binds the sink/src pads. ### Supported property types `ElementParams` accepts the following CLR types and maps them to the matching `GLib.Value`: | CLR type | GStreamer property kind | | --- | --- | | `int` | `gint`, `enum` | | `uint` | `guint`, `flags` | | `long` | `gint64` | | `ulong` | `guint64` | | `float` | `gfloat` | | `double` | `gdouble` (most of `videobalance`, `gamma`, audio volumes, etc.) | | `string` | `gchararray` | | `bool` | implicit via `GLib.Value` | | `Enum` | converted to `int` | Match the GStreamer property type **exactly**. `videobalance.saturation` is a `gdouble` — pass `0.0`, not `0` (int) and not `0.0f` (float). Mis-typed properties are a silent no-op. ### Wrapping multi-element chains: bin syntax If your transformation needs more than one GStreamer element, you can pass a bin description in `[ ... ]` instead of a single element name. The block parses it with `Gst.Parse.BinFromDescription` and adds the resulting bin: ``` var settings = new CustomMediaBlockSettings("[ videoconvert ! videobalance saturation=0 ! videoconvert ]"); settings.Pads.Add(new CustomMediaBlockPad(MediaBlockPadDirection.In, MediaBlockPadMediaType.Video)); settings.Pads.Add(new CustomMediaBlockPad(MediaBlockPadDirection.Out, MediaBlockPadMediaType.Video)); var block = new CustomMediaBlock(settings); ``` ### Dynamic pads (demuxer-like elements) For elements that create their src pads at runtime (e.g. `decodebin`, `tsdemux`), set `UsePadAddedEvent = true` on the settings. `CustomMediaBlock` inserts an `identity` per declared output pad and links them as the element fires `pad-added`. ### Late tweaks via `OnElementAdded` If you need to touch the raw `Gst.Element` after creation but before the pipeline starts (signal handlers, structure caps, properties that don't fit the `ElementParams` map), subscribe to `OnElementAdded`: ``` var block = new CustomMediaBlock(settings); block.OnElementAdded += (s, element) => { element.SetProperty("brightness", new GLib.Value(0.1)); // … any other tweak }; ``` ### When `CustomMediaBlock` is not enough You want a typed block when: - You will use it in many places and want IntelliSense for properties. - You want a static `IsAvailable()` to fail fast on systems where the plugin is missing. - You want a settings class with validation, defaults, and XML docs. - You want the block to look and feel like every other SDK block in someone else's code review. That is **Approach B**. ## Approach B — a typed `MediaBlock` subclass A custom block is `MediaBlock` + `IMediaBlockInternals` + two `MediaBlockPad`s. The pattern is small enough to memorise. Below is the complete `MyGrayscaleBlock` from the [`CustomGrayscaleBlock` console sample](#sample-app); read it once, then the step-by-step breakdown after it. ``` using System; using Gst; using VisioForge.Core.MediaBlocks; public class MyGrayscaleBlock : MediaBlock, IMediaBlockInternals { private const string TAG = "MyGrayscaleBlock"; private Element _element; private readonly MediaBlockPad _inputPad; private readonly MediaBlockPad _outputPad; public override MediaBlockType Type => MediaBlockType.Custom; public override MediaBlockPad Input => _inputPad; public override MediaBlockPad[] Inputs => new[] { _inputPad }; public override MediaBlockPad Output => _outputPad; public override MediaBlockPad[] Outputs => new[] { _outputPad }; public MyGrayscaleBlock() { Name = "MyGrayscale"; _inputPad = new MediaBlockPad(this, MediaBlockPadDirection.In, MediaBlockPadMediaType.Video); _outputPad = new MediaBlockPad(this, MediaBlockPadDirection.Out, MediaBlockPadMediaType.Video); } public static bool IsAvailable() { var factory = ElementFactory.Find("videobalance"); if (factory == null) return false; factory.Dispose(); return true; } public override bool Build() { if (_isBuilt) return true; _element = ElementFactory.Make("videobalance", $"videobalance_{Guid.NewGuid():N}"); if (_element == null) { Context?.Error(TAG, "Build", "Unable to create videobalance element."); return false; } _element.SetProperty("saturation", new GLib.Value(0.0)); _pipelineCtx.Pipeline.Add(_element); var sink = _element.GetStaticPad("sink"); var src = _element.GetStaticPad("src"); if (sink == null || src == null) { Context?.Error(TAG, "Build", "Unable to retrieve videobalance static pads."); _pipelineCtx.Pipeline.Remove(_element); _element.Dispose(); _element = null; return false; } _inputPad.SetInternalPad(sink); _outputPad.SetInternalPad(src); _isBuilt = true; return true; } void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline) { SetPipeline(pipeline); Context = pipeline.GetContext(); } bool IMediaBlockInternals.Build() => Build(); Gst.Element IMediaBlockInternals.GetElement() => _element; VisioForge.Core.GStreamer.Base.BaseElement IMediaBlockInternals.GetCore() => null; public void CleanUp() { _element?.Dispose(); _element = null; } protected override void Dispose(bool disposing) { if (disposing) CleanUp(); base.Dispose(disposing); } } ``` ### Step by step #### 1. Inherit `MediaBlock`, implement `IMediaBlockInternals` `MediaBlock` is the public, non-abstract base class. `IMediaBlockInternals` is the public interface the pipeline calls into during preload, build, and teardown. You implement both. #### 2. Declare the pads in the constructor A `MediaBlockPad` is the MediaBlocks-level pad. The pipeline connects two `MediaBlockPad`s with `pipeline.Connect(a, b)`; under the covers each one forwards to an underlying GStreamer pad you assign in `Build()` via `SetInternalPad`. ``` _inputPad = new MediaBlockPad(this, MediaBlockPadDirection.In, MediaBlockPadMediaType.Video); _outputPad = new MediaBlockPad(this, MediaBlockPadDirection.Out, MediaBlockPadMediaType.Video); ``` Use `MediaBlockPadMediaType.Audio` for audio elements (e.g. `audioconvert`, `volume`), or one pad of each kind for elements that touch both streams. #### 3. Override `Type`, `Input/Inputs`, `Output/Outputs` `MediaBlockType.Custom` is the catch-all enum value for user-authored blocks. The four pad properties return your single pads (singular) or single-element arrays (plural) — the SDK uses one or the other depending on how it is enumerating blocks. #### 4. Implement `Build()` This is where the GStreamer side comes alive. `Build()` runs during `pipeline.StartAsync(...)` (or `StartAsync(onlyPreload: true)`), **not in your constructor**. Inside it: 1. Guard `_isBuilt` to make repeat calls a no-op. 2. Create the element with `ElementFactory.Make(name, uniqueInstanceName)`. Pass a unique instance name (`Guid.NewGuid().ToString("N")` works) — GStreamer requires unique element names within a pipeline. 3. Null-check the element. `null` means the plugin is missing or the factory is unavailable on this platform. 4. Apply properties with `element.SetProperty("name", new GLib.Value(...))`. Match the property's GStreamer type exactly (see the supported types table above). 5. **Add the element to the pipeline before retrieving its pads.** The pipeline reference is exposed via the protected field `_pipelineCtx.Pipeline`. 6. Retrieve the element's static pads with `element.GetStaticPad("sink")` / `GetStaticPad("src")` and bind them with `MediaBlockPad.SetInternalPad(...)`. #### 5. Static `IsAvailable()` Conventionally every SDK block exposes a static `IsAvailable()` that checks the registry for the underlying element. Callers use this to decide between alternatives or fail fast with a useful diagnostic. ``` public static bool IsAvailable() { var factory = ElementFactory.Find("videobalance"); if (factory == null) return false; factory.Dispose(); return true; } ``` #### 6. `IMediaBlockInternals.SetContext` The pipeline calls this when the block is added. It wires the block to its parent pipeline and stores the GStreamer-level `Context` for error reporting: ``` void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline) { SetPipeline(pipeline); Context = pipeline.GetContext(); } ``` `SetPipeline` is a protected method on `MediaBlock` that stores a weak reference to the pipeline and populates the protected `_pipelineCtx` field your `Build()` uses. #### 7. `CleanUp()` and `Dispose` `CleanUp()` is called by the pipeline during teardown. Dispose the underlying element and clear the reference. Forward `Dispose(bool)` to `CleanUp` for normal IDisposable lifecycle: ``` public void CleanUp() { _element?.Dispose(); _element = null; } protected override void Dispose(bool disposing) { if (disposing) CleanUp(); base.Dispose(disposing); } ``` #### 8. `GetElement` / `GetCore` `GetElement` exposes the raw `Gst.Element` for advanced inspection. `GetCore` exposes the internal `BaseElement` wrapper used by built-in blocks; user code does not have one, so return `null`. ### Using your block Once the class compiles, it slots into a pipeline like any other block: ``` var grayscale = new MyGrayscaleBlock(); pipeline.AddBlock(source); pipeline.AddBlock(grayscale); pipeline.AddBlock(encoder); pipeline.AddBlock(sink); pipeline.Connect(source.Output, grayscale.Input); pipeline.Connect(grayscale.Output, encoder.Input); ``` ## Adding properties and settings `MyGrayscaleBlock` hardcodes `saturation = 0`. To expose configurable properties, the SDK convention is a separate settings class passed to the block's constructor: ``` public class MyVideoBalanceSettings { public double Brightness { get; set; } = 0.0; // -1.0 to 1.0 public double Contrast { get; set; } = 1.0; // 0.0 to 2.0 public double Saturation { get; set; } = 1.0; // 0.0 to 2.0 (0 = grayscale) public double Hue { get; set; } = 0.0; // -1.0 to 1.0 } public class MyVideoBalanceBlock : MediaBlock, IMediaBlockInternals { public MyVideoBalanceSettings Settings { get; } public MyVideoBalanceBlock(MyVideoBalanceSettings settings) { Settings = settings ?? new MyVideoBalanceSettings(); // … pads as before } public override bool Build() { // … create element as before _element.SetProperty("brightness", new GLib.Value(Settings.Brightness)); _element.SetProperty("contrast", new GLib.Value(Settings.Contrast)); _element.SetProperty("saturation", new GLib.Value(Settings.Saturation)); _element.SetProperty("hue", new GLib.Value(Settings.Hue)); // … add to pipeline, bind pads } } ``` For real-time property updates, store a reference to `_element` and expose `Update(Settings settings)` that calls `SetProperty` on a live element. The SDK's `VideoBalanceBlock` uses an `OnUpdate` event on its settings class for this — read it for a fuller example. ## Discovering elements and their properties Use the `gstreamer-doc` agent skill — or, on Windows, the local `gst-inspect-1.0.exe` at `C:\gstreamer\1.0\msvc_x86_64x\bin\gst-inspect-1.0.exe` — to inspect any element before wrapping it: ``` gst-inspect-1.0.exe videobalance ``` The output lists every property (with its GStreamer type and range) and both pad templates (with their caps). Confirm: - The element exists in the GStreamer install your customers will have. - The properties you intend to set are named exactly what you think. - The sink/src pad caps accept `video/x-raw` or whatever your upstream produces — most simple video effects negotiate `video/x-raw` agnostically and need no extra `capsfilter`. ## Lifecycle and caveats - **`Build()` runs during pipeline preload, not in the constructor.** Do not touch the underlying element from your block's constructor — it doesn't exist yet. - **Add the element to `_pipelineCtx.Pipeline` *before* you call `GetStaticPad`.** Pads exist as soon as the factory creates the element, but the pipeline manages lifecycle from the moment `Add` is called. - **Match GStreamer property types exactly.** A `gdouble` property set with an `int` value is a silent no-op. `gst-inspect-1.0` tells you the type. - **Use unique element instance names.** Two elements with the same name in one `Gst.Pipeline` is an error. - **Don't use `ConfigureAwait(false)` in SDK-adjacent code.** Project convention; the SDK enforces it. - **Custom elements with dynamic pads** (decoders, demuxers) belong in `CustomMediaBlock` with `UsePadAddedEvent = true`, not in a hand-written subclass — the bookkeeping for `pad-added` is non-trivial. ## When to prefer a different block type `MediaBlock` is the right base when you want to **wrap a GStreamer element**. The SDK has two related public blocks for different use cases: | Block | Use it when | | --- | --- | | [`CustomMediaBlock`](../../Special/) | You want Approach A from this guide — wrap a single element or a bin description without subclassing. | | `CustomTransformBlock` | You want a managed-side transform: input samples arrive in your code via an event, and you push output samples back. No GStreamer-level transformation element. | | `DataProcessorBlock` | You want to read or modify raw video/audio buffers in managed code without producing different output (pure inspection, frame counting, metadata extraction). | | `SuperMediaBlock` | You want to group several existing blocks into a single composite block with shared lifecycle. | ## Sample app The companion sample `CustomGrayscaleBlock` lives in the SDK samples tree under `_DEMOS/Media Blocks SDK/Console/CustomGrayscaleBlock/`. It runs both approaches back-to-back and writes one MP4 per approach so you can compare them. Files: - `Program.cs` — builds both pipelines. - `MyGrayscaleBlock.cs` — the typed subclass from this guide. - `CustomGrayscaleBlock.csproj` — cross-platform console project. ## See also - [Custom Video Effects and OpenGL Shaders](../custom-video-effects-csharp/) — the SDK's catalog of built-in effect blocks, including the production `GrayscaleBlock` and `VideoBalanceBlock`. - [Special blocks](../../Special/) — `CustomMediaBlock`, `CustomTransformBlock`, `DataProcessorBlock`, `SuperMediaBlock`. - [Video Processing blocks](../../VideoProcessing/) — the full set of typed effect blocks. ---END OF PAGE--- ## Custom Video Effects and OpenGL Shaders in C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/custom-video-effects-csharp/ **Description:** Apply real-time video effects, GLSL shaders, LUT color grading, and pan/zoom animations in C# .NET with VisioForge Media Blocks SDK and GPU acceleration. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Linux, Android, iOS, Encoding, Effects, Webcam, C# **API:** LUTProcessorBlock, MediaBlocksPipeline, GLUploadBlock, GLDownloadBlock, GLShaderBlock # Custom Video Effects and OpenGL Shaders in C# .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) The VisioForge Media Blocks SDK provides 70+ video processing blocks for real-time effects, GPU-accelerated OpenGL shaders, professional LUT color grading, and animated pan/zoom transformations. Effects are applied by inserting processing blocks into the pipeline between a video source and a renderer or encoder. ## Built-in Video Effects [MediaBlocksPipeline](#) All built-in effects follow the same pipeline pattern — insert the effect block between your source and renderer: ``` VideoSource → EffectBlock → VideoRenderer ``` ### Gaussian Blur Apply blur or sharpening with configurable sigma. Positive values blur, negative values sharpen: ``` using VisioForge.Core.MediaBlocks.VideoProcessing; // Blur with sigma 1.2 (higher = more blur) var blur = new GaussianBlurBlock(1.2); pipeline.Connect(videoSource.Output, blur.Input); pipeline.Connect(blur.Output, videoRenderer.Input); ``` ### Noise Reduction (Smooth Filter) OpenCV-based noise reduction with edge-preserving smoothing: ``` using VisioForge.Core.Types.X.VideoEffects; var smoothSettings = new SmoothVideoEffect() { FilterSize = 5, // kernel size (larger = stronger smoothing) Tolerance = 128, // contrast threshold (0-255) LumaOnly = true // smooth brightness only, preserve color }; var smooth = new SmoothBlock(smoothSettings); pipeline.Connect(videoSource.Output, smooth.Input); pipeline.Connect(smooth.Output, videoRenderer.Input); ``` ### Color Balance Adjust brightness, contrast, saturation, and hue in real time: ``` var balance = new VideoBalanceBlock(new VideoBalanceVideoEffect { Brightness = 0.1, // -1.0 to 1.0 (0 = no change) Contrast = 1.2, // 0.0 to infinity (1 = no change) Saturation = 1.5, // 0.0 to infinity (1 = no change) Hue = 0.0 // -1.0 to 1.0 (0 = no change) }); pipeline.Connect(videoSource.Output, balance.Input); pipeline.Connect(balance.Output, videoRenderer.Input); ``` ### Preset Color Effects Apply artistic color presets (sepia, heat map, cross-processing, etc.): ``` var colorFx = new ColorEffectsBlock(ColorEffectsPreset.Sepia); pipeline.Connect(videoSource.Output, colorFx.Input); pipeline.Connect(colorFx.Output, videoRenderer.Input); ``` ## GPU-Accelerated Effects with OpenGL [MediaBlocksPipeline](#) OpenGL effects run on the GPU for significantly better performance with HD/4K video. They require uploading video frames to GPU memory and downloading them back: ``` VideoSource → GLUploadBlock → GLEffectBlock → GLDownloadBlock → VideoRenderer ``` ### Using Built-in OpenGL Effects The SDK includes 25+ GPU-accelerated effects: ``` using VisioForge.Core.MediaBlocks.OpenGL; var glUpload = new GLUploadBlock(); var glBlur = new GLBlurBlock(); var glDownload = new GLDownloadBlock(); pipeline.Connect(videoSource.Output, glUpload.Input); pipeline.Connect(glUpload.Output, glBlur.Input); pipeline.Connect(glBlur.Output, glDownload.Input); pipeline.Connect(glDownload.Output, videoRenderer.Input); ``` ### Available OpenGL Effects | Effect Block | Description | | --- | --- | | `GLBlurBlock` | 9x9 separable convolution blur | | `GLColorBalanceBlock` | Brightness, contrast, hue, saturation | | `GLGrayscaleBlock` | Grayscale conversion | | `GLSepiaBlock` | Sepia tone | | `GLSobelBlock` | Sobel edge detection | | `GLLaplacianBlock` | Laplacian edge detection | | `GLFishEyeBlock` | Fisheye lens distortion | | `GLBulgeBlock` | Bulge distortion | | `GLTwirlBlock` | Twirl/swirl effect | | `GLMirrorBlock` | Mirror reflection | | `GLSqueezeBlock` | Squeeze distortion | | `GLStretchBlock` | Stretch distortion | | `GLHeatBlock` | Heat map visualization | | `GLGlowLightingBlock` | Glow/lighting effect | | `GLLightTunnelBlock` | Light tunnel effect | | `GLSinCityBlock` | Sin City (selective desaturation) | | `GLXRayBlock` | X-ray visualization | | `GLLumaCrossProcessingBlock` | Luma cross-processing | | `GLFlipBlock` | GPU flip/mirror | | `GLDeinterlaceBlock` | GPU deinterlacing | | `GLTransformationBlock` | Affine transformations | | `GLAlphaBlock` | Alpha channel / chroma key | | `GLEquirectangularViewBlock` | 360 equirectangular projection | ## Custom GLSL Shaders [MediaBlocksPipeline](#) Write custom GLSL fragment and vertex shaders and apply them to live video in real time. The `GLShaderBlock` executes your shader on the GPU for every video frame. ### Pipeline Architecture ``` SystemVideoSourceBlock → GLUploadBlock → GLShaderBlock → GLDownloadBlock → VideoRendererBlock ``` ### Complete Example ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.OpenGL; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoRendering; using VisioForge.Core.Types.X.OpenGL; using VisioForge.Core.Types.X.Sources; await VisioForgeX.InitSDKAsync(); var pipeline = new MediaBlocksPipeline(); // Video source (webcam) var videoDevices = await DeviceEnumerator.Shared.VideoSourcesAsync(); var videoSource = new SystemVideoSourceBlock( new VideoCaptureDeviceSourceSettings(videoDevices[0])); // Upload frames to GPU memory var glUpload = new GLUploadBlock(); // Custom GLSL shader — grayscale conversion var vertexShader = @" #version 100 #ifdef GL_ES precision mediump float; #endif attribute vec4 a_position; attribute vec2 a_texcoord; varying vec2 v_texcoord; void main() { gl_Position = a_position; v_texcoord = a_texcoord; }"; var fragmentShader = @" #version 100 #ifdef GL_ES precision mediump float; #endif varying vec2 v_texcoord; uniform sampler2D tex; void main() { vec4 color = texture2D(tex, v_texcoord); float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114)); gl_FragColor = vec4(vec3(gray), color.a); }"; var shader = new GLShader(vertexShader, fragmentShader); var shaderBlock = new GLShaderBlock(new GLShaderSettings(shader)); // Download frames back from GPU var glDownload = new GLDownloadBlock(); // Video renderer var videoRenderer = new VideoRendererBlock(pipeline, VideoView1); // Build pipeline pipeline.Connect(videoSource.Output, glUpload.Input); pipeline.Connect(glUpload.Output, shaderBlock.Input); pipeline.Connect(shaderBlock.Output, glDownload.Input); pipeline.Connect(glDownload.Output, videoRenderer.Input); await pipeline.StartAsync(); ``` ### Switching Shaders at Runtime You can change the shader while the pipeline is running: ``` // Invert color shader var invertFragment = @" #version 100 #ifdef GL_ES precision mediump float; #endif varying vec2 v_texcoord; uniform sampler2D tex; void main() { vec4 color = texture2D(tex, v_texcoord); gl_FragColor = vec4(vec3(1.0) - color.rgb, color.a); }"; shaderBlock.Settings.Fragment = invertFragment; shaderBlock.Update(); // apply changes without restarting pipeline ``` ## Shader Uniforms for Dynamic Effects [MediaBlocksPipeline](#) Pass parameters to GLSL shaders at runtime using the `Uniforms` dictionary. This enables dynamic, real-time control over shader behavior. ### Two-Pass Gaussian Blur with Adjustable Radius ``` // Horizontal blur pass var horizontalSettings = new GLShaderSettings(vertexShader, horizontalFragmentShader); horizontalSettings.Uniforms["blur_radius"] = 2.0f; horizontalSettings.Uniforms["tex_width"] = 1920.0f; var blurH = new GLShaderBlock(horizontalSettings); // Vertical blur pass var verticalSettings = new GLShaderSettings(vertexShader, verticalFragmentShader); verticalSettings.Uniforms["blur_radius"] = 2.0f; verticalSettings.Uniforms["tex_height"] = 1080.0f; var blurV = new GLShaderBlock(verticalSettings); // Pipeline: Source → Upload → H-Blur → V-Blur → Download → Renderer pipeline.Connect(videoSource.Output, glUpload.Input); pipeline.Connect(glUpload.Output, blurH.Input); pipeline.Connect(blurH.Output, blurV.Input); pipeline.Connect(blurV.Output, glDownload.Input); pipeline.Connect(glDownload.Output, videoRenderer.Input); ``` ### Updating Uniforms at Runtime ``` // Adjust blur radius in response to a slider change float newRadius = 5.0f; blurH.Settings.Uniforms["blur_radius"] = newRadius; blurH.Update(); blurV.Settings.Uniforms["blur_radius"] = newRadius; blurV.Update(); ``` ## LUT Color Grading [MediaBlocksPipeline](#) Apply professional color grading using 3D Look-Up Table (LUT) files. The `LUTProcessorBlock` transforms every pixel's color through a 3D color cube for cinematic color effects. ### Supported LUT Formats | Format | Extension | Origin | | --- | --- | --- | | Iridas/Resolve | `.cube` | DaVinci Resolve, Adobe | | After Effects | `.3dl` | Adobe After Effects | | DaVinci | `.dat` | DaVinci Resolve | | Pandora | `.m3d` | Pandora | | CineSpace | `.csp` | CineSpace | ### Basic LUT Application ``` using VisioForge.Core.MediaBlocks.VideoProcessing; using VisioForge.Core.Types.X.VideoEffects; var lutPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cinematic.cube"); var lutProcessor = new LUTProcessorBlock(new LUTVideoEffect(lutPath)); pipeline.Connect(videoSource.Output, lutProcessor.Input); pipeline.Connect(lutProcessor.Output, videoRenderer.Input); ``` ### Side-by-Side Comparison Use a `TeeBlock` to show original and graded video side by side: ``` using VisioForge.Core.MediaBlocks.Special; var tee = new TeeBlock(2, MediaBlockPadMediaType.Video); var lutProcessor = new LUTProcessorBlock(new LUTVideoEffect(lutPath)); // Original output var rendererOriginal = new VideoRendererBlock(pipeline, null); // Graded output var rendererGraded = new VideoRendererBlock(pipeline, null); pipeline.Connect(videoSource.Output, tee.Input); pipeline.Connect(tee.Outputs[0], lutProcessor.Input); pipeline.Connect(lutProcessor.Output, rendererGraded.Input); pipeline.Connect(tee.Outputs[1], rendererOriginal.Input); ``` ### Interpolation Modes The `LUTVideoEffect` supports three interpolation modes for quality/performance trade-offs: - **Tetrahedral** — highest quality, best for final output - **Trilinear** — good balance of quality and speed - **NearestNeighbor** — fastest, lowest quality ## Pan, Zoom, and Ken Burns Animations [MediaBlocksPipeline](#) The `PanZoomBlock` provides static and animated pan/zoom transformations — ideal for Ken Burns effects, region-of-interest viewing, and dynamic video framing. ### Pipeline Setup ``` using VisioForge.Core.MediaBlocks.VideoProcessing; using VisioForge.Core.Types.X.VideoEffects; var panZoom = new PanZoomBlock(); pipeline.Connect(fileSource.VideoOutput, panZoom.Input); pipeline.Connect(panZoom.Output, videoRenderer.Input); ``` ### Static Zoom Zoom into a specific point in the frame: ``` // 2x zoom centered on the middle of the frame panZoom.SetZoom(new VideoStreamZoomSettings( zoomX: 2.0, // horizontal zoom factor zoomY: 2.0, // vertical zoom factor centerX: 0.5, // center point X (0.0 - 1.0) centerY: 0.5 // center point Y (0.0 - 1.0) )); ``` ### Static Pan Shift the visible region: ``` // Pan 100 pixels right, 50 pixels down panZoom.SetPan(new VideoStreamPanSettings(100, 50)); ``` ### Dynamic Zoom (Ken Burns Effect) Animate a smooth zoom transition over a time range: ``` // Slowly zoom from 1x to 2x over 5 seconds starting at current position var startTime = await pipeline.Position_GetAsync(); var endTime = startTime + TimeSpan.FromSeconds(5); panZoom.SetDynamicZoom(new VideoStreamDynamicZoomSettings( startZoomX: 1.0, startZoomY: 1.0, // start at normal size stopZoomX: 2.0, stopZoomY: 2.0, // end at 2x zoom startTime: startTime, stopTime: endTime )); ``` ### Dynamic Pan Animate a smooth pan movement: ``` panZoom.SetDynamicPan(new VideoStreamDynamicPanSettings( startPanX: 0, startPanY: 0, // start position stopPanX: 200, stopPanY: 100, // end position startTime: startTime, stopTime: endTime )); ``` ### Rect Crop and Pan Focus on a specific rectangular region of the video: ``` // Show only the region starting at (50, 50) with 400x300 size panZoom.SetRect(VideoStreamRectSettings.FromPositionAndSize(50, 50, 400, 300)); ``` ### Resetting Pan/Zoom Clear all pan/zoom settings to return to the original view: ``` panZoom.SetZoom(null); panZoom.SetDynamicZoom(null); panZoom.SetPan(null); panZoom.SetDynamicPan(null); panZoom.SetRect(null); ``` ## Chaining Multiple Effects Connect multiple effect blocks in series to build complex processing chains: ``` VideoSource → GaussianBlurBlock → VideoBalanceBlock → LUTProcessorBlock → VideoRenderer ``` ``` var blur = new GaussianBlurBlock(0.8); var balance = new VideoBalanceBlock(new VideoBalanceVideoEffect { Brightness = 0.05, Contrast = 1.1 }); var lut = new LUTProcessorBlock(new LUTVideoEffect("cinematic.cube")); pipeline.Connect(videoSource.Output, blur.Input); pipeline.Connect(blur.Output, balance.Input); pipeline.Connect(balance.Output, lut.Input); pipeline.Connect(lut.Output, videoRenderer.Input); ``` For GPU-accelerated chains, keep frames in GPU memory between effects: ``` pipeline.Connect(videoSource.Output, glUpload.Input); pipeline.Connect(glUpload.Output, glBlur.Input); pipeline.Connect(glBlur.Output, glColorBalance.Input); pipeline.Connect(glColorBalance.Output, glDownload.Input); pipeline.Connect(glDownload.Output, videoRenderer.Input); ``` ## Troubleshooting ### OpenGL Effects Not Working **Symptom:** Pipeline fails to start or video appears black when using GL effects. **Solutions:** - Verify GPU drivers are up to date — OpenGL effects require hardware OpenGL support - Ensure `GLUploadBlock` and `GLDownloadBlock` are used to transfer frames to/from GPU memory - Fall back to CPU-based equivalents (e.g., `GaussianBlurBlock` instead of `GLBlurBlock`) on systems without GPU support - Check `GLShaderBlock.IsAvailable()` before creating OpenGL blocks ### LUT File Not Loading **Symptom:** `LUTProcessorBlock` throws an exception or has no visible effect. **Solutions:** - Verify the LUT file path is correct and the file exists - Ensure the file format is supported (`.cube`, `.3dl`, `.dat`, `.m3d`, `.csp`) - Check `LUTProcessorBlock.IsAvailable()` before creating the block - Use an absolute path or `Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "file.cube")` ### High CPU Usage with Effects **Symptom:** Performance degrades when applying multiple effects. **Solutions:** - Switch from CPU effects to OpenGL GPU-accelerated equivalents - Reduce video resolution before applying effects (use `VideoResizeBlock`) - Minimize the number of chained effects — combine operations in a single custom shader when possible - For two-pass blur, use the single-pass simple blur as a faster alternative ## Frequently Asked Questions ### How do I apply a custom GLSL shader to live video in C#? Create a `GLShaderBlock` with your vertex and fragment shader source code, then insert it between `GLUploadBlock` and `GLDownloadBlock` in your pipeline. The standard vertex shader passes through position and texture coordinates. Your fragment shader receives the video frame as `uniform sampler2D tex` and outputs to `gl_FragColor`. Use `shaderBlock.Update()` to change shaders at runtime without restarting the pipeline. See the [Custom GLSL Shaders](#custom-glsl-shaders) section for a complete example. ### What LUT file formats does the SDK support for color grading? The `LUTProcessorBlock` supports five industry-standard 3D LUT formats: Iridas/Resolve `.cube`, After Effects `.3dl`, DaVinci `.dat`, Pandora `.m3d`, and CineSpace `.csp`. The `.cube` format is the most widely used and is exported by DaVinci Resolve, Adobe Premiere, and most color grading tools. Three interpolation modes are available: Tetrahedral (highest quality), Trilinear, and NearestNeighbor. ### Can I chain multiple video effects together in a pipeline? Yes. Connect effect blocks in series: `Source → Effect1 → Effect2 → Effect3 → Renderer`. Each block processes the output of the previous one. For GPU-accelerated chains, keep frames in OpenGL memory by connecting GL effect blocks directly without inserting `GLDownloadBlock` / `GLUploadBlock` between them — only upload at the start and download at the end. ### How do I create a Ken Burns pan/zoom animation? Use `PanZoomBlock` with `SetDynamicZoom()` to animate a smooth zoom transition over time. Pass a `VideoStreamDynamicZoomSettings` with start/stop zoom factors and start/stop timestamps. The block interpolates between the values automatically. Combine with `SetDynamicPan()` for simultaneous pan and zoom animation. See the [Pan, Zoom, and Ken Burns Animations](#pan-zoom-and-ken-burns-animations) section for code examples. ### What platforms support OpenGL video effects? OpenGL effects are supported on Windows, Linux, macOS, and Android — any platform with OpenGL ES 2.0 or higher support. On iOS and macOS, the SDK also provides Metal-accelerated equivalents (`MetalVideoFilterBlock`) for native GPU performance. CPU-based effects (`GaussianBlurBlock`, `SmoothBlock`, `ColorEffectsBlock`, etc.) work on all platforms including iOS. ## See Also - [Video Processing Blocks Reference](../../VideoProcessing/) — complete list of 70+ processing blocks - [OpenGL Effects Reference](../../OpenGL/) — GPU-accelerated OpenGL effect settings and types - [Video Effects Overview](../../../general/video-effects/) — Classic and Cross-Platform effect categories - [Effects Reference (100+ effects)](../../../general/video-effects/effects-reference/) — detailed parameters for all effects - [Deployment Guide](../../../deployment-x/) — platform-specific runtime packages - [Code Samples on GitHub](https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Blocks%20SDK) — shader and effects demos - [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) — product page and downloads ---END OF PAGE--- ## KLV / MISB Metadata in MPEG-TS Streams with C# .NET **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/klv-metadata-mpegts-csharp/ **Description:** Extract, decode, and mux KLV (MISB 0601 / STANAG 4609) metadata in MPEG-TS streams from C# with the Media Blocks SDK .NET — UAV, ISR, and surveillance video. **Tags:** Media Blocks SDK, .NET, MPEG-TS, KLV, MISB, STANAG 4609, C# **API:** MPEGTSDemuxBlock, KLVFileSinkBlock, KLVDecoder, KLVParser, KLVMetadata # KLV / MISB Metadata in MPEG-TS with C# .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Overview KLV (Key-Length-Value) is the binary metadata encoding used by MISB / STANAG 4609 MPEG-TS streams to carry geospatial and sensor telemetry alongside video — UAV/drone, ISR, and surveillance feeds. The Media Blocks SDK .NET lets you: 1. **Extract** the KLV metadata stream from an MPEG-TS file. 2. **Parse** MISB ST 0601 elements (or read raw key/value items). 3. **Embed** a KLV payload into an MPEG-TS output. ``` graph LR; BasicFileSourceBlock-->MPEGTSDemuxBlock; MPEGTSDemuxBlock-- MetadataOutput -->KLVFileSinkBlock; MPEGTSDemuxBlock-- VideoOutput -->VideoRendererBlock; ``` The KLV blocks live in `VisioForge.Core.MediaBlocks.Sinks` / `VisioForge.Core.MediaBlocks.Sources`; the decoders live in `VisioForge.Core.Metadata` and `VisioForge.Core.Metadata.KLV`. KLV demux/extract works on Windows, Linux, and macOS. ## Prerequisites Install the Media Blocks SDK NuGet package and the platform runtime package (for example `VisioForge.CrossPlatform.Core.Windows.x64`). Call `VisioForgeX.InitSDKAsync()` once at startup. ## Extract KLV from an MPEG-TS file Demux the transport stream and route its **metadata pad** to a `KLVFileSinkBlock`, which writes the `meta/x-klv` packets to a `.klv` file. Pass `renderMetadata: true` so the demuxer exposes its `MetadataOutput` pad. ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.MediaBlocks.Sources; await VisioForgeX.InitSDKAsync(); var pipeline = new MediaBlocksPipeline(); var fileSource = new BasicFileSourceBlock("mission.ts"); // renderVideo: false, renderMetadata: true -> we only want the KLV metadata pad. var demux = new MPEGTSDemuxBlock(false, renderMetadata: true); var klvSink = new KLVFileSinkBlock("mission_metadata.klv"); pipeline.Connect(fileSource.Output, demux.Input); pipeline.Connect(demux.MetadataOutput, klvSink.Input); await pipeline.StartAsync(); ``` To preview the video at the same time, also connect `demux.VideoOutput` to a `VideoRendererBlock` (build the demuxer with `renderVideo: true`). ## Parse the extracted KLV For **standard MISB KLV** extracted from an MPEG-TS stream, use `KLVParser`. It decodes MISB ST 0601 local-set elements (precision time stamp, platform/sensor position and orientation, frame-center geolocation, target location, and 100+ more) and handles the **BER-encoded lengths** that MISB packets use: ``` using VisioForge.Core.Metadata.KLV; var klv = new KLVParser("mission_metadata.klv"); // also accepts a Stream foreach (var element in klv.Elements) { Console.WriteLine(element.ToString()); } ``` `KLVDecoder` is a lighter raw reader that walks 16-byte keys each followed by a **fixed 4-byte little-endian length**. It does NOT decode BER lengths, so use it only for KLV stored in that fixed-length layout — not for standard MISB transport-stream KLV (use `KLVParser` for that): ``` using VisioForge.Core.Metadata; // DecodeFromBytes(byte[]) is the in-memory equivalent of DecodeFromFile. foreach (KLVItem item in KLVDecoder.DecodeFromFile("fixed_length.klv")) { // item.Key - 16-byte universal key as a hex string // item.Value - raw value bytes Console.WriteLine($"{item.Key} ({item.Value.Length} bytes)"); } ``` ## Embed a KLV payload into an MPEG-TS output To attach a KLV payload to an MPEG-TS file, set the `MPEGTSSinkSettings.Metadata` property to a `KLVMetadata` source. `KLVMetadata` accepts a `.klv` file path or a `byte[]`. ``` using VisioForge.Core.MediaBlocks.Sinks; using VisioForge.Core.Types.X.Metadata; using VisioForge.Core.Types.X.Sinks; var tsSettings = new MPEGTSSinkSettings("output.ts") { Metadata = new KLVMetadata("mission_metadata.klv"), }; var tsSink = new MPEGTSSinkBlock(tsSettings); // Connect your video (and audio) producers to tsSink, then start the pipeline. ``` Static payload, not a re-timed metadata track `KLVMetadata` loads the whole `.klv` as a single `byte[]`, and the muxer embeds it without per-packet timestamps. This attaches a **static** KLV payload to the output — it does not reconstruct the original frame-accurate, PCR/PTS-synchronized metadata track. For applications that need per-frame KLV synchronized to the video, drive the KLV from a live source as it is produced rather than re-embedding a flat file. ## Record live KLV while capturing (Video Capture SDK) When capturing a MISB IP-camera/UAV feed with the [Video Capture SDK .NET](https://www.visioforge.com/video-capture-sdk-net) `VideoCaptureCore` engine, enable KLV on the MPEG-TS output to pass the metadata through to the recording: ``` // In-process MF muxer output: videoCapture.Output_Format = new MPEGTSOutput { KLVEnabled = true }; // Or external ffmpeg.exe pipe output: videoCapture.Network_Streaming_Output = new FFMPEGEXEOutput { OutputMuxer = OutputMuxer.MPEGTS, KLVEnabled = true, UsePipe = true, }; ``` Subscribe to `VideoCaptureCore.OnDataFrameBuffer` and filter for `DataFrameType.KLV` to read the live KLV packets as they arrive. See the `ip-camera-klv-mpegts-recorder` code snippet under `_DEMOS/Video Capture SDK/_CodeSnippets/`. ## Demos - **KLV Demo** (WPF) — `_DEMOS/Media Blocks SDK/WPF/CSharp/KLV Demo` — extract KLV from an MPEG-TS file and parse MISB 0601 elements in a viewer. - **ip-camera-klv-mpegts-recorder** (code snippet) — `_DEMOS/Video Capture SDK/_CodeSnippets/ip-camera-klv-mpegts-recorder` — capture a MISB IP camera and record/restream KLV in MPEG-TS. ## See also - [MPEG-TS Stream Analyzer Block](../../Special/TSAnalyzerBlock/) — PAT/PMT/PCR, per-PID bitrate, and TR 101 290 compliance. - [Record a UDP MPEG-TS Stream Without Re-encoding](../udp-mpegts-record-without-reencoding/) - [Media Demuxer Blocks](../../Demuxers/) - [Sinks — KLV File Sink](../../Sinks/#klv-file-sink) ---END OF PAGE--- ## Live Subtitles and Speech-to-Text in C# .NET (Whisper) **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/live-subtitles-whisper-csharp/ **Description:** Transcribe audio and video to text or live subtitles in C# with the Media Blocks SDK .NET using a local Whisper model and Silero VAD — no cloud, fully offline. **Tags:** Media Blocks SDK, .NET, Whisper, Speech-to-Text, Subtitles, VAD, C# **API:** SpeechToTextBlock, SpeechToTextSettings, SileroVadSettings, SpeechRecognizedEventArgs # Live Subtitles and Speech-to-Text in C# .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Overview `SpeechToTextBlock` adds **local, offline speech recognition** to any Media Blocks pipeline. It runs the [Whisper](https://github.com/openai/whisper) ASR model (through [Whisper.net](https://github.com/sandrohanea/whisper.net), the whisper.cpp / GGML backend) on the CPU or an NVIDIA GPU (CUDA), with optional [Silero VAD](https://github.com/snakers4/silero-vad) voice-activity detection to split speech into clean segments. Nothing is sent to the cloud. The block sits **inline** in the audio path — audio passes through unchanged — and raises an `OnSpeechRecognized` event with timed text segments. Use it to: 1. **Transcribe a media file** to text, SRT, or VTT (lossless, paced to the transcriber). 2. **Caption a live source** (microphone, capture card, RTSP camera) in real time. ``` graph LR; Source-->SpeechToTextBlock; SpeechToTextBlock-->AudioRendererBlock; SpeechToTextBlock-. OnSpeechRecognized .->App[Your app]; ``` The block lives in the `VisioForge.Core.MediaBlocks.AI` namespace and ships in the **VisioForge AI Whisper** add-on — NuGet package `VisioForge.DotNet.Core.AI.Whisper` (assembly `VisioForge.Core.AI.Whisper`), built on `Whisper.net`. It needs the usual platform runtime package (for example `VisioForge.CrossPlatform.Core.Windows.x64`) and works on Windows, Linux, and macOS. ## Models The Whisper GGML weights and the Silero VAD model are **downloaded at runtime** — neither is shipped inside the NuGet packages. Cache them once and reuse the local files: - **Whisper GGML model** (`ggml-*.bin`): download with Whisper.net's `WhisperGgmlDownloader`, or fetch a `ggml-*.bin` from the whisper.cpp model repository. - **Silero VAD model** (`silero_vad.onnx`, MIT): from the [silero-vad](https://github.com/snakers4/silero-vad) repository. ``` using Whisper.net.Ggml; // Download the "base" Whisper model to a local cache the first time, then reuse it. var modelsDir = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "VisioForge", "models"); Directory.CreateDirectory(modelsDir); var whisperModelPath = Path.Combine(modelsDir, "ggml-base.bin"); if (!File.Exists(whisperModelPath)) { using var modelStream = await WhisperGgmlDownloader.Default.GetGgmlModelAsync(GgmlType.Base); using var fileStream = File.Create(whisperModelPath); await modelStream.CopyToAsync(fileStream); } // Silero VAD model — download silero_vad.onnx into the same cache (see "Models" above). var sileroModelPath = Path.Combine(modelsDir, "silero_vad.onnx"); ``` Pick the model size by the accuracy/speed/RAM trade-off you need. `SpeechToTextSettings.ModelSize` is informational (it lets your app label or choose a download); the file actually loaded is always `WhisperModelPath`. | `WhisperModelSize` | Notes | | --- | --- | | `Tiny` / `TinyQuantized` | Fastest, lowest accuracy. | | `Base` | Good real-time CPU default. | | `Small` / `Medium` | Higher accuracy, heavier. | | `LargeV3` / `LargeV3Turbo` | Highest accuracy; GPU recommended. | ## Transcribe a media file For file transcription, enable **backpressure** so nothing is dropped: the block paces the source to exactly the transcription throughput (lossless), and the pipeline runs as fast as Whisper can keep up. Pair it with a non-synced sink so no real-time clock caps the speed. ``` using VisioForge.Core; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AI; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.Special; // NullRendererBlock using VisioForge.Core.Types; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.AI; using VisioForge.Core.Types.X.Sources; await VisioForgeX.InitSDKAsync(); var pipeline = new MediaBlocksPipeline(); var settings = new SpeechToTextSettings(whisperModelPath) { Language = "auto", // ISO 639-1 code ("en", "es", "fr") or "auto" Provider = OnnxExecutionProvider.Auto, // CUDA when available, else CPU EnableVad = true, // segment speech with Silero VAD BackpressureWhenBusy = true, // lossless: pace the source to Whisper OutputSrtPath = "subtitles.srt", // optional side-car SRT (VTT via OutputVttPath) }; settings.Vad.ModelPath = sileroModelPath; // path to silero_vad.onnx // Audio-only source from a file. var source = new UniversalSourceBlock( await UniversalSourceSettings.CreateAsync("input.mp4", renderVideo: false, renderAudio: true)); var stt = new SpeechToTextBlock(settings); stt.OnSpeechRecognized += (s, e) => { foreach (var seg in e.Segments) { if (!string.IsNullOrWhiteSpace(seg.Text)) { Console.WriteLine($"[{seg.StartTime:hh\\:mm\\:ss}] {seg.Text.Trim()}"); } } }; // Non-synced null sink: no real-time clock, so the run is bounded only by transcription speed. var sink = new NullRendererBlock(MediaBlockPadMediaType.Audio) { IsSync = false }; pipeline.Connect(source.AudioOutput, stt.Input); pipeline.Connect(stt.Output, sink.Input); await pipeline.StartAsync(); ``` Setting `OutputSrtPath` (or `OutputVttPath`) makes the block write a subtitle file directly as final segments are recognized — no extra code needed. ## Caption a live source For a live capture device, keep `BackpressureWhenBusy = false` (the default). A live device cannot slow down, so the block's internal audio ring overwrites the oldest samples on overload instead of stalling the source — captions stay close to real time at the cost of dropping audio when the transcriber falls behind. ``` using VisioForge.Core.MediaBlocks.AudioRendering; using VisioForge.Core.MediaBlocks.Sources; // Pick the first system microphone. var audioDevices = await SystemAudioSourceBlock.GetDevicesAsync(); var mic = new SystemAudioSourceBlock(audioDevices[0].CreateSourceSettings()); var settings = new SpeechToTextSettings(whisperModelPath) { Language = "en", Provider = OnnxExecutionProvider.Auto, EnableVad = true, BackpressureWhenBusy = false, // live: never stall the device; drop oldest audio on overload }; settings.Vad.ModelPath = sileroModelPath; var stt = new SpeechToTextBlock(settings); stt.OnSpeechRecognized += (s, e) => { // Raised on a background worker thread — marshal to the UI thread before touching UI. foreach (var seg in e.Segments) { Console.WriteLine(seg.Text); } }; var audioRenderer = new AudioRendererBlock(); pipeline.Connect(mic.Output, stt.Input); // audio passes through the block unchanged pipeline.Connect(stt.Output, audioRenderer.Input); await pipeline.StartAsync(); ``` Backpressure and live sources Never set `BackpressureWhenBusy = true` on a live capture source — a microphone or camera cannot slow down to absorb the backpressure. Use backpressure only for file/seekable sources, and pair it with a non-synced sink (`NullRendererBlock { IsSync = false }`). ## Recognition results `OnSpeechRecognized` is raised on a **background worker thread** and carries a `SpeechRecognizedEventArgs`: - `Segments` — a `SpeechSegment[]` (one event may carry several segments). - `Timestamp` — the media time the segments belong to. Each `SpeechSegment` has: | Property | Description | | --- | --- | | `Text` | The recognized text. | | `StartTime` / `EndTime` | Span on the media timeline (ready for SRT/VTT or an overlay schedule). | | `Language` | Detected/used language (ISO 639-1), or `null`. | | `Confidence` | Average token confidence (0..1), or 0 when the model does not report it. | | `IsFinal` | Always `true` today (reserved for future interim hypotheses). | ## Key settings | Property | Default | Description | | --- | --- | --- | | `WhisperModelPath` | — | Absolute path to the Whisper GGML model (`ggml-*.bin`). Required. | | `Language` | `"auto"` | ISO 639-1 code or `"auto"` for detection. | | `Task` | `Transcribe` | `Transcribe` (source language) or `Translate` (to English). | | `Provider` | `Auto` | `CPU` or `CUDA` are meaningful (GGML has no DirectML); `Auto` picks CUDA when present, else CPU. | | `DeviceId` | `0` | GPU device id when a GPU provider is used. | | `Threads` | `0` | CPU threads; `0` lets Whisper.net choose. | | `EnableVad` | `true` | Use Silero VAD to segment speech. Disable for fixed-window chunking. | | `Vad` | (defaults) | `SileroVadSettings` — set `Vad.ModelPath` to `silero_vad.onnx`. | | `FixedWindowSeconds` | `5` | Window length when `EnableVad = false` (clamped to 1–30 s). | | `BackpressureWhenBusy` | `false` | `false` = live (drop oldest); `true` = file (lossless, paced). | | `OutputSrtPath` | `null` | Optional side-car `.srt` written as segments finalize. | | `OutputVttPath` | `null` | Optional side-car `.vtt` (WebVTT). | `SileroVadSettings` exposes `SpeechThreshold` (0.5), `MinSilenceMs` (100), `MinSpeechMs` (250), `SpeechPadMs` (30), and `MaxSpeechMs` (15000) to tune segmentation, plus its own `Provider`/`DeviceId`. Call the static `SpeechToTextBlock.IsAvailable()` to verify the AI Whisper redistributable is present before building a pipeline. ## Demos - **Live Subtitles** (Console) — `_DEMOS/Media Blocks SDK/Console/Live Subtitles` — file transcription with backpressure and progress reporting. - **Live Subtitles Demo** (WPF) — `_DEMOS/Media Blocks SDK/WPF/CSharp/Live Subtitles Demo` — live microphone/camera captioning with an on-screen overlay. - **Live Subtitles MB** (MAUI) — `_DEMOS/Media Blocks SDK/MAUI/Live Subtitles MB`. ## See also - [AI Blocks: OCR, License Plate Recognition, and Object Analytics](../../AI/) - [ElevenLabs Text-to-Speech and Voice Cloning](../../ElevenLabs/) ---END OF PAGE--- ## MPEG-TS Analysis in C# .NET: VisioForge vs ffprobe **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/mpeg-ts-analysis-vs-ffprobe/ **Description:** In-process .NET MPEG-TS analysis with live ETSI TR 101 290 monitoring — how the Media Blocks SDK TS Analyzer compares to ffprobe and broadcast analyzers. **Tags:** Media Blocks SDK, .NET, MPEG-TS, Analysis, TR 101 290, ffprobe, Streaming, C# **API:** TSAnalyzerBlock, TSAnalyzerReport, TSAnalyzerSettings # MPEG-TS Analysis in C#: VisioForge vs ffprobe [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Why this matters ffprobe is a superb command-line tool for a quick look at a media file. But the moment you need transport-stream analysis **inside a .NET application** — a live monitoring dashboard, an ingest validator, an automated QC gate — the CLI model starts working against you: you have to spawn a separate process, capture its text or JSON output, parse it, and you still only get a one-shot snapshot with no compliance framework. The [Media Blocks SDK .NET](https://www.visioforge.com/media-blocks-sdk-net) `TSAnalyzerBlock` is built for exactly that job. It is an **in-process, live, broadcast-grade MPEG-TS monitor** that reports strongly-typed results continuously, with full ETSI **TR 101 290** Priority 1/2/3 compliance — something ffprobe simply does not provide. ## What sets the TS Analyzer apart ### 1. In-process, strongly-typed — no CLI, no text parsing You connect a source block to the analyzer and read a `TSAnalyzerReport` object. No `Process.Start`, no stdout capture, no brittle string/JSON parsing, no version-dependent output format to track. Every metric is a typed property you can bind, log, or assert on directly. ### 2. Live and event-driven ffprobe is one-shot: it runs, prints, exits. The `TSAnalyzerBlock` raises `OnAnalysisUpdated` on a configurable cadence (every second by default) for the entire life of the stream — perfect for real-time dashboards, drift detection, and alerting. A final report is delivered at end-of-stream. ### 3. Broadcast-grade TR 101 290 — built in The analyzer evaluates the full TR 101 290 Priority 1/2/3 check list (sync loss, PAT/PMT/PID errors, continuity-count errors, transport errors, CRC errors, PCR/PTS errors, SDT/EIT/TDT/NIT errors) and returns each check with its priority, error count, and pass/fail status. ffprobe has no equivalent compliance framework — you would have to build one yourself on top of its output. ### 4. Passthrough mode — analyze while you record or relay In `InputOutput` mode the original transport stream is forwarded unchanged to the next block, so you can validate a feed **at the same time** as you record or restream it — zero re-mux, one pipeline. ffprobe sits outside your media path entirely. ### 5. One API, any source, every platform File, UDP (unicast and multicast), and SRT all feed the same analyzer through the same API, on Windows, macOS, Linux, iOS, and Android. ## Feature comparison The matrix below reflects the **current** capabilities of the `TSAnalyzerBlock`. ✅ = supported, ⚠️ = partial/indirect, ❌ = not available. | Capability | VisioForge TS Analyzer | ffprobe | | --- | --- | --- | | Packet size 188/192 auto-detect | ✅ | ✅ | | PAT/PMT, programs, PCR PID | ✅ | ✅ | | stream\_type → codec | ✅ | ✅ | | Per-PID bitrate + packet count | ✅ | ⚠️ | | Per-PID instantaneous + peak bitrate | ✅ | ❌ | | Continuity-counter errors | ✅ | ⚠️ | | PCR interval min/avg/max + discontinuities | ✅ | ❌ | | PCR jitter (max) + repetition >40 ms | ✅ | ❌ | | PCR accuracy / drift (ppm) | ⚠️ | ❌ | | Transport-error indicator | ✅ | ⚠️ | | Null % / stuffing / effective bitrate | ✅ | ❌ | | Scrambling (TSC + free\_CA\_mode) | ✅ | ⚠️ | | PTS/DTS presence + A/V sync offset | ✅ | ✅ | | SDT → service name / provider / type | ✅ | ⚠️ | | Audio language (ISO 639, PMT) | ✅ | ✅ | | NIT network name; TDT/TOT stream UTC | ✅ | ⚠️ | | EIT → EPG events | ✅ (opt-in) | ⚠️ | | Unreferenced PID detection | ✅ | ❌ | | Codec resolution / profile / level / chroma / aspect | ✅ (H.264/HEVC/MPEG-2) | ✅ | | CRC-32 PSI validation | ✅ | ⚠️ | | **Structured TR 101 290 P1/P2/P3** | ✅ | ❌ | | **In-process .NET API (no CLI / parsing)** | ✅ | ❌ | | **Live continuous monitoring (events)** | ✅ | ❌ | | **Passthrough (analyze while recording/relaying)** | ✅ | ❌ | | Cross-platform (Windows/macOS/Linux/mobile) | ✅ | ✅ | A few honest notes so the table stays trustworthy. Codec coverage is per-attribute, not uniform: **resolution** is parsed for H.264, HEVC, and MPEG-2; **profile, level, and chroma** for H.264/HEVC only; **aspect ratio and frame rate** from the MPEG-1/2 sequence header (not yet from the H.264/HEVC VUI). The PCR clock **drift in ppm** field is reserved and not yet computed (jitter and repetition are). ffprobe also remains excellent at exhaustive per-codec metadata and supports a far wider range of container/codec formats beyond MPEG-TS. ## When to use which - **Reach for ffprobe** when you want a quick terminal check of an arbitrary media file, or you are scripting a one-off in a shell and the format may not be MPEG-TS. - **Reach for the `TSAnalyzerBlock`** when transport-stream analysis needs to live **inside your .NET app** — continuous monitoring, TR 101 290 compliance gating, live dashboards/alerts, or analyzing a feed while you simultaneously record or relay it. They are not mutually exclusive: many teams use ffprobe at the desk and ship VisioForge in the product. ## Next steps - [MPEG-TS Stream Analyzer Block](../../Special/TSAnalyzerBlock/) — the full block reference: modes, settings, and the complete report model. - [Analyze and validate an MPEG-TS stream in C#](../mpeg-ts-stream-validation-csharp/) — a step-by-step task guide. ---END OF PAGE--- ## Analyze and Validate MPEG-TS Transport Streams in C# **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/mpeg-ts-stream-validation-csharp/ **Description:** Step-by-step C# guide to analyze a file or live UDP/SRT MPEG-TS stream, read ETSI TR 101 290 results, and alert on errors with the Media Blocks SDK .NET. **Tags:** Media Blocks SDK, .NET, MPEG-TS, Analysis, TR 101 290, UDP, SRT, C# **API:** TSAnalyzerBlock, TSAnalyzerSettings, TSAnalyzerReport, UDPRAWMPEGTSSourceBlock # Analyze and Validate MPEG-TS Streams in C# .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) ## Overview This guide shows how to analyze and validate an MPEG-TS transport stream from C# using the [Media Blocks SDK .NET](https://www.visioforge.com/media-blocks-sdk-net) `TSAnalyzerBlock`. You will: 1. Analyze a local `.ts` / `.m2ts` file and read the final report. 2. Monitor a **live** `udp://` or `srt://` feed with periodic updates. 3. Read **ETSI TR 101 290** results and raise an alert when the stream is non-compliant. 4. Analyze a feed **while you record it** using passthrough mode. For the full API reference (every setting and report field), see the [MPEG-TS Stream Analyzer Block](../../Special/TSAnalyzerBlock/) page. ## Prerequisites Install the Media Blocks SDK NuGet package and the platform runtime package: - `VisioForge.DotNet.MediaBlocks` - A platform runtime, e.g. `VisioForge.CrossPlatform.Core.Windows.x64` on Windows. Initialize the SDK once at startup: ``` using VisioForge.Core; await VisioForgeX.InitSDKAsync(); ``` The namespaces used throughout this guide: ``` using System; using System.Linq; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.Special; using VisioForge.Core.Types.X; using VisioForge.Core.Types.X.Sources; using VisioForge.Core.Types.X.Special; ``` ## 1. Analyze a file For a file, run the pipeline to end-of-stream and read the final report. Connect the analyzer in `Input` mode (terminal): ``` var pipeline = new MediaBlocksPipeline(); var source = new BasicFileSourceBlock("stream.ts"); var analyzer = new TSAnalyzerBlock(TSAnalyzerMode.Input); // Signal completion when the pipeline stops on its own (end-of-stream). var completed = new TaskCompletionSource(); pipeline.OnStop += (s, e) => completed.TrySetResult(true); pipeline.Connect(source.Output, analyzer.Input); await pipeline.StartAsync(); await completed.Task; // wait for end-of-stream await pipeline.StopAsync(); TSAnalyzerReport report = analyzer.GetReport(); Console.WriteLine($"Packet size: {report.PacketSize} | total: {report.TotalBitrateKbps:F0} kbps"); Console.WriteLine($"Programs: {report.Programs.Count} | PAT: {(report.HasPAT ? "yes" : "no")}"); foreach (var program in report.Programs) { var name = string.IsNullOrEmpty(program.ServiceName) ? "(no name)" : program.ServiceName; Console.WriteLine($"Program {program.ProgramNumber} \"{name}\" (PMT {program.PmtPid}, PCR {program.PcrPid})"); foreach (var es in program.Streams) { var lang = string.IsNullOrEmpty(es.Language) ? "" : $" [{es.Language}]"; Console.WriteLine($" PID {es.Pid} {es.Kind} {es.Codec}{lang}"); } } ``` ## 2. Monitor a live stream For a live `udp://` or `srt://` feed, subscribe to `OnAnalysisUpdated` and read each periodic snapshot. Set `StatisticsInterval` to control the cadence. ``` var pipeline = new MediaBlocksPipeline(); // Live UDP multicast (raw MPEG-TS, no demux) var source = new UDPRAWMPEGTSSourceBlock(new UDPRAWMPEGTSSourceSettings("udp://239.0.0.1:1234")); var analyzer = new TSAnalyzerBlock( TSAnalyzerMode.Input, new TSAnalyzerSettings { StatisticsInterval = TimeSpan.FromSeconds(1) }); analyzer.OnAnalysisUpdated += (sender, e) => { if (e.IsFinal) { return; // end-of-stream report; periodic snapshots have IsFinal == false } TSAnalyzerReport report = e.Report; Console.WriteLine( $"{report.TotalBitrateKbps:F0} kbps total, " + $"{report.EffectiveBitrateKbps:F0} kbps effective, " + $"programs: {report.Programs.Count}"); }; pipeline.Connect(source.Output, analyzer.Input); await pipeline.StartAsync(); // ... keep running while you monitor ... ``` To feed SRT instead of UDP, swap the source: ``` var srtSettings = await SRTSourceSettings.CreateAsync(new Uri("srt://server:9000"), ignoreMediaInfoReader: true); var source = new SRTRAWSourceBlock(srtSettings); ``` > **Threading.** Periodic `OnAnalysisUpdated` callbacks run on a background timer thread. In a UI app, marshal to the UI thread before updating controls — e.g. `Dispatcher.BeginInvoke(() => UpdateUI(e.Report));` in WPF. ## 3. Read TR 101 290 and alert on errors The TR 101 290 report groups errors by priority. A common pattern is to alert whenever a Priority 1 (critical) error appears, and to log the individual failing checks: ``` analyzer.OnAnalysisUpdated += (sender, e) => { var tr = e.Report.Tr101290; if (tr == null || tr.AllOk) { return; // TR 101 290 disabled, or the stream is fully compliant } if (tr.P1Count > 0) { RaiseAlert($"Critical TR 101 290 (P1) errors: {tr.P1Count}"); } foreach (var check in tr.Checks.Where(c => c.Count > 0)) { Console.WriteLine($"P{check.Priority} {check.Name}: {check.Count}"); } }; ``` `tr.P1Count` / `P2Count` / `P3Count` give you the per-priority totals; `tr.Checks` lets you drill into a specific failing measurement (for example `PCR_repetition_error` or `Continuity_count_error`). Use `tr.AllOk` as a single-line compliance gate. ## 4. Analyze while recording (passthrough) To validate a feed and record it in the same pipeline, create the analyzer in `InputOutput` mode and connect its `Output` to a sink. The transport stream is forwarded unchanged, so the recording is a bit-exact copy: ``` var pipeline = new MediaBlocksPipeline(); var source = new UDPRAWMPEGTSSourceBlock(new UDPRAWMPEGTSSourceSettings("udp://239.0.0.1:1234")); // Passthrough analyzer: forwards the stream while analyzing it var analyzer = new TSAnalyzerBlock(TSAnalyzerMode.InputOutput); analyzer.OnAnalysisUpdated += (s, e) => { /* monitor while recording */ }; var sink = new MPEGTSSinkBlock(new MPEGTSSinkSettings("recording.ts")); pipeline.Connect(source.Output, analyzer.Input); pipeline.Connect(analyzer.Output, sink.Input); await pipeline.StartAsync(); ``` ## Troubleshooting - **`HasPAT` is false / no programs.** The input is probably not a valid MPEG-TS byte stream, or the packet size was misdetected. Force it via `TSAnalyzerSettings.PacketSize` (`Size188` or `Size192`), or check the source URI. - **Many `PCR_repetition_error` entries on a valid file.** This is expected when the muxer emits PCR slower than the 40 ms TR 101 290 limit (common for file-oriented muxing). The stream still plays; it is simply not 40 ms-PCR compliant. - **`GetReport()` returns null.** The block has not been built yet — call it after `StartAsync()`. - **No multicast packets received.** Verify `AutoJoinMulticast` is `true` (the default) and set `MulticastInterface` if the host has multiple network interfaces. - **High CPU on a heavy stream.** Disable stages you do not need via `TSAnalyzerSettings` — `ParseEPG` is off by default; you can also turn off `ParseCodecDetails` or `TrackPtsDts`. ## Frequently asked questions ### How do I analyze a live UDP multicast MPEG-TS stream in C#? Create a `UDPRAWMPEGTSSourceBlock` with a `udp://group:port` URI, connect its `Output` to a `TSAnalyzerBlock` in `Input` mode, and subscribe to `OnAnalysisUpdated` for periodic snapshots. See [section 2](#2-monitor-a-live-stream). ### Can I check ETSI TR 101 290 compliance from .NET? Yes. With `ValidateTR101290` enabled (the default), `report.Tr101290` exposes the Priority 1/2/3 check list with per-check counts and pass/fail status, plus `P1Count`/`P2Count`/`P3Count` totals and an `AllOk` flag. See [section 3](#3-read-tr-101-290-and-alert-on-errors). ### Can I record a stream and analyze it at the same time? Yes. Use `TSAnalyzerMode.InputOutput` and connect the analyzer's `Output` to a sink such as `MPEGTSSinkBlock`. The stream is forwarded unchanged. See [section 4](#4-analyze-while-recording-passthrough). ## See also - [MPEG-TS Stream Analyzer Block](../../Special/TSAnalyzerBlock/) — the complete block reference. - [MPEG-TS Analysis in C#: VisioForge vs ffprobe](../mpeg-ts-analysis-vs-ffprobe/) — positioning and feature comparison. ---END OF PAGE--- ## Multi-Camera RTSP Grid in C# .NET for 4x4 NVR Walls **URL:** https://www.visioforge.com/help/docs/dotnet/mediablocks/Guides/multi-camera-rtsp-grid/ **Description:** Build a 4×4 NVR-style RTSP camera wall in C# / .NET with VisioForge Media Blocks SDK. WPF and MAUI examples, synchronized start, low-latency tuning. **Tags:** Media Blocks SDK, .NET, MediaBlocksPipeline, Windows, macOS, Android, iOS, WPF, MAUI, GStreamer, Streaming, Decoding, Mixing, IP Camera, RTSP, ONVIF, H.264, C#, NuGet **API:** VideoView, RTSPPlayEngine, VideoRendererBlock, RTSPSourceSettings, IVideoView # Multi-Camera RTSP Grid — 4×4 NVR Wall in C# / .NET [Media Blocks SDK .Net](https://www.visioforge.com/media-blocks-sdk-net) Cross-platform support The Media Blocks SDK runs on **Windows, macOS, Linux, Android, and iOS** via GStreamer — the WPF and MAUI examples below cover the full cross-platform story. See the [platform support matrix](../../../platform-matrix/) for codec and hardware-acceleration details, and the [Linux deployment guide](../../../deployment-x/Ubuntu/) for Ubuntu / NVIDIA Jetson / Raspberry Pi setup. This guide shows how to build a 4×4 live preview grid (16 RTSP cameras at once) using the VisioForge Media Blocks SDK — the classic NVR / video wall / surveillance dashboard layout. You'll get a reusable `RTSPPlayEngine` helper class plus full XAML + code-behind examples for WPF and MAUI, including the synchronized-start pattern that keeps all 16 streams frame-aligned on screen. ## Architecture — One Pipeline per Camera The Media Blocks SDK supports two ways to show multiple videos at once, and picking the right one matters: - **One pipeline per camera, one `VideoRendererBlock` per cell** (this guide). Each camera gets its own `MediaBlocksPipeline` + `RTSPSourceBlock` + `VideoRendererBlock`, and each `VideoRendererBlock` draws into its own `VideoView` on the UI. This is what an NVR wall needs — 16 independent streams, each resizable, each restartable on its own. - **One pipeline with `VideoMixerBlock`** compositing all sources into a single output frame. Useful when you want a single merged video (stream the whole wall out as one RTMP feed, record it as one MP4). Not what you want for an interactive preview grid — you lose independent control. This guide uses the first pattern. The topology for 16 cameras: ``` ┌───────────────────────┐ ┌──────────────────────┐ │ RTSPSourceBlock #0 │ ──► │ VideoRendererBlock #0 │ ──► videoView[0,0] └───────────────────────┘ └──────────────────────┘ ┌───────────────────────┐ ┌──────────────────────┐ │ RTSPSourceBlock #1 │ ──► │ VideoRendererBlock #1 │ ──► videoView[0,1] └───────────────────────┘ └──────────────────────┘ ... ×16 independent pipelines ... ``` ## Required NuGet Packages **WPF (Windows x64)**: - [VisioForge.DotNet.Core.UI.WPF](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.WPF/) — WPF `VideoView` control - [VisioForge.CrossPlatform.Core.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Windows.x64/) — GStreamer runtime for Windows x64 **MAUI (Windows / Android / iOS / macCatalyst)**: - [VisioForge.DotNet.Core.UI.MAUI](https://www.nuget.org/packages/VisioForge.DotNet.Core.UI.MAUI/) — MAUI `VideoView` control - Per-platform: [VisioForge.CrossPlatform.Core.Windows.x64](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Windows.x64/), [VisioForge.CrossPlatform.Core.Android](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.Android/), [VisioForge.CrossPlatform.Core.iOS](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.iOS/), [VisioForge.CrossPlatform.Core.macCatalyst](https://www.nuget.org/packages/VisioForge.CrossPlatform.Core.macCatalyst/) ## The Reusable `RTSPPlayEngine` Helper Both the WPF and MAUI examples use the same wrapper class. It takes an already-configured `RTSPSourceSettings` plus an `IVideoView`, builds a single-pipeline playback graph, and exposes async lifecycle methods plus an `OnError` event. ``` using System; using System.Threading.Tasks; using VisioForge.Core.MediaBlocks; using VisioForge.Core.MediaBlocks.AudioRendering; using VisioForge.Core.MediaBlocks.Sources; using VisioForge.Core.MediaBlocks.VideoRendering; using VisioForge.Core.Types; using VisioForge.Core.Types.Events; using VisioForge.Core.Types.X.Sources; public class RTSPPlayEngine : IAsyncDisposable { private MediaBlocksPipeline _pipeline; private VideoRendererBlock _videoRenderer; private AudioRendererBlock _audioRenderer; private RTSPSourceBlock _source; private bool _disposed; public event EventHandler OnError; public RTSPPlayEngine(RTSPSourceSettings rtspSettings, IVideoView videoView) { _pipeline = new MediaBlocksPipeline(); _pipeline.OnError += (s, e) => OnError?.Invoke(this, e); _source = new RTSPSourceBlock(rtspSettings); _videoRenderer = new VideoRendererBlock(_pipeline, videoView) { IsSync = false }; _pipeline.Connect(_source.VideoOutput, _videoRenderer.Input); if (rtspSettings.AudioEnabled) { _audioRenderer = new AudioRendererBlock() { IsSync = false }; _pipeline.Connect(_source.AudioOutput, _audioRenderer.Input); } } // Start the pipeline in paused state (used for synchronized start) public Task PreloadAsync() => _pipeline.StartAsync(true); // Start playing immediately (non-synchronized use) public Task StartAsync() => _pipeline.StartAsync(); // Resume a pipeline that was preloaded public Task ResumeAsync() => _pipeline.ResumeAsync(); public Task StopAsync() => _pipeline.StopAsync(true); public bool IsPaused() => _pipeline.State == PlaybackState.Pause; public bool IsStarted() => _pipeline.State == PlaybackState.Play; public async ValueTask DisposeAsync() { if (_disposed) return; _disposed = true; if (_pipeline != null) { await _pipeline.DisposeAsync(); _pipeline = null; } _videoRenderer?.Dispose(); _audioRenderer?.Dispose(); _source?.Dispose(); } } ``` The two key design points: - **`IsSync = false`** on both renderers. For live surveillance you want drop-late-frame behaviour, not the default clock-based lipsync (which would stall the whole cell if a single packet is late). - **`PreloadAsync` vs `StartAsync`**. `PreloadAsync` calls `pipeline.StartAsync(true)` which preloads the pipeline into Paused state. Combined with a later `ResumeAsync` this lets you fire up all 16 cameras, wait until each is sitting at its first frame, then kick them all to Play at once — no stagger on the wall. ## WPF Example — 4×4 Grid ### XAML ```