but I also wanted to get the opinion of you guys over here.
I have a feature in my application that captures the screen in realtime and writes it out to a WebM file using the VP8 codec. I was never able to get the cues and seek elements quite right and was able to use the
mkclean tool to get those elements setup correctly.
I am now recording to VP9. Most of my code works fine for VP9 and I'm getting a valid file (checked by mkvalidator) however it does not seek correctly. I attempted to use mkclean again to fix this however it does not accept VP9 encoded files. As such when I attempt to seek within the file VLC, Chrome and Firefox they fail to seek correctly.
I have been using the example code from libvpx in the file
webmenc.cc to create the WebM file. It looks like it creates a seek element and then puts the cues element at the end. I added one line in the `write_webm_file_header` to ensure that the cues are added to the correct track
segment->CuesTrack(video_track_id);. I added to the
write_webm_file_footer function to move the cues element to the front of the file.
void write_webm_file_footer(struct EbmlGlobal *glob, const std::string& filename, const std::string& tempFilename)
{
mkvmuxer::MkvWriter *const writer =
reinterpret_cast<mkvmuxer::MkvWriter*>(glob->writer);
mkvmuxer::Segment *const segment =
reinterpret_cast<mkvmuxer::Segment*>(glob->segment);
segment->Finalize();
writer->Close();
fclose(glob->stream);
FILE* recordedFile;
const errno_t e_orig = fopen_s(&recordedFile, filename.c_str(), "rb+");
if (e_orig)
{
printf("\n Filename is invalid or error while opening <%s>.\n", filename.c_str());
return;// EXIT_FAILURE;
}
mkvparser::MkvReader* reader = new mkvparser::MkvReader(recordedFile);
FILE* tempFilePointer;
const errno_t e_temp = fopen_s(&tempFilePointer, tempFilename.c_str(), "wb+");
if (e_temp)
{
printf("\n Filename is invalid or error while opening <%s>.\n", tempFilename.c_str());
return;// EXIT_FAILURE;
}
mkvmuxer::MkvWriter *tempWriter = new mkvmuxer::MkvWriter(tempFilePointer);
if (!segment->CopyAndMoveCuesBeforeClusters(reader, tempWriter)) {
printf("\n Unable to copy and move cues before clusters.\n");
return;// EXIT_FAILURE;
}
reader->Close();
fclose(recordedFile);
delete reader;
tempWriter->Close();
fclose(tempFilePointer);
delete tempWriter;
delete segment;
delete writer;
glob->writer = NULL;
glob->segment = NULL;
}
After this I have some code to remove the original file and then replace it with the temp file. I have tried calling `AddCuePoint` each time I put in a keyframe but that hasn't seemed to help. What am I missing?
I am working in Visual Studio 2013 on Windows 10 (although this application will be used on Windows 7 and up). I am using
libvpx 1.5.0 (from the github tag) and
libwebm 1.0.0.27 (also from the github tag).