A method of controlling a video transcoding device and a transcoding method
By virtualizing the video transcoding device as a storage device and dividing and mapping the LBAs of I/O read and write commands, the system incompatibility and permission issues of ioctl control of the video transcoding device are resolved, achieving cross-operating system compatibility and security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- RONG MING MICROELECTRONICS (JINAN) CO LTD
- Filing Date
- 2022-09-30
- Publication Date
- 2026-07-03
AI Technical Summary
Existing methods for controlling video transcoding devices via ioctl suffer from system incompatibility and require administrator privileges.
The video transcoding device is virtualized as a storage device, and the logical block address (LBA) of the I/O read and write commands is divided according to a preset partitioning principle. Different segments are mapped to different preset encoding and decoding commands according to a preset mapping principle, and the video transcoding device is controlled through I/O read and write commands.
It achieves compatibility between the operating system and the video transcoding device, avoids administrator privilege requirements, supports virtual machines and containers, and ensures the security and compatibility of the operating system.
Smart Images

Figure CN115633004B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method for controlling a video transcoding device and a transcoding method. Background Technology
[0002] Common I / O operations include opening a device, closing a device, reading from a device, writing to a device, and managing device I / O (ioctl). To fully control a video transcoding device's encoding and decoding, "control commands" are generally needed to configure transcoding parameters and obtain transcoding status. Additionally, "read commands" are needed to retrieve the transcoded video stream, and "write commands" are needed to write the video stream to be transcoded. Currently, these three commands are typically implemented using ioctl. ioctl is a system call specifically for device input / output operations. It can use command codes to tell the driver what operation it wants to control the device to perform. For example, on a Linux system, a video transcoding device using an NVMe driver can be controlled by sending the 0x42 command code via ioctl, and read / write operations can be performed by sending the 0x43 command code via ioctl.
[0003] However, existing methods for controlling video transcoding via ioctl have significant limitations. First, ioctl operations generally require administrator privileges, and their compatibility is poor. Different operating systems or virtualization technologies use different drivers, requiring the development of new interfaces for each driver, all of which limit the application of video transcoding devices. Summary of the Invention
[0004] This invention provides a method for controlling a video transcoding device and a transcoding method to solve the problem of system incompatibility in the prior art when using ioctl for video transcoding.
[0005] Firstly, a control method for a video transcoding device, applied to an operating system, includes: virtualizing the video transcoding device as a storage device; dividing the logical block addresses (LBAs) of I / O read / write commands according to a preset partitioning principle; and mapping different segments to different preset encoding / decoding commands according to a preset mapping principle; mapping the I / O read / write commands to preset encoding / decoding commands through the LBAs of the I / O read / write commands, thereby controlling the video transcoding device by sending I / O read / write commands to the storage device, ultimately achieving video compression processing; wherein the preset encoding / decoding commands include open commands, close commands, control commands, read commands, and write commands.
[0006] Optionally, the preset division principle is set to meet the requirement of identifying and distinguishing each preset encoding and decoding command.
[0007] Optionally, the logical block addresses (LBAs) of I / O read / write commands are divided according to a preset partitioning principle, and different segments are mapped to different preset encoding / decoding commands according to a preset mapping principle, including:
[0008] The logical block address (LBA) of the I / O read / write command is divided into multiple segments according to the flag bits required by the preset encoding / decoding command. Different segments are then assigned to different preset encoding / decoding commands according to the preset mapping principle.
[0009] Optionally, the identifier bits include: instance number identifier bit, device type identifier bit, command type identifier bit, operation type identifier bit, and operation subtype identifier bit;
[0010] The instance number identifier, which occupies 7 bits, is used to identify the video stream;
[0011] The device type identifier bit occupies 1 bit and is used to identify decoding commands and encoding commands to distinguish whether they are decoding commands or encoding commands;
[0012] The command type identifier bit occupies 2 bits and is used to identify the command type, which includes control commands, read input stream commands, and write input stream commands.
[0013] The operation type identifier, which occupies 3 bits, is used to identify the operation type of the control command. The operation types include: open instance, close instance, query command, and configuration command.
[0014] The operation subtype occupies 4 bits and is used to identify the specific operation that distinguishes each operation type.
[0015] Optionally, the method further includes setting a reserved bit of a preset number of bits for each of the instance number identifier bit, the device type identifier bit, the command type identifier bit, the operation type identifier bit, and the operation subtype identifier bit, so as to facilitate the subsequent addition of encoding paths and encoding types.
[0016] Optionally, controlling the video transcoding device by sending I / O read / write commands to the storage device includes:
[0017] The video transcoding device can be controlled to perform corresponding operations by sending I / O read and write commands to the storage device.
[0018] Optionally, the step of dividing the logical block address (LBA) of I / O read / write commands according to a preset partitioning principle, and assigning different segments to different preset encoding / decoding commands according to a preset mapping principle, includes:
[0019] The logical block address (LBA) of I / O read / write commands is divided into multiple segments according to a preset partitioning principle. Each LBA segment is uniquely associated with a preset encoding / decoding command according to the order of the LBA segments. The correspondence between LBA segments and preset encoding / decoding commands is saved for later querying.
[0020] Secondly, the present invention provides a transcoding method based on any of the control methods described above, applied to a video transcoding device. The method includes: receiving a preset encoding / decoding command sent by an operating system; parsing the preset encoding / decoding command based on a preset mapping principle to obtain an instance number of the preset encoding / decoding command; configuring transcoding parameters according to the instance number; and completing the control operation of the video transcoding device based on the configured transcoding parameters.
[0021] Optionally, configuring transcoding parameters based on the instance number includes configuring the video format and resolution based on the instance number.
[0022] Thirdly, the present invention provides a computer-readable storage medium storing a computer program for signal mapping, which, when executed by at least one processor, implements the control method of any of the video transcoding devices described above, and / or the transcoding method described above.
[0023] The beneficial effects of this invention are as follows:
[0024] This invention divides the LBA (Logical Block Address) of read and write commands, assigning different LBAs to represent different transcoding commands. This allows for communication between the operating system and the video transcoding device via I / O read / write commands, independent of the operating system's explicit control and without requiring administrator privileges. Thus, it achieves video transcoding compatibility while ensuring operating system security. In other words, this invention guarantees the compatibility of the video transcoding device on any operating system, addresses permission management issues, and provides excellent support for virtual machines and containers without requiring additional permission settings.
[0025] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0026] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0027] Figure 1 This is a flowchart illustrating a control method for a video transcoding device provided in the first embodiment of the present invention;
[0028] Figure 2 This is a flowchart illustrating another control method for a video transcoding device provided in the first embodiment of the present invention;
[0029] Figure 3 This is a flowchart illustrating a video transcoding method provided in the second embodiment of the present invention. Detailed Implementation
[0030] This invention addresses the issues of system incompatibility and the need for administrator privileges in existing video transcoding methods using ioctl. By dividing the LBA (Logical Block Address) of read and write commands, different LBAs represent different transcoding commands. This allows for communication between the operating system and the video transcoding device through I / O read / write commands, independent of the operating system's explicit control and without requiring administrator privileges. Thus, video transcoding compatibility is achieved while ensuring operating system security. The invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and do not limit the scope of the invention.
[0031] The first embodiment of the present invention provides a control method for a video transcoding device, see below. Figure 1 Applied to operating systems, the method includes:
[0032] S101. Virtualize the video transcoding device as a storage device, and divide the logical block address (LBA) of I / O read and write commands according to the preset division principle, and assign different preset encoding and decoding commands to different segments according to the preset mapping principle.
[0033] That is, in this embodiment of the invention, the logical block address (LBA) of the I / O read / write command is divided into multiple segments according to a preset division principle. In accordance with the order of the divided LBA segments, each LBA segment is set to uniquely correspond to a preset encoding / decoding command. At the same time, the correspondence between the LBA segments and the preset encoding / decoding commands is saved for subsequent querying.
[0034] In this embodiment of the invention, the preset partitioning principle can be set according to the LBA block order, etc., and the preset mapping principle can also be set arbitrarily. After the mapping is completed, the LBA blocks and the corresponding commands are matched by setting an identifier. Of course, they can also be stored in a table, and the correspondence between blocks and commands can be clarified by looking up the table, etc. Those skilled in the art can set it according to actual needs, and this invention does not make specific limitations in this regard.
[0035] For example, in practical implementation, each command can be assigned a unique corresponding number, and then the LBA block can be bound to its corresponding command through this number.
[0036] S102. The I / O read / write command is mapped to a preset encoding / decoding command through the logical block address (LBA) of the I / O read / write command, so as to control the video transcoding device by sending I / O read / write commands to the storage device, and finally realize the compression processing of the video.
[0037] The preset encoding / decoding commands include open commands, close commands, control commands, read commands, and write commands.
[0038] In other words, this invention implements communication between the operating system and the video transcoding device by dividing the LBA (Logical Block Address) of read and write commands and assigning different LBAs to represent different transcoding commands. This allows communication to be achieved without being controlled by the operating system or requiring administrator privileges, thus ensuring video transcoding compatibility while maintaining operating system security. In other words, the method described in this invention guarantees device compatibility on any operating system and resolves permission management issues, while also providing excellent support for virtual machines and containers without requiring additional permission settings.
[0039] In simple terms, this invention divides the Logical Block Address (LBA) of I / O read / write commands based on the principle of identifying and distinguishing various preset encoding / decoding commands. This allows different segments to correspond to different preset encoding / decoding commands, thereby enabling control of the video transcoding device via I / O read / write commands. In other words, this invention controls the video transcoding device to perform corresponding operations by sending I / O read / write commands to the storage device.
[0040] In a specific implementation, the embodiment of the present invention divides the logical block address (LBA) of the I / O read / write command into multiple segments according to the flag bits required by the preset encoding / decoding command, and assigns different preset encoding / decoding commands to different segments according to the preset mapping principle.
[0041] Specifically, the identifier bits in the embodiments of the present invention may include: instance number identifier bit, device type identifier bit, command type identifier bit, operation type identifier bit, and operation subtype identifier bit;
[0042] The system includes: an instance number identifier (7 bits) for identifying the video stream; a device type identifier (1 bit) for identifying decoding and encoding commands to distinguish between them; a command type identifier (2 bits) for identifying the command type, including control commands, read input stream commands, and write input stream commands; an operation type identifier (3 bits) for identifying the operation type of the control command, including open instance, close instance, query command, and configuration command; and an operation subtype identifier (4 bits) for identifying the specific operation that distinguishes each operation type.
[0043] Of course, the above-mentioned settings of each identifier are just an example. In specific implementation, those skilled in the art can make arbitrary settings according to actual needs. This invention does not make specific limitations in this regard.
[0044] In specific implementation, in order to meet the needs of subsequent expansion, the method described in this embodiment of the invention can also set a preset number of reserved bits for the instance number identifier bit, the device type identifier bit, the command type identifier bit, the operation type identifier bit, and the operation subtype identifier bit, so as to facilitate the subsequent addition of encoding paths and encoding types.
[0045] Once the above settings are completed, the encoding and decoding functions of the transcoding device can be implemented by sending I / O read and write commands to the transcoding device.
[0046] The following will combine Figure 2 The method described in the embodiments of the present invention will be explained and illustrated in detail through a specific example:
[0047] In this embodiment of the invention, the video transcoding device will be recognized by the system as a storage device with a certain capacity, supporting commonly used management commands for storage devices, but without actual data storage functionality. The displayed storage capacity is only a virtual capacity used to implement various video transcoding commands. Encoding and decoding are controlled by reading / writing specific LBA addresses.
[0048] To control the video transcoding process, at least three types of commands are required: control commands, write input stream commands, and read output stream commands. This invention distinguishes different commands using different LBA addresses. Taking a transcoding device supporting up to 128 video channels as an example, the instance number requires 7 bits. Adding the device type, operation type, operation subtype, and reserved bits, a total of 30 bits are needed to distinguish all commands. Assuming the smallest logical block of the transcoding device is 512 bytes, meaning each LBA corresponds to 512 bytes, the LBA addressing range needs to be hexadecimal 0x0 to 0x3FFF FFFF, totaling 30 bits (bits 0 to 29). Therefore, the virtual capacity of the transcoding device needs to be configured as 512 bytes × 2. 30 =512GB. The specific configuration of each bit is as follows.
[0049]
[0050] In this embodiment of the invention, the three types of commands have three common identifier bits: instance number, device type, and command type. The instance number occupies 7 bits, ranging from 0 to 127, and is an identifier for one video stream. The video transcoding device uses the instance number to distinguish which encoded stream the current command belongs to.
[0051] Device type: Occupies 1 bit, used to distinguish between decoding command (0) and encoding command (1).
[0052] Command type: Occupies 2 bits and is used to describe the type of command. It is mainly divided into control commands (00), read input stream commands (01) and write input stream commands (10).
[0053] Control commands also include two additional flags: operation type and operation subtype.
[0054] Operation type: Occupies 3 positions and is mainly used to describe the operation type of the control command. There are 4 types: open instance (000), close instance (001), query command (010) and configuration command (011).
[0055] Operation subtype: Occupies 4 bits and is mainly used to distinguish the specific operation of each operation type. For example, query commands can be further divided into write buffer query, output stream query, error query, etc.
[0056] Reserved bits: Reserved bits to facilitate future additions of encoding paths, encoding types, etc.
[0057] See Figure 2 The video transcoding control method in this embodiment of the invention includes:
[0058] Step 1: Send control commands to obtain transcoding instances;
[0059] A video transcoding device can support multiple transcoding instances simultaneously. The transcoding instance number is obtained by sending the "Get Instance Number" command. Subsequent transcoding commands will include the number information to distinguish each transcoding stream. After completion, proceed to step 2.
[0060] Step 2: Send control commands to configure transcoding parameters, including video format, resolution, etc. If successful, proceed to Step 3; otherwise, proceed to Step 13.
[0061] Step 3: Send a control command to query the instance status. If successful, proceed to Step 4; otherwise, proceed to Step 13.
[0062] Step 4: Confirm whether a control command needs to be sent to end transcoding. If yes, proceed to step 13; otherwise, proceed to step 12 to continue transcoding.
[0063] Step 5: Send a control command to query the input status. If successful, proceed to Step 6; otherwise, proceed to Step 13.
[0064] Step 6: Check if the input buffer is full using the status information obtained in Step 5. If so, wait for a certain period of time and continue with Step 5 to query again; otherwise, proceed to Step 6.
[0065] Step 7: When the transcoding device has sufficient buffer, send the input stream to the transcoding device via a write command.
[0066] Proceed to step 8 after sending;
[0067] Step 8: Send a control command to check the output status. If there is an error or the transcoding is detected to be finished, proceed to step 13; otherwise, proceed to step 9.
[0068] Step 9: Check if there is a decoded output stream based on the status information obtained in Step 8. If yes, proceed to Step 10; otherwise, proceed to Step 11.
[0069] Step 10: When the transcoding device has an output stream, obtain the input stream from the transcoding device using a read command. After sending, proceed to step 4;
[0070] Step 11: When there is no output stream, it is necessary to check whether an end command has been sent to the transcoding device. If so, it is necessary to wait for a period of time and then continue to step 8 to check the output status until all write streams have been transcoded or an error has occurred. Otherwise, step 4.
[0071] Step 12: When it is necessary to send a transcoding end command, send a control command to notify the transcoding card that transcoding has ended. After receiving the transcoding end command, the transcoding card will continue to decode the received stream.
[0072] Step 13: When an error is detected, or after transcoding is complete, send a control command to close the transcoding instance.
[0073] Our method controls the transcoding device by dividing the LBAs of read / write commands, with different LBAs representing different transcoding commands. Practice has proven that the method described in this embodiment has good compatibility, a short development cycle, low cost, good stability, and fast transmission speed, effectively ensuring efficient and stable communication with video transcoding devices.
[0074] The second embodiment of the present invention provides a transcoding method based on any of the control methods described in the first embodiment of the present invention, see [link to relevant documentation]. Figure 3 Applied to the video transcoding device side, the method includes:
[0075] S301, Receive preset encoding / decoding commands sent by the operating system;
[0076] S302. The preset encoding and decoding command is parsed based on the preset mapping principle to obtain the instance number of the preset encoding and decoding command, and the transcoding parameters are configured according to the instance number. The control operation of the video transcoding device is completed based on the configured transcoding parameters.
[0077] In specific embodiments of the present invention, the control operations of the video transcoding device include open commands, close commands, control commands, read commands, and write commands, etc. Those skilled in the art can make arbitrary settings, and the present invention will not elaborate on them in detail.
[0078] In other words, by configuring the video transcoding device to perform encoding and decoding operations based on commands sent by the operating system, different operating systems can control the video transcoding device.
[0079] In practice, the video transcoding device configures the video format and resolution based on the instance number to meet different user needs.
[0080] The relevant content of the embodiments of the present invention can be understood by referring to the first embodiment of the present invention, and will not be described in detail here.
[0081] A third embodiment of the present invention provides a computer-readable storage medium storing a computer program for signal mapping. When executed by at least one processor, the computer program implements the control method of any of the video transcoding devices described in the first embodiment of the present invention, as well as the transcoding method described in the second embodiment of the present invention.
[0082] The relevant content of the embodiments of the present invention can be understood by referring to the first and second embodiments of the present invention, and will not be discussed in detail here.
[0083] Although preferred embodiments of the invention have been disclosed for illustrative purposes, those skilled in the art will recognize that various modifications, additions, and substitutions are possible, and therefore the scope of the invention should not be limited to the embodiments described above.
Claims
1. A control method for a video transcoding device, characterized in that, When applied to an operating system, the method includes: The video transcoding device is virtualized as a storage device, and the logical block address (LBA) of the I / O read and write commands is divided according to a preset partitioning principle. Different segments are mapped to different preset encoding and decoding commands according to a preset mapping principle. The I / O read / write commands are mapped to preset encoding / decoding commands by using the logical block address (LBA) of the I / O read / write commands. This allows control of the video transcoding device to be achieved by sending I / O read / write commands to the storage device, ultimately realizing video compression processing. The preset encoding / decoding commands include open commands, close commands, control commands, read commands, and write commands; The logical block address (LBA) of the I / O read / write command is divided according to a preset partitioning principle, and different segments are assigned to different preset encoding / decoding commands according to a preset mapping principle. This includes: dividing the logical block address (LBA) of the I / O read / write command into multiple segments according to the flag bits required by the preset encoding / decoding command, and assigning different segments to different preset encoding / decoding commands according to the preset mapping principle. The identifier bits include: instance number identifier bit, device type identifier bit, command type identifier bit, operation type identifier bit, and operation subtype identifier bit.
2. The method according to claim 1, characterized in that, The preset division principle is set to identify and distinguish each preset encoding / decoding command.
3. The method according to claim 1, characterized in that, The instance number identifier, which occupies 7 bits, is used to identify the video stream; The device type identifier bit occupies 1 bit and is used to identify decoding commands and encoding commands to distinguish whether they are decoding commands or encoding commands; The command type identifier bit occupies 2 bits and is used to identify the command type, which includes control commands, read input stream commands, and write input stream commands. The operation type identifier, which occupies 3 bits, is used to identify the operation type of the control command. The operation types include: open instance, close instance, query command, and configuration command. The operation subtype occupies 4 bits and is used to identify the specific operation that distinguishes each operation type.
4. The method according to claim 1, characterized in that, The method further includes: The instance number identifier, device type identifier, command type identifier, operation type identifier, and operation subtype identifier are all reserved with a preset number of bits to facilitate the subsequent addition of encoding paths and encoding types.
5. The method according to any one of claims 1-4, characterized in that, The method of controlling the video transcoding device by sending I / O read / write commands to the storage device includes: The video transcoding device can be controlled to perform corresponding operations by sending I / O read and write commands to the storage device.
6. The method according to any one of claims 1-4, characterized in that, The step of dividing the logical block address (LBA) of I / O read / write commands according to a preset partitioning principle, and assigning different segments to different preset encoding / decoding commands according to a preset mapping principle, includes: The logical block address (LBA) of I / O read / write commands is divided into multiple segments according to a preset partitioning principle. Each LBA segment is uniquely associated with a preset encoding / decoding command according to the order of the LBA segments. The correspondence between LBA segments and preset encoding / decoding commands is saved for later querying.
7. A transcoding method based on the control method according to any one of claims 1-6, characterized in that, Applied to the video transcoding device side, the method includes: Receive preset encoding / decoding commands sent by the operating system; The preset encoding / decoding command is parsed based on a preset mapping principle to obtain the instance number of the preset encoding / decoding command. The transcoding parameters are configured according to the instance number, and the control operation of the video transcoding device is completed based on the configured transcoding parameters.
8. The method according to claim 7, characterized in that, The configuration of transcoding parameters based on the instance number includes: Configure the video format and resolution based on the instance number.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that maps signals, which, when executed by at least one processor, implements the control method of the video transcoding device according to any one of claims 1-6, and / or the transcoding method according to claim 7 or 8.