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 3456986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:48:18+00:00 2026-05-18T09:48:18+00:00

I am using ffmpeg.exe to convert video files to flv format . For that

  • 0

I am using ffmpeg.exe to convert video files to flv format. For that purpose i use a windows service to run the conversion process in background. While trying to convert large files(i experienced it when the file size is >14MB) through windows service it gets stuck at the line which starts the process(ie, process.start();).

But when i tried to execute ffmpeg.exe directly from command prompt it worked with out any problems.

My code in windows service is as follows:

private Thread WorkerThread; 
protected override void OnStart(string[] args)
{ 

   WorkerThread = new Thread(new ThreadStart(StartHandlingVideo));
   WorkerThread.Start();
}

protected override void OnStop()
{ 
   WorkerThread.Abort();
}

private void StartHandlingVideo()
{   
   FilArgs = string.Format("-i {0} -ar 22050 -qscale 1 {1}", InputFile, OutputFile);
   Process proc;
   proc = new Process();

   try
   {

     proc.StartInfo.FileName = spath + "\\ffmpeg\\ffmpeg.exe";
     proc.StartInfo.Arguments = FilArgs;
     proc.StartInfo.UseShellExecute = false;
     proc.StartInfo.CreateNoWindow = false;
     proc.StartInfo.RedirectStandardOutput = true;
     proc.StartInfo.RedirectStandardError = true;

     eventLog1.WriteEntry("Going to start process of convertion");

     proc.Start();

     string StdOutVideo = proc.StandardOutput.ReadToEnd();
     string StdErrVideo = proc.StandardError.ReadToEnd();

     eventLog1.WriteEntry("Convertion Successful");
     eventLog1.WriteEntry(StdErrVideo);               
 }
 catch (Exception ex)
 {
     eventLog1.WriteEntry("Convertion Failed");
     eventLog1.WriteEntry(ex.ToString());            
 }
 finally
 {
     proc.WaitForExit();
     proc.Close();
 }

How can I get rid of this situation.

  • 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-05-18T09:48:19+00:00Added an answer on May 18, 2026 at 9:48 am

    It seems you caught a deadlock because you performed a synchronous read to the end of both redirected streams.

    A reference from MSDN:

    There is a similar issue when you read
    all text from both the standard output
    and standard error streams. The
    following C# code, for example,
    performs a read operation on both
    streams.

     // Do not perform a synchronous read to the end of both
     // redirected streams.
     // string output = p.StandardOutput.ReadToEnd();
     // string error = p.StandardError.ReadToEnd();
     // p.WaitForExit();
     // Use asynchronous read operations on at least one of the streams.
     p.BeginOutputReadLine();
     string error = p.StandardError.ReadToEnd();
     p.WaitForExit();
    

    The code example avoids the deadlock
    condition by performing asynchronous
    read operations on the StandardOutput
    stream. A deadlock condition results
    if the parent process calls
    p.StandardOutput.ReadToEnd followed by
    p.StandardError.ReadToEnd and the
    child process writes enough text to
    fill its error stream. The parent
    process would wait indefinitely for
    the child process to close its
    StandardOutput stream. The child
    process would wait indefinitely for
    the parent to read from the full
    StandardError stream.

    You can use asynchronous read
    operations to avoid these dependencies
    and their deadlock potential.
    Alternately, you can avoid the
    deadlock condition by creating two
    threads and reading the output of each
    stream on a separate thread.

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

Sidebar

Related Questions

I am using FFmpeg to convert a video from one format to another. I
i found some articles, some projects to create thumbnail of a video, using ffmpeg.exe,
How can i find duration of an uploaded video ,****convert it to flv format****
I need to join several jpg files into video using FFmpeg library. But I
I've compiled an MTS video into MP4 format using FFMPEG. The video is 2
I want to batch convert a directory containing hundreds of FLV files so that
I am converting videos to flv using ffmpeg.exe through c# and the process gets
I've made a batch file for drag and drop conversion of video using ffmpeg.
I'm using ffmpeg on Windows to create mp4 files for web distribution. As libfaac
I'm using a simple QProcess-Project on a WindowsXP-Machine: QString program = U:\\ffmpeg.exe; QStringList arguments;

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.