sliu

Forum Replies Created

Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • in reply to: Why OpenXml SDK 2.5doesn't support mp4 format? #2551

    sliu
    Participant

    Hi Eric,

    After added Mp4 in MediaDataPartType and modified the corresponding MediaDataPartTypeInfo methods and GetMediadataPartTypeFromContentType in PowerTools, Mp4 works fine.

    Finally, I can use the modified OpenXml SDK 2.6 to make my videos (mp4) working.

    in reply to: Why OpenXml SDK 2.5doesn't support mp4 format? #2544

    sliu
    Participant

    Ok, I’ll do it tomorrow and let you know.

    in reply to: Why OpenXml SDK 2.5doesn't support mp4 format? #2541

    sliu
    Participant

    I think both deal with the specifics of video and sound. Please take a look at the code I got from PresentationBuilder::CopyRelatedMedia and the definition of DocumentFormat.OpenXml.Packaging.MediaDataPartType.

    Since MediaDataPartType doesn’t have mp4 in its enumeration, PowerTools GetMediadataPartTypeFromContentType uses the default value – MediaDataPartType.Wmv – as mp4 media type. That is why mp4 file cannot be played correctly.

    I can play my mp4 in my original pptx. I converted my mp4 to .avi file and inserted it in my original pptx. Both .mp4 and .avi can play. After copied version generated, only .avi file can play, but .mp4 gives the error “Codec Unavailable”.

    if (temp.DataPart == null)
    {
    var ct = oldPart.ContentType;
    MediaDataPartType mdpt = GetMediadataPartTypeFromContentType(ct);
    MediaDataPart newPart = newContentPart.OpenXmlPackage.CreateMediaDataPart(mdpt);
    newPart.FeedData(oldPart.GetStream());

    private static MediaDataPartType GetMediadataPartTypeFromContentType(string ct)
    {
    MediaDataPartType mdpt = MediaDataPartType.Wmv;

    if (ct == “audio/aiff”)
    mdpt = MediaDataPartType.Aiff;
    else if (ct == “video/x-ms-asf-plugin”)
    mdpt = MediaDataPartType.Asx;
    else if (ct == “video/avi”)
    mdpt = MediaDataPartType.Avi;
    else if (ct == “audio/midi”)
    mdpt = MediaDataPartType.Midi;
    else if (ct == “audio/mp3”)
    mdpt = MediaDataPartType.Mp3;
    else if (ct == “audio/mpeg”)
    mdpt = MediaDataPartType.MpegAudio;
    else if (ct == “audio/mpegurl”)
    mdpt = MediaDataPartType.MpegUrl;
    else if (ct == “video/mpeg”)
    mdpt = MediaDataPartType.MpegVideo;
    else if (ct == “video/mpg”)
    mdpt = MediaDataPartType.Mpg;
    else if (ct == “audio/ogg”)
    mdpt = MediaDataPartType.OggAudio;
    else if (ct == “video/ogg”)
    mdpt = MediaDataPartType.OggVideo;
    else if (ct == “video/quicktime”)
    mdpt = MediaDataPartType.Quicktime;
    else if (ct == “video/vc1”)
    mdpt = MediaDataPartType.VC1;
    else if (ct == “audio/wav”)
    mdpt = MediaDataPartType.Wav;
    else if (ct == “audio/x-ms-wma”)
    mdpt = MediaDataPartType.Wma;
    else if (ct == “video/x-ms-wmv”)
    mdpt = MediaDataPartType.Wmv;
    else if (ct == “video/x-ms-wmx”)
    mdpt = MediaDataPartType.Wmx;
    else if (ct == “video/x-ms-wvx”)
    mdpt = MediaDataPartType.Wvx;
    else if (ct == “audio/unknown”)
    mdpt = MediaDataPartType.Wav;
    return mdpt;
    }

    namespace DocumentFormat.OpenXml.Packaging
    {
    // Summary:
    // Defines part media types.
    public enum MediaDataPartType
    {
    // Summary:
    // Audio Interchange File Format (.aiff)
    Aiff = 0,
    //
    // Summary:
    // MIDI Audio (.mid)
    Midi = 1,
    //
    // Summary:
    // MP3 (.mp3)
    Mp3 = 2,
    //
    // Summary:
    // MP3 Playlist File (.m3u)
    MpegUrl = 3,
    //
    // Summary:
    // WAV audio (.wav)
    Wav = 4,
    //
    // Summary:
    // Windows Media Audio File (.wma)
    Wma = 5,
    //
    // Summary:
    // Mpeg audio (.mpeg)
    MpegAudio = 6,
    //
    // Summary:
    // Ogg Vorbis (.ogg)
    OggAudio = 7,
    //
    // Summary:
    // Advanced Stream Redirector File (.asx)
    Asx = 8,
    //
    // Summary:
    // Audio Video Interleave File (.avi)
    Avi = 9,
    //
    // Summary:
    // MPEG 1 System Stream (.mpg)
    Mpg = 10,
    //
    // Summary:
    // MPEG 1 System Stream (.mpeg)
    MpegVideo = 11,
    //
    // Summary:
    // Windows Media File (.wmv)
    Wmv = 12,
    //
    // Summary:
    // Windows Media Player A/V Shortcut (.wmx)
    Wmx = 13,
    //
    // Summary:
    // Windows Media Redirector (.wvx)
    Wvx = 14,
    //
    // Summary:
    // QuickTime video (.mov)
    Quicktime = 15,
    //
    // Summary:
    // Ogg Stream (.ogg)
    OggVideo = 16,
    //
    // Summary:
    // VC-1 Stream (.wmv)
    VC1 = 17,
    }
    }

    in reply to: PresentationBuilder cannot copy video slides correctly #2529

    sliu
    Participant

    Thanks for the explanation.

    After reading the code, I realized all the media files are created as DataPart in PresentationBuilder and the Non-Public memember TargetFileExtension is “.bin”. For images, OpenXml SDK adds .bin to media files. For audio and video files, it doesn’t add any extension. I know audios created by OpenXml SDK are playable, but not video. I’m not sure if it is caused by file extension. I thought using OpenXm SDK I can create exactly folder layouts as pptx generated by PowerPoint. It seems like not exactly.

    I’m wondering how [Content_Type].xml is created by sdk. Which sdk api or part is related to its generation? Can I load in this xml and modify it and save it back to some part. When package is saved, my modified content is in [Content_Type].xml?


    sliu
    Participant

    Hi Eric,

    In PresentationBuilder::CopyRelatedImage, it calls

    var oldPartIdPair = oldContentPart.Parts.FirstOrDefault(p => p.RelationshipId == relId);

    I looked into oldPartIdPair, in its OpenXmlPart.Non-Public memebers, TargetFileExtension = “.bin”.

    I think this is assigned by OpenXml SDK. Does this mean the bug is in OpenXml SDK instead of in PresentationBuilder. Do you know how long it will take to fix it? I really need to make video working using OpenXml SDK.

    Thanks

    in reply to: PresentationBuilder cannot copy video slides correctly #2516

    sliu
    Participant

    Hi Eric,

    That would be great! I’m new on OpenXml SDK. I’m reading PowerTool code. I see PtOpenXmlExtensions.GetXDocument and PutXDocument use OpenXmlPart.Annotation<XDocument> method to store part xml. I don’t fully understand its purpose. If all the parts have their annotations with different types, when the presentation is saved to pptx, can I see the annotations? Do they affect pptx rendering?

    Thanks very much!!!

Viewing 6 posts - 16 through 21 (of 21 total)