德阳百度网站建设,谷歌优化师,网页美工工资水平,网站备案期间可以用二级域名访问网站吗除了网络、文件io#xff0c;由python或java或go或c等语言开启的ffmpeg子进程还支持pipe#xff0c;可以从stdin读入数据#xff0c;输出转化后的图像到stdout。无需编译 ffmpeg#xff0c;直接调用 ffmpeg.exe不香么#xff01; 
“从内存读”可用于边下载边转码#xf…除了网络、文件io由python或java或go或c等语言开启的ffmpeg子进程还支持pipe可以从stdin读入数据输出转化后的图像到stdout。无需编译 ffmpeg直接调用 ffmpeg.exe不香么 
“从内存读”可用于边下载边转码节省硬盘寿命。 
“提取到内存”可用于服务端生成缩小的预览图然后发给客户端传输较快。 
从内存读数据流 注意事项 
对格式有要求不能是需要随机读取的文件比如不能是 MP4可以是 flv。 
参考资料 1go - ffmpeg via pipe: stream 1, offset 0x30: partial file - Stack Overflow 
参考资料 2command line - FFmpeg “Pipe:0: Invalid data found when processing input” TGA files - Super User 
ffmpeg_subprocess.py 代码示例 
import subprocessprint(123)# Assuming you have the buffer stored in a variable called bufferffmpegexe  rffmpeg.exe# Invoke FFmpeg and pass the buffer as input using the pipe protocol
process  subprocess.Popen([ffmpegexe# , -loglevel, quiet# , -f, ts, -f, flv, -i, pipe:0, -c, copy, -y, E:\\test_output.flv], stdinsubprocess.PIPE)path  E:\\test.flv
length  0
# Read from the file path in a while loop, 1024 bytes per loop, and write the buffer to process.stdin
with open(path, rb) as file:while True:buffer  file.read(1024)if not buffer:breaksize  len(buffer)print(read::, size)length  sizeprocess.stdin.write(buffer)process.stdin.flush()print(readed all::, length)# Close the stdin to indicate the end of input
process.stdin.close()# Wait for the FFmpeg process to finish
process.wait()结果是while一边读取flv视频流ffmpeg一边转换。 
输出图像至内存 
比如用于为视频生成缩略图不用产生临时文件比较干净 
\生成视频、图片缩略图的办法 
别老抱着es不放了视频、图片缩略图可以都用 ffmpeg 生成有多种办法实现可移植到windows平台。 
方法一、将 lib_ffmpeg 集成到客户端从网络生成缩略图 
这种方法需要编译支持ftp协议的 ffmpeg然后自行适配各个平台需要解决各种问题开发效率低下而且一旦处理不好会导致jni崩溃。 
结果是传输慢、消耗流量多。 
方法二、魔改ftp服务端调用 ffmpeg.exe 生成缩略图直接返回图片 
无需编译 ffmpeg直接调用 ffmpeg.exe。 
由服务端生成缩小的预览图然后发给ftp客户端传输较快。 
而且得益于 ffmpeg 丰富的命令配置可以自定义缩小的尺寸(-vf scale100:100)、无需生成临时文件PIPE等等。 
ftp服务端 客户端 我用的都是 appache ftpserver并加以扩展。 
新增 服务端缩略图生成能力 
新增 支持目录链接lnk可用一个账号管理全部磁盘 高维文件管理器