Q：What platforms does PAG support?
PAG's rendering SDK can be used on multiple platforms, including Android, iOS, macOS, Windows, Linux, Web, and WeChat Mini Program. Both macOS and Windows are supported by the PAGViewer desktop preview tool and the AE exporting plugin. We regularly release prebuilt libraries for Android, iOS, Web, and WeChat Mini Program：
We have not released a prebuilt library because there is no unified UI framework, and we need to do some rendering bridge adaptation on other platforms. However, you can build the library yourself from the source code available on Github.
Q: What should I do if an error is reported when compiling the PAG source code?
The compilation of the PAG project depends on the download synchronization of some third-party libraries and the installation of the correct version of the compilation tool. Before running the Demo, please be sure to read the README.md located in the root directory and follow the instructions in the development guide section. If you have any questions, feel free to provide feedback on the Github Discussions .
Q: Does PAG support emulators? Is it accurate to test performance on the simulator?
The PAG can only provide a basic preview of UI animation in the emulator and should not be used extensively or for performance testing. It is a rendering solution that relies on GPU acceleration, which cannot be enabled on the emulator. As a result, performance on the emulator will be much slower than in actual situations. Furthermore, certain interfaces that are necessary for advanced video editing functions are not supported on the emulator.For example, it is not possible to draw to a CVPixelBuffer off-screen object. Besides, the simulator is not a real user scenario, so please use a real device for performance testing.
Q: Does PAG support Flutter usage?
PAG supports the use of Flutter. Here is also a demo project uploaded and maintained by a third-party author for reference: https://github.com/libpag/pag-flutter.git. If you face any issues related to usage, you can submit it as an issue in the same github repository. The author will update and maintain it regularly.
Q: What's the relationship between PAG and video editing?
Initially, PAG was created to handle intricate animation effects rendering needs in video editing scenarios. It offered interfaces that could be effortlessly incorporated into the native video rendering pipelines. Nevertheless, it's important to note that PAG is not a video editing tool; its sole responsibility is to render and restore general animation graphics. Additionally, PAG can be applied to numerous other scenarios beyond video editing.The video editing framework belongs to a different technical domain, so the business side needs to either create or acquire established solutions from the industry in order to address tasks such as video encoding, decoding, synthesis, export and other capabilities.
We have listed the TAVMedia video editing framework on the PAG official website for sale. TAVMedia is a comprehensive framework used by Tencent and it can meet the diverse requirements for audio and video editing. We have extracted the video template-related capabilities from TAVMedia and integrated them into the PAG Enterprise Edition for businesses that only need these features. This results in higher cost performance and makes it easier to use. This kind of video editing framework also supports placeholder images to replace videos in PAG files, audio play, and one-click export of rendered content to video files.It can help users focus on their business needs, and quickly and easily implement multi-platform (Andorid, iOS, server-side) video template functions. For more detailed information, please visit the product /docs/en/terms.html#pag-fileintroduction page of PAG official website.
PAG file play sound on the mobile terminal?Q: Why can't the
PAG files support the integration of audio data. For specific export methods, please refer to how to export audio in AE. However, since PAG supports combined playback and runtime editing capabilities, it must rely on the audio and video framework for streaming to achieve complete audio playback, which is not included in the PAG Community Edition. Therefore, implementing audio playback or synthesis into video requires the business side to handle it on their own.The built-in audio data of the PAG can be accessed by the R&D team through the PAGFile.audioBytes interface. This data can be either saved as a local file or decoded in memory directly. It is worth noting that the encoding format of audioBytes byte stream is AAC, and the container format is MPEG-4.
The PAG Enterprise Edition comes with a built-in video template capability and supports audio playback through its audio and video processing module. This feature allows users to combine audio with their videos within PAG and also add audio files to replace the original video audio tracks. Users can then merge and export their video files.If necessary, welcome to access and use PAG Enterprise.
Q: Does the PAG SDK support loading network files?
The PAG SDK, with a minimum requirement of version 4.3, enables loading pag files for network paths. You can check the relevant interfaces of PAGFile, PAGView and PAGImageView for details.
Q: Can the PAG Windows version be directly integrated with existing DirectX 11 games?
Currently, there is no plan to directly support DX's rendering backend. However, you can use Google's ANGLE project to package DX into OpenGL for PAG to render. This implementation is also being used on Windows Chrome.
Q: Why does using PAGView in the UI scenario of a mobile app consume so much memory when only one animation file is played?
PAG is a GPU rendering solution that creates an independent GPU context environment and, unlike in game engines or audio and video editing frameworks, cannot obtain the context of the mobile terminal's system UI framework. This results in some additional bridging overhead. When using an independent context GPU rendering method, there will be a screen buffer overhead. If the test is full screen, each pixel will need 4 bytes of memory and double buffering will double the memory usage, resulting in tens of M of memory usage. This is basic for any GPU rendering solution and does not increase linearly. Please note that this memory usage is not related to PAG animation.PAGView can be used to draw multiple PAG animation files together, allowing for streamlined rendering. The process only requires the creation of one PAGView. In the case of sharing PAGView, the cost of each additional PAG animation file may only increase by a few M after an initial cost of tens of M. Therefore, it is not possible to determine the memory usage of N PAG animation effects by testing the memory usage of a single PAG file played through a full-screen PAGView. It is recommended to test the actual business scenario to accurately determine memory usage. It is also advised not to over-optimize if there is no real bottleneck and to focus on prioritizing bigger issues instead of smaller ones.
Since version 4.2, we have included a new playback component called PAGImageView specifically for UI scenes. This component bypasses the drawbacks of GPU real-time rendering solutions in UI scenes. Its use is particularly effective for scenarios where multiple PAG files are played simultaneously on the UI list or the same page. It significantly reduces memory usage and improves rendering performance.The main principle is to use the disk cache effectively by storing data locally while rendering the current frame. Throughout the animation file's lifespan, users will only see a short-lived, real-time, GPU-based rendering, and then access the high-speed disk cache directly for presentation. The cache remains valid even after restarting the App. This reduces the basic overhead introduced by GPU real-time rendering throughout the rendering process.In addition, PAGImageView can achieve high-performance mixing without the need for a GPU bridging layer between it and the UI framework. This means that there is no additional merge playback logic to deal with. However, if you're working on a non-UI scene, such as video editing and processing, it's still best to use PAGView for real-time combined rendering of multiple animation graphics on the same screen.
PAG file after performing placeholder image replacement or text editing in PAGViewer?Q: How to export a
PAGViewer is a preview tool that cannot export PAG files. PAG files can only be exported through the AE plugin. It is important to note that the PAG runtime editing replacement function is not used to create a new PAG file. Instead, it is used to make edits that can be used to generate a video or play the animation directly. The PAG file is like a template for animations that can be customized with user personality information at runtime. This allows for endless variations. However, if a new PAG file is created for every possibility, it defeats the purpose of having a template and would require downloading countless PAG files. The proper way to use it is to have only one PAG file that can render many different effects through customization.
Q: Does the PAG export plugin support AE expressions?
At moment, AE does not have native support for expressions due to potential issues with package size resulting from implanting a JS virtual machine. However, it's still possible to export animation content that includes expressions using the following two methods:
- Right click the layer containing expressions, use the shortcut menu to convert the expressions into standard keyframes, and then export.
- Layers containing expression effects can also be marked as BMP composition and exported if they do not need to be edited at runtime. This method not only exports expressions, but also the effects of third-party plugins.
Q: What does it mean that an optimization suggestion page pops up when you export your PAG?
The prompt page provides two types of information. Firstly, it suggests performance optimizations that you can implement when you notice that a file's performance is not ideal. Secondly, it displays currently unsupported capabilities. In cases where a capability is unsupported, you can convert it to BMP composition and export it. To learn more, you can refer to the BMP composition export and view the list of AE features that support direct exports.
Q: Many special effects have been added, but why they disappear after exporting?
Special effects that currently support direct export can be found in the AE feature support list. If not in this list and not used on the editable layer at runtime (not intended to replace the content), or a special effect of a third-party plugin, it can be converted to BMP composition for export. You can refer to BMP composition export. If you need to use it on a layer that can be edited at runtime but currently does not support direct export, you can provide us with a request through Github Discussions . We will prioritize each request based on its generality and provide support one by one.
BMP composition, but it seems the clarity is insufficient?Q: The unsupported effects can be exported after being marked as
You can configure the plugin options by referring to the clarity parameters on Use Configuration Panel page:
Image Compression Qualityand
Bitmap Pixel Densityon the
Image Compression Qualityon the
But usually there is no need to modify these default parameters, they have been set at the best balance between file size and clarity. Normally, clarity issues typically result from additional file conversion operations. For example, you might convert some effects into videos in advance and put them in AE, and then mark them as BMP Composition for export, or you could compress image resources by yourself and put them into AE for use. All these operations will only result in loss of clarity and do nothing to any file size optimization to the final exported PAG file. The PAG export plugin has a built-in algorithm with a very high compression rate. Please do not do any additional operations to optimize the file size. In AE, please use the highest-definition resources for animation design, and finally hand it over to the PAG export plugin for unified compression. We recommend the following best practices:
- For those that can be drawn directly with vectors, such as graphics or text, do not use PS to convert them into pictures and then import them into AE for use. Draw directly in AE.
- If you must import AE resources from external tools, and the original resources are vector, please try to convert them to AE native layer types, otherwise PAG cannot recognize them and can only take screenshots.
- or AE special effects that cannot be directly exported, do not convert them into videos and put them in and mark them as BMP Composition for export. Marking them as BMP Composition is to help you capture screenshots and compress them into videos. Two times of video compression will reduce the clarity. Just mark it as BMP Composition and let PAG export the original layer.
- Pay attention to whether the resolution of the export is sufficient. If it is a vector content, it has nothing to do with the resolution. If the exported animation contains bitmap or BMP Composition, the clarity is directly related to the size of the root node's total composition. In the case of satisfying the clarity, choose the appropriate resolution as much as possible.
PAG file have chromatic aberration when rendering on the client side?Q: Why does the exported
To color accuracy, PAGViewer (version 2.1.40 and above) and the client SDK now use the sRGB color space instead of wide gamut color space like P3. It's important to note that not all devices support P3. If AE is set to a different color space, please change it to sRGB to prevent chromatic aberration when rendering the exported PAG file.
PAG file not play smoothly and how to optimize material performance?Q: Why does the exported
PAG supports both pure vector export (with image layers) and BMP Composition export. Material performance problems are usually caused by the excessive use of BMP composition. For the use of BMP composition, you can refer to the following rules：
- Avoid using：BMP composition is usually only used when the normal export effect is incorrect. You can refer to the AE feature support list document to view the AE features that support direct export.
- Minimize use：Try merging any layers and compositions that need BMP composition if possible to cut down on the number of BMP compositions.
- Control the area：Try to avoid the huge area of composition marked as BMP composition export, and only disassemble the necessary animation area and mark it as BMP composition export.
Most of the material performance problems can be solved through the above methods. For other material optimization techniques, please refer to the PAG material optimization guide.
PAG file or adjust the playback speed as interface can't be found on PAGView?Q: How to play only a certain section of a
People may intuitively think of searching for playback controls PAGView or PAGPlayer for such functions, but in fact, any customized playback requirements should be achieved by operating PAGFile.
Interval playback：First, create an empty PAGComposition container through the PAGComposition.Make() method, and then add the PAGFile object you want to play through its addLayer interface. Next, you can call setStartTime and setDuration on this PAGFile to control the specific interval you want to play. Finally, give the total PAGComposition to PAGView to play.
Example:An 8s-long pag file needs to be played in a loop for 3~6s. After adding PAGFile to PAGComposition, you can set the startTime of PAGFile to -3000000 and the duration to 6000000.
Variable speed playback:First, set PAGFile.setTimeStretchMode(PAGTimeStretchMode.Scale), and then use the PAGFile. setDuration() interface to set the length of time you want to play after variable speed. Set a longer time than the original for slow playback, and a shorter time for fast playback.
PAG provides a very flexible layer level control API, which allows for the free arrangement and combination of multiple PAGFiles at runtime. The timeline can be controlled through setStartTime and setDuration, relative position can be controlled through setMatrix, and layers can also be added, deleted, or modified. For details, please refer to the relevant interfaces of PAGLayer and PAGComposition. Through the layer-level control API, you can also design a series of complex atomic special effect combination features. When creating PAG materials, you no longer need to assemble and export various arranged and combined scenarios in AE one by one. Instead, you just need to export the split atomic PAG file, and then use programming control at runtime to combine an infinite variety of effects.
Q: Why can't the text on the Linux side be displayed normally? What is the strategy for font loading in the PAG?
Due to the large size, pag does not include font files, although font files are required for the text to be displayed.
On Android, iOS, macOS, and Windows, we have internally registered system fonts, so even if the user does not register fonts, the text content can still be displayed. There is no logic to register the default font in Linux, so if the font is not registered, the text cannot be displayed properly.
If a specific font needs to be displayed, regardless of which platform, font registration is required. Please refer to the relevant methods of PAGFont for font registration interfaces. The RegisterFont method is used to register fonts, and SetFallbackFontPaths is for setting the font fallback list. When the input text cannot be found in the registered font file, the font in the fallback list will be used.
Q: Is there a fee for PAG?
PAG's AE export plugin and desktop preview tool are currently completely free，and the SDK part is mainly divided into two versions:
The Community Edition is a free and open-source software that follows the Apache 2.0 License. It can be used for commercial purposes too. However, its focus is only on general animation rendering restoration and standardization of animation file formats. It's suitable for light usage scenarios like animation playback, but for heavy use scenarios such as video editing and live broadcast, businesses need to implement them themselves. This is appropriate for teams with enough manpower and framework accumulation.
The Enterprise Edition requires payment for use. PAG will add additional advanced feature encapsulation to the Enterprise Edition that will build on the general functions found in the Community Edition. For instance, these packages may include video template-related capabilities and material encryption. When purchased, the Enterprise Edition can alleviate the need for costly self-encapsulation and provide one-to-one technical support services to help implement product requirements more efficiently.
There is a simple but counterintuitive fact: a sound commercialization system is the only guarantee for the sustainable development of open source projects, rather than relying on emotions or commitments. Only fully commercialized projects can have more resources continuously invested in the iteration of free functions and community user engagement, otherwise, any team will eventually become a low-priority task, or a KPI product for short-term promotion and defense, ultimately leading to the lack of effective guarantee for the long-term stable use of all users. Therefore, the PAG team will always perform commercial exploration as a high-quality task. But in general, we will adhere to the following two principles:
The capability items that are already free will not be recharged in the future. All capabilities that are free now will not be converted to be paid in the future, so you can use them with confidence. We will only explore payment points for new advanced features, and mainly focus on vertical heavy use scenarios or new functions with very high R&D costs.
Maintain standard and universal PAG file format. The Community Edition will still be continuously updated with general capabilities, and some paid new features with very high R&D costs will be paid periodically, but will always remain open source at the file format level. The business side can also implement rendering in advance based on the standard format.
Q: What is the reason why PAG's AE export plugin is closed source? Will it be open source in the future?
The answer is no.
It may be better to take an example that everyone is familiar with: Google's Chrome browser is not open source, but the core Chromium project is. The current open source libpag project is not just a rendering library, the core codec module of the PAG file is also completely open source. So in principle, if you want to implement an AE export plugin from scratch, there are currently no technical obstacles. You only need to call the AE SDK and PAG encoding SDK. The rest is some UI business code work, which does not have much technical content. Then why don't we open source the code of this part of UI business? In fact, if you just use the PAG scheme normally and don't mean to hastily create an incompatible PAG split format, it will not involve any AE export plugin code content. But if this part of the code is open-sourced, it will significantly lower the threshold for creating a new split format. The format of PAG is different from other image formats. It is not a format that will be solidified after the standard is formulated, but a format that evolves dynamically and will continue to change incrementally as the support of AE functions increases. If a decentralized management method is adopted, it is difficult for us to guarantee the general consistency of the PAG. Once a format with many split versions is produced, it will become a private format for certain specific businesses, and various optimizations cannot be returned to the community. Designers also have to face the extra workload of exporting the same resource in multiple formats, and need to repeatedly produce a large number of similar animation files, instead of directly reusing the exported resources in stock. This is detrimental to the development of the animation graphics community, and we are very reluctant to see it.