Home > Archive (Community help, from old helpdesk) > SeparateCapture_ChangeFilenameOnTheFly does not work in the trial version?

SeparateCapture_ChangeFilenameOnTheFly does not work in the trial version?

Avatar image
Aug 24, 2015
Archive Agent wrote
I am trying to assemble a simple video capture sample into short MPEG2TS chunks (Capture device -> *.ts chunk) using FFMPEG as the encoder.

It seems that SeparateCapture_ChangeFilenameOnTheFly() method call does not change the output file - the component keeps writing to the original file which was first opened.

Any help would be appreciated - here's the source code I've been able to assemble at this point (.NET 4.0 console application, 32bit):

private static void TestVideoCapture()
{
string outputFolder = @"c:\local\temp\output";

VideoCapture capture = new VideoCapture();

capture.Video_CaptureDevice = capture.Video_CaptureDevices[0];
capture.Video_CaptureFormat_UseBest = true;

capture.Audio_CaptureDevice = capture.Audio_CaptureDevices[0];
capture.Audio_CaptureFormat_UseBest = true;

capture.Video_Renderer = VFVideoRenderer.None; // No renderer

capture.Mode = VFVideoCaptureMode.VideoCapture;

capture.Output_Format = VFVideoCaptureOutputFormat.FFMPEG;

capture.SeparateCapture_AutostartCapture = false;
capture.SeparateCapture_Mode = VFSeparateCaptureMode.Normal;
capture.SeparateCapture_Enabled = true;

capture.FFMPEG_OutputFormat = VFFFMPEGOutputFormat.MPEG2TS;
capture.FFMPEG_TVSystem = VFFFMPEGTVSystem.Film;

capture.FFMPEG_VideoBitrate = 1500000;
capture.FFMPEG_VideoWidth = 640;
capture.FFMPEG_VideoHeight = 360;
capture.FFMPEG_Interlace = false;
capture.Video_FrameRate = 25;

capture.FFMPEG_AudioBitrate = 128000;
capture.FFMPEG_AudioChannels = 2;
capture.FFMPEG_AudioSampleRate = 44100;

string fileName = Path.Combine(outputFolder, GetOutputFileName(DateTime.Now));

capture.Output_Filename = fileName;

capture.Start();

Console.WriteLine("Started capture.");

if (capture.SeparateCapture_Start())
{
Console.WriteLine("Start capture to: {0}", fileName);

while (true)
{
Thread.Sleep(5000);

fileName = Path.Combine(outputFolder, GetOutputFileName(DateTime.Now));

if (capture.SeparateCapture_ChangeFilenameOnTheFly(fileName))
{
Console.WriteLine("Changed output file to: {0}", fileName);
}
else
{
Console.WriteLine("Failed chaning output file.");
}
}
}
}

private static string GetOutputFileName(DateTime now)
{
return string.Format("{0}.ts", now.ToString("yyyy-MM-dd_HHmmss"));
}

Ilya Jazz Melamed on May 22, 2014 5:41 PM
Completed
0
Vote
Reply
5 Answers
Aug 24, 2015
Archive Agent agent wrote
Roman Minyaylov

SDK can work in service application or GUI application, not console application. Some limitations present, file splitting (separate capture) doesn't worked normally in console.

So, use service please or made GUI application with hidden window.

on May 22, 2014 17:50
Aug 24, 2015
Archive Agent agent wrote
Ilya Jazz Melamed

Hi Roman,

Thanks for the tip! I figured it has something to do with the thread's message loop, so I tried calling Application.DoEvents() and it actually resolved the issue :)

Regards,
Ilya

on May 25, 2014 11:02
Aug 24, 2015
Archive Agent agent wrote
Roman Minyaylov

Really? Can you show us full code? Because we unable to made this workaround on our side.

on May 25, 2014 11:06
Aug 24, 2015
Archive Agent agent wrote
Ilya Jazz Melamed

Sure, just replace Thread.Sleep(5000); above with this:

for (int i = 0; i < 5000 / 100; ++i)
{
Application.DoEvents();

Thread.Sleep(100);
}

I figured several DoEvents() calls should be made.

I recall Windows Media Encoder SDK had the same issue 10 years ago.

on May 25, 2014 11:41
Aug 24, 2015
Archive Agent agent wrote
Roman Minyaylov

Thank you!

on May 25, 2014 15:54