Skip to content
Snippets Groups Projects

Resolves #343 GUI and Frame Refactor

Merged Nicolas Pope requested to merge feature/gui2 into master
Compare and Show latest version
10 files
+ 91
108
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -17,7 +17,7 @@ extern "C" {
using ftl::codecs::codec_t;
using ftl::codecs::Channel;
static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet &pkt)
static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet &pkt, const ftl::rgbd::Camera &cam)
{
//AVCodecContext *c;
AVStream *st;
@@ -47,9 +47,9 @@ static AVStream *add_video_stream(AVFormatContext *oc, const ftl::codecs::Packet
//st->nb_frames = 0;
st->codecpar->codec_id = codec_id;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->width = ftl::codecs::getWidth(pkt.definition);
st->codecpar->width = cam.width; //ftl::codecs::getWidth(pkt.definition);
//if (pkt.flags & ftl::codecs::kFlagStereo) st->codecpar->width *= 2;
st->codecpar->height = ftl::codecs::getHeight(pkt.definition);
st->codecpar->height = cam.height; //ftl::codecs::getHeight(pkt.definition);
st->codecpar->format = AV_PIX_FMT_NV12;
st->codecpar->bit_rate = 4000000;
@@ -111,6 +111,7 @@ int main(int argc, char **argv) {
AVFormatContext *oc;
AVStream *video_st[10][2] = {nullptr};
// TODO: Remove in newer versions
av_register_all();
fmt = av_guess_format(NULL, outputfile.c_str(), NULL);
@@ -127,7 +128,11 @@ int main(int argc, char **argv) {
return -1;
}
oc->oformat = fmt;
// TODO: Use URL in newer versions
snprintf(oc->filename, sizeof(oc->filename), "%s", outputfile.c_str());
//oc->url = (char*)av_malloc(outputfile.size()+1);
//snprintf(oc->url, outputfile.size()+1, "%s", outputfile.c_str());
/* open the output file, if needed */
if (!(fmt->flags & AVFMT_NOFILE)) {
@@ -149,6 +154,11 @@ int main(int argc, char **argv) {
// TODO: In future, find a better way to discover number of streams...
// Read entire file to find all streams before reading again to write data
bool res = r.read(90000000000000, [&first_ts,&current_stream,&current_channel,&r,&video_st,oc](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) {
// Extract calibration information to determine frame resolution
if (spkt.channel == ftl::codecs::Channel::Calibration) {
// FIXME: Implement this!!
}
if (spkt.channel != static_cast<ftl::codecs::Channel>(current_channel) && current_channel != -1) return;
if (spkt.frame_number == current_stream || current_stream == 255) {
@@ -161,7 +171,7 @@ int main(int argc, char **argv) {
if (spkt.timestamp < first_ts) first_ts = spkt.timestamp;
if (video_st[spkt.frame_number][(spkt.channel == Channel::Left) ? 0 : 1] == nullptr) {
video_st[spkt.frame_number][(spkt.channel == Channel::Left) ? 0 : 1] = add_video_stream(oc, pkt);
video_st[spkt.frame_number][(spkt.channel == Channel::Left) ? 0 : 1] = add_video_stream(oc, pkt, {0}); // FIXME: Use real calib data
}
}
});
Loading