• 大小: 25.46MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-16
  • 语言: C#
  • 标签: C#  FFMPEG  

资源简介

C#开发FFMPEG例子(API方式) FFmpeg拉取RTMP流并播放原始源码

资源截图

代码片段和文件信息

using System;
using System.IO;
using System.Runtime.InteropServices;

namespace FFmpegDemo
{
    public class FFmpegBinariesHelper
    {
        private const string LD_LIBRARY_PATH = “LD_LIBRARY_PATH“;

        internal static void RegisterFFmpegBinaries()
        {
            switch (Environment.OSVersion.Platform)
            {
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                    var current = Environment.CurrentDirectory;
                    var probe = $“FFmpeg/bin/{(Environment.Is64BitProcess ? @“x64“ : @“x86“)}“;
                    while (current != null)
                    {
                        var ffmpegDirectory = Path.Combine(current probe);
                        if (Directory.Exists(ffmpegDirectory))
                        {
                            Console.WriteLine($“FFmpeg binaries found in: {ffmpegDirectory}“);
                            RegisterLibrariesSearchPath(ffmpegDirectory);
                            return;
                        }
                        current = Directory.GetParent(current)?.FullName;
                    }
                    break;
                case PlatformID.Unix:
                case PlatformID.MacOSX:
                    var libraryPath = Environment.GetEnvironmentVariable(LD_LIBRARY_PATH);
                    RegisterLibrariesSearchPath(libraryPath);
                    break;
            }
        }
        private static void RegisterLibrariesSearchPath(string path)
        {
            switch (Environment.OSVersion.Platform)
            {
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                    SetDllDirectory(path);
                    break;
                case PlatformID.Unix:
                case PlatformID.MacOSX:
                    string currentValue = Environment.GetEnvironmentVariable(LD_LIBRARY_PATH);
                    if (string.IsNullOrWhiteSpace(currentValue) == false && currentValue.Contains(path) == false)
                    {
                        string newValue = currentValue + Path.PathSeparator + path;
                        Environment.SetEnvironmentVariable(LD_LIBRARY_PATH newValue);
                    }
                    break;
            }
        }
        
        [DllImport(“kernel32“ SetLastError = true)]
        private static extern bool SetDllDirectory(string lpPathName);
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        187  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\App.config

     文件   25478656  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\avcodec-57.dll

     文件    1433088  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\avdevice-57.dll

     文件    6795776  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\avfilter-6.dll

     文件    3971584  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\avformat-57.dll

     文件     687104  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\avutil-55.dll

     文件     126464  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\postproc-54.dll

     文件     377344  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\swresample-2.dll

     文件     528896  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x64\swscale-4.dll

     文件   22285824  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\avcodec-57.dll

     文件    1208320  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\avdevice-57.dll

     文件    6437376  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\avfilter-6.dll

     文件    3991552  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\avformat-57.dll

     文件     693248  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\avutil-55.dll

     文件     297984  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\ffmpeg.exe

     文件     147968  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\ffplay.exe

     文件     162816  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\ffprobe.exe

     文件     116224  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\postproc-54.dll

     文件     324096  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\swresample-2.dll

     文件     504320  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\bin\x86\swscale-4.dll

     文件     217771  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\avcodec.h

     文件       2570  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\avdct.h

     文件       3111  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\avfft.h

     文件       2853  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\d3d11va.h

     文件       4044  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\dirac.h

     文件       3715  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\dv_profile.h

     文件       2361  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\dxva2.h

     文件       1650  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\jni.h

     文件       2825  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\mediacodec.h

     文件       3763  2019-04-15 09:34  FFmpegDemo\FFmpegDemo\bin\FFmpeg\include\libavcodec\qsv.h

............此处省略137个文件信息

评论

共有 条评论