PDF video generation method and device, equipment and storage medium
By OCR parsing and image processing of PDF documents, video content scripts are generated, and combined with natural language processing and video synthesis technology, PDF documents are converted into vivid videos, solving the problem of invisible content display of PDF documents in the existing technology, and achieving richer and more efficient information display.
Patent Information
- Application Number
- CN202411520046.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-03-11
AI Technical Summary
It is difficult for the prior art to display PDF document content in a more vivid way, and simply reading and sharing cannot fully display the content of the document.
By analyzing PDF documents based on the OCR library, identifying text content and image elements, generating video content scripts, using natural language processing algorithms to convert text into speech, and synthesizing preliminary videos through the audio and video synthesis library, finally synchronizing voice with images in the video to generate the final video.
It realizes the conversion of PDF document content into video, displaying information more vividly, retains the visual effect of the document, makes the video more attractive, and improves the efficiency of information transmission.
Smart Images

Figure CN119603512A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a method, device, computer equipment and computer-readable storage medium for generating videos from PDF. Background Art
[0002] In the modern information age, PDF files, as a common document format, are widely used in document delivery and storage. There are several ways to display PDF: using PDF readers, online preview tools, built-in functions of the operating system, and display through front-end technology. First of all, using a PDF reader is the most direct way. These software usually provide rich preview functions, such as thumbnail preview, bookmark navigation, page jump, etc., which can meet different reading needs. There are also many common PDF readers that can provide users with reading and sharing PDF documents. However, for some PDF documents with rich content and rich pictures and texts, simple reading and sharing sometimes cannot meet the needs of users. Although some products provide the function of converting PDF to pictures or splitting it into slides, this still cannot fully display the content of the document. Therefore, a more comprehensive solution is needed to display information in a more vivid way.
[0003] Therefore, how to display information in PDF documents in a more vivid way has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the present invention is to provide a method, device, equipment and computer-readable storage medium for generating videos from PDF, aiming to solve the technical problem that the current PDF document content display method cannot fully display the content of the document.
[0005] To achieve the above object, the present invention provides a method for generating a video from a PDF, the method comprising the following steps:
[0006] Parse the uploaded PDF document based on the OCR library to identify the text content and image elements in each page;
[0007] Generate a video content script according to the text content and the image elements;
[0008] Convert the text content into speech through a natural language processing algorithm;
[0009] The text content and the image elements are synthesized into a preliminary video through an audio synthesis library and a video synthesis library;
[0010] According to the video content script, the voice is gradually synchronized with the image in the preliminary video to generate a final video.
[0011] In addition, to achieve the above-mentioned purpose, the present invention also provides a device for generating a video from a PDF, the device for generating a video from a PDF comprising:
[0012] Parsing module, used to parse the uploaded PDF document based on the OCR library and identify the text content and image elements in each page;
[0013] A generating module, used for generating a video content script according to the text content and the image elements;
[0014] A conversion module, used to convert the text content into speech through a natural language processing algorithm;
[0015] A synthesis module, used for synthesizing the text content and the image elements into a preliminary video through an audio synthesis library and a video synthesis library;
[0016] The generation module is also used to gradually synchronize the voice with the image in the preliminary video according to the video content script to generate a final video.
[0017] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer device, which includes a processor, a memory, and a program for generating a video from PDF stored in the memory and executable by the processor, wherein when the program for generating a video from PDF is executed by the processor, the steps of the method for generating a video from PDF as described above are implemented.
[0018] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a program for generating video from PDF is stored, wherein when the program for generating video from PDF is executed by a processor, the steps of the method for generating video from PDF as described above are implemented.
[0019] The present application provides a method for generating videos from PDF, which parses the uploaded PDF document based on the OCR library to identify the text content and image elements in each page; generates a video content script based on the text content and the image elements; converts the text content into speech through a natural language processing algorithm; synthesizes the text content and the image elements into a preliminary video through an audio synthesis library and a video synthesis library; and gradually synchronizes the speech with the image in the preliminary video according to the video content script to generate a final video, which can convert the content of the PDF document into a video and display the information in a more vivid way. The PDF-to-video solution based on OCR will achieve the following advantages: Rich content display: Converting the content of the PDF document into a video can not only display text, but also present elements such as images and charts, making the information more vivid; Better visualization effect: Through image processing technology, the visual effects in the PDF document are retained to make the generated video more attractive; Convenient information transmission: Converting the document content into a video is easier to share and transmit in various platforms and scenarios, improving the efficiency of information transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 A schematic diagram of a flow chart of a first embodiment of a method for generating a video from PDF according to the present invention;
[0021] Figure 2 A schematic diagram of a device for generating a video from PDF of the present invention;
[0022] Figure 3 The figure is a schematic diagram of the hardware structure of a computer device involved in an embodiment of the present invention.
[0023] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0025] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0026] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0027] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0028] The method for generating a video from PDF involved in the embodiment of the present invention is mainly applied to computer equipment. The device for generating the video from PDF can be a device with display and processing functions, such as a PC, a portable computer, or a mobile terminal.
[0029] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0030] Reference Figure 1 , Figure 1 A schematic flow chart of a first embodiment of a method for generating a video from PDF according to the present invention.
[0031] like Figure 1 As shown, an embodiment of the present invention provides a method for generating a video from a PDF, and the method for generating a video from a PDF includes steps S10 to S50.
[0032] In this embodiment, the method for generating a video from a PDF includes the following steps:
[0033] Step S10: Parse the uploaded PDF document based on the OCR library to identify the text content and image elements in each page.
[0034] In the specific implementation, an existing OCR library, such as Tesseract, will be used to parse the uploaded PDF document. The parsing process will be performed page by page, and the text content of each page will be extracted, retaining the original layout and format. During the document parsing process, we will identify image elements such as images and charts in each page. Using image processing techniques, such as edge detection and color analysis, the outline and main features of the image can be identified.
[0035] It is understandable that the specific recognition algorithm and steps are as follows:
[0036] 1. PDF document parsing
[0037] First, you need to parse the PDF file to get the content of each page. PDF files usually contain multiple elements such as text, images, vector graphics, etc. The libraries and tools used include:
[0038] PDF.js: A widely used JavaScript library for parsing and rendering PDF files in browsers.
[0039] PyMuPDF or PDFMiner: A PDF parsing library for Python environment that can extract text and images.
[0040] 2. Recognition of image elements
[0041] The recognition of image elements mainly relies on image processing and computer vision algorithms. The following are the common steps:
[0042] 2.1 Image Extraction
[0043] After parsing each page of the PDF, extract the image elements. This includes:
[0044] Direct extraction: Many PDF parsing libraries can directly extract image elements and save them as image files.
[0045] Graphics reconstruction: For some vector graphics, it may be necessary to obtain the image by reconstructing the graphics.
[0046] 2.2 Image Preprocessing
[0047] The extracted images are preprocessed to improve the accuracy of subsequent recognition. The preprocessing steps include:
[0048] Grayscale: Convert the image to grayscale, which helps with subsequent threshold processing and feature extraction.
[0049] Denoising: Use Gaussian blur, median filtering and other techniques to remove noise from the image to improve image quality.
[0050] Edge detection: Extract the edges of the image through methods such as Canny edge detection to identify the structure and shape of the image.
[0051] 2.3 Image Classification and Recognition
[0052] Use machine learning or deep learning algorithms to classify and identify the extracted images. Common methods include:
[0053] Convolutional Neural Network (CNN): A deep learning model that is particularly good for image classification and feature extraction. A CNN model is trained to recognize specific types of images (such as charts, photos, illustrations, etc.).
[0054] Pre-trained models: Use pre-trained models that have been trained on large-scale datasets (such as ResNet, Inception, VGG, etc.) for feature extraction and classification. These models can recognize common image features and objects.
[0055] Image segmentation: If the document contains complex charts or information, you can use image segmentation techniques (such as MaskR-CNN or U-Net) to separate different parts of the image and identify elements such as the chart's coordinate axes and data points.
[0056] 3. Identification of chart elements
[0057] For charts in PDF documents (such as bar charts, line charts, pie charts, etc.), additional processing steps are required:
[0058] 3.1 Chart Detection
[0059] Template matching: Use template matching technology to identify common chart types. The structural features of different charts can be learned by training the model.
[0060] Hough transform: Identify straight lines (such as coordinate axes and data lines) and circular (such as pie charts) elements in charts.
[0061] 3.2 Data Extraction
[0062] After identifying the chart, you need to extract relevant data from it. You can do this by:
[0063] Optical Character Recognition (OCR): Perform OCR recognition on text in charts (such as axis labels and legends).
[0064] Graphics analysis: By analyzing the shape, color, and relative position of the chart, the numerical information of the data points can be extracted. For bar charts, the numerical value can be obtained by identifying the height of the bar; for line charts, the position of the points can be extracted to reconstruct the data.
[0065] 4. Output results
[0066] Finally, the recognized images and chart elements are collated together with the text content of the original document to prepare the input data required to generate the video. The following formats can be considered:
[0067] Structured data: Generates JSON or XML format, including information such as image path, chart type, data points, etc.
[0068] Directly generate video frames: Merge the extracted images and chart elements into video frames and display them as visual elements.
[0069] 5. Tools and frameworks used
[0070] In the process of implementing these algorithms, the following tools and frameworks may be used:
[0071] OpenCV: An open source library for image processing and computer vision tasks.
[0072] TensorFlow / PyTorch: Deep learning framework for training and deploying image recognition models.
[0073] Tesseract OCR: An open source OCR engine capable of recognizing text in images.
[0074] Step S20: Generate a video content script according to the text content and the image elements.
[0075] In this embodiment, a detailed video content script will be generated based on the extracted text and image content. The script will contain information such as the text and image display order, dwell time, switching effect, etc. for each page.
[0076] It should be understood that the specific steps for generating the video content script are as follows:
[0077] 1. Text Extraction
[0078] First, extract the text content from the PDF document. This process can use OCR technology to recognize and extract text, making sure to include text in images.
[0079] Use an OCR engine (such as Tesseract) to process the extracted image and recognize the text in it.
[0080] For text in PDF files, you can directly use a PDF parsing library (such as PyMuPDF or PDFMiner) to extract it.
[0081] 2. Image and chart extraction
[0082] Extract images, charts and other visual elements from PDF at the same time. Use image processing technology and PDF parsing library to extract these elements.
[0083] 3. Content Analysis
[0084] The extracted text and images are analyzed to identify key information, themes, sentiment, and logical structure. This includes:
[0085] Topic identification: Use natural language processing (NLP) technology to analyze the topic of the text and identify the main content.
[0086] Sentiment analysis: Analyze the emotional tendencies of text to determine how to express those emotions in the video.
[0087] Keyword Extraction: Extract keywords and phrases from text for use in your scripts.
[0088] 4. Script generation
[0089] Generate video content script based on the extracted text and analysis results. The script generation process includes:
[0090] 4.1 Paragraph and Sentence Organization
[0091] Organize the extracted text into logical paragraphs and sentences, making sure each section coherently tells a story or conveys a message. You can use the following structure:
[0092] Introduction: Introduce the topic of the video and arouse the audience's interest.
[0093] Body: Discuss the main content in detail, using extracted text and images for support.
[0094] Conclusion: Summarize the main points and provide a conclusion or call to action.
[0095] 4.2 Timeline Design
[0096] Design a timeline for each section of your script, deciding how long each clip will appear in your video.
[0097] 4.3 Integrate images and visual elements
[0098] Mark the spots in your script where images, charts, and video clips should be inserted to ensure that the visual content matches the text.
[0099] 5. Dynamic adjustment and iteration
[0100] Based on the content analysis and preliminary script, the script may need to be dynamically adjusted and iterated to ensure accuracy and flow of information. This can be done by:
[0101] User feedback: Ask relevant people (such as content experts or target audiences) for feedback.
[0102] Machine learning: Analyze the audience's reaction to the content through training models to further optimize the script content and structure. Further, in this embodiment, step S20 includes:
[0103] Analyze the text content and the image elements to identify at least one of key information, theme, emotion and logical structure;
[0104] Organize the text into logical paragraphs and sentences so that each section coherently tells a story or conveys a message;
[0105] Design a timeline for each section and decide how long each clip will appear in the video;
[0106] Mark the locations where images, diagrams, and video clips should be inserted so that the visual content matches the text content and generate the initial video script;
[0107] According to the analysis of the text content and the initial video script, the initial video script is dynamically adjusted and iterated to generate a video content script.
[0108] Further, in this embodiment, dynamically adjusting and iterating the initial video script according to the analysis of the text content and the initial video script to generate a video content script includes:
[0109] The audience's reaction to the text content is analyzed by training a model, the content and structure of the initial video script are optimized according to the reaction results, the initial video script is dynamically adjusted and iterated, and a video content script is generated.
[0110] 6. Output script
[0111] Finally, the generated video content script is output to a format that can be used by video editing software, such as a text file, a Word document, or a specific script format.
[0112] Step S30: convert the text content into speech through a natural language processing algorithm.
[0113] It should be noted that the extracted text content is converted into speech through natural language processing technology. You can choose a suitable speech synthesis engine, such as Google Text-to-Speech, to convert the text content into natural and fluent speech.
[0114] Step S40: synthesize the text content and the image elements into a preliminary video through an audio synthesis library and a video synthesis library.
[0115] In the specific implementation, an audio synthesis library (such as FFmpeg) and a video synthesis library (such as MoviePy) will be used to automatically synthesize text and image elements into a video.
[0116] It is understood that the steps of synthesizing the preliminary video include:
[0117] 1. Generate video clips:
[0118] Create an image segment and a text segment for each text.
[0119] Use MoviePy's CompositeVideoClip to composite each image and text.
[0120] 2. Merge video clips: Use concatenate_videoclips to merge all clips.
[0121] 3. Add audio: Add background music or other audio if necessary.
[0122] 4. Export video: Save the final synthesized video as a file.
[0123] Step S50: according to the video content script, gradually synchronize the voice with the image in the preliminary video to generate a final video.
[0124] In this embodiment, according to the generated content script, the system will gradually synchronize the voice with the image and add appropriate transition effects to generate the final video. The MoviePy library is used to implement these effects. The types of transition effects include the following:
[0125] 1. Fade in and out: This can be achieved using the crossfadein() and crossfadeout() methods.
[0126] 2. Sliding transition: This can be achieved by changing the position parameters, for example, letting the current fragment slide in from left to right.
[0127] 3. Scaling transition: This can be achieved through the resize() method, allowing the image to be displayed gradually from small to large.
[0128] Further, in this embodiment, after gradually synchronizing the voice with the image in the preliminary video according to the video content script, the method further includes:
[0129] Add transition effects, including fade in and fade out, slide transition, or zoom transition.
[0130] It should be noted that the proposed OCR-based PDF-to-video solution not only achieves automation, but also greatly simplifies the conversion process from PDF documents to videos. By making full use of key steps such as OCR technology, image processing, text-to-speech, and video synthesis, users can automatically generate rich video content without manual editing. It not only greatly improves the efficiency of information transmission, but also enables users to easily create influential videos. Whether in education, training, publicity or other fields, it can provide users with efficient and convenient information display methods and enhance user experience.
[0131] In this embodiment, the uploaded PDF document is parsed based on the OCR library to identify the text content and image elements in each page; a video content script is generated based on the text content and the image elements; the text content is converted into speech through a natural language processing algorithm; the text content and the image elements are synthesized into a preliminary video through an audio synthesis library and a video synthesis library; according to the video content script, the speech is gradually synchronized with the image in the preliminary video to generate a final video, which can convert the PDF document content into a video and display the information in a more vivid way. The PDF video generation solution based on OCR will achieve the following advantages: Rich content display: Converting the PDF document content into a video can not only display text, but also present elements such as images and charts, making the information more vivid; Better visualization effect: Through image processing technology, the visual effects in the PDF document are retained to make the generated video more attractive; Convenient information transmission: Converting the document content into a video is easier to share and transmit in various platforms and scenarios, improving the efficiency of information transmission.
[0132] Continue to refer to Figure 1 Based on the first embodiment of the method for generating video from PDF mentioned above, a second embodiment of the method for generating video from PDF of the present invention is proposed.
[0133] Based on the above Figure 1 In the embodiment shown, in this embodiment, step S10 includes:
[0134] Parse the uploaded PDF document page by page based on the OCR library, extract the text content of each page, and retain the original layout and format;
[0135] During the parsing process, the images and charts in each page are identified, and the image processing algorithm is used to identify the outline and main features of the image to obtain the image elements.
[0136] It should be noted that the detailed steps and technical details of image and chart recognition are as follows:
[0137] 1. PDF document parsing
[0138] First, the image elements of each page are extracted through the PDF parsing library.
[0139] Extract images from PDF using libraries such as PyMuPDF, PDFMiner, or PDF.js to get image data for each page.
[0140] 2. Image Preprocessing
[0141] Before edge detection and color analysis, the extracted image needs to be preprocessed to improve the effect of subsequent processing.
[0142] 2.1 Grayscale
[0143] Convert color images to grayscale to reduce computational complexity.
[0144] 2.2 Denoising
[0145] Apply filters to remove image noise and enhance edge detection.
[0146] 3. Edge Detection
[0147] Use edge detection algorithms to identify the contours of an image.
[0148] 3.1 Canny edge detection
[0149] Canny edge detection is a commonly used edge detection algorithm that can identify edges in images.
[0150] 3.2 Displaying edge graph
[0151] Visualize the results of edge detection.
[0152] 4. Contour extraction
[0153] The contours are extracted from the binary image (i.e. edge map) obtained through edge detection.
[0154] 4.1 Finding contours
[0155] Use OpenCV’s findContours function to find contours in an image.
[0156] 4.2 Draw the outline
[0157] The detected contours are plotted on the original image for visual verification.
[0158] 5. Color analysis
[0159] After identifying the contours of the image, color analysis can be performed to extract the main features.
[0160] 5.1 Color Histogram
[0161] Calculate the color histogram of an image to understand the distribution of different colors in the image.
[0162] 5.2 Main color extraction
[0163] The main colors can be analyzed by K-means clustering.
[0164] 6. Extract features and output results
[0165] The main features are extracted by combining contour and color information, and the results can finally be output as a data structure for subsequent processing.
[0166] 6.1 Feature Output
[0167] The identified contours and main color information are integrated into structured data.
[0168] Furthermore, in this embodiment, the parsing process identifies images and charts in each page, including:
[0169] During the parsing process, the image elements in each page of the PDF document are directly extracted or graphically reconstructed to obtain an initial image;
[0170] Performing image preprocessing on the initial image;
[0171] Classify and identify the preprocessed images to obtain the images in each page;
[0172] During the parsing process, the charts in each page of the PDF document are detected and data extracted to obtain the charts in each page.
[0173] Furthermore, in this embodiment, the parsing process identifies images and charts in each page, including:
[0174] If the PDF document contains a complex chart, an image segmentation algorithm is used to segment different parts of the complex chart and identify the coordinate axes and data point elements of the complex chart.
[0175] In this embodiment, the uploaded PDF document is parsed page by page based on the OCR library, the text content of each page is extracted, and the original layout and format are retained, so as to ensure the accuracy of the PDF document conversion into a video; the images and charts in each page are identified during the parsing process, and the image processing algorithm is used to identify the outline and main features of the image to obtain the image elements. The PDF-to-video solution based on OCR will provide users with a comprehensive and vivid way to display information. Whether it is education, training, demonstration or other fields, this solution will enable users to share and convey information more easily and leave a deep impression on the audience.
[0176] See also Figure 2 , Figure 2 The present invention provides a schematic diagram of the functional modules of a device for generating videos from PDF according to an embodiment of the present application.
[0177] like Figure 2 As shown, the device 200 for generating a video from PDF includes:
[0178] The parsing module 10 is used to parse the uploaded PDF document based on the OCR library and identify the text content and image elements in each page;
[0179] A generating module 20, for generating a video content script according to the text content and the image elements;
[0180] A conversion module 30, used to convert the text content into speech through a natural language processing algorithm;
[0181] A synthesis module 40, used to synthesize the text content and the image elements into a preliminary video through an audio synthesis library and a video synthesis library;
[0182] The generating module 20 is further used to gradually synchronize the voice with the image in the preliminary video according to the video content script to generate a final video.
[0183] Furthermore, the parsing module 10 is also used to parse the uploaded PDF document page by page based on the OCR library, extract the text content of each page, and retain the original layout and format; during the parsing process, the images and charts in each page are identified, and the image processing algorithm is used to identify the outline and main features of the image to obtain image elements.
[0184] Furthermore, the parsing module 10 is also used to directly extract or graphically reconstruct image elements in each page of the PDF document during the parsing process to obtain an initial image; perform image preprocessing on the initial image; classify and recognize the preprocessed image to obtain the image in each page; and detect and extract data from charts in each page of the PDF document during the parsing process to obtain charts in each page.
[0185] Furthermore, the parsing module 10 is also used to use an image segmentation algorithm to segment different parts of the complex chart if the PDF document contains a complex chart, and identify the coordinate axes and data point elements of the complex chart.
[0186] Furthermore, the generation module 20 is also used to analyze the text content and the image elements to identify at least one of key information, themes, emotions and logical structures; organize the text content into logical paragraphs and sentences so that each part can coherently tell a story or convey a message; design a timeline for each part to determine the length of time each segment appears in the video; mark the positions of images, charts and video segments to be inserted so that the visual content matches the text content and generate an initial video script; dynamically adjust and iterate the initial video script based on the analysis of the text content and the initial video script to generate a video content script.
[0187] Furthermore, the generation module 20 is also used to analyze the audience's reaction to the text content through a training model, optimize the content and structure of the initial video script according to the reaction results, dynamically adjust and iterate the initial video script, and generate a video content script.
[0188] Furthermore, the generating module 20 is also used to add a transition effect after gradually synchronizing the voice with the image in the preliminary video according to the video content script, and the transition effect includes fade-in and fade-out, sliding transition or zooming transition.
[0189] In this embodiment, the parsing module 10 is used to parse the uploaded PDF document based on the OCR library to identify the text content and image elements in each page; the generating module 20 is used to generate a video content script based on the text content and the image elements; the conversion module 30 is used to convert the text content into speech through a natural language processing algorithm; the synthesis module 40 is used to synthesize the text content and the image elements into a preliminary video through an audio synthesis library and a video synthesis library; the generating module 20 is also used to gradually synchronize the speech with the image in the preliminary video according to the video content script to generate a final video. The content of the PDF document can be converted into a video to display information in a more vivid way. The PDF video generation solution based on OCR will achieve the following advantages: Rich content display: Converting the content of the PDF document into a video can not only display text, but also present elements such as images and charts, making the information more vivid; Better visualization effect: Through image processing technology, the visual effects in the PDF document are retained to make the generated video more attractive; Convenient information transmission: Converting the document content into a video is easier to share and transmit in various platforms and scenarios, improving the efficiency of information transmission.
[0190] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0191] The above-mentioned device can be implemented in the form of a computer program. Figure 3 Runs on the computer device shown.
[0192] See also Figure 3 , Figure 3 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0193] See also Figure 3The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0194] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any method of generating a video from a PDF.
[0195] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0196] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any method of generating a video from a PDF.
[0197] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will appreciate that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0198] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0199] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0200] Parse the uploaded PDF document based on the OCR library to identify the text content and image elements in each page;
[0201] Generate a video content script according to the text content and the image elements;
[0202] Convert the text content into speech through a natural language processing algorithm;
[0203] The text content and the image elements are synthesized into a preliminary video through an audio synthesis library and a video synthesis library;
[0204] According to the video content script, the voice is gradually synchronized with the image in the preliminary video to generate a final video.
[0205] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0206] Parse the uploaded PDF document page by page based on the OCR library, extract the text content of each page, and retain the original layout and format;
[0207] During the parsing process, the images and charts in each page are identified, and the image processing algorithm is used to identify the outline and main features of the image to obtain the image elements.
[0208] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0209] During the parsing process, the image elements in each page of the PDF document are directly extracted or graphically reconstructed to obtain an initial image;
[0210] Performing image preprocessing on the initial image;
[0211] Classify and identify the preprocessed images to obtain the images in each page;
[0212] During the parsing process, the charts in each page of the PDF document are detected and data extracted to obtain the charts in each page.
[0213] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0214] If the PDF document contains a complex chart, an image segmentation algorithm is used to segment different parts of the complex chart and identify the coordinate axes and data point elements of the complex chart.
[0215] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0216] Analyze the text content and the image elements to identify at least one of key information, theme, emotion and logical structure;
[0217] Organize the text into logical paragraphs and sentences so that each section coherently tells a story or conveys a message;
[0218] Design a timeline for each section and decide how long each clip will appear in the video;
[0219] Mark the locations where images, diagrams, and video clips should be inserted so that the visual content matches the text content and generate the initial video script;
[0220] According to the analysis of the text content and the initial video script, the initial video script is dynamically adjusted and iterated to generate a video content script.
[0221] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0222] The audience's reaction to the text content is analyzed by training a model, the content and structure of the initial video script are optimized according to the reaction results, the initial video script is dynamically adjusted and iterated, and a video content script is generated.
[0223] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0224] Add transition effects, including fade in and fade out, slide transition, or zoom transition.
[0225] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the methods for generating a video from a PDF provided in the embodiments of the present application.
[0226] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0227] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for generating a video from a PDF, characterized in that: The method for generating a video from PDF comprises the following steps: Parse the uploaded PDF document based on the OCR library to identify the text content and image elements in each page; Generate a video content script according to the text content and the image elements; Convert the text content into speech through a natural language processing algorithm; The text content and the image elements are synthesized into a preliminary video through an audio synthesis library and a video synthesis library; According to the video content script, the voice is gradually synchronized with the image in the preliminary video to generate a final video.
2. The method for generating a video from PDF as claimed in claim 1, characterized in that: The OCR library is used to parse the uploaded PDF document and identify the text content and image elements in each page, including: Parse the uploaded PDF document page by page based on the OCR library, extract the text content of each page, and retain the original layout and format; During the parsing process, the images and charts in each page are identified, and the image processing algorithm is used to identify the outline and main features of the image to obtain the image elements.
3. The method for generating a video from PDF as claimed in claim 2, characterized in that: The parsing process identifies images and charts on each page, including: During the parsing process, the image elements in each page of the PDF document are directly extracted or graphically reconstructed to obtain an initial image; Performing image preprocessing on the initial image; Classify and identify the preprocessed images to obtain the images in each page; During the parsing process, the charts in each page of the PDF document are detected and data extracted to obtain the charts in each page.
4. The method for generating a video from PDF as claimed in claim 2, characterized in that: The parsing process identifies images and charts on each page, including: If the PDF document contains a complex chart, an image segmentation algorithm is used to segment different parts of the complex chart and identify the coordinate axes and data point elements of the complex chart.
5. The method for generating a video from PDF as claimed in claim 1, characterized in that: The step of generating a video content script according to the text content and the image element includes: Analyze the text content and the image elements to identify at least one of key information, theme, emotion and logical structure; Organize the text into logical paragraphs and sentences so that each section coherently tells a story or conveys a message; Design a timeline for each section and decide how long each clip will appear in the video; Mark the locations where images, diagrams, and video clips should be inserted so that the visual content matches the text content and generate the initial video script; According to the analysis of the text content and the initial video script, the initial video script is dynamically adjusted and iterated to generate a video content script.
6. The method for generating a video from PDF as claimed in claim 5, characterized in that: The step of dynamically adjusting and iterating the initial video script based on the analysis of the text content and the initial video script to generate a video content script includes: The audience's reaction to the text content is analyzed by training a model, the content and structure of the initial video script are optimized according to the reaction results, the initial video script is dynamically adjusted and iterated, and a video content script is generated.
7. The method for generating a video from PDF as claimed in claim 6, characterized in that: After the step of synchronizing the voice with the image in the preliminary video according to the video content script, the method further includes: Add transition effects, including fade in and fade out, slide transition, or zoom transition.
8. A device for generating video from PDF, characterized in that: The device for generating a video from PDF comprises: Parsing module, used to parse the uploaded PDF document based on the OCR library and identify the text content and image elements in each page; A generating module, used for generating a video content script according to the text content and the image elements; A conversion module, used to convert the text content into speech through a natural language processing algorithm; A synthesis module, used for synthesizing the text content and the image elements into a preliminary video through an audio synthesis library and a video synthesis library; The generation module is also used to gradually synchronize the voice with the image in the preliminary video according to the video content script to generate a final video.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a program for generating a video from a PDF stored in the memory and executable by the processor, wherein when the program for generating a video from a PDF is executed by the processor, the steps of the method for generating a video from a PDF as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program for generating a video from PDF, wherein when the program for generating a video from PDF is executed by a processor, the steps of the method for generating a video from PDF as claimed in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Performance description meeting video generation method and device based on artificial intelligence
CN121037640A