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

  • SEARCH
  • Home
  • 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 8199419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:09:52+00:00 2026-06-07T06:09:52+00:00

I am trying to get a poster frame from a video file, using ffmpeg.

  • 0

I am trying to get a poster frame from a video file, using ffmpeg.

I have been following this tutorial and come up with the following code(which is taken/adapted from the link I gave):

public bool GetVideoThumbnail(string path, string saveThumbnailTo, int seconds)
        {
            string parameters = string.Format("-i {0} {1} -vcodec mjpeg -ss {2} -vframes 1 -an -f rawvideo", path, saveThumbnailTo, seconds);

            if (File.Exists(saveThumbnailTo))
            {
                return true;
            }
            else
            {
                using (Process process = Process.Start(pathToConvertor, parameters))
                {
                    process.WaitForExit();
                }
                return File.Exists(saveThumbnailTo);
            }
        }

At the moment this code is successfully creating a file in the correct destination (saveThumbnailTo) only the picture is completely black. I have tried changing the seconds value in the code to ensure that I am not just getting a blank picture from the start of the video. The path refers to where my video is stored, by the way.

I am currently calling the above code like so:

GetVideoThumbnail(videoPath, folderPath + "/poster.jpg", 100)

..and then passing it out to my view to display the picture. I just wonder whether “.jpg” is the extension I should be giving to this file as I am not entirely sure?

Edit: When I run the same command from the command line I get the following errors:

Incompatible pixel format ‘yuv420p’ for codec ‘mjpeg’, auto-selecting
format ‘yuvj420p’

which appears in yellow, and

[image2 @ 02S96AE0] Could not get frame filename number 2 from pattern
‘poster.jpg’ an_interleaved_write_frame(): Invalid argument

which appears in red.

Could anyone help me with getting this working properly as I am completely unfamiliar with the ffmpeg command line and not sure what I am doing wrong. I have tried removing the vcodec parameter and get the same error message.

  • 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-07T06:09:53+00:00Added an answer on June 7, 2026 at 6:09 am

    Try this:

    public bool GetVideoThumbnail(string path, string saveThumbnailTo, int seconds)
    {
        string parameters = string.Format("-ss {0} -i {1} -f image2 -vframes 1 -y {2}", seconds, path, saveThumbnailTo);
    
        var processInfo = new ProcessStartInfo();
        processInfo.FileName = pathToConvertor;
        processInfo.Arguments = parameters;
        processInfo.CreateNoWindow = true;
        processInfo.UseShellExecute = false;
    
        File.Delete(saveThumbnailTo);
    
        using(var process = new Process())
        {
            process.StartInfo = processInfo;
            process.Start();
            process.WaitForExit();
        }
    
        return File.Exists(saveThumbnailTo);
    }
    

    Short explanation:

    • f image2 : output is image
    • vframes 1 : take one frame from the input
    • y : overwrite output file
    • “processInfo.CreateNoWindow = true” : do not show the ffmpeg window

    Try several times with different values for the “seconds” parameter.
    Also, make sure the “pathToConvertor” is correct.

    This worked for me, with recent build of ffmpeg.exe on a Windows machine.

    Let me know how it goes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is for a jQuery Mobile app using version 1.0.1. I'm trying to get
Using jQuery and jQuery.Colors, I've been trying to come up with a way to
I'm trying to get the movie poster from IMDB according to the title of
When trying to store a file I get the following: TypeError: can't convert nil
I am trying to upload video to Wordpress.using following method string expression = videoData.VideoTitle;
First, please see this post on Doctype I've been trying to get an answer
I'm using Visual C# Studio 2010 express and have been trying to batch update
I'm trying get the visible portion of UIImage from an UIImageView . UIImageView takes
I am trying get all html links within a string and replace them using
I am trying get all html links within a string and replace them using

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.