تحويل عروض PowerPoint إلى فيديو على Android

من خلال تحويل عرض PowerPoint إلى فيديو، ستحصل على

  • زيادة في إمكانية الوصول: جميع الأجهزة (بغض النظر عن النظام) مزودة بمشغلات الفيديو بشكل افتراضي مقارنةً بتطبيقات فتح العروض التقديمية، لذا يجد المستخدمون سهولة أكبر في فتح أو تشغيل الفيديوهات.
  • نطاق أوسع: عبر الفيديوهات، يمكنك الوصول إلى جمهور كبير وتوجيههم بمعلومات قد تبدو مملة في عرض تقديمي. تشير معظم الاستطلاعات والإحصاءات إلى أن الناس يشاهدون الفيديوهات ويستهلكونها أكثر من غيرها من أشكال المحتوى، وعادةً ما يفضلون هذا النوع من المحتوى.

تحويل PowerPoint إلى فيديو في Aspose.Slides

في Aspose.Slides 22.11، نفّذنا دعم تحويل العروض التقديمية إلى فيديو.

  • استخدم Aspose.Slides لإنشاء مجموعة من الإطارات (من شرائح العرض) التي توافق عددًا معينًا من الإطارات في الثانية (FPS).
  • استخدم أداة طرف ثالث مثل ffmpeg (لـ java) لإنشاء فيديو بناءً على الإطارات.

تحويل PowerPoint إلى فيديو

  1. أضف هذا إلى ملف POM الخاص بك:
   <dependency>
     <groupId>net.bramp.ffmpeg</groupId>
     <artifactId>ffmpeg</artifactId>
     <version>0.7.0</version>
   </dependency>
  1. نزِّل ffmpeg هنا.

  2. شغِّل كود Java لتحويل PowerPoint إلى فيديو.

هذا الكود بلغة Java يوضح كيفية تحويل عرض تقديمي (يحتوي على شكل وتأثيرين حركيين) إلى فيديو:

Presentation presentation = new Presentation();
try {
    // يضيف شكل ابتسامة ثم يحركه
    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());
                    arguments.getFrame().save(frame, ImageFormat.Png);
                    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();
    }

    // تكوين مجلد ملفات ffmpeg التنفيذية. راجع هذه الصفحة: 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();
}

تأثيرات الفيديو

يمكنك تطبيق الحركات على الكائنات داخل الشرائح واستخدام الانتقالات بين الشرائح.

الحركات والانتقالات تجعل عروض الشرائح أكثر جذبًا وإثارة—وتفعل نفس الشيء مع الفيديوهات. دعنا نضيف شريحة وانتقالًا آخرين إلى الكود الخاص بالعرض السابق:

// يضيف شكل ابتسامة ويحركه

// ...

// يضيف شريحة جديدة وانتقال متحرك

ISlide newSlide = presentation.getSlides().addEmptySlide(presentation.getSlides().get_Item(0).getLayoutSlide());

newSlide.getBackground().setType(BackgroundType.OwnBackground);

newSlide.getBackground().getFillFormat().setFillType(FillType.Solid);

newSlide.getBackground().getFillFormat().getSolidFillColor().setColor(Color.MAGENTA);

newSlide.getSlideShowTransition().setType(TransitionType.Push);

كما يدعم Aspose.Slides حركة النصوص. لذا نقوم بتحريك الفقرات على الكائنات لتظهر واحدة تلو الأخرى (مع تأخير ثانية واحدة):

Presentation presentation = new Presentation();
try {
    // يضيف النصوص والرسوم المتحركة
    IAutoShape autoShape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 210, 120, 300, 300);
    Paragraph para1 = new Paragraph();
    para1.getPortions().add(new Portion("Aspose Slides for Java"));
    Paragraph para2 = new Paragraph();
    para2.getPortions().add(new Portion("convert PowerPoint Presentation with text to video"));

    Paragraph para3 = new Paragraph();
    para3.getPortions().add(new Portion("paragraph by paragraph"));
    IParagraphCollection paragraphCollection = autoShape.getTextFrame().getParagraphs();
    paragraphCollection.add(para1);
    paragraphCollection.add(para2);
    paragraphCollection.add(para3);
    paragraphCollection.add(new Paragraph());

    ISequence mainSequence = presentation.getSlides().get_Item(0).getTimeline().getMainSequence();
    IEffect effect1 = mainSequence.addEffect(para1, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
    IEffect effect2 = mainSequence.addEffect(para2, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
    IEffect effect3 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);
    IEffect effect4 = mainSequence.addEffect(para3, EffectType.Appear, EffectSubtype.None, EffectTriggerType.AfterPrevious);

    effect1.getTiming().setTriggerDelayTime(1f);
    effect2.getTiming().setTriggerDelayTime(1f);
    effect3.getTiming().setTriggerDelayTime(1f);
    effect4.getTiming().setTriggerDelayTime(1f);

    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());
                    arguments.getFrame().save(frame, ImageFormat.Png);
                    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();
    }

    // تكوين مجلد ملفات ffmpeg التنفيذية. راجع هذه الصفحة: 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 إلى فيديو، يوفر Aspose.Slides الفئتين PresentationAnimationsGenerator وPresentationPlayer.

PresentationAnimationsGenerator يسمح لك بتحديد حجم الإطار للفيديو (الذي سيُنشأ لاحقًا) من خلال المُنشئ الخاص به. إذا قمت بتمرير نسخة من العرض، سيتم استخدام Presentation.SlideSize ويولد حركات يستخدمها PresentationPlayer.

عند توليد الحركات، يتم إنشاء حدث NewAnimation لكل حركة تالية، ويحمل معامل IPresentationAnimationPlayer. الأخيرة هي فئة تمثل مشغلًا لحركة منفصلة.

للعمل مع IPresentationAnimationPlayer، يتم استخدام خاصية Duration (المدة الكاملة للحركة) وطريقة SetTimePosition. يتم ضبط موضع كل حركة ضمن النطاق 0 إلى المدة، ثم تُعيد طريقة GetFrame صورة BufferedImage تمثل حالة الحركة في تلك اللحظة:

Presentation presentation = new Presentation();
try {
    // يضيف شكل ابتسامة ويحركه
    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);

    PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
    try {
        animationsGenerator.setNewAnimation(animationPlayer ->
        {
            System.out.println(String.format("Animation total duration: %f", animationPlayer.getDuration()));
            animationPlayer.setTimePosition(0); // حالة الرسوم المتحركة الأولية
            try {
                // صورة bitmap لحالة الرسوم المتحركة الأولية
                animationPlayer.getFrame().save("firstFrame.png", ImageFormat.Png);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            animationPlayer.setTimePosition(animationPlayer.getDuration()); // الحالة النهائية للرسوم المتحركة
            try {
                // الإطار الأخير للرسوم المتحركة
                animationPlayer.getFrame().save("lastFrame.png", ImageFormat.Png);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
    } finally {
        if (animationsGenerator != null) animationsGenerator.dispose();
    }
} finally {
    if (presentation != null) presentation.dispose();
}

لجعل جميع الحركات في عرض تقديمي تُشغل مرة واحدة، تُستخدم فئة PresentationPlayer. تأخذ هذه الفئة نسخة من PresentationAnimationsGenerator وعدد FPS للتأثيرات في مُنشئها ثم تستدعي حدث FrameTick لجميع الحركات لتشغيلها:

Presentation presentation = new Presentation("animated.pptx");
try {
    PresentationAnimationsGenerator animationsGenerator = new PresentationAnimationsGenerator(presentation);
    try {
        PresentationPlayer player = new PresentationPlayer(animationsGenerator, 33);
        try {
            player.setFrameTick((sender, arguments) ->
            {
                try {
                    arguments.getFrame().save("frame_" + sender.getFrameIndex() + ".png", ImageFormat.Png);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            });
            animationsGenerator.run(presentation.getSlides());
        } finally {
            if (player != null) player.dispose();
        }
    } finally {
        if (animationsGenerator != null) animationsGenerator.dispose();
    }
} finally {
    if (presentation != null) presentation.dispose();
}

بعد ذلك يمكن تجميع الإطارات المُولدة لإنتاج فيديو. راجع قسم تحويل PowerPoint إلى فيديو.

الرسوم المتحركة والتأثيرات المدعومة

الدخول:

نوع الحركة Aspose.Slides PowerPoint
Appear not supported supported
Fade supported supported
Fly In supported supported
Float In supported supported
Split supported supported
Wipe supported supported
Shape supported supported
Wheel supported supported
Random Bars supported supported
Grow & Turn not supported supported
Zoom supported supported
Swivel supported supported
Bounce supported supported

التأكيد:

نوع الحركة Aspose.Slides PowerPoint
Pulse not supported supported
Color Pulse not supported supported
Teeter supported supported
Spin supported supported
Grow/Shrink not supported supported
Desaturate not supported supported
Darken not supported supported
Lighten not supported supported
Transparency not supported supported
Object Color not supported supported
Complementary Color not supported supported
Line Color not supported supported
Fill Color not supported supported

الخروج:

نوع الحركة Aspose.Slides PowerPoint
Disappear not supported supported
Fade supported supported
Fly Out supported supported
Float Out supported supported
Split supported supported
Wipe supported supported
Shape supported supported
Random Bars supported supported
Shrink & Turn not supported supported
Zoom supported supported
Swivel supported supported
Bounce supported supported

مسارات الحركة:

نوع الحركة Aspose.Slides PowerPoint
Lines supported supported
Arcs supported supported
Turns supported supported
Shapes supported supported
Loops supported supported
Custom Path supported supported

الأسئلة المتكررة

هل يمكن تحويل العروض التقديمية المحمية بكلمة مرور؟

نعم، يسمح Aspose.Slides بالعمل مع العروض التقديمية المحمية بكلمة مرور. عند معالجة مثل هذه الملفات، تحتاج إلى توفير كلمة المرور الصحيحة لكي يتمكن المكتبة من الوصول إلى محتوى العرض.

هل يدعم Aspose.Slides الاستخدام في حلول السحابة؟

نعم، يمكن دمج Aspose.Slides في التطبيقات والخدمات السحابية. تم تصميم المكتبة للعمل في بيئات الخادم، مما يضمن أداءً عاليًا وقابلية توسيع للمعالجة الدفعية للملفات.

هل هناك أية قيود على حجم العروض أثناء التحويل؟

يمكن لـ Aspose.Slides التعامل مع عروض تقديمية بحجم شبه غير محدود. ومع ذلك، عند العمل مع ملفات كبيرة جدًا، قد تحتاج إلى موارد نظام إضافية، وقد يُنصح أحيانًا بتحسين العرض لتحسين الأداء.