大佬教程收集整理的这篇文章主要介绍了delphi – 从MemoryStream播放视频,使用FFMpeg,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
一个名为FFMpeg Vcl Player的组件声称从内存流播放视频格式.我下载了试用版,我猜这是使用CircularBuffer.pas(也许).
有谁知道如何做到这一点?
编辑:
现在更好的问题是如何使用FFMpeg或类似的库来播放加密的视频文件.
static const int kBufferSize = 4 * 1024; class my_iocontext_private { private: my_iocontext_private(my_iocontext_private const &); my_iocontext_private& operator = (my_iocontext_private const &); public: my_iocontext_private(IInputStreamPtr inputStream) : inputStream_(inputStream),buffer_size_(kBufferSizE),buffer_(static_cast<unsigned char*>(::av_malloc(buffer_size_))) { ctx_ = ::avio_alloc_context(buffer_,buffer_size_,this,&my_iocontext_private::read,NULL,&my_iocontext_private::seek); } ~my_iocontext_private() { ::av_free(ctx_); ::av_free(buffer_); } void reset_inner_context() { ctx_ = NULL; buffer_ = NULL; } static int read(void *opaque,unsigned char *buf,int buf_sizE) { my_iocontext_private* h = static_cast<my_iocontext_private*>(opaquE); return h->inputStream_->Read(buf,buf_sizE); } static int64_t seek(void *opaque,int64_t offset,int whencE) { my_iocontext_private* h = static_cast<my_iocontext_private*>(opaquE); if (0x10000 == whencE) return h->inputStream_->Size(); return h->inputStream_->Seek(offset,whencE); } ::AVIOContext *get_avio() { return ctx_; } private: IInputStreamPtr inputStream_; // abstract stream interface,You can adapt it to TMemoryStream int buffer_size_; unsigned char * buffer_; ::AVIOContext * ctx_; }; //// .......... /// prepare input stream: IInputStreamPtr inputStream = MyCustomcatreateInputStreamFromMemory(); my_iocontext_private priv_ctx(inputStream); AVFormatContext * ctx = ::avformat_alloc_context(); ctx->pb = priv_ctx.get_avio(); int err = avformat_open_input(&ctx,"arbitrarytext",null); if (err < 0) return -1; //// normal usage of ctx //// avformat_find_stream_info(ctx,null); //// av_read_frame(ctx,&pkt); //// etc..
以上是大佬教程为你收集整理的delphi – 从MemoryStream播放视频,使用FFMpeg全部内容,希望文章能够帮你解决delphi – 从MemoryStream播放视频,使用FFMpeg所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。