Skip to content

Commit

Permalink
Merge pull request #32 from darbyjohnston/refactor7
Browse files Browse the repository at this point in the history
Improve error handling
  • Loading branch information
darbyjohnston authored Dec 10, 2024
2 parents 42247cb + ebd39a8 commit 83d632a
Show file tree
Hide file tree
Showing 17 changed files with 518 additions and 238 deletions.
4 changes: 2 additions & 2 deletions data/Filter.otio
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"OTIO_SCHEMA": "Effect.1",
"effect_name": "toucan:Blur",
"metadata": {
"radius": 50.0
"radius": 10.0
}
}
],
Expand Down Expand Up @@ -245,7 +245,7 @@
"effect_name": "toucan:UnsharpMask",
"metadata": {
"kernel": "gaussian",
"width": 50.0,
"width": 10.0,
"contrast": 1.0,
"threshold": 0.0
}
Expand Down
52 changes: 52 additions & 0 deletions data/MissingMedia.otio
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"OTIO_SCHEMA": "Timeline.1",
"metadata": {},
"name": "Gap",
"tracks": {
"OTIO_SCHEMA": "Stack.1",
"children": [
{
"OTIO_SCHEMA": "Track.1",
"children": [
{
"OTIO_SCHEMA": "Clip.1",
"media_reference": {
"OTIO_SCHEMA": "ExternalReference.1",
"available_range": {
"OTIO_SCHEMA": "TimeRange.1",
"duration": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 3
},
"start_time": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 0
}
},
"target_url": "Letter_None.png"
},
"source_range": {
"OTIO_SCHEMA": "TimeRange.1",
"duration": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 3
},
"start_time": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 0
}
},
"name": "Letter_None"
}
],
"kind": "Video",
"name": "Video"
}
],
"name": "Stack"
}
}
86 changes: 86 additions & 0 deletions data/MissingMedia2.otio
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"OTIO_SCHEMA": "Timeline.1",
"metadata": {},
"name": "Gap",
"tracks": {
"OTIO_SCHEMA": "Stack.1",
"children": [
{
"OTIO_SCHEMA": "Track.1",
"children": [
{
"OTIO_SCHEMA": "Clip.1",
"media_reference": {
"OTIO_SCHEMA": "ExternalReference.1",
"available_range": {
"OTIO_SCHEMA": "TimeRange.1",
"duration": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 3
},
"start_time": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 0
}
},
"target_url": "Letter_A.png"
},
"source_range": {
"OTIO_SCHEMA": "TimeRange.1",
"duration": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 3
},
"start_time": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 0
}
},
"name": "Letter_A"
},
{
"OTIO_SCHEMA": "Clip.1",
"media_reference": {
"OTIO_SCHEMA": "ExternalReference.1",
"available_range": {
"OTIO_SCHEMA": "TimeRange.1",
"duration": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 3
},
"start_time": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 0
}
},
"target_url": "Letter_None.png"
},
"source_range": {
"OTIO_SCHEMA": "TimeRange.1",
"duration": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 3
},
"start_time": {
"OTIO_SCHEMA": "RationalTime.1",
"rate": 24,
"value": 0
}
},
"name": "Letter_None"
}
],
"kind": "Video",
"name": "Video"
}
],
"name": "Stack"
}
}
2 changes: 1 addition & 1 deletion lib/toucan/FFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace toucan

std::vector<std::string> getVideoExtensions()
{
return std::vector<std::string>({ ".mov", ".mp4", ".m4v" });
return std::vector<std::string>({ ".mov", ".mp4", ".m4v", ".y4m" });
}

bool hasVideoExtension(const std::string& value)
Expand Down
29 changes: 27 additions & 2 deletions lib/toucan/FFmpegWrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "Util.h"

#include <OpenImageIO/imagebufalgo.h>

#include <iostream>
#include <sstream>

Expand Down Expand Up @@ -173,7 +175,30 @@ namespace toucan

void Write::writeImage(const OIIO::ImageBuf& buf, const OTIO_NS::RationalTime& time)
{
const auto& spec = buf.spec();
auto spec = buf.spec();
const OIIO::ImageBuf* bufP = &buf;
OIIO::ImageBuf tmp;
switch (spec.format.basetype)
{
case OIIO::TypeDesc::INT8:
spec.format.basetype = OIIO::TypeDesc::UINT8;
break;
case OIIO::TypeDesc::INT16:
case OIIO::TypeDesc::UINT32:
case OIIO::TypeDesc::INT32:
case OIIO::TypeDesc::UINT64:
case OIIO::TypeDesc::INT64:
case OIIO::TypeDesc::HALF:
case OIIO::TypeDesc::FLOAT:
spec.format.basetype = OIIO::TypeDesc::UINT16;
break;
}
if (buf.spec().format.basetype != spec.format.basetype)
{
tmp = OIIO::ImageBufAlgo::copy(buf, spec.format);
bufP = &tmp;
}

AVPixelFormat avPixelFormatIn = AV_PIX_FMT_NONE;
switch (spec.nchannels)
{
Expand Down Expand Up @@ -251,7 +276,7 @@ namespace toucan
av_image_fill_arrays(
_avFrame2->data,
_avFrame2->linesize,
reinterpret_cast<const uint8_t*>(buf.localpixels()),
reinterpret_cast<const uint8_t*>(bufP->localpixels()),
_avPixelFormatIn,
spec.width,
spec.height,
Expand Down
Loading

0 comments on commit 83d632a

Please sign in to comment.