locked
Having the image at the third second of a video RRS feed

  • Question

  • Hello ! ^^

    I'm desperately trying to recover the image to the third second of a video, in MP4 format as Bitmap.

    I need this to analyze the image and get some information from it.

    Thank you for the person who will take the time to answer me and guide me.

    Code for the moment :

                    foreach (string file in filePaths)
                    {
    
                    }

    Thursday, July 30, 2020 2:51 PM

Answers

  • Hi Staszewski,

    Thank you for posting here.

    You can also use some third-party packages to get screenshots from a certain moment in the video.

    I wrote an example with MediaToolkit.

    using (var engine = new Engine()) { var mp4 = new MediaFile { Filename = @"D:\test\video\test.mp4" }; engine.GetMetadata(mp4); var i = 0; while (i < 5) {

                 //Decide in which second of the video to capture the image var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(i) }; var outputFile = new MediaFile { Filename = string.Format("{0}\\image-{1}.jpeg", @"D:\test\video", i) }; engine.GetThumbnail(mp4, outputFile, options); i++; } }

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 31, 2020 5:27 AM

All replies

  • A way is with IMFSourceReader

    like in the MS C++ VideoThumbnail Sample

    (P/Invoke to declare interfaces)

    Thursday, July 30, 2020 7:47 PM
  • Hi Staszewski,

    Thank you for posting here.

    You can also use some third-party packages to get screenshots from a certain moment in the video.

    I wrote an example with MediaToolkit.

    using (var engine = new Engine()) { var mp4 = new MediaFile { Filename = @"D:\test\video\test.mp4" }; engine.GetMetadata(mp4); var i = 0; while (i < 5) {

                 //Decide in which second of the video to capture the image var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(i) }; var outputFile = new MediaFile { Filename = string.Format("{0}\\image-{1}.jpeg", @"D:\test\video", i) }; engine.GetThumbnail(mp4, outputFile, options); i++; } }

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 31, 2020 5:27 AM
  • Hi,

    Has your issue been resolved?

    If so, please click on the "Mark as answer" option of the reply that solved your question, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 6, 2020 8:06 AM