Skip to content

Commit

Permalink
Prepare v3 (#24)
Browse files Browse the repository at this point in the history
* Better not leak memory there

* Update `FFmpeg.AutoGen`

* Update `PixelFormat`

* Update Readme
  • Loading branch information
Speykious authored Feb 19, 2022
1 parent e4228a2 commit 1f12d67
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 31 deletions.
15 changes: 8 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
# SeeShark

> Simple C# camera library.
> Simple C# camera and display library.
[![Discord](https://img.shields.io/discord/871618277258960896?color=7289DA&label=%20&logo=discord&logoColor=white)](https://discord.gg/Tz96ZdKjSA) ![NuGet](https://img.shields.io/nuget/v/SeeShark)

When you SeeShark, you C#!

SeeShark is a simple cross-platform .NET library for handling camera inputs on Linux, Windows and MacOS.
SeeShark is a simple cross-platform .NET library for handling camera and screen display inputs on Linux, Windows and MacOS.

Using FFmpeg, it allows you to enumerate camera devices and decode raw frames in 199 different pixel formats (because that's how powerful FFmpeg is!).

Features include:
- Zero-copy.
- Memory-safe.
- Cross platform (Tested on Windows and Linux, might work on more platforms like MacOS).
- Managing camera devices.
- Managing camera and display devices.
- Control framerate, resolution and input format.
- Notifies the application if devices get connected/disconnected.
- Event-driven code flow.
- Supports 199 different pixel formats.
- Provides synchronous (method-driven) and asynchronous (event-driven) code flow.
- Supports 206 different pixel formats.
- Conversion of a frame from a pixel format to another.
- Scaling frames.
- Access to raw pixel data.

Features **don't** include:
- Saving a frame as an image (here's a [wiki page on how to do it](https://github.com/vignetteapp/SeeShark/wiki/Saving-images) using ImageSharp).
- Recording a camera stream to a video file.
- Manage audio devices.
- Recording a video stream to a video file.
- Managing audio devices.

***

Expand Down
2 changes: 1 addition & 1 deletion SeeShark.Example.Ascii/SeeShark.Example.Ascii.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FFmpeg.AutoGen" Version="4.4.1" />
<PackageReference Include="FFmpeg.AutoGen" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions SeeShark/Decode/VideoStreamDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public VideoStreamDecoder(string url, AVInputFormat* inputFormat = null, IDictio
}

ffmpeg.avformat_open_input(&formatContext, url, inputFormat, &dict).ThrowExceptionIfError();
ffmpeg.av_dict_free(&dict);

AVCodec* codec = null;
StreamIndex = ffmpeg
Expand Down
70 changes: 48 additions & 22 deletions SeeShark/PixelFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ public enum PixelFormat : int
/// planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P
/// and setting color_range
/// </summary>
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV420P")]
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV420P and setting color_range")]
Yuvj420P = AVPixelFormat.AV_PIX_FMT_YUVJ420P,
/// <summary>
/// planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P
/// and setting color_range
/// </summary>
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV422P")]
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV422P and setting color_range")]
Yuvj422P = AVPixelFormat.AV_PIX_FMT_YUVJ422P,
/// <summary>
/// planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P
/// and setting color_range
/// </summary>
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV444P")]
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV444P and setting color_range")]
Yuvj444P = AVPixelFormat.AV_PIX_FMT_YUVJ444P,
/// <summary>
/// packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Expand Down Expand Up @@ -159,7 +159,7 @@ public enum PixelFormat : int
/// planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P
/// and setting color_range
/// </summary>
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV440P")]
[Obsolete("Deprecated in favor of AV_PIX_FMT_YUV440P and setting color range")]
Yuvj440P = AVPixelFormat.AV_PIX_FMT_YUVJ440P,
/// <summary>
/// planar YUV 4:2:0, 20bpp, (1 Cr &#38; Cb sample per 2x2 Y &#38; A samples)
Expand Down Expand Up @@ -208,22 +208,7 @@ public enum PixelFormat : int
/// </summary>
Bgr555Le = AVPixelFormat.AV_PIX_FMT_BGR555LE,
/// <summary>
/// HW acceleration through VA API at motion compensation entry-point, Picture.data[3]
/// contains a vaapi_render_state struct which contains macroblocks as well as various
/// fields extracted from headers
/// </summary>
VaapiMoco = AVPixelFormat.AV_PIX_FMT_VAAPI_MOCO,
/// <summary>
/// HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains
/// a vaapi_render_state struct which contains fields extracted from headers
/// </summary>
VaapiIdct = AVPixelFormat.AV_PIX_FMT_VAAPI_IDCT,
/// <summary>
/// HW decoding through VA API, Picture.data[3] contains a VASurfaceID
/// </summary>
VaapiVld = AVPixelFormat.AV_PIX_FMT_VAAPI_VLD,
/// <summary>
/// alias for VaapiVld
/// Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
/// </summary>
Vaapi = AVPixelFormat.AV_PIX_FMT_VAAPI,
/// <summary>
Expand Down Expand Up @@ -345,6 +330,7 @@ public enum PixelFormat : int
/// </summary>
Gbrp = AVPixelFormat.AV_PIX_FMT_GBRP,
/// <summary>
/// alias for GBRP
/// </summary>
Gbr24P = AVPixelFormat.AV_PIX_FMT_GBR24P,
/// <summary>
Expand Down Expand Up @@ -544,7 +530,7 @@ public enum PixelFormat : int
/// <summary>
/// packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
/// </summary>
ZeroRgb = AVPixelFormat.AV_PIX_FMT_0RGB,
Xrgb = AVPixelFormat.AV_PIX_FMT_0RGB,
/// <summary>
/// packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
/// </summary>
Expand Down Expand Up @@ -859,10 +845,50 @@ public enum PixelFormat : int
/// </summary>
X2Rgb10Be = AVPixelFormat.AV_PIX_FMT_X2RGB10BE,
/// <summary>
/// packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined
/// </summary>
X2Bgr10Le = AVPixelFormat.AV_PIX_FMT_X2BGR10LE,
/// <summary>
/// packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), big-endian, X=unused/undefined
/// </summary>
X2Bgr10Be = AVPixelFormat.AV_PIX_FMT_X2BGR10BE,
/// <summary>
/// interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, big-endian
/// </summary>
P210Be = AVPixelFormat.AV_PIX_FMT_P210BE,
/// <summary>
/// interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, little-endian
/// </summary>
P210Le = AVPixelFormat.AV_PIX_FMT_P210LE,
/// <summary>
/// interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, big-endian
/// </summary>
P410Be = AVPixelFormat.AV_PIX_FMT_P410BE,
/// <summary>
/// interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, little-endian
/// </summary>
P410Le = AVPixelFormat.AV_PIX_FMT_P410LE,
/// <summary>
/// interleaved chroma YUV 4:2:2, 32bpp, big-endian
/// </summary>
P216Be = AVPixelFormat.AV_PIX_FMT_P216BE,
/// <summary>
/// interleaved chroma YUV 4:2:2, 32bpp, liddle-endian
/// </summary>
P216Le = AVPixelFormat.AV_PIX_FMT_P216LE,
/// <summary>
/// interleaved chroma YUV 4:4:4, 48bpp, big-endian
/// </summary>
P416Be = AVPixelFormat.AV_PIX_FMT_P416BE,
/// <summary>
/// interleaved chroma YUV 4:4:4, 48bpp, little-endian
/// </summary>
P416Le = AVPixelFormat.AV_PIX_FMT_P416LE,
/// <summary>
/// number of pixel formats, DO NOT USE THIS if you want to link with shared libav*
/// because the number of formats might differ between versions
/// </summary>
AvPixFmtNb = AVPixelFormat.AV_PIX_FMT_NB
Nb = AVPixelFormat.AV_PIX_FMT_NB
}

public static class PixelFormatExtensions
Expand Down
2 changes: 1 addition & 1 deletion SeeShark/SeeShark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<ItemGroup Label="Package References">
<PackageReference Include="DirectShowLib.Standard" Version="2.1.0" />
<PackageReference Include="FFmpeg.AutoGen" Version="4.4.1" />
<PackageReference Include="FFmpeg.AutoGen" Version="5.0.0" />
</ItemGroup>

<ItemGroup Label="Documents">
Expand Down

0 comments on commit 1f12d67

Please sign in to comment.