जावा में पीपीटी को वीडियो में बदलें

जावा कोड का उपयोग करके PowerPoint को वीडियो में बदलने के लिए शक्तिशाली क्रॉस-प्लेटफ़ॉर्म Java API

Aspose.Slides का उपयोग करके PowerPoint को वीडियो में बदलें

Aspose.Slides for Java एक शक्तिशाली जावा लाइब्रेरी है जिसका उपयोग प्रस्तुतियों को बनाने, संपादित करने और हेरफेर करने और PowerPoint प्रस्तुतियों को अन्य दस्तावेज़ों और वीडियो में बदलने के लिए किया जाता है . इस स्थिति में, PowerPoint को वीडियो में बदलने के लिए, आपको Fmpeg के साथ Aspose.Slides का उपयोग करना होगा।

पीपीटी से वीडियो रूपांतरण प्रक्रिया इस प्रकार काम करती है: Aspose.Slides का उपयोग फ्रेम का एक सेट (प्रस्तुति स्लाइड से) उत्पन्न करने के लिए किया जाता है और फिर FFMpegCore (ffmpeg) का उपयोग फ्रेम के आधार पर वीडियो बनाने के लिए किया जाता है।

पीपीटी को वीडियो में कैसे बदलें

  1. यहाँ निर्देशों का पालन करके Aspose.Slides for Java इंस्टॉल करें। डाउनलोड Ffmpeg यहां।

  2. इसे अपनी पीओएम फ़ाइल में जोड़ें:

       <निर्भरता>
         <groupId>net.bramp.ffmpeg</groupId>
         <artifactId>ffmpeg</artifactId>
         <संस्करण>0.7.0</संस्करण>
       </निर्भरता>
    

  3. प्रतिलिपि बनाएँ, चिपकाएँ, और फिर Java PowerPoint को वीडियो कोड में चलाएँ।

जावा में PowerPoint को वीडियो में कनवर्ट करें

पीपीटी को वीडियो में बदलने के लिए इस जावा कोड का प्रयोग करें:

PowerPoint को वीडियो में बदलने के लिए जावा कोड


Presentation presentation = new Presentation();
try {
    // Adds a smile shape and then animates it
    IAutoShape smile = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.SmileyFace, 110, 20, 500, 500);
    ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
    IEffect effectIn = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.TopLeft, EffectTriggerType.AfterPrevious);
    IEffect effectOut = mainSequence.addEffect(smile, EffectType.Fly, EffectSubtype.BottomRight, EffectTriggerType.AfterPrevious);
    effectIn.getTiming().setDuration(2f);
    effectOut.setPresetClassType(EffectPresetClassType.Exit);

    final int fps = 33;
    ArrayList<String> frames = new ArrayList<String>();

    PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
    try
    {
        PresentationPlayer player = new PresentationPlayer(animationsGenerator, fps);
        try {
            player.setFrameTick((sender, arguments) ->
            {
                try {
                    String frame = String.format("frame_%04d.png", sender.getFrameIndex());
                    ImageIO.write(arguments.getFrame(), "PNG", new java.io.File(frame));
                    frames.add(frame);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            });
            animationsGenerator.run(presentation.getSlides());
        } finally {
            if (player != null) player.dispose();
        }
    } finally {
        if (animationsGenerator != null) animationsGenerator.dispose();
    }

    // Configure ffmpeg binaries folder. See this page: https://github.com/rosenbjerg/FFMpegCore#installation
    FFmpeg ffmpeg = new FFmpeg("path/to/ffmpeg");
    FFprobe ffprobe = new FFprobe("path/to/ffprobe");

    FFmpegBuilder builder = new FFmpegBuilder()
            .addExtraArgs("-start_number", "1")
            .setInput("frame_%04d.png")
            .addOutput("output.avi")
            .setVideoFrameRate(FFmpeg.FPS_24)
            .setFormat("avi")
            .done();

    FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
    executor.createJob(builder).run();
} catch (IOException e) {
    e.printStackTrace();
}

अन्य समर्थित रूपांतरण

आप PowerPoint को अन्य स्वरूपों में फ़ाइलों में भी रूपांतरित कर सकते हैं