GHC 2020-08-02

7 comments.

, https://git.io/JJw3v in zmwangx/rust-ffmpeg
You're right. So I generated this simple gif at 10 fps looping from 1 to 10 using ImageMagick:

![input](https://user-images.githubusercontent.com/4149852/89126382-d738a800-d517-11ea-9524-2f87ac8cf75c.gif)

Using FFmpeg on the command line:

```console
$ ffmpeg -y -i input.gif -filter:v fps=fps=25.0,format=bgr8 output.gif
```

we get a gif with 25 frames:

```console
$ identify output.gif
output.gif[0] GIF 100x50 100x50+0+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[1] GIF 23x36 100x50+38+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[2] GIF 22x35 100x50+39+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[3] GIF 24x37 100x50+37+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[4] GIF 22x37 100x50+39+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[5] GIF 25x38 100x50+36+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[6] GIF 22x38 100x50+39+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[7] GIF 5x5 100x50+55+5 8-bit sRGB 256c 0.000u 0:00.001
output.gif[8] GIF 26x38 100x50+36+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[9] GIF 17x34 100x50+45+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[10] GIF 25x37 100x50+37+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[11] GIF 22x37 100x50+40+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[12] GIF 1x4 100x50+57+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[13] GIF 25x38 100x50+37+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[14] GIF 18x37 100x50+42+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[15] GIF 25x38 100x50+37+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[16] GIF 23x36 100x50+39+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[17] GIF 1x1 100x50+99+49 8-bit sRGB 256c 0.000u 0:00.001
output.gif[18] GIF 24x38 100x50+38+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[19] GIF 22x37 100x50+39+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[20] GIF 23x38 100x50+38+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[21] GIF 20x21 100x50+41+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[22] GIF 3x10 100x50+58+8 8-bit sRGB 256c 0.000u 0:00.001
output.gif[23] GIF 58x38 100x50+21+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[24] GIF 55x37 100x50+24+1 8-bit sRGB 256c 5962B 0.000u 0:00.001
```

Using your sample program, on the other hand, we get a gif with 22 frames:

```console
$ identify output.gif
output.gif[0] GIF 100x50 100x50+0+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[1] GIF 23x36 100x50+38+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[2] GIF 22x35 100x50+39+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[3] GIF 24x37 100x50+37+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[4] GIF 22x37 100x50+39+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[5] GIF 25x38 100x50+36+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[6] GIF 22x38 100x50+39+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[7] GIF 5x5 100x50+55+5 8-bit sRGB 256c 0.000u 0:00.001
output.gif[8] GIF 26x38 100x50+36+0 8-bit sRGB 256c 0.000u 0:00.001
output.gif[9] GIF 17x34 100x50+45+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[10] GIF 25x37 100x50+37+1 8-bit sRGB 256c 0.000u 0:00.001
output.gif[11] GIF 22x37 100x50+40+1 8-bit sRGB 256c 0.000u 0:00.000
output.gif[12] GIF 1x4 100x50+57+1 8-bit sRGB 256c 0.000u 0:00.000
output.gif[13] GIF 25x38 100x50+37+0 8-bit sRGB 256c 0.000u 0:00.000
output.gif[14] GIF 18x37 100x50+42+0 8-bit sRGB 256c 0.000u 0:00.000
output.gif[15] GIF 25x38 100x50+37+0 8-bit sRGB 256c 0.000u 0:00.000
output.gif[16] GIF 23x36 100x50+39+1 8-bit sRGB 256c 0.000u 0:00.000
output.gif[17] GIF 1x1 100x50+99+49 8-bit sRGB 256c 0.000u 0:00.000
output.gif[18] GIF 24x38 100x50+38+0 8-bit sRGB 256c 0.000u 0:00.000
output.gif[19] GIF 22x37 100x50+39+0 8-bit sRGB 256c 0.000u 0:00.000
output.gif[20] GIF 23x38 100x50+38+0 8-bit sRGB 256c 0.000u 0:00.000
output.gif[21] GIF 20x21 100x50+41+0 8-bit sRGB 256c 5156B 0.000u 0:00.000
```

Ignoring the last column, the difference is exactly the last three frames:

```diff
 output.gif[18] GIF 24x38 100x50+38+0 8-bit sRGB 256c 0.000u
 output.gif[19] GIF 22x37 100x50+39+0 8-bit sRGB 256c 0.000u
 output.gif[20] GIF 23x38 100x50+38+0 8-bit sRGB 256c 0.000u
-output.gif[21] GIF 20x21 100x50+41+0 8-bit sRGB 256c 5156B
+output.gif[21] GIF 20x21 100x50+41+0 8-bit sRGB 256c 0.000u
+output.gif[22] GIF 3x10 100x50+58+8 8-bit sRGB 256c 0.000u
+output.gif[23] GIF 58x38 100x50+21+0 8-bit sRGB 256c 0.000u
+output.gif[24] GIF 55x37 100x50+24+1 8-bit sRGB 256c 5962B
```

and with a cursory look I can't spot a problem in the program, except maybe the lack of an `encoder.flush` at the end which doesn't actually do anything in this case.

I don't have more time today, will try to take a deeper look tomorrow.

, https://git.io/JJwmZ in zmwangx/rust-ffmpeg
Now that I'm basically done fixing most things on my backlog, I'll add a video transcode example soon (tm).

, https://git.io/JJwIo in zmwangx/rust-ffmpeg-sys
Released v4.3.3 for this.

, https://git.io/JJwIK in zmwangx/rust-ffmpeg-sys
Cool, thanks. Squashed and merged in b80ddfc.

, https://git.io/JJwv0 in zmwangx/rust-ffmpeg
Since I don’t actually have a ton of time to investigate a potential problem (i.e. a potential non-problem), it would be best if you could distill your implementation down to a simple reproducible example that’s not intertwined with `gifski::Collector`, `BinResult`, etc. Then I could take a look.

, https://git.io/JJVMC in zmwangx/rust-ffmpeg
Implement automatic FFmpeg version detection
============================================

Based on ffmpeg-sys-next 4.3.2.

, https://git.io/JJVXO in zmwangx/rust-ffmpeg-sys
I finally tried this. It's pretty nice to be able to build against a managed FFmpeg installation, rather than an ad-hoc one. I would have considered this the goto method, such a shame that vcpkg's FFmpeg is on 4.2, one year out of date...

Two things:

1. I'd rather have `VCPKGRS_DYNAMIC` set automatically, since the presence of `static` or lack thereof is a clear enough signal of intent. So something like

```diff
diff --git a/build.rs b/build.rs
index 32cf00f..a81c14b 100644
--- a/build.rs
+++ b/build.rs
@@ -350,7 +350,10 @@ fn try_vcpkg() -> Option<Vec<PathBuf>> {
 }

 #[cfg(target_env = "msvc")]
-fn try_vcpkg() -> Option<Vec<PathBuf>> {
+fn try_vcpkg(statik: bool) -> Option<Vec<PathBuf>> {
+    if !statik {
+        env::set_var("VCPKGRS_DYNAMIC", "1");
+    }
     vcpkg::find_package("ffmpeg")
         .map_err(|e| {
             println!("Could not find ffmpeg with vcpkg: {}", e);
@@ -612,16 +615,7 @@ fn main() {
         );
         link_to_libraries(statik);
         vec![ffmpeg_dir.join("include")]
-    } else if let Some(paths) = try_vcpkg() {
-        let is_vcpkg_static = env::var_os("VCPKGRS_DYNAMIC").is_none();
-        if is_vcpkg_static != statik {
-            panic!(
-                "vcpkg settings do not match ffmpeg-sys settings: VCPKGRS_DYNAMIC is {}, but ffmpeg-sys static feature is {}",
-                if is_vcpkg_static { "not defined, which means that vcpkg libraries are linked statically" } else { "defined" },
-                if statik { "specified" } else { "not specified "}
-            );
-        }
-
+    } else if let Some(paths) = try_vcpkg(statik) {
         // vcpkg doesn't detect the "system" dependencies
         if statik {
             if cfg!(feature = "avcodec") || cfg!(feature = "avdevice") {
```

2. (I'm a Unix guy with a Windows machine on the side but little to no knowledge of Windows development, so please bear with me.) I tried static linking and it works well. But I couldn't get dynamic linking to work.

Consider building an example program from [zmwangx/rust-ffmpeg](https://github.com/zmwangx/rust-ffmpeg):

```
cargo build --no-default-features --features ffmpeg42,codec,format --example metadata
```

Now when I execute `.\target\debug\examples\metadata` I get -1073741515 `STATUS_DLL_NOT_FOUND`. And Dependency Walker says I'm missing a whole bunch of DLLs, including `AVCODEC`, `AVFORMAT` and `AVUTIL`.

![image](https://user-images.githubusercontent.com/4149852/89114149-d833f000-d4ab-11ea-854e-36e454cd26ed.png)

Any idea what's going wrong here? My Rust toolchain:

```console
$ rustup show
Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\zmwang\.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.45.1 (c367798cf 2020-07-26)
```