Page 1 of 1

BRAW SDKv1.7 trim job hangs

PostPosted: Thu Jun 18, 2020 4:18 pm
by Hendrik Proosa
Hi,

I have a problem I can't seem to figure out. I want to add trim capabilities to my small video player. Win, braw sdk 1.7.

I create and submit new trim job like this:
Code: Select all
    trimCallback = new CameraCodecCallback();
    HRESULT result = S_OK;

    BSTR clipName;
    clipName = _com_util::ConvertStringToBSTR(outputFileName.toStdString().c_str());

    do {
        result = codec->SetCallback(trimCallback);
        if (result != S_OK)
        {
            break;
        }

        result = clip->CreateJobTrim(clipName, inPoint, outPoint - inPoint + 1, nullptr, nullptr, &trimJob);
        if (result != S_OK)
        {
            break;
        }

        result = trimJob->Submit();
        if (result != S_OK)
        {
            trimJob->Release();
            break;
        }

    } while(0);

Trim job is created and does not fail in any of the results. File is created and so it seems that trim is successfully triggered etc. Problem is, that created .braw file does not open, looks like it is not finalized properly. Trim job seems to never complete beause if I add
Code: Select all
codec->FlushJobs();
it never returns.

Any ideas? I'm probably missing something simple.

Do I have to create new separate decoder instance for trim process maybe..? Currently I reuse the same I create for player.

For processing settings I currently supply nullptr-s because I'm not interested in applying any specific dev settings yet (like example frame decode code does), could this be a problem?

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Fri Jun 19, 2020 11:35 am
by Hendrik Proosa
Tried the most basic trim job creation in Linux too, some observations. I am able to produce a .braw file, get trim progress printout and detect trim process complete. Application also exits normally. But created .braw file does not play in official braw player, although original, from which trim was done, plays without problems.

Adding
Code: Select all
codec->FlushJobs();
leaves application hanging and I also don't get progress printout as if it doesn't even start. My impression from docs is that it should wait until all codec jobs are processed, but seems that it disables the callback mechanism and also never returns when trim job is in processing queue. Flushing works as expected in case of frame processing jobs.

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Tue Jun 23, 2020 6:19 am
by CaptainHook
Hi, can you upload an example of one of your trimmed clips?
How are you processing the trimComplete callback?

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Tue Jun 23, 2020 8:07 am
by Hendrik Proosa
Hi, I uploaded one example trim here: https://drive.google.com/drive/folders/ ... sp=sharing

Source for it was one of the example braw files from BMD website, Rabbit_ear_clones.
I'm currently not doing anything in trimComplete callback besides printing to std::cout to see it was called. It is called and prints to cout if I don't add the flushJobs and does not get called if I do.

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Thu Jun 25, 2020 11:20 pm
by CaptainHook
Your implementation of the TrimCallback function needs to in addition to any of your own processing also release the job (job->Release()), where the job is passed in as the first argument.
Once this is in place, you can use FlushJobs() to wait for completion.

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Fri Jun 26, 2020 6:56 am
by Hendrik Proosa
Thanks for the info! So I must release the job inside trimComplete(), as I understand it? I'll add it and report back. I suspected it is something simple I'm missing.

May I ask why a trim job must be released? Why doesn't automatically release itself when trim is complete?

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Fri Jun 26, 2020 7:55 am
by Hendrik Proosa
Adding
Code: Select all
job->Release()
to trimComplete callback did the trick, thanks again!

May I suggest stating it clearly in BRAW documentation too, I looked specifically for this now and was unable to find any mention of necessity to explicitly release the trim job. From other example code I can now see that job is released when frame is processed etc but it was not obvious to add it to trim job (maybe it's just me :D). A minimal trim example would also be nice in sdk samples.

Re: BRAW SDKv1.7 trim job hangs

PostPosted: Fri Jun 26, 2020 1:05 pm
by CaptainHook
Glad it worked, noted on the feedback. We have limited resources and time so as for anyone its a case of trying to get as much done as possible and prioritize as best we can. Thanks.