Processing jpgs stream from standard output

Using FFmpeg, I converted the video (mpeg2) to jpgs, redirecting the output to standard output.

StringBuilder str = new StringBuilder();

    //Input file path
    str.Append(string.Format(" -i {0}", myinputFile));

    //Set the frame rate
    str.Append(string.Format(" -r {0}", myframeRate);

    //Indicate the output format
    str.Append(" -f image2pipe");

    //Connect the output to the standard output
    str.Append(" pipe:1");
    return str.ToString();

I can get a callback from a process with data:

_ffmpegProc.OutputDataReceived += new DataReceivedEventHandler(_ffmpegProc_OutputDataReceived);

But how can I save this back to jpg files ?, I need to know the size of each jpg, but I cannot figure out how to do it.

Thank.

0
source share
1 answer

You cannot but read and at least partially understand the structure of the stream, because JPEG files do not contain, for example. an explicit indication of the length somewhere at the beginning of the file.

I see two possibilities that do not include transcoding:

  • store intermediate files on disk, but I assume that this is what you want to avoid.
  • - JPEG SOI (hex FF D8) EOI (hex FF D9). JPG . , , , (. JPEG ). ffmpeg mjpeg, .
+1

All Articles