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

某个 mp4 生成缩略图失败 #64

Closed
nanpuyue opened this issue Sep 1, 2021 · 6 comments
Closed

某个 mp4 生成缩略图失败 #64

nanpuyue opened this issue Sep 1, 2021 · 6 comments
Assignees

Comments

@nanpuyue
Copy link
Contributor

nanpuyue commented Sep 1, 2021

video.mp4

下载这个 mp4,替换 tests/assets/vids/bear.mp4,然后执行 thumbnail 测试:

wget https://user-images.githubusercontent.com/1524609/131678290-c6b90aee-d018-4078-99b4-45cc410bd67b.mp4 -O video.mp4
cp video.mp4 tests/assets/vids/bear.mp4
cargo test --test thumbnail

会得到如下错误:

    Finished test [unoptimized + debuginfo] target(s) in 0.04s
     Running tests/thumbnail.rs (target/debug/deps/thumbnail-fb8cd98fade3377b)

running 1 test
test thumbnail_test ... FAILED

failures:

---- thumbnail_test stdout ----
thread 'thumbnail_test' panicked at 'called `Result::unwrap()` on an `Err` value: Cannnot find video cover packet', tests/thumbnail.rs:132:6
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    thumbnail_test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--test thumbnail'
@nanpuyue
Copy link
Contributor Author

nanpuyue commented Sep 1, 2021

但是直接使用 ffmpeg 命令是可以的:

ffmpeg -i video.mp4 -frames:v 1 1.png

@nanpuyue nanpuyue changed the title 某个 mp4生成缩略图 某个 mp4 生成缩略图失败 Sep 1, 2021
@nanpuyue
Copy link
Contributor Author

nanpuyue commented Sep 1, 2021

糊了一个 telegram bot 用来设置群头像,之前用的 opencv,想用 ffmpeg 代替 opencv,糊好了发现有个文件不能生成图片,这也太惨了。
https://github.com/nanpuyue/avatar-bot

@ldm0 ldm0 self-assigned this Sep 1, 2021
@ldm0
Copy link
Member

ldm0 commented Sep 1, 2021

惨,原因是当时写测试的时候没有想到超短视频。
image
改成这样这样就可以了。拿不到新packet的时候向解码 context 发送一下None 用以 flush,那个图片就能出来了。

@nanpuyue
Copy link
Contributor Author

nanpuyue commented Sep 1, 2021

Wow,谢谢!

@nanpuyue
Copy link
Contributor Author

nanpuyue commented Sep 1, 2021

顺便在隔壁 pr 提交了修复。
#65

@ldm0
Copy link
Member

ldm0 commented Sep 1, 2021

Closed by #65

@ldm0 ldm0 closed this as completed Sep 1, 2021
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

No branches or pull requests

2 participants