Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg 生成缩略图忧化 #1817

Open
zephyrgeek opened this issue Aug 14, 2023 · 1 comment · May be fixed by #1818
Open

ffmpeg 生成缩略图忧化 #1817

zephyrgeek opened this issue Aug 14, 2023 · 1 comment · May be fixed by #1818

Comments

@zephyrgeek
Copy link

ffmpeg -i 参数支持url

原流程:非本机存储需要先下载完整视频文件到cloudreve服务端 存储到临时目录 再获取缩略图
忧化后:直接读取视频url元数据后 获取缩略图(不需要读取视频整个文件,文件存储端 需要支持range)
ffmpegOpts["thumb_ffmpeg_path"], "-ss", ffmpegOpts["thumb_ffmpeg_seek"], "-i", tempInputPath, "-vf", scaleOpt, "-vframes", "1", tempOutputPath)
ffmpeg命令行执行代码中,只需要 tempInputPath 换成 视频URL地址,不需要变更/增加其它参数

6372984 -rwxr--r-- 1 root root 6525927788 Aug 14 00:33 AiwonviV_test.mp4
一个6G 的文件 只需要3s即可获取到视频第一帧,改成url网络地址后 ,文件大小限制可以不受 cloudreve磁盘大小影响(最大原始文件1GB的限制),也节省了中转到cr服务端的视频文件流量

` Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 2023-01-01T03:30:57.000000Z
encoder : Lavf59.34.101
Duration: 04:23:48.75, start: 0.000000, bitrate: 3298 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 3101 kb/s, 24.83 fps, 25 tbr, 90k tbn, 50 tbc (default)
Metadata:
creation_time : 2023-01-01T03:30:57.000000Z
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 188 kb/s (default)
Metadata:
creation_time : 2023-01-01T03:30:57.000000Z
handler_name : SoundHandler
Stream #0:2: Video: png, pal8(pc), 250x100, 90k tbr, 90k tbn, 90k tbc (attached pic)
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> mjpeg (native))
Press [q] to stop, [?] for help
[swscaler @ 0x555f4991f680] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to 'output_frame.jpg':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0(und): Video: mjpeg, yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc (default)
Metadata:
creation_time : 2023-01-01T03:30:57.000000Z
handler_name : VideoHandler
encoder : Lavc58.91.100 mjpeg
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame= 1 fps=0.0 q=5.4 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.0936x
video:65kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

real 0m3.499s
user 0m0.776s
sys 0m0.135s`

@01101sam
Copy link
Contributor

既然有人发现了,那我就勉强的开个PR给出代码吧

@01101sam 01101sam linked a pull request Aug 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants