แปลงงานนำเสนอ PowerPoint เป็นวิดีโอบน Android
บทนำ
โดยการแปลงงานนำเสนอ PowerPoint ของคุณเป็นวิดีโอ คุณจะได้รับ
- เพิ่มการเข้าถึง: ทุกอุปกรณ์ (ไม่ว่าจะเป็นแพลตฟอร์มใด) มีเครื่องเล่นวิดีโอเป็นค่าเริ่มต้นเมื่อเทียบกับแอปพลิเคชันเปิดงานนำเสนอ ดังนั้นผู้ใช้จึงพบว่าการเปิดหรือเล่นวิดีโอทำได้ง่ายขึ้น.
- เข้าถึงมากขึ้น: ด้วยวิดีโอ คุณสามารถเข้าถึงผู้ชมจำนวนมากและนำเสนอข้อมูลที่อาจดูน่าเบื่อถ้าใช้ในงานนำเสนอ สถานะสำรวจและสถิติมากมายแสดงว่าผู้คนดูและบริโภควิดีโอมากกว่าชนิดเนื้อหาอื่น ๆ และโดยทั่วไปพวกเขาชอบเนื้อหาแบบนี้.
การแปลง PowerPoint เป็นวิดีโอใน Aspose.Slides
Aspose.Slides รองรับการแปลงงานนำเสนอเป็นวิดีโอ.
- ใช้ Aspose.Slides เพื่อสร้างชุดเฟรม (จากสไลด์ของงานนำเสนอ) ที่สอดคล้องกับ FPS (เฟรมต่อวินาที) ที่กำหนด
- ใช้ยูทิลิตี้ของบุคคลที่สามเช่น ffmpeg (สำหรับ java) เพื่อสร้างวิดีโอจากเฟรมเหล่านั้น.
แปลง PowerPoint เป็นวิดีโอ
- เพิ่มนี้ลงในไฟล์ POM ของคุณ:
<dependency>
<groupId>net.bramp.ffmpeg</groupId>
<artifactId>ffmpeg</artifactId>
<version>0.7.0</version>
</dependency>
-
ดาวน์โหลด ffmpeg ที่นี่.
-
รันโค้ด 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 ถึง duration จากนั้นเมธอด 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 {
// บิตแมพของสถานะเริ่มต้นแอนิเมชัน
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();
}
จากนั้นเฟรมที่สร้างขึ้นสามารถรวมเป็นวิดีโอได้ ดูส่วน Convert PowerPoint to Video.
แอนิเมชันและเอฟเฟกต์ที่รองรับ
การเข้าสู่
| ประเภทแอนิเมชัน | Aspose.Slides | PowerPoint |
|---|---|---|
| Appear | ![]() |
![]() |
| Fade | ![]() |
![]() |
| Fly In | ![]() |
![]() |
| Float In | ![]() |
![]() |
| Split | ![]() |
![]() |
| Wipe | ![]() |
![]() |
| Shape | ![]() |
![]() |
| Wheel | ![]() |
![]() |
| Random Bars | ![]() |
![]() |
| Grow & Turn | ![]() |
![]() |
| Zoom | ![]() |
![]() |
| Swivel | ![]() |
![]() |
| Bounce | ![]() |
![]() |
การเน้น
| ประเภทแอนิเมชัน | Aspose.Slides | PowerPoint |
|---|---|---|
| Pulse | ![]() |
![]() |
| Color Pulse | ![]() |
![]() |
| Teeter | ![]() |
![]() |
| Spin | ![]() |
![]() |
| Grow/Shrink | ![]() |
![]() |
| Desaturate | ![]() |
![]() |
| Darken | ![]() |
![]() |
| Lighten | ![]() |
![]() |
| Transparency | ![]() |
![]() |
| Object Color | ![]() |
![]() |
| Complementary Color | ![]() |
![]() |
| Line Color | ![]() |
![]() |
| Fill Color | ![]() |
![]() |
การออก
| ประเภทแอนิเมชัน | Aspose.Slides | PowerPoint |
|---|---|---|
| Disappear | ![]() |
![]() |
| Fade | ![]() |
![]() |
| Fly Out | ![]() |
![]() |
| Float Out | ![]() |
![]() |
| Split | ![]() |
![]() |
| Wipe | ![]() |
![]() |
| Shape | ![]() |
![]() |
| Random Bars | ![]() |
![]() |
| Shrink & Turn | ![]() |
![]() |
| Zoom | ![]() |
![]() |
| Swivel | ![]() |
![]() |
| Bounce | ![]() |
![]() |
เส้นทางการเคลื่อนที่:
| ประเภทแอนิเมชัน | Aspose.Slides | PowerPoint |
|---|---|---|
| Lines | ![]() |
![]() |
| Arcs | ![]() |
![]() |
| Turns | ![]() |
![]() |
| Shapes | ![]() |
![]() |
| Loops | ![]() |
![]() |
| Custom Path | ![]() |
![]() |
คำถามที่พบบ่อย
สามารถแปลงงานนำเสนอที่มีการป้องกันด้วยรหัสผ่านได้หรือไม่?
ใช่, Aspose.Slides รองรับการทำงานกับ งานนำเสนอที่ป้องกันด้วยรหัสผ่าน. เมื่อประมวลผลไฟล์ดังกล่าว คุณต้องระบุรหัสผ่านที่ถูกต้องเพื่อให้ไลบรารีสามารถเข้าถึงเนื้อหาของงานนำเสนอได้.
Aspose.Slides รองรับการใช้งานในโซลูชันคลาวด์หรือไม่?
ใช่, Aspose.Slides สามารถรวมเข้ากับแอปพลิเคชันและบริการคลาวด์ได้ ไลบรารีถูกออกแบบให้ทำงานในสภาพแวดล้อมเซิร์ฟเวอร์, รับประกันประสิทธิภาพสูงและการขยายขนาดสำหรับการประมวลผลไฟล์เป็นชุด.
มีข้อจำกัดขนาดสำหรับงานนำเสนอระหว่างการแปลงหรือไม่?
Aspose.Slides สามารถจัดการงานนำเสนอที่มีขนาดใกล้เคียงกับไม่จำกัด อย่างไรก็ตามเมื่อทำงานกับไฟล์ขนาดใหญ่มาก อาจต้องการทรัพยากรระบบเพิ่มเติม และบางครั้งแนะนำให้ทำการปรับขนาดงานนำเสนอเพื่อเพิ่มประสิทธิภาพ.

