Disclosure of Invention
In order to solve the technical problem or at least partially solve the technical problem, embodiments of the present invention provide a resource processing method, device, server, and storage medium.
In a first aspect, an embodiment of the present invention provides a resource processing method, where the method includes:
receiving resources for configuring AI advertisements;
acquiring a preset script and a preset resource processing program;
calling the resource processing program through the script, processing the resource and generating a resource file in a target format;
and sending the resource file to a client so that the client loads the resource file and renders the resource in the resource file.
In an optional implementation manner of the embodiment of the present invention, the invoking the resource processing program through the script to process the resource and generate the resource file in the target format includes:
acquiring a first storage path corresponding to the resource and a second storage path corresponding to the AI advertisement template;
creating a temporary folder through the script, and copying the AI advertisement template into the temporary folder according to the second storage path;
updating the AI advertisement template in the temporary folder according to the resource based on the first storage path through the script;
and calling the resource processing program through the script to process the updated temporary folder, and generating a resource file in a WebGL format.
In an optional implementation manner of the embodiment of the present invention, the loading, by the client, the resource file, and rendering the resource in the resource file includes:
the client receives a resource file in a WebGL format;
judging whether a local browser of the client is compatible with the WebGL format or not;
and if the local browser of the client is not compatible with the WebGL format, calling a target browser compatible with the WebGL format, loading the resource file by using a WebView component in the target browser, and rendering the resource in the resource file.
In an optional implementation of the embodiment of the present invention, the method further comprises:
and if the browser local to the client is compatible with the WebGL format, directly loading the resource file by using a WebView component in the browser local to the client, and rendering the resource in the resource file.
In an optional implementation manner of the embodiment of the present invention, the invoking the resource processing program through the preset script to process the resource includes:
determining a resource type corresponding to the resource;
extracting a resource identifier corresponding to the resource;
judging whether the resource identification is matched with the resource type;
and if the resource identifier is matched with the resource type, calling the resource processing program through the preset script to process the resource.
In an optional implementation manner of the embodiment of the present invention, the resource includes at least one of:
a 3D model resource, a picture type resource, an audio type resource, and a video type resource.
In a second aspect, an embodiment of the present invention provides a resource processing apparatus, where the apparatus includes:
the resource receiving module is used for receiving resources for configuring the AI advertisement;
the script and program acquisition module is used for acquiring a preset script and a preset resource processing program;
the resource processing module is used for calling the resource processing program through the script, processing the resource and generating a resource file in a target format;
and the file sending module is used for sending the resource file to a client so as to enable the client to load the resource file and render the resource in the resource file.
In an optional implementation manner of the embodiment of the present invention, the resource processing module is specifically configured to:
acquiring a first storage path corresponding to the resource and a second storage path corresponding to the AI advertisement template;
creating a temporary folder through the script, and copying the AI advertisement template into the temporary folder according to the second storage path;
updating the AI advertisement template in the temporary folder according to the resource based on the first storage path through the script;
and calling the resource processing program through the script to process the updated temporary folder, and generating a resource file in a WebGL format.
In a third aspect, an embodiment of the present invention provides a server, including: at least one processor, and at least one memory, bus connected with the processor; the processor and the memory complete mutual communication through the bus; the processor is configured to call program instructions in the memory to perform the resource processing method of any of the first aspects.
In a fourth aspect, an embodiment of the present invention provides a storage medium, where the storage medium stores one or more programs, and the one or more programs are executable by one or more processors to implement the resource processing method according to any one of the first aspects.
According to the technical scheme provided by the embodiment of the invention, for the received resources configured with the AI advertisement, the preset resource processing program is called through the preset script, the resources are processed, the resource file in the target format is generated, and the subsequent client can load the resource file and render the resources in the resource file. Therefore, the resources for configuring the AI advertisement are processed by calling the resource processing program through the script, and a uniform resource file with a target format is generated, so that the problem of compatibility can be avoided.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
As shown in fig. 1, an implementation flow diagram of a resource processing method provided in an embodiment of the present invention is specifically applicable to a server, and specifically includes the following steps:
s101, receiving resources for configuring AI advertisements;
in the embodiment of the present invention, the resource configured with the AI advertisement may be a resource configured with the AI advertisement uploaded by the user through the AI advertisement management platform, and the embodiment of the present invention may receive the resource configured with the AI advertisement.
Of course, the resource for configuring the AI advertisement may also be a resource for configuring the AI advertisement sent by another AI advertisement platform (for example, an AI advertisement production platform), and the embodiment of the present invention may receive a resource for configuring the AI advertisement sent by another AI advertisement platform, which is not limited in this embodiment of the present invention.
In addition, for configuring resources of the AI advertisement, at least one of: a 3D model resource, a picture type resource, an audio type resource, and a video type resource. For convenience of the following description, the picture type resource, the audio type resource, the video type resource, and/or the like may be collectively referred to as other resources.
For example, the resources for configuring the AI advertisement include a 3D model resource, a picture type resource, an audio type resource, and a video type resource, wherein the 3D model resource includes: 3D grid, 3D model skeleton, 3D model animation, 3D model chartlet, 3D model material etc. and image type resource includes: still pictures, moving pictures, etc., video type assets include video, etc., and audio type assets include audio, etc.
Specifically, as the 3D model resources include more contents, the 3D model resources can be compressed into a customized compressed file, and other resources (picture type resources, audio type resources, and/or video type resources) exist as separate resources and are not compressed.
Based on the above, in the embodiment of the present invention, the received resource for configuring the AI advertisement may be as follows:
1. AdMats folder: saving all picture type resources;
2. AudioClips folder: saving all audio type resources;
3. VideoClips folder: storing all video type resources;
4. model compression package: all 3D model resources are saved.
It should be noted that the resources for configuring the AI advertisement may also include other types of resources, which is not limited in this embodiment of the present invention.
S102, acquiring a preset script and a preset resource processing program;
in the embodiment of the invention, a script and a resource processing program are preset. The preset script is used for calling the preset resource processing program, and the preset resource processing program is used for processing resources for configuring the AI advertisement so as to generate a resource file in a target format.
For example, in the embodiment of the present invention, the preset script may be a Shell script.
Under the condition that resources for configuring the AI advertisement need to be processed, the embodiment of the invention can obtain a preset script and a preset resource processing program.
S103, calling the resource processing program through the script, processing the resource and generating a resource file in a target format;
aiming at the resources for configuring the AI advertisement received in the above steps, the preset script and the preset resource processing program obtained in the above steps, the preset resource processing program can be called through the preset script, the resources for configuring the AI advertisement are processed, and the resource file in the target format is generated, that is, the preset resource processing program is called through the preset script, the resources for configuring the AI advertisement are packaged, and the resource file in the target format is generated uniformly.
For example, for resources (3D model resources, picture type resources, audio type resources, and video type resources) configuring the AI advertisement, the 3D model resources include: 3D mesh, 3D model skeleton, 3D model animation, 3D model chartlet, 3D model material etc. other resources include: and calling the preset resource processing program through the preset script, packaging the resources configured with the AI advertisement, and uniformly generating a resource file in a target format. Therefore, the resources for configuring the AI advertisement are processed by calling the resource processing program through the script, and a uniform resource file with a target format is generated, so that the problem of compatibility can be avoided.
In the embodiment of the present invention, the type of the AI advertisement may be determined, a target format may be determined according to the type of the AI advertisement, and then the preset resource processing program may be called through the preset script to process the resource configured with the AI advertisement, so as to generate the resource file in the target format. Thus, different resource files in target formats can be generated for different AI advertisement types.
As for the type of the AI advertisement, the AI advertisement may be a 3D type or a 2D type in the embodiment of the present invention, which is not limited in the embodiment of the present invention.
The type of the AI advertisement described above may be determined by the resources that configure the AI advertisement. For example, if the resources for configuring the AI advertisement include 3D model resources, the type of the AI advertisement may be determined to be a 3D type, otherwise the type of the AI advertisement may be determined to be a 2D type.
If the type of the AI advertisement is a 3D type, a target format may be determined: the resource file is in a WebGL format, and the preset resource processing program can be called through the preset script to process the resources for configuring the AI advertisement, so that the resource file in the WebGL format is generated; if the type of the AI advertisement is a 2D type, the preset resource processing program can be called through the preset script to process the resources for configuring the AI advertisement, and a resource file in an H5 format is generated.
And S104, sending the resource file to a client so that the client loads the resource file and renders the resource in the resource file.
For the resource file obtained in the above step, the resource file may be sent to the client.
On the client side, the resource file can be received and loaded, and the resource configured with the AI advertisement in the resource file is rendered, so that the AI advertisement can be played. The resource file can be loaded through the WebView component, and resources configured with the AI advertisement in the resource file are rendered.
Specifically, in the embodiment of the present invention, the resource file may be issued to an AI advertisement player in the client, and the AI advertisement player loads the resource file through the WebView component, and renders the resource configured with the AI advertisement in the resource file, thereby completing playing the AI advertisement.
Through the above description of the technical solution provided by the embodiment of the present invention, for the received resource configured with the AI advertisement, the preset resource processing program is called through the preset script, the resource is processed, a resource file in a target format is generated, and a subsequent client can load the resource file and render the resource in the resource file. Therefore, the resources for configuring the AI advertisement are processed by calling the resource processing program through the script, and a uniform resource file with a target format is generated, so that the problem of compatibility can be avoided.
As shown in fig. 2, an implementation flow diagram of another resource processing method provided in the embodiment of the present invention is shown, where the method specifically includes the following steps:
s201, receiving resources for configuring AI advertisements;
in the embodiment of the present invention, this step is similar to the step S101, and the details of the embodiment of the present invention are not repeated herein.
S202, acquiring a preset script and a preset resource processing program;
in the embodiment of the present invention, this step is similar to the step S102, and the details of the embodiment of the present invention are not repeated herein.
S203, determining a resource type corresponding to the resource;
in the embodiment of the invention, for the resources configured with the AI advertisement, validity check is required to ensure the validity of the resources configured with the AI advertisement.
Therefore, in the embodiment of the present invention, a resource type corresponding to a resource configuring the AI advertisement needs to be determined.
For example, resources for configuring AI advertisements include: the method includes the following steps that 3D model resources, picture type resources, audio type resources and video type resources are used, wherein the resource type corresponding to the 3D model resources can be determined to be the 3D model type, and the 3D model type comprises the following formats: fbx, obj, avatar, anim, png, jpg, tex, tif, mat, it may be determined that the resource type corresponding to the picture type resource is a picture type, and the format included in the picture type is as follows: png, jpg, gif, etc., and it may be determined that the resource type corresponding to the audio type resource may be an audio type, and the audio type includes the following format: ogg, mp3, wav, etc., it may be determined that the resource type corresponding to the video type resource may be a video type, and the video type includes the following format: mp4, avi, etc.
S204, extracting a resource identifier corresponding to the resource;
and aiming at the resources configured with the AI advertisement, extracting corresponding resource identifiers in the resources configured with the AI advertisement. In the embodiment of the present invention, the resource identifier may be a suffix name corresponding to a resource configured with the AI advertisement, that is, a corresponding format in the resource configured with the AI advertisement.
For example, for a 3D model resource required for an AI advertisement, extracting a corresponding suffix name in the 3D model resource required for the AI advertisement: obj (3D network), avatar (3D model skeleton), anim (3D model animation), png (3D model map), mat (3D model material);
aiming at the picture type resources required by the AI advertisement, extracting the corresponding suffix name in the picture type resources required by the AI advertisement: png (still picture), gif (moving picture);
aiming at the audio type resources required by the AI advertisement, extracting the corresponding suffix name in the audio type resources required by the AI advertisement: mp 3;
aiming at the video type resources required by the AI advertisement, extracting the corresponding suffix name in the video type resources required by the AI advertisement: mp 4.
S205, judging whether the resource identifier is matched with the resource type;
and judging whether the resource identifier is matched with the resource type or not according to the determined resource type and the extracted resource identifier in the step, and finishing the validity check of the resource configured with the AI advertisement according to the judgment result.
For example, the validity of the picture type resource required by the AI advertisement is checked, that is, whether the picture type resource is doped with the audio type resource or the video type resource is checked in the picture type resource, if the picture type resource is doped with the audio type resource or the video type resource, it indicates that the picture type resource required by the AI advertisement is illegal, otherwise, it indicates that the picture type resource required by the AI advertisement is legal.
Taking 3D model resources required by the AI advertisement as an example, for the 3D model resources required by the AI advertisement, extracting corresponding suffix names in the 3D model resources required by the AI advertisement: obj (3D network), avatar (3D model skeleton), anim (3D model animation), png (3D model map), mat (3D model material), where the 3D model resources include the following formats: fbx, obj, avatar, anim, png, jpg, tex, tif, mat, it is known through judgment that the format in the 3D model resource includes a suffix name corresponding to the 3D model resource required by the AI advertisement, that is, the resource identifier matches with the resource type, otherwise, it can be judged that the resource identifier does not match with the resource type.
For picture type resources, audio type resources, and video type resources required for the AI advertisement, the validity check is similar to the validity check of the 3D model resources required for the AI advertisement, and the embodiments of the present invention are not described herein any more.
In addition, for the picture type resource, the resolution of the picture type resource may be checked in the embodiment of the present invention to determine the resolution of the picture in the picture type resource.
S206, if the resource identifier is matched with the resource type, calling the resource processing program through the script to process the resource and generate a resource file in a target format;
as for the judgment result of the above step, if the resource identifier is matched with the resource type, it indicates that the resource configured with the AI advertisement is legal, and a preset resource processing program can be called through a preset script to process the resource and generate a resource file in a target format; if the resource identifier is not matched with the resource type, the resource configured with the AI advertisement is not legal, and the user can be prompted to upload the resource configured with the AI advertisement again.
In the embodiment of the invention, the preset script is used for calling the preset resource processing program to process the resource, so as to generate the resource file in the WebGL format.
In addition, as for an optional implementation manner in which a preset script calls a preset resource handler to process a resource and generate a resource file in a WebGL format, as shown in fig. 3:
s301, acquiring a first storage path corresponding to the resource and a second storage path corresponding to the AI advertisement template;
s302, creating a temporary folder through the script, and copying the AI advertisement template into the temporary folder according to the second storage path;
s303, updating the AI advertisement template in the temporary folder according to the resources based on the first storage path through the script;
s304, the updated temporary folder is processed by calling the resource processing program through the script, and a resource file in a WebGL format is generated.
For example, a first storage path corresponding to the resource configured with the AI advertisement and a second storage path of the AI advertisement template (or the AI advertisement item) are acquired, and the first storage path corresponding to the resource configured with the AI advertisement and the second storage path of the AI advertisement template (or the AI advertisement item) are passed to the Shell script as parameters.
Creating three temporary folders of Assets, ProjectSettings and Packages at a server side through the Shell script, and copying historical resources (or blank resources) of a corresponding directory in an AI advertisement template (or an AI advertisement project) into the three temporary folders;
taking the three temporary folders together as a new AI advertisement template (or AI advertisement item), updating the AI advertisement template in the temporary folders according to the resources based on the first storage path through the script: replacing historical resources (or blank resources) in the three temporary folders with resources corresponding to a first storage path and configured with AI advertisements through the Shell script;
and calling a resource processing program in an AI advertisement template (or AI advertisement project) through the Shell script to process the resources in the three temporary folders, namely calling a BuildWebGLForMobile () method of a packaging program MyBuildTool.cs in the AI advertisement template (or AI advertisement project) to compile, so that a resource file in a WebGL format can be generated.
And S207, sending the resource file to a client so that the client loads the resource file and renders the resource in the resource file.
In the embodiment of the invention, for the generated resource file in the WebGL format, the resource file can be compressed by a preset script and copied to the specified storage path, and then the compressed resource file in the WebGL format can be found according to the specified storage path and sent to the client.
For example, the obtained resource file in the WebGL format is compressed into a custom format by the Shell script and copied to the specified storage path, the Shell script feeds the specified storage path back to the server, the subsequent server can find the compressed resource file (WebGL. zip) in the WebGL format through the specified storage path, and the compressed resource file in the WebGL format is sent to the client.
Receiving a resource file in a WebGL format at the client side; judging whether a local browser of the client is compatible with a WebGL format or not; if the local browser of the client is compatible with the WebGL format, directly loading the resource file through a WebView component in the local browser of the client, and rendering the resource in the resource file; and if the local browser of the client is not compatible with the WebGL format, calling a target browser compatible with the WebGL format, loading the resource file through a WebView component in the target browser, and rendering the resource in the resource file.
For example, on the client side, a resource file (WebGL. zip) in a WebGL format is received, the resource file (WebGL. zip) in the WebGL format is decompressed, whether a browser local to the client is compatible with the WebGL format is determined, if the browser local to the client is not compatible with the WebGL format, a third-party browser (for example, a third-party browser is called from a server) can be called, the third-party browser is a target browser compatible with the WebGL format, and the resource file is loaded through a WebView component in the target browser, so as to render resources in the resource file.
In the embodiment of the invention, the compatibility problem can be avoided by processing various types of resources for configuring the AI advertisement into the resource file in the uniform WebGL format.
Corresponding to the foregoing method embodiment, an embodiment of the present invention further provides a resource processing apparatus, and as shown in fig. 4, the apparatus may specifically include the following modules: a resource receiving module 410, a script and program obtaining module 420, a resource processing module 430 and a file sending module 440.
A resource receiving module 410, configured to receive a resource for configuring the AI advertisement;
a script and program obtaining module 420, configured to obtain a preset script and a preset resource processing program;
the resource processing module 430 is configured to call the resource processing program through the script, process the resource, and generate a resource file in a target format;
the file sending module 440 is configured to send the resource file to a client, so that the client loads the resource file and renders the resource in the resource file.
In a specific implementation manner of the embodiment of the present invention, the resource processing module 430 is specifically configured to:
acquiring a first storage path corresponding to the resource and a second storage path corresponding to the AI advertisement template;
creating a temporary folder through the script, and copying the AI advertisement template into the temporary folder according to the second storage path;
updating the AI advertisement template in the temporary folder according to the resource based on the first storage path through the script;
and calling the resource processing program through the script to process the updated temporary folder, and generating a resource file in a WebGL format.
The resource processing apparatus includes a processor and a memory, the resource receiving module 410, the script and program obtaining module 420, the resource processing module 430, the file sending module 440, and the like are all stored in the memory as program modules, and the processor executes the program modules stored in the memory to implement corresponding functions.
As shown in fig. 5, which is a schematic structural diagram of a server provided in an embodiment of the present invention, the server shown in fig. 5 includes: a processor 51, a communication interface 52, a memory 53 and a communication bus 54, wherein the processor 51, the communication interface 52 and the memory 53 are communicated with each other through the communication bus 54,
a memory 53 for storing a computer program;
the processor 51 is configured to implement the following steps when executing the program stored in the memory 53:
receiving resources for configuring AI advertisements;
acquiring a preset script and a preset resource processing program;
calling the resource processing program through the script, processing the resource and generating a resource file in a target format;
and sending the resource file to a client so that the client loads the resource file and renders the resource in the resource file.
The communication bus mentioned in the above server may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the server and other devices.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
The embodiment of the invention also provides a storage medium (computer readable storage medium). The storage medium herein stores one or more programs. Among others, the storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, a hard disk, or a solid state disk; the memory may also comprise a combination of memories of the kind described above.
When one or more programs in the storage medium are executable by one or more processors, the resource processing method executed on the resource processing device side as described above is realized.
The processor is used for executing the resource processing program stored in the memory to realize the following steps of the resource processing method executed on the resource processing device side:
receiving resources for configuring AI advertisements;
acquiring a preset script and a preset resource processing program;
calling the resource processing program through the script, processing the resource and generating a resource file in a target format;
and sending the resource file to a client so that the client loads the resource file and renders the resource in the resource file.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a device includes one or more processors (CPUs), memory, and a bus. The device may also include input/output interfaces, network interfaces, and the like.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present invention, and are not intended to limit the present invention. Various modifications and alterations to this invention will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.