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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:47:09+00:00 2026-05-26T00:47:09+00:00

In reference to this question, as you can see I managed to run and

  • 0

In reference to this question, as you can see I managed to run and receive data from the program.

However I didn’t manage to submit data to it, for instance, while converting a file, pressing q immediately stop conversion and stops the program.
I need my application to support stopping the process as well, and I think this should be done by passing this parameter to the ffmpeg app, since I want it to take care of all uncollected resource or whatever dust it would leave behind if I would just go and use process.Kill()

Here is what I’ve tried:

static int lineCount = 0;
static bool flag;
static void process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
  Console.WriteLine("Error ({1:m:s:fff}: {0})", lineCount++,
      DateTime.Now);

  if (e.Data != null && string.Equals(e.Data,"Press [q] to stop, [?] for help")) 
    flag = true;

  if (flag)
  {
    flag = false;
    Console.WriteLine("Stopping ({0:m:s:fff})...", DateTime.Now);
    process.CancelErrorRead();
    process.CancelOutputRead();
    process.StandardInput.WriteLine("q");
  }   

  Console.WriteLine(e.Data);
  Console.WriteLine();
}

But it doesn’t do anything, seems that once the conversion has been requested, I have no control on it any more, I can only receive output from it. Running it as stand alone does allow me interaction of course.

What am I missing here, is it a different trick in submitting the output or the code in previous answer is wrong, or I should have chosen a different approach?

For your attention, RedirectStandardInput is on.

NOTE: as you can see in the answer of my previous question, ffmpeg interacts differently, I think the one who knows the answer will be (maybe I’m wrong) someone with experience in ffmpeg.

  • 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-26T00:47:10+00:00Added an answer on May 26, 2026 at 12:47 am

    Use WriteLine('q'); instead of Write('q');.

    🙂

    I tried to run ffmpeg from cygwin bash shell and saw that I had to type an enter after 'q'. So….

        static void process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            Console.WriteLine("Error line: {0} ({1:m:s:fff})", lineCount++,
                DateTime.Now);
            Console.WriteLine(e.Data);
            Console.WriteLine();
            if (lineCount == 5)
                process.StandardInput.WriteLine("q");
        }
    

    With the stock c:\Documents and Settings\All Users\Documents\My Music\Sample Music\Beethoven's Symphony No. 9 (Scherzo).wma

    • without the process.StandardInput.WriteLine it prints 61 lines on stderr, 1 line on stdout and creates mp3 file of 1212457 bytes.
    • add the quit and it prints less number of lines on stderr, nothing on stdout and a much smaller mp3 file.

    Note that it does leave the mp3 file around.

    So there.

    EDIT

    After seeing your comment that you already tried this..

    I just rechecked. The behavior is strange.

    First I retried what I had and saw that sending "q\n" on the 5th line to sterr creates a much smaller file, though slightly different sizes in different runs — between 160K and 220K.

    Next I commented out Console.WriteLine hoping it will make ffmpeg quit faster. On the contrary, ffmpeg now did not stop at all and created the full file with exact same byte count, 1,212,457 bytes. This behavior is consistent with your observation

    Finally, with WriteLines in place, I pumped "q\n" on every line to stderr after the fifth. Big surprise! After logging 40 error lines,

    Unhandled Exception: System.InvalidOperationException: StandardIn has not been redirected.
       at System.Diagnostics.Process.get_StandardInput()
       at StandAlone.Program.process_ErrorDataReceived(Object sender, DataReceivedEventArgs e) in C:\[..]\StandAlone\Program.cs:line 171
       at System.Diagnostics.Process.ErrorReadNotifyUser(String data)
    

    Not redirected? And you are telling me after I sent 35 lines to its input?

    Something is not quite right…smells like a bug.

    Update by asker:

    Updating the windows builds from here (static) solved my issue, I used some builds from an unofficial website apparently.

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

Sidebar

Related Questions

This is with reference to the below question: Execute program from within a C
This is in reference to a question I asked earlier. Aside from viewing the
I can see that this question has been asked several times, but none of
The short version of this question is: How can I take data that only
I'm writing this question with reference to this one which I wrote yesterday. After
EDIT: This question is about finding definitive reference to MySQL syntax on SELECT modifying
This question builds off of a previously asked question: Pass by reference multidimensional array
In reference to this answer to a Stack Overflow question : what is bench-testing
This is in reference to the question previously asked The problem here is, each
This is in reference to my other question Auto Clearing Textbox . If I

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.