Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8579541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:37:46+00:00 2026-06-11T20:37:46+00:00

So I’m writing a pptx parser and using OpenXML to get the data loaded

  • 0

So I’m writing a pptx parser and using OpenXML to get the data loaded in. It’s all going pretty well (that’s a lie – I’m actually ready to throw the computer across the room and jump out of the window), but I’ve run into an issue with loading videos that I simply can’t figure out. The problem is that OpenXML doesn’t seem to be able to locate the relationship tag that specifies video URIs.

What I’ve done is written code to cycle through the parts in the slide and log out their Ids, like so:

SlidePart slidePart = ...;
foreach(var curPart in slidePart.Parts)
  Console.WriteLine("Part ID: " + curPart.RelationshipId);

So that works great – it logs out all of the relationships specified in the slide.xml.rels file – except for the video relationships for the relevant file. I can see the video relationship in the rels file, and it matches the link ID of the videoFile tag in the slide, but I can’t figure out how to get at it through code. I’ve got image loading working fine (OpenXML can find the image relationships). Are video relationships treated differently than other relationships? How can I get at the video URIs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:37:47+00:00Added an answer on June 11, 2026 at 8:37 pm

    Video releationships are stored in the ExternalReleationships collection of a SlidePart.

    Powerpoint embeds a video (external file) into a presentation in the following way (simplified):

    1. It creates a p:video (class Video) tag within a p:timing (class Timing) tag for
      the slide containing the video.
    2. The p:video tag contains a child called p:cMediaNode (class CommonMediaNode).

    3. The p:cMediaNode contains a child called p:tgtEl (class TargetElement).

    4. Again, the p:cMediaNode contains a child called p:spTgt (class ShapeTarget) which
      points to the ID of the picture shape releated to the video. The ID of the picture
      shape is stored in the NonVisualDrawingProperties Id member.
      So, the video is connected to the picture shape via these Ids.

    5. Furthermore, the picture shape contains a child called a:videoFile (class VideoFromFile).
      The class VideoFromFile has a member called Link which points to the Id of
      the external releationship.

    I highy recommend you to download the OpenXML SDK 2.0 productivity tool. This tool
    allows you to inspect the generated XML of your presentation file.

    The following code enumerates all videos for all slides in a given presentation.
    For each video the Uri to the external file is printed. This is done by finding
    the releated external releationship for the given video.

    using (var doc = PresentationDocument.Open("c:\\temp\\presentation.pptx", false))
    {
      var presentation = doc.PresentationPart.Presentation;
    
      foreach (SlideId slideId in presentation.SlideIdList)
      {
        SlidePart slidePart = doc.PresentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
        if (slidePart == null || slidePart.Slide == null)
        {
          continue;
        }
    
        Slide slide = slidePart.Slide;
    
        var videos = slide.Descendants<Video>();
    
        Console.Out.WriteLine("Found videos for slide ID: {0}", slideId.Id);
        foreach (Video video in videos)
        {
          ShapeTarget shapeTarget = video.Descendants<ShapeTarget>().FirstOrDefault();
    
          Console.Out.WriteLine("ShapeTargetId = {0}", shapeTarget.ShapeId);
    
          var videoFromFile = slide.CommonSlideData.ShapeTree.Descendants<Picture>().
                    Where<Picture>(p => p.NonVisualPictureProperties.Descendants<NonVisualDrawingProperties>().FirstOrDefault().Id == shapeTarget.ShapeId).
                    FirstOrDefault().Descendants<VideoFromFile>().FirstOrDefault();                
    
          Console.Out.WriteLine("Releationship ID: {0}", videoFromFile.Link);
    
          var externalReleationship = 
                    slidePart.ExternalRelationships.Where(er => er.Id == videoFromFile.Link).FirstOrDefault();
    
          if(externalReleationship == null) // Then it must be embedded
          {
             ReferenceRelationship rr = slidePart.GetReferenceRelationship(videoFromFile.Link);
             if (rr != null)
             {
               Console.Out.WriteLine(rr.Uri.OriginalString);
             }
          }
          else
          {
            Console.Out.WriteLine("Path to video file: {0}", externalReleationship.Uri.AbsolutePath);
          }
        }
      }
    }
    

    Of course, you could also directly enumerate the a:videoFile (class VideoFromFile) tags.
    See the code below.

    foreach (SlideId slideId in presentation.SlideIdList)
    {
      SlidePart slidePart = doc.PresentationPart.GetPartById(slideId.RelationshipId) as SlidePart;
      if (slidePart == null || slidePart.Slide == null)
      {
        continue;
      }
    
      Slide slide = slidePart.Slide;
    
      var videos = slide.CommonSlideData.ShapeTree.Descendants<VideoFromFile>();
    
      foreach (VideoFromFile video in videos)
      {                                
        Console.Out.WriteLine("Releationship ID: {0}", video.Link);
    
        var externalReleationship =
               slidePart.ExternalRelationships.Where(er => er.Id == video.Link).FirstOrDefault();
    
        if(externalReleationship == null) 
        {
            ReferenceRelationship rr = slidePart.GetReferenceRelationship(videoFromFile.Link);
            if (rr != null)
            {
              Console.Out.WriteLine(rr.Uri.OriginalString);
            }
        }
        else
        {
          Console.Out.WriteLine("Path to video file: {0}", externalReleationship.Uri.AbsolutePath);
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.