init commit
This commit is contained in:
27
output/VideoReader/SaveVideo.cs
Normal file
27
output/VideoReader/SaveVideo.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using FFmpeg.AutoGen;
|
||||
|
||||
namespace VideoReader;
|
||||
|
||||
internal class SaveVideo
|
||||
{
|
||||
private unsafe AVFormatContext* pFormatContext;
|
||||
|
||||
private unsafe AVStream* st;
|
||||
|
||||
private unsafe void Write_Frame(byte[] buff, long number)
|
||||
{
|
||||
AVPacket aVPacket = default(AVPacket);
|
||||
AVPacket* ptr = &aVPacket;
|
||||
ffmpeg.av_init_packet(ptr);
|
||||
IntPtr intPtr = Marshal.AllocHGlobal(buff.Length);
|
||||
Marshal.Copy(buff, 0, intPtr, buff.Length);
|
||||
ptr->data = (sbyte*)intPtr.ToPointer();
|
||||
ptr->size = buff.Length;
|
||||
ptr->pts = ffmpeg.av_rescale_q(number, st->codec->time_base, st->time_base);
|
||||
int num = ffmpeg.av_interleaved_write_frame(pFormatContext, ptr);
|
||||
Marshal.FreeHGlobal(intPtr);
|
||||
ffmpeg.av_free_packet(ptr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user